IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit

Smoothes the input image replacing aberrant values by the neighbourhood's mean intensity. More...

IPSDKIPLFILTERING_API image::ImagePtr ipsdk::imaproc::filter::despeckleFilter2dImg (const image::ImageConstPtr &pInImg, const ipUInt32 inHalfKnlSizeX, const ipUInt32 inHalfKnlSizeY, const ipReal64 inFactor)
 wrapper function for Smoothes the input image replacing aberrant values by the neighbourhood's mean intensity More...
 
IPSDKIPLFILTERING_API void ipsdk::imaproc::filter::despeckleFilter2dImg (const image::ImageConstPtr &pInImg, const ipUInt32 inHalfKnlSizeX, const ipUInt32 inHalfKnlSizeY, const ipReal64 inFactor, const image::ImagePtr &pOutRealImg)
 wrapper function for Smoothes the input image replacing aberrant values by the neighbourhood's mean intensity More...
 

Detailed Description

Smoothes the input image replacing aberrant values by the neighbourhood's mean intensity.

This algorithm is inspired from the sigma filter proposed by Lee in 1983 [1]. The sigma filter is based on the idea that impulse noise intensity differs from the local intensity according to a given standard deviation. Hence, it smooths the image impulse noise by averaging only the pixels in the current neighbourhood having their intensities within a fixed range.

The DespeckleFilter2dImg algorithm uses the same hypothesis that a noisy pixel will differ from the neighbourhood mean intensity, according to a range given by the local standard deviation. It suppresses the impulse noise in the input image replacing aberrant values by the mean intensity of the neighourhood defined by $inHalfKnlSizeX$ and $inHalfKnlSizeY $ (the central pixel is not taken into account).

For each pixel $(x, y)$, the local mean $\mu(x, y)$ and the local standard deviation $\sigma(x, y)$ are calculated. The filtered resulting image is then given by:

\[ OutImg(x, y) = \begin{cases} \mu(x, y), & \text{if } inFactor \times \vert InputImg(x, y) - \mu(x, y) \vert > \sigma(x, y)\\ InImg(x, y), & \text{otherwise} \end{cases} \]

Where $inFactor$ is a weight factor on the distance between the current pixel and the local mean. A high value of $inFactor$ yields to a strong blur whereas a too low value of $inFactor$ will not suppress all noisy pixels. Moreover, calculating the local mean on a too large neighbourhood will take into account more noisy pixels, degrading the quality of the smoothed image.

Here is an example of an image with salt and pepper noise and the result of the despeckle filter algorithm. In this example, $inHalfKnlSizeX$, $inHalfKnlSizeY $ and $inFactor$ were set to 1:

despeckleFilter2dImg.png

[1] "Digital image smoothing and the sigma filter", J.-S. Lee, Computer Vision, Graphics, and Image Processing, Vol. 24, pp. 255 - 269, 1983.

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InImg [Input] image for processing 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::InFactor [Input] Multiplying factor. Used for instance by shading correction algorithm X
ipsdk::imaproc::attr::OutImg [Output] image for processing operation ipsdk::imaproc::duplicateInOut (_pOutImg, _pInImg)

Global Rule description

Global rule description for algorithm :
ipsdk::imaproc::matchSizeAndType (_pInImg,_pOutImg)

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLFiltering as filter

Code Example

# opening of input images
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# convolution filter 2d computation
outImg = filter.despeckleFilter2dImg(inImg, 1, 1, 1)

Example of C++ code :

Example informations

Associated library

IPSDKIPLFiltering

Header file

Code Example

// opening input image
ImagePtr pInImg = loadTiffImageFile(inputImgPath);
// compute variance on input image
ImagePtr pOutImg = despeckleFilter2dImg(pInImg, halfkernelSizeX, halfkernelSizeY, lambda);
See also
DespeckleFilter2dImgLvl1
DespeckleFilter2dImgLvl2
DespeckleFilter2dImgLvl3

Function Documentation

◆ despeckleFilter2dImg() [1/2]

IPSDKIPLFILTERING_API image::ImagePtr ipsdk::imaproc::filter::despeckleFilter2dImg ( const image::ImageConstPtr pInImg,
const ipUInt32  inHalfKnlSizeX,
const ipUInt32  inHalfKnlSizeY,
const ipReal64  inFactor 
)

wrapper function for Smoothes the input image replacing aberrant values by the neighbourhood's mean intensity

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ despeckleFilter2dImg() [2/2]

IPSDKIPLFILTERING_API void ipsdk::imaproc::filter::despeckleFilter2dImg ( const image::ImageConstPtr pInImg,
const ipUInt32  inHalfKnlSizeX,
const ipUInt32  inHalfKnlSizeY,
const ipReal64  inFactor,
const image::ImagePtr pOutRealImg 
)

wrapper function for Smoothes the input image replacing aberrant values by the neighbourhood's mean intensity

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure