How create a filter? (Mean, mode, median)

1 view (last 30 days)
Ha
Ha on 1 Dec 2014
Commented: Image Analyst on 1 Dec 2014
Someone can help me to create roles for the filter:
Mode Mean Median
Thanks.

Answers (1)

Image Analyst
Image Analyst on 1 Dec 2014
Try mode(), conv() or smooth(), and medfilt1().
Not sure what a "role" is - please explain. And say whether your filter has some window width.
  4 Comments
Ha
Ha on 1 Dec 2014
Is that all? In class for the middle did the following:
function imgOut = filtroMedia (imgIn)
imagemDouble = im2double(imgIn);
for i=1:size(imagemDouble,1)
for j=1:size(imagemDouble,2)
for k=1:size(imagemDouble,3)
%i,j; i,j+1; i,j-1; i-1,j; i+1, j;
vetor =0;
numeroPosi =0;
if(i>1)
vetor = vetor + imagemDouble(i-1,j, k);
numeroPosi = numeroPosi +1;
end
if(j-1>0)
vetor = vetor +imagemDouble(i,j-1, k);
numeroPosi = numeroPosi +1;
end
if(i+1<0)
vetor = vetor + imagemDouble(i+1,j, k);
numeroPosi = numeroPosi +1;
end
if(j+1<0)
vetor = vetor + imagemDouble(i, j+1, k);
numeroPosi = numeroPosi +1;
end
vetor = vetor+ imagemDouble(i, j, k);
vetor = vetor/numeroPosi;
imgOut(i,j,k) = vetor;
end
end
end
imshow(imgOut);
end
Image Analyst
Image Analyst on 1 Dec 2014
You don't need to do all that - there's a built in function for 2D median: medfilt2().

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!