<< maskthresh Image_Processing_Tool_3 padding >>

Image_Processing_Tool_3 >> Image_Processing_Tool_3 > medfilt2

medfilt2

It performs 2-d median filtering operation on a gray scale image.

Calling Sequence

y = medfilt2(x)
y = medfilt2(x,sz)
y = medfilt2(x,sz,opt)

Arguments

x

A matrix representing a grayscale image.

sz

A two-element vector specifiying the size of the kernel for 2-d median filtering. By default its value is [3 3] for 3x3 kernel.

opt

A character constant representing the padding option used for median filtering of boundary pixels. By default it is 'z' for zero padding.

y

A matrix representing the median filtered image.

Description

It performs 2-d median filtering image on a given gray scale image. It takes one, two or three arguments as input parameters. If only first argument is given, the size of the kernel is taken as [3 3] and zero padding is used as padding option, which is also used as padding option if not given explicitly in the third parameter. The possible values of the padding option opt are 'z' for zero padding(default), 'p' for periodic padding 'o' for padding with ones 'm' for padding with median value '-' for padding with minimum value '+' for padding with maximum values. It may be noted that median filtering with periodic padding gives smoother boundary in the resulting filtered image.

Examples

x=imread('lena.png');
x=rgb2gray(x);
// Median filtering with kernel size (3x3)
y=medfilt2(x);
imshow(uint8(y))
// Median filtering with kernel size (5x5)
y1=medfilt2(x,[5 5]);
imshow(uint8(y1))
//Median filtering with kernel size (5x5) 
//and perioding padding
y2=medfilt2(x,[5 5],'p');
imshow(uint8(y2))

See Also

Authors

<< maskthresh Image_Processing_Tool_3 padding >>