IPSDK 0.2
IPSDK : Image Processing Software Development Kit
bool  =median2dImg_allow8bitsCompression (inImg,inHalfKnlSizeX,inHalfKnlSizeY,outImg)
imagemedian2dImg (inImg,inHalfKnlSizeX,inHalfKnlSizeY)

Detailed Description

Median filter on a 2d image.

The median filter is a non-linear filter used to reduce impulsive noise in an image while preserving edges.

The median filter computes, for each pixel of input image, the median of its neighbouring pixels.

On output image values are given by:

\[ OutImg[x, y] = median(\left\lbrace InImg(x+o_x, y+o_y), -n_x \leq o_x \leq n_x, -n_y \leq o_y \leq n_y\rbrace\right) \]

where :

Input and output images must have same size.

The algorithm is optimized if at least one of the following conditions is satisfied:

If none of the previous conditions are satisfied, the user has all the same the possibility to execute a fast 2d median filter, by setting the attribute "InOutOptAllow8bitsCompression" to value true (this attribute is set to false by default). In this case, he will get a resulting image that will be an approximation of a real median (the resulting image will contain a maximum of 256 different grey level values).

Here are 2 examples of a median filter operation applied to a noised 8-bits grey levels input image:

median2d_knl3x3.png
median2d_knl21x21.png
See also
http://en.wikipedia.org/wiki/Median_filter

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLFiltering as filter

Code Example

# opening of input images
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# median filter 2d computation
outImg = filter.median2dImg(inImg, 3, 3)

Example of C++ code :

Example informations

Header file

#include <IPSDKIPL/IPSDKIPLFiltering/Processor/Median2dImg/Median2dImg.h>

Code Example

// opening input image
ImagePtr pInImg = loadTiffImageFile(inputImgPath);
if(pInImg->getBufferType() != imageBufferType)
pInImg = util::convertImg(pInImg, imageBufferType);
// compute median on input image
ImagePtr pOutImg = median2dImg(pInImg, inHalfKnlSizeX, inHalfKnlSizeY);