Add periodic noise¶
| Fact | Value |
|---|---|
| Also called | Sinusoidal noise, Periodic interference |
| Status | Implemented and tested |
| Family | Utilities |
| Engine | Browser |
| Type | Linear, spatial, additive sine wave |
| Output | Image |
| Operator shown as | random-process (exact) |
| Support radius | 0 |
| Code | web/src/core/filters/frequency/notch.ts, noisePeriodicFilter |
| Operator code | web/src/core/filters/frequency/notch.ts, noisePeriodicFilter |
| Channels | RGB, Brightness only |
Overview¶
Add periodic noise lays a sine wave of one frequency and direction over the image. It is the model of periodic interference in Gonzalez and Woods, and it makes test images for the notch filters and periodic noise suppression. The wave makes two bright peaks in the spectrum.
How it works¶
- Compute the wave A sin(2 pi (fx x + fy y) + phase) at the image position of each pixel.
- Add it to the value of the pixel.
- Clip the result to 0 to 255.
Mathematical foundation¶
The formula shows the default parameter values.
where
- \(A\): The amplitude in 8-bit levels
- \(f_x, f_y\): The frequency in cycles per pixel
- \(\varphi\): The phase
x and y are the image position of the pixel, so a region gives the same noise as the whole image. The wave makes two peaks in the spectrum, at (f_x, f_y) and at (-f_x, -f_y). This is the model of periodic noise in Gonzalez and Woods. Results outside 0 to 255 are clipped.
A sine wave holds a single frequency. Its spectrum is a pair of impulses at (fx, fy) and (-fx, -fy). The stripes run across the direction of (fx, fy), with a period of 1 / sqrt(fx^2 + fy^2) pixels.
Kernel or operator¶
There is no kernel. The Inspector describes the wave with the current values.
Algorithm¶
- For each pixel, compute the wave at its image position.
- Add it to the value.
- Clip to 0 to 255 and round. Keep alpha unchanged.
Parameters¶
| Parameter | Default | Values | Meaning |
|---|---|---|---|
Amplitude amplitude |
40 | 0 to 128 levels | The height A of the wave, in 8-bit levels. |
Frequency x fx |
0.125 | -0.5 to 0.5 cycles/px | How many waves fit in one pixel along x. 0.125 means a wave every 8 pixels. |
Frequency y fy |
0 | -0.5 to 0.5 cycles/px | How many waves fit in one pixel along y. |
Phase phase |
0 | 0 to 360 deg | Where the wave starts at the top left pixel. |
Channels channelScope |
RGB | RGB, Brightness only | Which part of the color image the filter changes. |
Implementation¶
noisePeriodicFilter in web/src/core/filters/frequency/notch.ts adds the wave. It uses the image position of each pixel, so a region gives the same values as the whole image. The filter runs through the shared framework in web/src/core/filters/run.ts, which handles the channel scope, alpha and clipping.
Worked example¶
| x | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|---|---|---|---|---|---|---|---|---|---|
| Value | 100 | 128 | 140 | 128 | 100 | 72 | 60 | 72 | 100 |
A flat gray image of value 100 with a wave of amplitude 40 and frequency (0.125, 0). The wave repeats every 8 pixels: 100 + 40 sin(2 pi x / 8), rounded.
Complexity¶
- Time: \(O(N)\)
- Memory: \(O(N)\)
N is the number of pixels.
Artifacts and limitations¶
Limitations
- Real interference often has several frequencies and changing strength. This is one pure wave.
Artifacts
- Clipping flattens the wave in very dark and very bright areas.
Tests¶
The reference computes the same wave with numpy.sin. The cases cover an oblique wave with a phase and a vertical one.
References¶
- Gonzalez, R. C. and Woods, R. E. Digital Image Processing, 4th edition. Pearson, 2018. Chapter 5, periodic noise and its reduction.