Mining an Image for All It's Worth: From Recognition to Reconstruction

Bryan de Bourbon · · Part 1

Take a picture of a squirrel on a branch. You can follow the curve of its tail and see where its paws grip the bark. Open the same image in code and you’ll find rows of numbers. Every step from the camera to a computer vision model changes what those numbers represent.

Three squirrels in grass, with one partly obscured by the orange squirrel’s tail.

From bits to a picture

A bit has two possible values, 0 and 1. Think of it as a bucket that can be empty or full. Line up several bits and you have a sequence. Arrange that sequence in rows and columns and you have a matrix. Nine values can fill a single row of nine or a grid three rows high and three columns wide. The values are the same, but their positions in the grid give them new neighbors.

A row of nine cells split into three equal groups and stacked into a three-by-three matrix.
Figure 1. Cut a row of nine values into three equal pieces and stack them to make a 3 × 3 grid. Reading the grid row by row recovers the original sequence.

With a grid of bits, you can draw a symbol by deciding which cells are on. Give each cell a color and you have a color image. Each cell is a pixel, with a column x and a row y.

A grid with one dark cell marked at coordinates x, y.
Figure 2. A pixel’s coordinates locate a single cell in the grid. Its value tells you what to draw there.

What the camera records

A lens focuses light onto a sensor made up of light-sensitive sites. In many cameras, a filter over each site lets it measure mainly red, green, or blue light. The camera estimates the missing color components from nearby measurements and processes the result into a color image.

In an RGB image, each position holds three channel values. If each channel uses eight bits, its values run from 0 to 255. You can write a pixel as I(x, y) = (R, G, B). The three numbers describe the color together, and each channel has its own scale.

An enlarged squirrel sprite on a pixel grid, with one orange pixel broken into red, green, and blue channel values.
Figure 3. The enlarged squirrel shows the grid behind a small image. The highlighted orange pixel has a red value around 75% of the channel maximum, green around 31%, and blue around 5%.

The grid also sets the detail you can see. Enlarge a small image by repeating its pixels and the squares become visible. Blend neighboring pixels during enlargement and the edges look smoother. Both methods start with the same measurements.

A small squirrel sprite above two enlarged copies, one with square pixel edges and the other with blended edges.
Figure 4. The same squirrel enlarged to 400%. The left version keeps the pixel edges visible. The right version blends neighboring values.

JPEG, PNG, and tensors

JPEG is a practical way to store photographs. The common lossy encoding represents each 8 × 8 block in terms of patterns that range from slowly varying tones to fine detail. It rounds the numbers describing those patterns so the file packs down smaller. On decoding, pixel values can differ from the ones the encoder started with. Heavy compression can leave visible blocks or distort fine edges, such as the whiskers in an animal portrait. Christopher G. Jennings’s interactive JPEG walkthrough

An eight-by-eight array of grayscale frequency patterns beside a diagram of the JPEG zigzag scan.
Figure 5. Left, the patterns used to describe an 8 × 8 block. Right, the zigzag order in which JPEG groups the resulting coefficients for encoding.

PNG compresses its stored image samples losslessly. It’s a useful choice for diagrams and segmentation masks, where changing a pixel value can change the label it represents. Saving a decoded JPEG as PNG preserves those decoded values. Any detail discarded during JPEG encoding is already gone.

A tensor is the array a model can work with after the file has been decoded and prepared. An RGB image might have shape height × width × 3. A model can keep the same row and column axes while using the third axis for something else, such as a score for each possible class. The position still refers to a location in the image, and the channel tells you what the number means.

One image, many questions

So far, we have been talking about how a computer stores an image. But what can it learn from one? Imagine a photograph of three squirrels in a woodland scene, one partly hidden by another. Each of the following questions asks for a little more information from the very same photograph.

Nine illustrated panels showing three squirrels through classification, localization, detection, semantic segmentation, instance segmentation, panoptic segmentation, amodal segmentation, depth estimation, and 3D reconstruction.
Figure 6. One image, many questions. A–C identify the subject and locate individual squirrels. D–F assign increasingly detailed labels to visible regions. G estimates hidden portions of an object, H estimates depth, and I illustrates a possible three-dimensional scene. The panels are conceptual illustrations, not measured model predictions.

A. Binary classification. Is there a squirrel in the photograph? The answer is yes or no. We know something about the image as a whole, but not where the squirrel is.

B. Single-object localization. Now ask where one squirrel is. A bounding box gives us its approximate position and size.

C. Object detection. Why stop at one box? A detector can return a box and class label for each squirrel, allowing us to locate and count all three.

D. Semantic segmentation. A box also contains some background. Instead, give every pixel a class label. All visible squirrel pixels receive the same label, so touching squirrels may appear as one region.

E. Instance segmentation. What if we want to distinguish the squirrels? Assign each individual squirrel its own mask, even though they share a class.

F. Panoptic segmentation. The squirrels are not the only information in the scene. Label the entire visible image, distinguishing individual squirrels while also identifying regions such as grass, tree and sky.

Beyond what is visible

G. Amodal segmentation. If one squirrel stands behind another, its visible outline stops at the occlusion. Yet we know squirrels have bodies that continue behind obstacles. Amodal segmentation estimates the full shape of an object, including portions hidden from view. It is an inference, not a measurement of the hidden region.

H. Depth estimation. Once we start thinking about what is behind something else, we are already reasoning about three-dimensional space. We can estimate how far away different visible surfaces are, representing their distance or relative depth in a new image-shaped map.

I. 3D reconstruction. Take that reasoning further and ask what three-dimensional environment could have produced the photograph. Methods such as photogrammetry, neural radiance fields and 3D Gaussian splatting can reconstruct or represent a scene from observations, typically using multiple views. A single photograph can support plausible estimates, but it cannot uniquely determine the hidden geometry. Gaussian splatting represents scene appearance with spatially arranged Gaussian primitives; semantic labels are a separate question.

Mining an image for all it's worth

We started with a grid of colors and ended with an estimate of a three-dimensional world. The photograph never changed. What changed was the question we asked of it.

We went from what do I see? to what is probably there? to what world could have produced this image?

Themes to be expanded on

  • One-hot encoding for categories and binary grids for drawing symbols
  • RGB channel values, bit depth, and what color profiles change
  • JPEG chroma subsampling, frequency coefficients, and quantization
  • Tensor axis order, data types, and per-pixel class scores