cl; img=imread('1.bmp'); img=double(img); imshow(mat2gray(img)); [m n]=size(img); imgn=zeros(m-3,n-3); temp=[]; for i=1:m-3 for j=1:n-3 temp=img(i:i+3,j:j+3); imgn(i,j)=median(temp(:)); end end figure,imshow(mat2gray(imgn)) imgn=img(1:m-3,1:n-3)-imgn; figure,imshow(mat2gray(imgn)) imgn=imgn .* (imgn>0); figure,imshow(mat2gray(abs(imgn)))