IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Functions

Median filter on a 3d image. More...

Functions

IPSDKIPLFILTERING_API bool ipsdk::imaproc::filter::median3dImg_allow8bitsCompression (const image::ImageConstPtr &pInImg, const ipUInt32 inHalfKnlSizeX, const ipUInt32 inHalfKnlSizeY, const ipUInt32 inHalfKnlSizeZ, const image::ImagePtr &pOutImg)
 wrapper function for Median filter on a 3d image More...
 
IPSDKIPLFILTERING_API image::ImagePtr ipsdk::imaproc::filter::median3dImg (const image::ImageConstPtr &pInImg, const ipUInt32 inHalfKnlSizeX, const ipUInt32 inHalfKnlSizeY, const ipUInt32 inHalfKnlSizeZ)
 wrapper function for Median filter on a 3d image More...
 
IPSDKIPLFILTERING_API void ipsdk::imaproc::filter::median3dImg (const image::ImageConstPtr &pInImg, const ipUInt32 inHalfKnlSizeX, const ipUInt32 inHalfKnlSizeY, const ipUInt32 inHalfKnlSizeZ, const image::ImagePtr &pOutImg)
 wrapper function for Median filter on a 3d image More...
 

Detailed Description

Median filter on a 3d 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, z] = median(\left\lbrace InImg(x+o_x, y+o_y, z+o_z), -n_x \leq o_x \leq n_x, -n_y \leq o_y \leq n_y, -n_z \leq o_z \leq n_z\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:

median3d_knl3x3x3.png
median3d_knl21x21x21.png
See also
http://en.wikipedia.org/wiki/Median_filter

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InImg3d [Input] 3d image for operation X
ipsdk::imaproc::attr::InHalfKnlSizeX [Input] half kernel size along X axis for operation X
ipsdk::imaproc::attr::InHalfKnlSizeY [Input] half kernel size along Y axis for operation X
ipsdk::imaproc::attr::InHalfKnlSizeZ [Input] half kernel size along Z axis for operation X
ipsdk::imaproc::attr::InOutOptAllow8bitsCompression [InOut Optional] boolean determining whether 8 bits compression on output image is allowed to make median computation faster X
ipsdk::imaproc::attr::OutImg [Output] image for processing operation ipsdk::imaproc::duplicateInOut (_pOutImg, _pInImg3d)

Global Rule description

Global rule description for algorithm :
ipsdk::imaproc::matchSize (_pInImg3d,_pOutImg)

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 3d computation
outImg = filter.median3dImg(inImg, 3, 3, 3)

Example of C++ code :

Example informations

Associated library

IPSDKIPLFiltering

Header file

Code Example

// opening input image
ImagePtr pInImg = loadTiffImageFile(inputImgPath);
if(pInImg->getBufferType() != inImageBufferType)
pInImg = util::convertImg(pInImg, inImageBufferType);
ImageGeometryPtr pOutImageGeometry =
geometry3d(outImageBufferType, pInImg->getSizeX(), pInImg->getSizeY(), pInImg->getSizeZ());
boost::shared_ptr<MemoryImage> pOutImg =
boost::make_shared<MemoryImage>();
pOutImg->init(*pOutImageGeometry);
// compute median3d of input image
median3dImg(pInImg, inHalfKnlSizeX, inHalfKnlSizeY, inHalfKnlSizeZ, pOutImg);
See also
Median3dImgLvl1

Function Documentation

◆ median3dImg() [1/2]

IPSDKIPLFILTERING_API image::ImagePtr ipsdk::imaproc::filter::median3dImg ( const image::ImageConstPtr pInImg,
const ipUInt32  inHalfKnlSizeX,
const ipUInt32  inHalfKnlSizeY,
const ipUInt32  inHalfKnlSizeZ 
)

wrapper function for Median filter on a 3d image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ median3dImg_allow8bitsCompression()

IPSDKIPLFILTERING_API bool ipsdk::imaproc::filter::median3dImg_allow8bitsCompression ( const image::ImageConstPtr pInImg,
const ipUInt32  inHalfKnlSizeX,
const ipUInt32  inHalfKnlSizeY,
const ipUInt32  inHalfKnlSizeZ,
const image::ImagePtr pOutImg 
)

wrapper function for Median filter on a 3d image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure
Returns
flag indicating whether 8 bit compression has been used

◆ median3dImg() [2/2]

IPSDKIPLFILTERING_API void ipsdk::imaproc::filter::median3dImg ( const image::ImageConstPtr pInImg,
const ipUInt32  inHalfKnlSizeX,
const ipUInt32  inHalfKnlSizeY,
const ipUInt32  inHalfKnlSizeZ,
const image::ImagePtr pOutImg 
)

wrapper function for Median filter on a 3d image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure