StrataQuest Home › StrataQuest Glossary › Bilateral Filter
BOM Operation

Bilateral Filter

Edge-preserving smoothing by intensity-aware weighting

View
Definition
The Bilateral filter smooths an image while keeping its edges. Like the Gauss filterLoading..., it replaces each pixel with a weighted average of its neighbors, nearer ones counting more. It also lowers the weight of neighbors whose intensity differs from the center pixel's, so the averaging stays within a nucleus or within the background instead of mixing the two across their border.
Two weights, one average
Distance and intensity difference set each weight
Edges survive
Unlike neighbors count for little
Variances, not sigmas
Both controls are squared widths
The window caps the reach
Kernel height and width, default 5 × 5

How It Works

Take a pixel just inside the edge of a bright nucleus. Its 5 × 5 neighborhood holds nuclear pixels on one side and dark background on the other. An Average filterLoading... mixes them all, and the edge goes soft. The Bilateral filter weighs each neighbor by two things: its distance from the center pixel, and how much its intensity differs.

The Engines Reference puts it this way. Each output pixel is a weighted average of the neighboring pixels, with the weights adjusted by the Euclidean distance between pixels and by their intensity differences. It is a non-linear filter for attenuating image noise while preserving edges. You'll find it in the Basic Operations Module under Filters, and in the reference example it returns a grayscale image matching the input.

A neighbor on the far side of an edge is very different from the center pixel, so it counts for little, and the average draws mostly on the near side. Inside a uniform region every neighbor is similar, and the filter acts like an ordinary distance-weighted blur. Unlike the Median filterLoading..., which also keeps some borders, it averages, so it does create new gray levels.

Simplified

Each pixel is replaced by an average of its neighbors, but neighbors that look very different from it get little say. The dark background across the edge contributes little to a pixel inside a nucleus. Regions smooth out and edges stay put.

Image Processing Foundation

In image processing generally, the bilateral filter is the one Tomasi and Manduchi described in 1998. In that textbook form both weights are Gaussians: a spatial Gaussian on distance and a range Gaussian on intensity difference, multiplied and normalized so the weights sum to one. The Engines Reference doesn't print StrataQuest's weighting formula. Its two controls are variances, though, which is what you would set for two Gaussians.

A variance is the square of a standard deviation. If the textbook form holds, the default Variance (values) of 16 means a sigma of 4 gray levels, which is small on an 8-bit image, and that fits the reference's warning that small values give a barely visible effect. The reference example uses 750 for both variances, a sigma of about 27. Type a sigma from a textbook or another program into these fields and you'll be off by a square.

The window matters as much as the variances. Kernel height and Kernel width set the neighborhood, so nothing outside it contributes, however large Variance (positions) is. In the textbook form, a 5 × 5 window with a large positions variance gives every pixel in the window nearly the same spatial weight, and Variance (values) determines most of the weighting.

In that same form, a very large Variance (values) makes every neighbor count as similar, and the filter becomes a distance-weighted blur like the Gauss filterLoading.... The Anisotropic filterLoading... preserves edges by another route, a diffusion run over a set Diffusion time. And because the bilateral weights depend on the pixel values, the filter is not a convolutionLoading...; in general that makes it slower than a Gaussian of the same window size.

Simplified

The textbook bilateral filter multiplies two bell-curve weights, one for distance and one for brightness difference. StrataQuest's two settings are variances, and a variance is a width squared, so 16 means a width of 4. A plain Gaussian blur weights neighbors by distance only. The bilateral adds one condition, similarity in brightness, and that condition keeps the edges.

Parameters & Settings

ParameterDefaultDescription
ImageThe input image. The reference example uses an 8-bit grayscale DAPI image.
Border Value0The value used for the pixels on the border.
Border typeWrap BorderThe method used to create the border, which the window needs where it reaches past the image edge.
Kernel height (px)5The height of the processing window (kernel).
Kernel width (px)5The width of the processing window (kernel).
Variance (values)16The variance for differences of pixel values: it governs how intensity difference lowers a neighbor's weight.
Variance (positions)16The variance for pixel positions: it governs how distance lowers a neighbor's weight.
Step in kernel1The processing step in the kernel. Deprecated, and due to be removed in a future version.

High values for both variances make the image look "cartoonish", and small values give a barely visible effect. The reference example uses a 5 × 5 kernel with both variances at 750. A workable path is to start from the defaults and raise both variances until the texture inside nuclei settles, stopping before regions flatten into patches. When the filtered image feeds a thresholdLoading..., judge the result on the mask it produces, not only by eye.

Source: StrataQuest 8.1 Engines Reference, ch. 6.3 (pp. 113–135; Bilateral filter pp. 119–121).

Simplified

Two things determine the result: how big the neighborhood is, and how different a neighbor may be before it is mostly ignored. Turn both settings far up and the image starts to look like a cartoon. Leave them small and you'll barely see a change.

Connected Terms

Share This Term
Term Connections