'**SUMMARY**
Smooths the image, using bilateral filtering. Potential of bilateral filtering is for the removal of texture.
The optional parameter are diameter, sigmaColor, sigmaSpace.
Bilateral Filter
see : http://en.wikipedia.org/wiki/Bilateral_filter
see : http://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/MANDUCHI1/Bilateral_Filtering.html
**Parameters**
* *diameter* - A tuple for the window of the form (diameter,diameter). By default window = (3x3). ( for OpenCV versions <= 2.3.0)
- Diameter of each pixel neighborhood that is used during filtering. ( for OpenCV versions >= 2.3.0)
* *sigmaColor* - Filter the specified value in the color space. A larger value of the parameter means that farther colors within the pixel neighborhood (see sigmaSpace ) will be mixed together, resulting in larger areas of semi-equal color.
* *sigmaSpace* - Filter the specified value in the coordinate space. A larger value of the parameter means that farther pixels will influence each other as long as their colors are close enough
**NOTE**
For OpenCV versions <= 2.3.0
-- this acts as Convience function derived from the :py:meth:`smooth` method. Which internally calls cv.Smooth.
-- where aperture(window) is (diameter,diameter)
-- sigmaColor and sigmanSpace become obsolete
For OpenCV versions higher than 2.3.0. i.e >= 2.3.0
-- cv.bilateralFilter function is called
-- If the sigmaColor and sigmaSpace values are small (< 10), the filter will not have much effect, whereas if they are large (> 150), they will have a very strong effect, making the image look \'cartoonish\'
-- It is recommended to use diamter=5 for real time applications, and perhaps diameter=9 for offile applications that needs heavy noise filtering.'

def bilateralFilter(self, diameter=5, sigmaColor=10, sigmaSpace=10, grayscale=False):

    try:
        import cv2
        new_version = True
    except:
        new_version = False
        pass
    if is_tuple(diameter):
        (win_x, win_y) = diameter
        if ((win_x >= 0) and (win_y >= 0) and ((win_x % 2) == 1) and ((win_y % 2) == 1)):
            if (win_x != win_y):
                diameter = (win_x, win_y)
        else:
            logger.warning('The    aperture    (win_x,win_y)    must    be    odd    number    and    greater    than    0.')
            return None
    elif is_number(diameter):
        pass
    else:
        win_x = 3
        diameter = (win_x, win_x)
    if (not new_version):
        grayscale_ = grayscale
        if is_number(diameter):
            diameter = (diameter, diameter)
        return self.smooth(algorithm_name='bilateral', aperture=diameter, grayscale=grayscale_)
    elif grayscale:
        img_bilateral = cv2.bilateralFilter(self.getGrayNumpy(), diameter, sigmaColor, sigmaSpace)
        return Image(img_bilateral, colorSpace=ColorSpace.GRAY)
    else:
        img_bilateral = cv2.bilateralFilter(self.getNumpy()[:, :, ::(-1)].transpose([1, 0, 2]), diameter, sigmaColor, sigmaSpace)
        img_bilateral = img_bilateral[:, :, ::(-1)].transpose([1, 0, 2])
        return Image(img_bilateral, colorSpace=self._colorSpace)
