Gamma-MAP filter¶
| Fact | Value |
|---|---|
| Also called | Gamma maximum a posteriori filter |
| Status | Implemented and tested |
| Family | Adaptive and statistical filters |
| Engine | Browser |
| Type | Nonlinear, statistical, maximum a posteriori estimator |
| Output | Image |
| Operator shown as | estimator (exact) |
| Support radius | floor(size / 2) |
| Code | web/src/core/filters/adaptive/speckle.ts, gammaMapFilter |
| Operator code | web/src/core/filters/adaptive/speckle.ts, gammaMapValue |
| Channels | RGB, Brightness only |
Overview¶
The Gamma-MAP filter finds the most likely clean value of each pixel under a statistical model of radar images: the scene and the speckle both follow gamma distributions. Like the enhanced Lee filter, it keeps the mean for pure speckle and the pixel for strong targets, and uses the model for everything between.
How it works¶
- Find the mean and the coefficient of variation C_I of the window.
- If C_I is at most C_u, write the mean. If it is at least C_max, keep the pixel.
- Otherwise solve a quadratic for the most likely clean value, and write its larger root.
Mathematical foundation¶
The formula shows the default parameter values.
where
- \(m\): The window mean
- \(z\): The pixel value
- \(\alpha\): The shape parameter of the scene distribution
- \(L\): The number of looks
The formula is the larger root of the quadratic that the maximum a posteriori estimate solves when both the scene and the speckle follow gamma distributions. It applies where C_u < C_I < C_max. Below C_u the output is the mean m, above C_max = sqrt(1 + 2 C_u^2) the pixel z is kept, as in the enhanced Lee filter. L is the number of looks that matches C_u.
A maximum a posteriori estimate maximizes the probability of the clean value R given the pixel z. The prior for R is a gamma distribution whose shape alpha comes from the local statistics, and the speckle is L-look gamma noise. Then the condition is the quadratic alpha R^2 - (alpha - L - 1) m R - L z m = 0. Its larger root is the formula above. The number of looks L is 1 / C_u^2.
Kernel or operator¶
There is no kernel. The Inspector shows the formula with the current C_u. The Rank stepper in the Learn panel shows the window at any pixel next to the value the filter gives there.
Algorithm¶
- Pad the image with the border mode.
- Compute the mean and variance of each window with running sums.
- Find the class of C_I.
- Write the mean, the pixel, or the MAP estimate.
Parameters¶
| Parameter | Default | Values | Meaning |
|---|---|---|---|
Window size size |
7 | 3 to 15, odd px | Width and height of the window for the local statistics. |
Speckle variation C_u cu |
0.25 | 0.01 to 1 | The coefficient of variation of the speckle, its standard deviation over its mean. For an L-look intensity image it is 1 over the square root of L. |
Border mode border |
Reflect 101 (default) | Reflect 101 (default), Reflect, Replicate, Constant (zero), Wrap | How pixels outside the image are filled when the window reaches past the edge. |
Channels channelScope |
RGB | RGB, Brightness only | Which part of the color image the filter changes. |
Implementation¶
gammaMapValue in web/src/core/filters/adaptive/speckle.ts applies the classes and the closed-form root to each pixel, with the local statistics shared by all speckle filters. The filter runs in the browser engine, in Web Workers, through the shared filter framework in web/src/core/filters/run.ts. It handles the border mode, the channel scope, alpha and the rounding to 8 bits. Each strip of the image gets a halo as wide as the support radius, so strips give exactly the pixels of a whole-image run.
Worked example¶
The window mean is m = 106.24 and its standard deviation 14.627, so C_I = 14.627 / 106.24 = 0.1377. With C_u = 0.1, the number of looks is L = 1 / 0.1^2 = 100 and alpha = (1 + 0.1^2) / (0.1377^2 - 0.1^2) = 112.788. C_I lies between C_u and C_max = 1.0100, so the MAP formula applies. Its value for the center 150 is 124.548.
Complexity¶
- Time: \(O(N)\)
- Memory: \(O(N)\)
N is the number of pixels per channel.
Artifacts and limitations¶
Limitations
- The gamma model fits radar scenes, not general photos.
- Needs C_u.
Artifacts
- Class borders can show as a change in texture.
Tests¶
No common library has this filter, so the reference applies the same formulas to NumPy windows of an input whose values are all above 0. Before it is used, the script checks that every value solves its quadratic. The test covers two window and C_u settings for all five border modes.
References¶
- Lopes, A., Nezry, E., Touzi, R. and Laur, H. Maximum a posteriori speckle filtering and first order texture models in SAR images. 10th Annual International Symposium on Geoscience and Remote Sensing (IGARSS), 1990, pages 2409 to 2412. DOI 10.1109/IGARSS.1990.689026.
- Lopes, A., Touzi, R. and Nezry, E. Adaptive speckle filters and scene heterogeneity. IEEE Transactions on Geoscience and Remote Sensing 28(6), 992 to 1000, 1990. DOI 10.1109/36.62623.