Removing Noise By Linear Filtering Linear filters, such as averaging or Gaussian filters can be used to remove certain types of noise. An averaging filter is useful for removing grain noise from a photograph. Because each pixel gets set to the average of the pixels in its neighborhood, local variations caused by grain are reduced.
Removing Noise By Median Filtering With median filtering, the value of an output pixel is determined by the median of the neighborhood pixels, rather than the mean. The median is much less sensitive than the mean to extreme values (called outliers). Median filtering is therefore better able to remove these outliers without reducing the sharpness of the image.
Applying the median filter >>I=imread('img.bmp'); >> I=I(:,:,1); >> imshow(I); >> L = medfilt2(I,[3 3]); >>figure, imshow(L)
Rectifying background illumination Step 1: Read Image Step 2: Use Morphological Opening to Estimate the Background Step 3: View the Background Approximation as a Surface Step 4: Subtract the Background Image from the Original Image