Matlab functions    from  BioméCardio    

 
   fspecial3
idctn   

hmf

Hybrid median filtering

Contents

Download

hmf.m

Syntax

   B = hmf(A)
   B = hmf(A,n)

Description

B = hmf(A,n) performs hybrid median filtering of the matrix A using a n x n box. Hybrid median filter preserves edges better than a square kernel median filter because it is a three-step ranking operation: data from different spatial directions are ranked separately. Three median values are calculated: MR is the median of horizontal and vertical R pixels, and MD is the median of diagonal D pixels. The filtered value is the median of the two median values and the central pixel C: median([MR,MD,C]). As an example, for n = 5:

B = hmf(A) uses a 5 x 5 box (default value).

A can be a 2-D array or an RGB image. If A is an RGB image, hybrid median filtering is performed in the HSV color space.

Notes:

  1. The size box n must be odd. If n is even then n is incremented by 1.
  2. The Image Processing Toolbox is required.
  3. If the function nanmedian exists (Statistics Toolbox), NaNs are treated as missing values and are ignored.

Example

Let us read an RGB image and make it noisy with salt-and-pepper noise...

I = imread('board.tif');
I = imnoise(I,'salt & pepper');
imshow(imrotate(I,90)), title('Noisy image')

And let us reconstruct the image using hybrid median filter:

J = hmf(I);
imshow(imrotate(J,90)), title('Filtered image')

See also

medfilt2, medfilt3

About the author

Damien Garcia, Eng., Ph.D.
Assistant professor, Department of radiology
CRCHUM, University of Montreal Hospital
Montreal, QC, Canada
Damien.Garcia.REMOVE-THIS@BiomeCardio.com

www.biomecardio.com