Skip to content

Super-resolution reconstruction

Fact Value
Also called Iterative back-projection, IBP, Classical upscaling
Status Implemented and tested
Family Restoration and reconstruction (also Utilities)
Engine Science engine
Type Linear, spatial, iterative back-projection
Output Image
Operator shown as iterative (exact)
Support radius global
Code engine/src/pixelnexus_engine/filters/superresolution.py, sr_classical
Operator code engine/src/pixelnexus_engine/filters/superresolution.py, sr_representation
Packages SciPy
Channels Brightness only, RGB

Overview

Super-resolution reconstruction enlarges the image 2, 3 or 4 times. It starts from a bicubic enlargement, the same as Resize. Then it corrects the large image until shrinking it again gives back the original. This is iterative back-projection, after Irani and Peleg. Edges come out sharper than with bicubic, and every original pixel stays the mean of the pixels that replace it. It cannot invent detail that the image never held. The filter runs in the PixelNexus engine on your computer, and the result replaces the image.

Four panels: a Siemens star with 12 spokes, the same star shrunk to half and shown with large square pixels, a bicubic enlargement with soft spokes, and the back-projection result with slightly crisper spoke edges. Four panels: a Siemens star with 12 spokes, the same star shrunk to half and shown with large square pixels, a bicubic enlargement with soft spokes, and the back-projection result with slightly crisper spoke edges.
A Siemens star shrunk to half by block means, then enlarged again with bicubic and with 10 iterations of back-projection.

How it works

  1. Premultiply the colors by alpha, as Resize does.
  2. Enlarge the image with bicubic. This is the start.
  3. Shrink the estimate with the camera model, and take the difference from the image.
  4. Enlarge the difference with bicubic and add it to the estimate.
  5. Repeat steps 3 and 4 for the chosen number of iterations.
  6. Divide the colors by the enlarged alpha again.

Mathematical foundation

\[ u = \frac{x + 1/2}{s} - \frac{1}{2}, \qquad x_0 = U g, \qquad x_{k+1} = x_k + U \big(g - D x_k\big), \qquad s = 2 \]

The formula shows the default parameter values.

where

  • \(g\): The input image
  • \(x_k\): The estimate of the large image after k steps
  • \(s\): The scale
  • \(U\): Bicubic enlargement, Keys with a = -1/2
  • \(D\): The camera model, the mean of each s x s block

The center of output pixel x sits at position u of the input, so the picture does not shift. U is bicubic enlargement with Keys' kernel and a = -1/2, the same as Resize. D is a model of the camera: each input pixel is the mean of the s x s output pixels it covers. The start x_0 is the bicubic enlargement of the image g. Shrinking it with D does not give g back exactly, so each step takes the difference, enlarges it with U and adds it. This is the back-projection of Irani and Peleg, here for a single image. The eigenvalues of D U lie between 0 and 1, so the difference shrinks in every step, and in the end D x = g. The result then holds the same information as the input, with sharper edges than bicubic.

The geometry follows Resize. Pixel i covers the interval from i to i + 1, so its center is at i + 1/2. The center of output pixel x then sits at u = (x + 1/2) / s - 1/2 in input pixels. With this rule the picture does not shift, whatever the scale.

The filter needs a model of how the small image came about. Here each input pixel is the mean of the s x s output pixels it covers, as if a camera with bigger pixels had taken the picture. Call this shrinking D, and the bicubic enlargement U. The start x_0 = U g looks right, but D x_0 is not quite g, since bicubic is not the inverse of the block mean. Back-projection adds the enlarged difference, U (g - D x_k), in every step. For one image and no motion, this is the update of Irani and Peleg with the bicubic kernel as the back-projection kernel.

The difference g - D x_k is multiplied by the matrix I - D U in every step. The eigenvalues of D U lie between 0 and 1, so the difference shrinks every time, and in the end D x = g. The worked example shows how fast. Most of the gain comes in the first 3 steps.

Kernel or operator

The Inspector asks the engine for the stages with the current settings. They are the grid rule, the bicubic start with Keys' kernel, the camera model with its weight 1 / s^2, and the back-projection step with the number of iterations.

Algorithm

  1. Premultiply the colors by alpha.
  2. Enlarge the image with bicubic to get the start.
  3. Shrink the estimate with the camera model and take the difference from the image.
  4. Enlarge the difference with bicubic and add it to the estimate. Repeat.
  5. Divide the colors by the enlarged alpha again.

Parameters

Parameter Default Values Meaning
Scale scale 2 2 to 4 x How many times larger the image becomes in each direction. A 400 x 300 image becomes 800 x 600 at scale 2.
Iterations iterations 10 0 to 50 The number of back-projection steps. With 0, the result is Resize with the bicubic method.
Channels channelScope Brightness only RGB, Brightness only Which part of the color image the filter changes.

Implementation

sr_classical in engine/src/pixelnexus_engine/filters/superresolution.py builds the enlargement and the camera model as sparse matrices, one for the rows and one for the columns. The bicubic_matrix function gives the same weights as Resize, renormalized near the edge. The back_project function holds the iteration. By default only the brightness Y is back-projected, and the colors are enlarged with bicubic.

This filter changes the image size, so its catalog entry sets changesSize. The engine returns the larger result with its size. Before the job starts, the studio checks the new size against the image limits in Preferences. The filter runs on the whole image, and the selection is enlarged with the image. Undo brings back the image at its old size. There is no live preview. The result arrives when you click Apply.

Worked example

Image Scale Bicubic 3 iterations 10 iterations
Disks 2 31.49 32.09 32.10
Disks 3 28.71 29.26 29.26
Disks 4 26.55 27.12 27.13
Siemens star 2 22.61 23.56 23.59
Siemens star 3 19.43 20.21 20.22
Siemens star 4 17.54 18.27 18.29

Each 192 x 192 test image is shrunk with the camera model of the filter, the mean of each block, and rounded to 8 bits. Then the filter enlarges it again. The numbers are the PSNR in dB against the image before shrinking. For the star at scale 2, the root mean square difference between the shrunk image and the camera model of the estimate is 4.7241 levels for bicubic, 0.1843 after 3 iterations and 0.0007 after 10, before rounding.

Complexity

  • Time: \(O(K s^2 N)\)
  • Memory: \(O(s^2 N)\)

N is the number of input pixels, s the scale and K the number of iterations.

Artifacts and limitations

Limitations

  • It cannot invent detail that the image never held. Fine texture stays soft.
  • The camera model is a plain block mean. Images that were shrunk with another filter fit it less well.

Artifacts

  • Slight ringing next to strong edges, from the bicubic kernel.
  • Jagged diagonal edges at large scales.

Tests

The enlargement matrices must equal the weights of the NumPy reference for Resize to 1e-14, for several sizes and scales. With 0 iterations the whole filter must give Resize with the bicubic method, alpha included, to within one level where a value lands on a half. The camera model must be the mean of each block. A constant image must stay constant. The difference between the image and the camera model of the estimate must shrink in every step, and fall below 1e-6 after 30 steps. On a shrunk image, 10 iterations must beat bicubic by more than 1.4 dB. With the brightness scope, red, green and blue must change by the same amount. The engine API test checks the size of the result.

References

  • Irani, M., and Peleg, S. Improving resolution by image registration. CVGIP. Graphical Models and Image Processing 53(3), 231 to 239, 1991. DOI 10.1016/1049-9652(91)90045-L.
  • Keys, R. Cubic Convolution Interpolation for Digital Image Processing. IEEE Transactions on Acoustics, Speech, and Signal Processing 29(6), 1153 to 1160, 1981. DOI 10.1109/TASSP.1981.1163711.