Skip to content

FFDNet

Fact Value
Also called Fast and flexible denoising network
Status Available through an optional pretrained model
Family Deep learning and learned processing
Engine Science engine
Type Nonlinear, learned, CNN denoising with a noise map
Output Image
Operator shown as algorithm (exact)
Support radius 32
Code engine/src/pixelnexus_engine/filters/learned.py, ffdnet
Operator code engine/src/pixelnexus_engine/filters/learned.py, ffdnet_representation
Packages ONNX Runtime (optional)

Overview

FFDNet, by Zhang, Zuo and Zhang, is a denoising network that you tell how strong the noise is. The noise level enters as an extra input channel, so one model covers weak and strong noise, and you can trade detail against smoothness. It works on four half-size copies of the image, which makes it fast. The filter runs in the PixelNexus engine.

It needs an optional model. The model downloads only when you click Download model in the Properties panel, which first shows its size and license, and the engine checks its SHA-256 before it keeps it. Models published as PyTorch weights are converted to ONNX once on your computer with tools/export_models.py. The engine itself never uses PyTorch. Results carry the label: AI result. Detail may not exist in the original scene.

Four panels showing the red channel. The noisy input is the step and three lines under heavy grain. With the noise level set to 5, most of the grain stays. With 25, the grain is gone and the edge and lines are sharp. With 50, the image is smooth but a stretch of one thin line has faded. Four panels showing the red channel. The noisy input is the step and three lines under heavy grain. With the noise level set to 5, most of the grain stays. With 25, the grain is gone and the edge and lines are sharp. With 50, the image is smooth but a stretch of one thin line has faded.
The image of the DnCNN figure with noise of sigma 25 in each channel. Then FFDNet with the noise level set to 5, 25 and 50. The figure shows the red channel.

How it works

  1. Split the image into four half-size subimages.
  2. Add a channel filled with the noise level.
  3. Run 12 convolutions, and join the four outputs.

Mathematical foundation

\[ \hat{x} = \text{up}\big(f_\theta(\text{down}(y),\ M_\sigma)\big) \]

The formula shows the default parameter values.

where

  • \(y\): The noisy image
  • \(M_\sigma\): The noise level map
  • \(f_\theta\): The network

down splits the image into four subimages of half the width and height, and up joins them again. M is a map filled with the noise level, given to the network as an extra channel. 12 convolutions with ReLU map the subimages and the noise map to the clean subimages.

Splitting the image into four subimages halves the width and height, so the 12 convolutions see a larger area for the same cost. The noise level map tells the network how much to remove. A level below the true noise leaves noise. A level above it removes detail too.

Kernel or operator

A trained network has many learned kernels, not one. The Inspector shows the stages and the model with its license.

Parameters

Parameter Default Values Meaning
Noise level sigma 25 0 to 75 levels The standard deviation of the noise, on the 0 to 255 scale. The paper trains for 0 to 75. 25 is our choice.

Implementation

ffdnet in engine/src/pixelnexus_engine/filters/learned.py runs the ONNX file that tools/export_models.py made from KAIR's color weights, with 96 channels and 12 layers as in KAIR's test script. FFDNet's own code works out its edge padding with NumPy, so the export keeps the padding of its example size. The engine therefore pads the image to even sides by repeating the edge, as FFDNet itself does, and crops the result back. Tiles of 512 pixels start at even offsets with 32 pixels of margin.

Worked example

Noise level set FFDNet (dB)
5 22.63
15 26.53
25 35.24
35 32.83
50 29.67

The image of the figure, with noise of sigma 25 in each channel, 20.24 dB before. PSNR against the clean image over the three channels.

The best result comes with the level set to the true noise, 25. Set lower, noise stays. Set higher, detail goes, and at 50 a stretch of a thin line fades, as the figure shows.

Complexity

  • Time: \(O(N)\)
  • Memory: \(O(N)\)

N is the number of pixels. The work runs at half resolution.

Artifacts and limitations

Limitations

  • A wrong noise level leaves noise or removes detail.

Artifacts

  • Blotchy areas when the level is set far too low.

Tests

Tiny ONNX models made inside the tests check the plumbing in every test run. Tiles with enough margin must equal a run on the whole image. Color, alpha and padding must be handled as described. Where the real model is downloaded, as on the development machine, the real network is checked too. The noise level must reach the network, and odd sides must be padded and cropped back. On a noisy scene the real FFDNet must do better with the right level than with a level far too low.

References

  • Zhang, K., Zuo, W., and Zhang, L. FFDNet. Toward a fast and flexible solution for CNN-based image denoising. IEEE Transactions on Image Processing 27(9), 4608 to 4622, 2018. DOI 10.1109/TIP.2018.2839891.
  • KAIR, the image restoration toolbox of Kai Zhang, which holds the trained weights and the network code that tools/export_models.py imports. https://github.com/cszn/KAIR