Can you modify the code provided on given link.?

조회 수: 2 (최근 30일)
Nimisha
Nimisha 2014년 12월 17일
댓글: Geoff Hayes 2014년 12월 18일
My question is related with above link.
I want to replace the center pixel of a 3x3 window filter with the average of four neighbour pixels in 3 x 3 neighbourhood.
Can anyone modify code provided on that link..?
  댓글 수: 2
Geoff Hayes
Geoff Hayes 2014년 12월 17일
Nimisha - which four of the 3x3 neighbourhood do you wish to average? The ones at the north, south, east, and west of the centre pixel?
Nimisha
Nimisha 2014년 12월 17일
Yes,exactly..

댓글을 달려면 로그인하십시오.

채택된 답변

Thorsten
Thorsten 2014년 12월 17일
편집: Thorsten 2014년 12월 17일
Just convolve your data with the filter
F = [0 1 0; 1 0 1; 0 1 0]/4;
You can use imfilter for the convolution.
  댓글 수: 2
Nimisha
Nimisha 2014년 12월 18일
clear all;clc
grayImage = imread('Coins.jpg');
image1 = conv(grayImage, ([0 1 0; 1 0 1; 0 1 0]/4) , 'same');
imshow(image1)
it shows following error
Error using conv (line 27)
A and B must be vectors.
Error in Question_11_3_c (line 3)
image1 = conv(grayImage, ([0 1 0; 1 0 1; 0 1 0]/4) , 'same');
How to correct for given problem.?
Geoff Hayes
Geoff Hayes 2014년 12월 18일
The error message is telling you that your inputs to conv must be vectors. You are passing matrices. Try using conv2 instead.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by