medfilt2
medfilt2 is a function commonly found in image processing toolboxes, such as MATLAB's Image Processing Toolbox. Its primary purpose is to apply a 2-D median filter to an image. A median filter is a non-linear digital filtering technique used to remove noise from images. It works by sliding a neighborhood (often a square or disk) of pixels over the input image. For each pixel, the filter replaces its value with the median value of the pixels within that neighborhood. This process is particularly effective at removing salt-and-pepper noise, which appears as isolated dark or bright pixels, while generally preserving edges better than linear filters like the mean filter.
The medfilt2 function typically takes the input image and the size of the neighborhood (often specified as