IPSDK 4.1.0.2
IPSDK : Image Processing Software Development Kit
Despeckle Filter 2d
imagedespeckleFilter2dImg (inImg,inHalfKnlSizeX,inHalfKnlSizeY,inFactor)

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.

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

Header file

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

Code Example

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