image = | bilateral2dImg (inImg,inSpaceSigma,inRangeSigma) |
image = | bilateral2dImg (inImg,inHalfKnlSize,inSpaceSigma,inRangeSigma) |
bilateral filter on 2d image
The bilateral filter is a non-linear smoothing filter that has good properties of edge-preserving. Each pixel value is replaced by a weighted average of the values of its neighbours. The weight is a product of two gaussian functions, one depending on the euclidian distance between the central pixel and its current neighbour, the other depending on the difference of the intensities of these 2 pixels.
On output image values are given by:
where:
is the weight function; ![$W(x, y, o_x, o_y)=f_S(o_x, o_y)*f_R(|InImg[x, y]-InImg[x+o_x, y+o_y]|)$](form_425.png)
is the space function; 
is the range function; 
is defined by InOptHalfKnlSize attribute (if this attribute is not initialized, then
equals to
)
is defined by InRangeSigma attribute
is defined by InSpaceSigma attribute
Input and output images must have same size.
Here is an example of a bilaterial filter applied to an 8-bits grey levels input image (with
and
) :
- See also
- http://en.wikipedia.org/wiki/Bilateral_filter
Example of Python code :
Example imports
import PyIPSDK
import PyIPSDK.IPSDKIPLFiltering as filter
Code Example
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
outImg = filter.bilateral2dImg(inImg, 5, 3)
Example of C++ code :
Example informations
Header file
#include <IPSDKIPL/IPSDKIPLFiltering/Processor/Bilateral2dImg/Bilateral2dImg.h>
Code Example
pInImg->getSizeX(),
pInImg->getSizeY());
boost::shared_ptr<MemoryImage> pOutImg = boost::make_shared<MemoryImage>();
pOutImg->init(*pOutImageGeometry);
bilateral2dImg(pInImg, inHalfKnlSize, inSpaceSigma, inRangeSigma, pOutImg);