← All guides

Basics Photography

How image enhancement works

What a photograph holds at its own pixels, how ESRGAN learned to enlarge from synthetic pairs, how diffusion transformers such as SeedVR work, and the three compared on real photographs.

A four-times enlargement has sixteen pixels for every pixel of the photograph. One of them can be taken from the photograph; the other fifteen have to come from somewhere. This guide is about where they come from.

The guide covers what a photograph holds at the scale of its own pixels, what plain interpolation does with it, how models like ESRGAN and its successor Real-ESRGAN learned to enlarge photos from synthetic training pairs, and how the newer diffusion transformers work, with SeedVR as the example. The last part compares a bicubic enlargement, Real-ESRGAN, SeedVR and CraterView.ai Enhance on the same four photographs.

What a photograph holds

A photograph is a sampled record of a scene, and each step between the scene and the file loses detail or adds errors:

A Bayer colour filter array: a grid of photosites, each under a red, green or blue filter, in a two-by-two tile of one red, two green and one blue that repeats across the sensor. Split by colour, red and blue each cover one photosite in four, green two in four.

A Bayer colour filter array, the arrangement most cameras use.

Four small regions of four photographs, each pixel drawn as a block of four by four, in a grid of four, two across: a rock face, re-saved at low JPEG quality, whose texture breaks into square blocks; a hiker from behind with dark outlines around the hair and the backpack, left by sharpening; the edge of a rising full moon, soft and without sharp detail; and a plain blue surface covered in fine coloured speckles of sensor noise

Four photographs scaled up four times to show individual pixels. Top left, JPEG blocks in a rock face above Lake Agnes, the photograph re-saved at JPEG quality 40 for this figure so that the blocks are plain (photograph by Garythai, CC BY-SA 4.0, via Wikimedia Commons). Top right, dark outlines left by sharpening around a hiker (photograph by Toomas Tartes on Unsplash). Bottom left, a full moon rising, blurred by the air (photograph by Astro Backyard). Bottom right, sensor noise in a plain surface at ISO 25600 (photograph by Dietmar Rabich, CC BY-SA 4.0, via Wikimedia Commons).

A photograph that needs enlarging usually has several of these at once, in amounts nobody recorded. The central challenge of image enhancement is recovering the true scene detail from a blurry, noisy and lossily encoded digital image.

Enlarging by interpolation

Nearest-neighbour, bilinear, bicubic and Lanczos interpolation compute each new pixel as a weighted average of the pixels near it. They differ in how many neighbours they weigh and how. None adds information: an interpolated enlargement holds no detail finer than the photograph’s own pixels, so it looks smooth, and it enlarges the photograph’s noise, blocks and halos along with everything else. Bicubic interpolation is a reference that research on image enhancement often measures itself against, and a bicubic enlargement is a fair picture of what the photograph holds.

Learning from pairs

A model that enlarges is trained on pairs: a sharp image, and a low-resolution (LR), worse copy of it. The model learns to produce the sharp image from the LR input. A sharper version of a real photograph usually does not exist, so nearly all training pairs are made by taking sharp images and degrading them. What a model can undo is therefore also usually bounded by the damage its training pairs contain.

Pairs made by reduction

The first learned models, SRCNN (2014), then SRGAN (2017) and ESRGAN (2018), were trained on pairs whose LR half was the sharp image reduced by bicubic interpolation. Such a copy is small but clean: no blur beyond the reduction, no noise and no compression. A model trained on it does very well on images reduced the same way and poorly on real photographs. Since the model never saw noise or JPEG blocks during training, it takes them for signs of scene detail and sharpens them.

Two-stage degradation used by Real-ESRGAN

Real-ESRGAN (2021) keeps ESRGAN’s network and changes how its training pairs are made. Each LR half is made by applying a chain of damage twice, with every setting drawn at random for every pair:

  1. Blur, with a Gaussian kernel, round or stretched and rotated, one of two variants with heavier or flatter tails, or now and then a sinc kernel.
  2. Resize, up or down by a random factor, by area averaging or by bilinear or bicubic interpolation.
  3. Noise, Gaussian or Poisson (the random photon count), in colour or the same in every channel.
  4. JPEG compression, at a quality between 30 and 95.

The second stage repeats the chain with its own draws, and its JPEG compression is the last step. Just before or just after it, the image is resized to a quarter of the original’s size and filtered with a sinc filter, which produces the ringing and overshoot beside edges that sharpening and some resizing leave. Applying the chain twice imitates a photograph that was processed and saved, then resized and saved again, which is how many photographs reach the web. BSRGAN, published the same year, makes its pairs from a similar set of degradations applied in random order.

Four views of an umbrella-shaped antenna on a mast against a black sky, in a grid of four, two across: the sharp original, its ribs and fittings clear; the same reduced to a quarter of the size by bicubic interpolation, smaller but clean; a heavily degraded quarter-size copy, blurred, with pale halos around the dish and blocky noise in the sky; and a lightly degraded copy, close to the bicubic one but with speckled noise and faint halos

The high-gain antenna on the Apollo 15 lunar rover, 1971, as training pairs see it. Top left, the sharp original. Top right, reduced to a quarter of the size by bicubic interpolation, the small half of a pair as ESRGAN was trained. Bottom, two quarter-size copies made by Real-ESRGAN’s two-stage degradation with different draws: a heavy one, blurred, with halos around the dish and blocks in the sky, and a light one. Photograph by NASA (AS15-85-11471).

Real-ESRGAN’s synthetic damage covers much of what real photographs suffer, but not all of it. It has no demosaicing errors, no camera-specific noise or sharpening, no motion blur, and no film grain or print damage. A model trained this way works well, but might still struggle with images from modern cameras that include image processing or with recovering detail from film and prints.

How the ESRGAN model works

The network

ESRGAN is a convolutional neural network, drawn below. Its first convolution turns each pixel of the small image into 64 numbers, or features. Twenty-three residual-in-residual dense blocks then refine those features at the small image’s size. Each block holds three dense blocks of five convolutions, in which each convolution reads the block’s input and the outputs of every convolution before it. Every dense block, and every residual-in-residual block around three of them, scales its output by 0.2 and adds it to its input, which keeps a network this deep trainable. One more convolution follows the last block, and its output is added to the first convolution’s features. Then two upsampling steps each double the size by repeating pixels and applying a convolution, and two last convolutions turn the features back into red, green and blue. The four-times network has about 16.7 million parameters.

ESRGAN's generator. The small image passes through a convolution that turns each pixel into 64 features, then a chain of 23 residual-in-residual dense blocks and another convolution, whose output is added to the first convolution's features. Two steps each double the size by repeating pixels and applying a convolution, and two last convolutions give the image at four times the size. Below, one residual-in-residual dense block: three dense blocks in a row, their output scaled by 0.2 and added to the block's input. Below that, one dense block: five convolutions, each reading the block's input and the output of every convolution before it, the fifth's output scaled by 0.2 and added to the block's input.

ESRGAN’s generator, drawn after Figures 3 and 4 of its paper.

Every operation is a small convolution, so each pixel of the result is computed mostly from a neighbourhood of the input around it: for a pixel of the trail map compared below, half of the effect comes from within 11 pixels and 90% from within 34. Distant parts of the picture reach it only faintly.

The losses

Training adjusts the network to reduce three measures of how far its result is from the sharp image:

No result can be both closest to the sharp image on average and most like a real photograph. Blau and Michaeli (2018) showed that the two goals trade off against each other. The adversarial loss moves ESRGAN toward the second.

What it does well and where it fails

ESRGAN is small and fast. Real-ESRGAN enlarges a small photograph in seconds, even without a graphics processor, and its results are clean and sharp at edges. It learned to make sharp texture that looks right locally, but not what objects are. Foliage becomes flat patches of colour, fur becomes glossy strokes, skin becomes smooth and waxy, and letters become shapes like letters that spell nothing. Because it was trained to remove heavy damage, it also removes fine detail it cannot tell apart from that damage.

Newer generative models

Newer enhancement models differ from ESRGAN in network and in how they produce a result. Many recent models are diffusion transformers: vision transformers trained as diffusion models.

Attention

A vision transformer divides the image into small patches and turns each into a vector, a token. Layers of self-attention then compute each token’s next value from all the others, weighted by how relevant each is to it. A convolution reads a fixed neighbourhood while attention can relate any patch to any other in the image. The model can use a letter’s shape elsewhere on the same sign, one eye of a face for the other, or a pattern that repeats across the frame. The cost of attention grows with the square of the number of tokens, so large images are processed in tiles, or with attention limited to windows.

Removing noise

A diffusion model learns to remove noise. In training, a sharp image is mixed with random noise in a proportion drawn at random and the network learns to predict from the mixture the way back to the sharp image. To produce an image, it starts from pure noise and takes a series of steps, each removing part of the noise, until only an image is left. Because the starting noise is random, two runs can end at two different images. The model has not learned one answer for each input; it has learned the range of images that fit, and each run ends at one of them.

For enhancement, the network is also given the photograph, beside the noisy image, at every step. Training pairs are made as they are for ESRGAN, by degrading sharp images, and the network learns to remove noise toward the sharp image that matches the degraded one. The photograph fixes the structure of the result, and the steps supply fine detail consistent with it.

Working in a compressed space

Many steps over every pixel of a large image would be slow, so most models of this kind work in the latent space of an autoencoder. Its encoder, trained beforehand, compresses an image into a smaller grid of numbers that keeps what matters to how the image looks, and its decoder turns such a grid back into pixels. The steps run on the compressed grid, the photograph is compressed the same way, and the decoder draws the result. The transformer makes each small group of grid positions into one token.

Learning what photographs look like

Models of this kind are far larger than ESRGAN and are trained on far larger collections of images. Many begin as models trained to generate images from text descriptions, so they begin already knowing what photographs of many kinds of subject look like: how a face is built, how letters are formed, how fur grows. Training for enhancement teaches them to draw that knowledge onto the structure of a photograph.

SeedVR, an example

SeedVR restores videos and still images (Wang et al., 2025, from Nanyang Technological University and ByteDance). The model in its paper is a diffusion transformer of about 2.5 billion parameters, some 150 times the size of ESRGAN, and its network began as Stable Diffusion 3 Medium, a text-to-image model. The versions its authors later released have 3 and 7 billion.

Its autoencoder’s encoder turns each block of 8 by 8 pixels into 16 numbers. The photograph, resized to the result’s size, is encoded this way and joined to a grid of noise of the same size. The transformer makes each 2 by 2 group of those positions into a token, so one token stands for 16 by 16 pixels of a frame, and a linear layer turns each token into the vector its blocks work on. The 7B model has 36 transformer blocks, each also told the noise level. A last linear layer and the reverse of the patching give back a grid, which the decoder turns into the result. The authors’ inference script then gives the result the photograph’s broad colours with a wavelet colour fix, and the comparisons below include it.

Its attention works within windows, not across the whole frame. Attention between every pair of tokens in a large frame would cost too much, and a model trained that way at one resolution would work poorly at others. Each window covers 64 by 64 positions of the compressed grid, or 512 by 512 pixels. As in the Swin Transformer, alternate blocks shift the windows by half their size, so information passes from window to window across the frame. It can also be given a text description for additional context during reconstruction. Text encoders turn the description into tokens, and attention in each window reads them beside the window’s image tokens, with separate weights for each kind of token, as in the Stable Diffusion 3 network it began as. The authors’ inference script gives every photograph the same prepared description.

SeedVR2's generator. The photograph, resized to the result's size, goes through the autoencoder's encoder, which turns each 8 by 8 pixels into 16 numbers, and is joined to a grid of noise of the same size. Each 2 by 2 group of positions becomes a token, and a linear layer turns each into the transformer's width. 36 transformer blocks follow, which also read a text description through text encoders and are told the noise level. A linear layer and the reverse of the patching give back a grid, which the decoder turns into the result. SeedVR runs the transformer once for each of many steps; SeedVR2 runs it once. Below, one transformer block: the frame's tokens are split into windows, which alternate blocks shift by half a window, and attention in each window reads that window's image tokens and the text tokens together, each kind with weights of its own, before a multilayer perceptron for each kind.

SeedVR2’s generator, drawn after Figure 2 of each paper, with the 7B model’s 36 blocks.

It was trained on about 10 million images and 5 million video clips, cropped from larger originals rather than reduced. Image pairs were made by degradations of the kind Real-ESRGAN uses.

Fewer steps

Each step is a pass through a network of billions of parameters, so the number of steps sets most of the cost. SeedVR2 (Wang et al., 2025) brings it down to one step, in two stages:

The one-step model is more than four times faster than diffusion restoration methods that take 50 steps. The gain is not fiftyfold because the autoencoder then takes most of the time: more than 95% of it for a 100-frame 720p video, by the authors’ measure.

SeedVR2 also sizes its windows to the frame. With windows of a fixed size, results at resolutions well above those it was trained at showed seams between windows, so it gives each window about as many tokens as one of a 720p frame’s 3 × 3 windows had in training, shaped to the frame, and a larger frame gets more of them: the trail map’s result is cut into 5 × 5 windows of about 300 by 340 pixels. Its authors name its limits: it is not always robust to heavy damage or very large motion, and on lightly damaged input it can add too much and oversharpen.

What follows from it

The detail such a model draws follows the objects in the picture rather than only the texture nearby. Strands follow a lock of fur, letters are drawn as letters, and skin is drawn with pores and creases. Where the photograph holds enough of a word, the model often reads it correctly. Where it does not, the model draws a plausible word that may be wrong. A result is an informed estimate: every detail the photograph does not hold is the model’s best guess at it. These models also need far more computation than ESRGAN, and run on graphics processors.

CraterView.ai Enhance

At CraterView.ai we follow the field closely. We build on existing research and open source approaches like the Real-ESRGAN’s synthetic training data procedure and SeedVR-like image context.

Our central focus remains the recovery of the true scene detail from digital images. Three things help to achieve this while maintaining high image quality: good training data, computer vision models that give better context at inference time, and every part of the model grounded and well implemented.

Compared on four photographs

Each figure below shows:

Text

Four views of a trail map's legend, two across: the bicubic enlargement, smooth, the words only just legible; Real-ESRGAN, crisp black strokes that form shapes like letters but spell nothing; SeedVR2-7B, clean type that gets the headings right and the small words wrong, such as Appcoermate tanes foen the; and CraterView.ai Enhance, which reads Trails, Baden Powell Trail, Bus stop, Trail Times and Approximate times from the Ecology Centre correctly
ZOOM & PAN to see more detail.

The legend of a trail map at Lynn Canyon Park. The words are only just legible in the bicubic enlargement. Real-ESRGAN draws crisp black strokes, shaped like letters, that spell nothing: it learned what the edges of letters look like but not what letters are. SeedVR2 draws clean type and gets the headings right, but not the small words: Appcoermate tanes foen the, Powell Trad, Sunpension Bridge, and the bridge’s 2 minutes become 3. Its letters are real letters, and the words are wrong. Enhance reads the legend correctly. The road names beside it are too small in the photograph to read, and Enhance gives them spellings the photograph cannot confirm, such as Demonry Road and Runth Road. A sharp word in a result is not evidence that the word was in the photograph.

A face

Four views of a bearded surfer in profile from an old sepia photograph, two across: the bicubic enlargement, soft; Real-ESRGAN, sharp outlines and smooth, waxy skin; SeedVR2-7B, a crisp ear and beard and smooth, glossy skin with bright highlights; and CraterView.ai Enhance, with skin texture, creases at the eye, separate hairs in the beard and a few white specks like dust on a print
ZOOM & PAN to see more detail.

A surfer with an alaia, a wooden surfboard, from an old print. Real-ESRGAN sharpens the outlines and smooths the skin until it looks waxy. SeedVR2 draws a crisp ear and beard, and smooth, glossy skin with bright highlights. Enhance draws skin texture, creases at the eye and single hairs in the beard, and a few white specks like dust on a print. The face it draws is an informed estimate of the person, not a record of them. Photograph by Frank Davey, public domain, via Wikimedia Commons.

Fur

Four views of a dark shaggy dog's face beside a red knitted hat, two across: the bicubic enlargement, soft; Real-ESRGAN, sharp, glossy locks with smooth surfaces like brush strokes; SeedVR2-7B, fine crisp strands spread evenly over the coat, the locks less distinct; and CraterView.ai Enhance, fine separate strands that follow the way each lock falls
ZOOM & PAN to see more detail.

A dog’s face and coat. Real-ESRGAN turns the locks into glossy, smooth strokes like brushwork. SeedVR2 draws fine, crisp strands spread evenly over the whole coat, so the separate locks are less distinct. Enhance draws fine strands that follow the way each lock falls. Photograph by Megs Harrison on Unsplash.

Foliage and sharpening

Four views of a hiker from behind with a backpack and a red scarf, scrub and a valley beyond, two across: the bicubic enlargement, with dark outlines around the hair and the pack; Real-ESRGAN, outlines gone, the scrub smoothed into flat patches of colour; SeedVR2-7B, the outlines kept as broken dark lines and specks, the hair painted smooth, the scrub soft with a few twigs; and CraterView.ai Enhance, outlines gone, with the pack's straps and seams drawn and the scrub drawn as twigs and leaves
ZOOM & PAN to see more detail.

This photograph has dark outlines around the hair and the pack from sharpening, and the bicubic enlargement keeps them. Real-ESRGAN and Enhance remove them. SeedVR2 keeps them as broken dark lines and specks, and paints the hair smooth. Real-ESRGAN smooths the scrub into flat patches of colour, and SeedVR2 draws it softly with a few twigs; Enhance draws twigs and leaves, and the pack’s straps and seams. The twigs are drawn, not recovered: they are plausible for the scene, and they are not the ones that were there. Photograph by Toomas Tartes on Unsplash.

Summary

Interpolation ESRGAN and Real-ESRGAN Diffusion transformers
What fills the new pixels Weighted averages of nearby pixels Texture learned from training pairs, from a neighbourhood of the input Detail learned from large image collections, from context across the picture
Detail it adds None Sharp edges and local texture Detail that follows the objects in the picture
Typical failure Soft; enlarges noise and blocks Waxy skin, flat foliage, letters that spell nothing Plausible detail that was not in the scene, including wrong words
Computation Negligible Seconds, even without a graphics processor Needs a graphics processor

Interpolation shows what the photograph holds and nothing more. A model shows its best estimate of what the scene looked like.

Further reading

Try it on your own file

No sign-up and no card — a workspace opens in your browser the moment you arrive.

Open Web App