Speckle reducing anisotropic diffusion¶
| Fact | Value |
|---|---|
| Also called | SRAD |
| Status | Implemented and tested |
| Family | Adaptive and statistical filters |
| Engine | Browser |
| Type | Nonlinear, iterative, nonlinear diffusion for multiplicative noise |
| Output | Image |
| Operator shown as | iterative (exact) |
| Support radius | iterations |
| Code | web/src/core/filters/adaptive/srad.ts, sradFilter |
| Operator code | web/src/core/filters/adaptive/srad.ts, sradStep |
| Channels | RGB, Brightness only |
Overview¶
Speckle reducing anisotropic diffusion, SRAD, combines the Lee filter with anisotropic diffusion. Each step lets values flow between neighbors, and the flow is blocked at edges. Unlike Perona-Malik diffusion, the edge measure is relative to the brightness, the instantaneous coefficient of variation. So speckle, which grows with the brightness, is smoothed the same way in dark and bright areas.
How it works¶
- For each pixel, compute the differences to its four neighbors.
- From them, compute q, the variation relative to the brightness, and the coefficient c.
- Add a time step times the divergence of c times the differences.
- Lower the speckle scale a little and repeat.
Mathematical foundation¶
The formula shows the default parameter values.
where
- \(q\): The instantaneous coefficient of variation
- \(q_0\): The speckle scale
- \(c\): The diffusion coefficient
- \(\Delta t\): The time step
q is the instantaneous coefficient of variation of Yu and Acton, from the differences to the four neighbors. Its square is the sum of the four squared differences, divided by I squared, combined with the sum of the differences, the Laplacian. In speckle, q is close to the speckle scale q0 and the coefficient c is near 1, so the image diffuses. On edges q is large and c is near 0. The divergence uses c at the pixel for the north and west differences, and at the south and east neighbors for the other two. Here c is limited to 0 to 1.
Yu and Acton show that the Lee and Frost filters are discrete steps of a diffusion. The instantaneous coefficient of variation q acts as an edge detector: it is near the speckle scale q0 in speckle and larger on edges. The coefficient c is near 1 where q is close to q0 and near 0 where q is much larger. The speckle scale falls with time, q0 exp(-rho t), so the diffusion slows down as the speckle goes. Here c is limited to 0 to 1.
Kernel or operator¶
The Inspector shows the update step and the coefficient with the current settings. The worked example below runs one step for one pixel.
Algorithm¶
- Extend the image by one pixel per iteration with the border mode.
- For each pixel, compute the four neighbor differences, q squared and c.
- Add dt / 4 times the divergence of c times the differences.
- Lower q0 by its decay, repeat, then cut the extension off.
Parameters¶
| Parameter | Default | Values | Meaning |
|---|---|---|---|
Iterations iterations |
30 | 1 to 200 | How many diffusion steps run. |
Time step dt |
0.1 | 0.01 to 0.5 | The time step of each update. The coefficient is limited to 1, so steps up to 1 stay stable. |
Speckle scale q0 q0 |
0.25 | 0.01 to 2 | The coefficient of variation of the speckle at the start. It plays the role of C_u in the Lee filter. |
Scale decay rho |
0.17 | 0 to 1 | q0 falls with time as q0 exp(-rho t), with t the number of steps times the time step. |
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¶
sradStep in web/src/core/filters/adaptive/srad.ts computes c for a whole plane, then the update. The plane is extended once by one pixel per step with the border mode, all steps run, and the frame is cut off. A tiny constant avoids a division by 0 on black pixels. 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¶
For the center 120, the differences to the north, south, west and east neighbors are -16, -23, -18, -21. The sum of their squares over 120 squared is 0.10764, and their sum over 120 is -0.65000. That gives q^2 = 0.03908. With q0 = 0.25, q0^2 = 0.0625, so q is below the speckle scale and the coefficient is c = 1, limited to 1. The center diffuses freely. One step with dt = 0.1 gives 118.050.
Complexity¶
- Time: \(O(N\,T)\)
- Memory: \(O(N)\)
N is the number of pixels per channel and T the number of iterations.
Artifacts and limitations¶
Limitations
- Many iterations are slow.
- Black pixels make q undefined. A tiny constant avoids the division by 0.
Artifacts
- Flat patches after many iterations.
Tests¶
The reference runs the same steps with NumPy on the extended plane, on an input whose values are all above 0. Before it is used, the script checks that a huge speckle scale, where c is 1 everywhere, gives linear diffusion. The test covers four steps for all five border modes.
References¶
- Yu, Y. and Acton, S. T. Speckle reducing anisotropic diffusion. IEEE Transactions on Image Processing 11(11), 1260 to 1270, 2002. DOI 10.1109/TIP.2002.804276.