Bilateral#
Approximate bilateral rank filter for local (custom kernel) mean.
The local histogram is computed using a sliding window similar to the method described in [Huang].
The pixel neighborhood is defined by:
the given structuring element
an interval [g-s0, g+s1] in greylevel around g the processed pixel greylevel
The kernel is flat (i.e. each pixel belonging to the neighborhood contributes equally).
Result image is 8-/16-bit or double with respect to the input image and the rank filter operation.
References
Huang, T. ,Yang, G. ; Tang, G.. “A fast two-dimensional median filtering algorithm”, IEEE Transactions on Acoustics, Speech and Signal Processing, Feb 1979. Volume: 27 , Issue: 1, Page(s): 13 - 18.
- mean_bilateral(source, selem=None, sink=None, mask=None, s0=10, s1=10, **kwargs)[source]#
Apply a flat kernel bilateral filter.
This is an edge-preserving and noise reducing denoising filter. It averages pixels based on their spatial closeness and radiometric similarity.
Spatial closeness is measured by considering only the local pixel neighborhood given by a structuring element.
Radiometric similarity is defined by the greylevel interval [g-s0, g+s1] where g is the current pixel greylevel.
Only pixels belonging to the structuring element and having a graylevel inside this interval are averaged.
Arguments
- sourcearray
Input array.
- selemarray
Structuring element, if None use a cube of size 3.
- sinkarray
Output array, if None, a new array is allocated.
- maskarray
Optional mask, if None, the complete source is used. Pixels in the mask are zero in the output.
- s0,s1int
The lower and upper widths around the center value for the bilateral window.
Returns
- sinkarray
The filtered array.
- mean_scale_bilateral(source, selem=None, sink=None, mask=None, s0=10, s1=10, p0=0, p1=0, **kwargs)[source]#
Mean pixel value using a bilateral window size that scales with local pixel intensity.
The filter linearly scales the biateral window size as [g-s0-p0*g, g+s1+p1*g].
Arguments
- sourcearray
Input array.
- selemarray
Structuring element, if None use a cube of size 3.
- sinkarray
Output array, if None, a new array is allocated.
- maskarray
Optional mask, if None, the complete source is used. Pixels in the mask are zero in the output.
- s0,s1int
The lower and upper widths around the center value for the bilateral window.
- p0,p1float
The lower and upper scale values for the bilateral window.
Returns
- sinkarray
The filtered array.
- pop_bilateral(source, selem=None, sink=None, mask=None, s0=10, s1=10, **kwargs)[source]#
Return the local number (population) of pixels.
The number of pixels is defined as the number of pixels which are included in the structuring element and the mask. Additionally pixels must have a graylevel inside the interval [g-s0, g+s1] where g is the gray value of the center pixel.
Arguments
- sourcearray
Input array.
- selemarray
Structuring element, if None use a cube of size 3.
- sinkarray
Output array, if None, a new array is allocated.
- maskarray
Optional mask, if None, the complete source is used. Pixels in the mask are zero in the output.
- s0,s1int
The lower and upper widths around the center value for the bilateral window.
Returns
- sinkarray
The filtered array.
- sum_bilateral(source, selem=None, sink=None, mask=None, s0=10, s1=10, **kwargs)[source]#
Apply a flat kernel bilateral filter.
This is an edge-preserving and noise reducing denoising filter. It sums pixels based on their spatial closeness and radiometric similarity.
Spatial closeness is measured by considering only the local pixel neighborhood given by a structuring element (structural_element).
Radiometric similarity is defined by the greylevel interval [g-s0, g+s1] where g is the current pixel greylevel.
Only pixels belonging to the structuring element AND having a greylevel inside this interval are summed.
Note that the sum may overflow depending on the data type of the input array.
Arguments
- sourcearray
Input array.
- selemarray
Structuring element, if None use a cube of size 3.
- sinkarray
Output array, if None, a new array is allocated.
- maskarray
Optional mask, if None, the complete source is used. Pixels in the mask are zero in the output.
- s0,s1int
The lower and upper widths around the center value for the bilateral window.
Returns
- sinkarray
The filtered array.
- sum_relative_bilateral(source, selem=None, sink=None, mask=None, s0=0.5, s1=2.0, **kwargs)[source]#
Apply a flat kernel bilateral filter.
This is an edge-preserving and noise reducing denoising filter. It sums pixels based on their spatial closeness and radiometric similarity.
Spatial closeness is measured by considering only the local pixel neighborhood given by a structuring element (structural_element).
Radiometric similarity is defined by the greylevel interval [g-s0, g+s1] where g is the current pixel greylevel.
Only pixels belonging to the structuring element AND having a greylevel inside this interval are summed.
Note that the sum may overflow depending on the data type of the input array.
Arguments
- sourcearray
Input array.
- selemarray
Structuring element, if None use a cube of size 3.
- sinkarray
Output array, if None, a new array is allocated.
- maskarray
Optional mask, if None, the complete source is used. Pixels in the mask are zero in the output.
- s0,s1int
The lower and upper widths around the center value for the bilateral window.
Returns
- sinkarray
The filtered array.