BilateralFilter2d
Applies a two-dimensional edge-preserving smoothing filter.
Access to parameter description
For an introduction to image filters: see Images Filtering.
This algorithm is an edge-preserving smoothing filter. The intensity value at each pixel in an image is replaced by a weighted average of intensity values from nearby pixels. Crucially, the weights depend on the distance in color space from the considered pixel.
It preserves sharp edges by systematically excluding pixels across discontinuities from consideration: $$ O(i,j)=\frac{1}{K(i,j)}\sum_{l=-\frac{n_x}{2}}^{\frac{n_x}{2}} \sum_{m=-\frac{n_y}{2}}^{\frac{n_y}{2}}e^{_\frac{(I(i,j)-I(l,m))^2}{h^2}} I(l,m) $$
Where $h$ is a weighting similarity factor and $K$ is a local normalisation factor given by: $$ K(i,j)=\sum_{l=-\frac{n_x}{2}}^{\frac{n_x}{2}} \sum_{m=-\frac{n_y}{2}}^{\frac{n_y}{2}}e^{_\frac{(I(i,j)-I(l,m))^2}{h^2}} I(l,m) $$
The greater $h$ is, the stronger the blur.
A filter mode parameter allows this algorithm to switch to the SUSAN filter (Smallest Univalue Segment Assimilating Nucleus).
The SUSAN filter reproduces bilateral filter behavior simply by excluding the central pixel of computation. This filter gives better results in the case of impulse noise.
Reference:
C.Tomasi, R.Manduchi. "Bilateral Filtering for Gray and Color Images". Sixth International Conference on Computer Vision (IEEE Cat. No.98CH36271), Bombay, India, pp. 839-846, 1998.
See also
Access to parameter description
For an introduction to image filters: see Images Filtering.
This algorithm is an edge-preserving smoothing filter. The intensity value at each pixel in an image is replaced by a weighted average of intensity values from nearby pixels. Crucially, the weights depend on the distance in color space from the considered pixel.
It preserves sharp edges by systematically excluding pixels across discontinuities from consideration: $$ O(i,j)=\frac{1}{K(i,j)}\sum_{l=-\frac{n_x}{2}}^{\frac{n_x}{2}} \sum_{m=-\frac{n_y}{2}}^{\frac{n_y}{2}}e^{_\frac{(I(i,j)-I(l,m))^2}{h^2}} I(l,m) $$
Where $h$ is a weighting similarity factor and $K$ is a local normalisation factor given by: $$ K(i,j)=\sum_{l=-\frac{n_x}{2}}^{\frac{n_x}{2}} \sum_{m=-\frac{n_y}{2}}^{\frac{n_y}{2}}e^{_\frac{(I(i,j)-I(l,m))^2}{h^2}} I(l,m) $$
The greater $h$ is, the stronger the blur.
A filter mode parameter allows this algorithm to switch to the SUSAN filter (Smallest Univalue Segment Assimilating Nucleus).
The SUSAN filter reproduces bilateral filter behavior simply by excluding the central pixel of computation. This filter gives better results in the case of impulse noise.
Reference:
C.Tomasi, R.Manduchi. "Bilateral Filtering for Gray and Color Images". Sixth International Conference on Computer Vision (IEEE Cat. No.98CH36271), Bombay, India, pp. 839-846, 1998.
See also
Function Syntax
This function returns the outputImage output parameter.
// Function prototype. std::shared_ptr< iolink::ImageView > bilateralFilter2d( std::shared_ptr< iolink::ImageView > inputImage, int32_t kernelSizeX, int32_t kernelSizeY, double similarity, BilateralFilter2d::FilterMode filterMode, std::shared_ptr< iolink::ImageView > outputImage = NULL );
This function returns the outputImage output parameter.
// Function prototype. bilateral_filter_2d( input_image, kernel_size_x = 3, kernel_size_y = 3, similarity = 20, filter_mode = BilateralFilter2d.FilterMode.BILATERAL, output_image = None )
This function returns the outputImage output parameter.
// Function prototype. public static IOLink.ImageView BilateralFilter2d( IOLink.ImageView inputImage, Int32 kernelSizeX = 3, Int32 kernelSizeY = 3, double similarity = 20, BilateralFilter2d.FilterMode filterMode = ImageDev.BilateralFilter2d.FilterMode.BILATERAL, IOLink.ImageView outputImage = null );
Class Syntax
Parameters
Class Name | BilateralFilter2d |
---|
Parameter Name | Description | Type | Supported Values | Default Value | |||||
---|---|---|---|---|---|---|---|---|---|
inputImage |
The input image. | Image | Binary, Label, Grayscale or Multispectral | nullptr | |||||
kernelSizeX |
The horizontal kernel size in pixels (odd value). | Int32 | [3, 100] | 3 | |||||
kernelSizeY |
The vertical kernel size in pixels (odd value). | Int32 | [3, 100] | 3 | |||||
similarity |
The weighting similarity factor (must be a positive value). | Float64 | >0 | 20 | |||||
filterMode |
The way to consider the central pixel.
|
Enumeration | BILATERAL | ||||||
outputImage |
The output image. Its dimensions, type, and calibration are forced to the same values as the input. | Image | nullptr |
Object Examples
std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" ); BilateralFilter2d bilateralFilter2dAlgo; bilateralFilter2dAlgo.setInputImage( polystyrene ); bilateralFilter2dAlgo.setKernelSizeX( 3 ); bilateralFilter2dAlgo.setKernelSizeY( 3 ); bilateralFilter2dAlgo.setSimilarity( 20.0 ); bilateralFilter2dAlgo.setFilterMode( BilateralFilter2d::FilterMode::BILATERAL ); bilateralFilter2dAlgo.execute(); std::cout << "outputImage:" << bilateralFilter2dAlgo.outputImage()->toString();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif")) bilateral_filter_2d_algo = imagedev.BilateralFilter2d() bilateral_filter_2d_algo.input_image = polystyrene bilateral_filter_2d_algo.kernel_size_x = 3 bilateral_filter_2d_algo.kernel_size_y = 3 bilateral_filter_2d_algo.similarity = 20.0 bilateral_filter_2d_algo.filter_mode = imagedev.BilateralFilter2d.BILATERAL bilateral_filter_2d_algo.execute() print( "output_image:", str( bilateral_filter_2d_algo.output_image ) )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" ); BilateralFilter2d bilateralFilter2dAlgo = new BilateralFilter2d { inputImage = polystyrene, kernelSizeX = 3, kernelSizeY = 3, similarity = 20.0, filterMode = BilateralFilter2d.FilterMode.BILATERAL }; bilateralFilter2dAlgo.Execute(); Console.WriteLine( "outputImage:" + bilateralFilter2dAlgo.outputImage.ToString() );
Function Examples
std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" ); auto result = bilateralFilter2d( polystyrene, 3, 3, 20.0, BilateralFilter2d::FilterMode::BILATERAL ); std::cout << "outputImage:" << result->toString();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif")) result = imagedev.bilateral_filter_2d( polystyrene, 3, 3, 20.0, imagedev.BilateralFilter2d.BILATERAL ) print( "output_image:", str( result ) )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" ); IOLink.ImageView result = Processing.BilateralFilter2d( polystyrene, 3, 3, 20.0, BilateralFilter2d.FilterMode.BILATERAL ); Console.WriteLine( "outputImage:" + result.ToString() );