| image = | separatedBilateral2dImg (inImg,inSpaceSigma,inRangeSigma) |
| image = | separatedBilateral2dImg (inImg,inHalfKnlSize,inSpaceSigma,inRangeSigma) |
separated version of bilateral filter on 2d image
The separated bilateral filter is an approximation of the Bilateral smoothing 2d 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 2 passes: first along x-axis, then along y-axis.
Output image pixel values are given by:
where:
![$ OutImg_x[x, y] = \dfrac { \sum_{o_x=-n}^{n}{W_x(x, y, o_x)*InImg[x+o_x, y]} } { \sum_{o_x=-n}^{n}{W_x(x, y, o_x)} } $](form_683.png)
is the weight function along x-axis; 
is the weight function along y-axis; 
is the space function; 
![$ f_{Rx}(InImg, x, y, o_x)= \begin{cases} 1, & \text{if } o_x=0 \\ f_R(|InImg[x, y]-InImg[x+o_x, y]|), & \text{if } o_x > 0 \text { and } f_R(|InImg[x, y]-InImg[x+o_x, y]|) < f_{Rx}(x, y, o_x-1) \\ f_{Rx}(x, y, o_x-1), & \text{if } o_x > 0 \text { and } f_R(|InImg[x, y]-InImg[x+o_x, y]|) \geq f_{Rx}(x, y, o_x-1) \\ f_R(|InImg[x, y]-InImg[x+o_x, y]|), & \text{if } o_x < 0 \text { and } f_R(|InImg[x, y]-InImg[x+o_x, y]|) < f_{Rx}(x, y, o_x+1) \\ f_{Rx}(x, y, o_x+1), & \text{if } o_x < 0 \text { and } f_R(|InImg[x, y]-InImg[x+o_x, y]|) \geq f_{Rx}(x, y, o_x+1) \end{cases} $](form_688.png)
![$ f_{Ry}(InImg, x, y, o_y)= \begin{cases} 1, & \text{if } o_y=0 \\ f_R(|InImg[x, y]-InImg[x, y+o_y]|), & \text{if } o_y > 0 \text { and } f_R(|InImg[x, y]-InImg[x, y+o_y]|) < f_{Ry}(x, y, o_y-1) \\ f_{Ry}(x, y, o_y-1), & \text{if } o_y > 0 \text { and } f_R(|InImg[x, y]-InImg[x, y+o_y]|) \geq f_{Ry}(x, y, o_y-1) \\ f_R(|InImg[x, y]-InImg[x, y+o_y]|), & \text{if } o_y < 0 \text { and } f_R(|InImg[x, y]-InImg[x, y+o_y]|) < f_{Ry}(x, y, o_y+1) \\ f_{Ry}(x, y, o_y+1), & \text{if } o_y < 0 \text { and } f_R(|InImg[x, y]-InImg[x, y+o_y]|) \geq f_{Ry}(x, y, o_y+1) \end{cases} $](form_689.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 attributeInput and output images must have same size.
Here is an example of a separated bilateral 2d operation applied to an 8-bits grey levels input image (with
and
):