image = | separatedBilateral3dImg (inImg,inSpaceSigma,inRangeSigma) |
image = | separatedBilateral3dImg (inImg,inHalfKnlSize,inSpaceSigma,inRangeSigma) |
separated version of bilateral filter on 3d image
The separated bilateral filter is an approximation of the Bilateral smoothing 3d that gives resulting images that may be close to what is obtained with the original bilateral filter with dramatically better time performance. The separated bilateral filter is executed in 3 passes: first along x-axis, then along y-axis and finally along z-axis.
Output image pixel values are given by:
where:
![$ OutImg_y[x, y, z] = \dfrac { \sum_{o_y=-n}^{n}{W_y(x, y, z, o_y)*OutImg_x[x, y+o_y, z]} } { \sum_{o_y=-n}^{n}{W_y(x, y, z, o_y)} } $](form_692.png)
![$ OutImg_z[x, y, z] = \dfrac { \sum_{o_x=-n}^{n}{W_x(x, y, z, o_x)*InImg[x+o_x, y, z]} } { \sum_{o_x=-n}^{n}{W_x(x, y, z, o_x)} } $](form_693.png)
is the weight function along x-axis; 
is the weight function along y-axis; 
is the weight function along z-axis; 
is the space function; 
![$ f_{Rx}(InImg, x, y, z, o_x)= \begin{cases} 1, & \text{if } o_x=0 \\ f_R(|InImg[x, y, z]-InImg[x+o_x, y, z]|), & \text{if } o_x > 0 \text { and } f_R(|InImg[x, y, z]-InImg[x+o_x, y, z]|) < f_{Rx}(x, y, z, o_x-1) \\ f_{Rx}(x, y, z, o_x-1), & \text{if } o_x > 0 \text { and } f_R(|InImg[x, y, z]-InImg[x+o_x, y, z]|) \geq f_{Rx}(x, y, z, o_x-1) \\ f_R(|InImg[x, y, z]-InImg[x+o_x, y, z]|), & \text{if } o_x < 0 \text { and } f_R(|InImg[x, y, z]-InImg[x+o_x, y, z]|) < f_{Rx}(x, y, z, o_x+1) \\ f_{Rx}(x, y, z, o_x+1), & \text{if } o_x < 0 \text { and } f_R(|InImg[x, y, z]-InImg[x+o_x, y, z]|) \geq f_{Rx}(x, y, z, o_x+1) \end{cases} $](form_699.png)
![$ f_{Ry}(InImg, x, y, z, o_y)= \begin{cases} 1, & \text{if } o_y=0 \\ f_R(|InImg[x, y, z]-InImg[x, y+o_y, z]|), & \text{if } o_y > 0 \text { and } f_R(|InImg[x, y, z]-InImg[x, y+o_y, z]|) < f_{Ry}(x, y, z, o_y-1) \\ f_{Ry}(x, y, z, o_y-1), & \text{if } o_y > 0 \text { and } f_R(|InImg[x, y, z]-InImg[x, y+o_y, z]|) \geq f_{Ry}(x, y, z, o_y-1) \\ f_R(|InImg[x, y, z]-InImg[x, y+o_y, z]|), & \text{if } o_y < 0 \text { and } f_R(|InImg[x, y, z]-InImg[x, y+o_y, z]|) < f_{Ry}(x, y, z, o_y+1) \\ f_{Ry}(x, y, z, o_y+1), & \text{if } o_y < 0 \text { and } f_R(|InImg[x, y, z]-InImg[x, y+o_y, z]|) \geq f_{Ry}(x, y, z, o_y+1) \end{cases} $](form_700.png)
![$ f_{Rz}(InImg, x, y, z, o_z)= \begin{cases} 1, & \text{if } o_z=0 \\ f_R(|InImg[x, y, z]-InImg[x, y, z+o_z]|), & \text{if } o_z > 0 \text { and } f_R(|InImg[x, y, z]-InImg[x, y, z+o_z]|) < f_{Rz}(x, y, z, o_z-1) \\ f_{Rz}(x, y, z, o_z-1), & \text{if } o_z > 0 \text { and } f_R(|InImg[x, y, z]-InImg[x, y, z+o_z]|) \geq f_{Rz}(x, y, z, o_z-1) \\ f_R(|InImg[x, y, z]-InImg[x, y, z+o_z]|), & \text{if } o_z < 0 \text { and } f_R(|InImg[x, y, z]-InImg[x, y, z+o_z]|) < f_{Rz}(x, y, z, o_z+1) \\ f_{Rz}(x, y, z, o_z+1), & \text{if } o_z < 0 \text { and } f_R(|InImg[x, y, z]-InImg[x, y, z+o_z]|) \geq f_{Rz}(x, y, z, o_z+1) \end{cases} $](form_701.png)
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.
See Separated bilateral smoothing 2d for an illustration of separated bilateral filter applied to a 2d image.
- See also
- M. Moreaud, F. Cokelaer, Flowing Bilateral Filter : definition and GPU implementation, Image Analysis and Stereology (revision in progress)
Example of Python code :
Example imports
import PyIPSDK
import PyIPSDK.IPSDKIPLFiltering as filter
Code Example
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
outImg = filter.separatedBilateral3dImg(inImg, 5, 3)
Example of C++ code :
Example informations
Header file
#include <IPSDKIPL/IPSDKIPLFiltering/Processor/SeparatedBilateral3dImg/SeparatedBilateral3dImg.h>
Code Example
outImageBufferType,
pInImg->getSizeX(),
pInImg->getSizeY(),
pInImg->getSizeZ());
boost::shared_ptr<MemoryImage> pOutImg = boost::make_shared<MemoryImage>();
pOutImg->init(*pOutImageGeometry);
separatedBilateral3dImg(pInImg, inHalfKnlSize, inSpaceSigma, inRangeSigma, pOutImg);