guided_filter — Guided filtering of an image.
guided_filter filters the input Image using the guidance image ImageGuide and returns the result in ImageGuided. Image and ImageGuide must be of the same size and type.
The Radius is the size of the filter mask. Bigger values increase the area of influence of the filter and less detail is preserved. The value of Radius does not influence the runtime of the operator.
Amplitude is used to decide what is an edge and what is a homogeneous area. Bigger values of Amplitude lead to stronger edges being smoothed. As a rule of thumb, Amplitude should be lower than the contrast of the edges that should be preserved. Please note that the contrast in uint2 or real images may differ significantly from the default values of Amplitude and adjust the parameter accordingly.
If Image and ImageGuide are identical, guided_filter behaves like an edge-preserving smoothing with a filter mask with Radius. Pixels at edges that have a contrast significantly greater than Amplitude are preserved, while pixels in homogeneous areas are smoothed. Hence, guided_filter is a fast alternative to anisotropic_diffusion or bilateral_filter.
If Image and ImageGuide are different, Image is smoothed with a filter mask with Radius, except in areas where ImageGuide has edges with a contrast significantly greater than Amplitude.
If ImageGuide is constant, guided_filter is equivalent to 2 consecutive calls of mean_image with mask size 2*Radius+1.
The following examples show the influence of Amplitude on an artificial image. In this image, the noise level is 10 gray values, the left edge has a contrast of 50 gray values, the right edge has a contrast of 100 gray values. The yellow line shows a gray-value profile of a horizontal cross section.
guided_filter can be applied iteratively. In this case, the result of one iteration is used as guidance image for the next iteration. This can be useful, e.g., to remove small structures from the original image even if they have a high contrast.
In the following example, the rolling guided filter is used to separate the texture from the original image.
* Apply the rolling guided filter * (use a constant guide for the first iteration). gen_image_proto (Image, ImageStructure, 0) for I := 1 to 4 by 1 guided_filter (Image, ImageStructure, ImageStructure, 1.5, 60) endfor * Separate texture by subtracting large structures from the original. sub_image (Image, ImageStructure, ImageTexture, 1, 128)
Since guided_filter with a constant ImageGuide is similar to mean_image, the first iteration could be replaced by a call of mean_image (or a similar smoothing filter), which is faster.
The calculation of the filtered gray value at the position is done according to the following formula:
Radius of the filtering operation.
Default value: 3
Suggested values: 1, 2, 3, 5, 10
Restriction: Radius > 0
Controls the influence of edges on the smoothing.
Default value: 20.0
Suggested values: 3.0, 10.0, 20.0, 50.0, 100.0
Restriction: Amplitude > 0
read_image (Image, 'mreut') * Edge-preserving smoothing guided_filter (Image, Image, ImageGuided, 5, 20) * Rolling filter (5 iterations) gen_image_proto (Image, ImageGuide, 0) for I := 1 to 5 by 1 guided_filter (Image, ImageGuide, ImageGuide, 5, 20) endfor
threshold, dyn_threshold, regiongrowing
bilateral_filter, anisotropic_diffusion, median_image
Kaiming He, Jian Sun, Xiaoou Tang: “Guided Image Filtering”; IEEE Transactions on Pattern Analysis and Machine Intelligence; PAMI-35, no. 6; S. 1397-1409; 2013.