Filtering
(i) Write an m-file "mymedian.m" which will take an image and filter size and perform median filtering. Display input and output image. Use
help median
function imm=mymedian(imn,msize) [h w]=size(imn); kernel_size=? imm=imn; for i=msize+1:(h-msize) for j=msize+1:(w-msize) imm(i,j)=median(reshape(imn(i-msize:i+msize,j-msize:j+msize),1,kernel_size)); end end
What is the median value of an image?
Comment on the complexity (number of operations per pixel) of the algorithm.
(ii) Write an m-file "mygaussian.m" which will take an image and filter size and perform Gaussian filtering. Display input and output image.
function img=mygaussian(imn,sigma) g=gauss(sigma);
img=?(iii) Perform median and Gaussian filtering on face_g.png, face_m.png,statue_m.png. What kind of noise the median filer is useful for? What kind of noise the Gaussian filer is useful for?