Every digital color photograph hides a remarkable trick. Your camera's sensor cannot actually see color. Each of its millions of photosites measures only brightness, not hue. Yet the images you get are full of rich, accurate color. The process that bridges that gap is called demosaicing, and understanding it explains a great deal about why RAW files look the way they do and why the conversion software you choose matters.

This article explains demosaicing from the sensor up, in plain terms but without dumbing down the technical reality. When you are ready to put it into practice and develop your own RAW files, the free RAW to JPG converter from jpeg2raw performs high-quality demosaicing for you.

Why sensors need demosaicing at all

A camera sensor is a grid of photosites that each count photons and output a brightness value. They are inherently colorblind. To capture color, manufacturers place a color filter array (CFA) over the sensor, a grid of tiny red, green and blue filters, one over each photosite. A photosite under a red filter only records red light; one under green records only green, and so on.

The overwhelmingly common CFA layout is the Bayer pattern, invented by Bryce Bayer at Kodak. It uses a repeating 2x2 tile of two green filters, one red and one blue. Green gets double weight because human vision is most sensitive to green and derives most luminance detail from it. The result: at any given pixel location, the sensor has measured only one of the three color channels. The other two are missing. To understand the file this produces, see what is a RAW file.

What demosaicing actually does

Demosaicing (also called debayering) is the process of estimating the two missing color values at every pixel, so that each pixel ends up with a full red, green and blue value. A red-filtered pixel knows its own red but must infer green and blue from its neighbors; a green pixel infers red and blue; and so on. The algorithm interpolates these missing values using the surrounding pixels.

A naive approach simply averages the nearest same-color neighbors. That works but smears fine detail and produces color artifacts. Modern demosaicing algorithms are far smarter: they detect edges and gradients, interpolate along edges rather than across them, and cross-reference the channels so a sharp luminance edge in green guides the reconstruction of red and blue. This is why good software produces noticeably crisper, cleaner results than crude interpolation.

Why the demosaicing algorithm matters

Because demosaicing is an act of intelligent guessing, different algorithms produce different results from the exact same RAW data. The quality of demosaicing affects several visible qualities of your final image:

  • Sharpness: better edge-aware interpolation preserves fine detail that simple averaging blurs.
  • Color fringing: poor demosaicing creates colored speckles along high-contrast edges, sometimes called zipper artifacts.
  • Moire and false color: repeating fine patterns, fabric, distant railings, can confuse the interpolation and produce false rainbow patterns.
  • Noise behavior: the algorithm interacts with noise reduction, affecting how clean shadows look.

This is one reason the same RAW file can look slightly different in different converters. The sensor data is fixed, but the reconstruction is not. It is also why developing from RAW gives better results than relying on your camera's in-camera JPEG, which uses a small, speed-limited processor; a dedicated converter can apply more sophisticated demosaicing.

Demosaicing in the wider RAW pipeline

Demosaicing is one stage in the chain that turns sensor data into a viewable photo. The full sequence, covered in our how to convert RAW to JPG guide, runs roughly:

  1. Black-level and linearization: normalize the raw sensor values.
  2. White balance: scale the red, green and blue channels for the light source.
  3. Demosaicing: reconstruct full RGB from the Bayer mosaic.
  4. Color space conversion: map sensor colors into a standard space like sRGB.
  5. Tone curve and gamma: reshape linear data into pleasing contrast.
  6. Sharpening and noise reduction: finish the image.

Notice that white balance often precedes demosaicing, because balancing the channels first improves the interpolation. The order and quality of these steps is what separates a flat, artifact-ridden export from a clean, vibrant one.

Bayer vs other color filter arrays

Most sensors use the Bayer pattern, but a few alternatives exist:

  • Fujifilm X-Trans: uses a larger 6x6 pattern designed to reduce moire without an optical low-pass filter. It requires its own demosaicing approach.
  • Foveon (Sigma): stacks three light-sensitive layers so every pixel records all three colors directly, eliminating the need for demosaicing altogether, at the cost of other trade-offs.
  • Quad Bayer: common in smartphones, groups four same-color photosites together, then bins or remosaics them for different shooting modes.

For nearly all dedicated cameras, though, demosaicing a Bayer mosaic is the core task, and a capable converter handles it whether your file is a Canon CR2, Nikon NEF or Sony ARW, as covered in the Nikon NEF to JPG guide and related articles.

How algorithms reconstruct the missing colors

It helps to see roughly how a good demosaicing algorithm thinks. Consider a pixel that sat under a red filter; it knows its own red value but must estimate green and blue. The green channel is reconstructed first because green pixels are twice as dense in the Bayer pattern and carry most of the luminance detail. A simple method would average the four neighboring green pixels, but a smarter one examines the gradients around the pixel: if there is a strong edge running vertically, it interpolates green along that edge rather than across it, avoiding the blur that crossing an edge would cause.

Once a full green channel is reconstructed, red and blue are estimated using the relationship between channels. The algorithm assumes that color ratios change smoothly even where brightness does not, so it interpolates the difference between red and green, and blue and green, rather than the raw color values. This cross-channel approach dramatically reduces color fringing because it ties the sparse red and blue data to the dense, detailed green channel. The most advanced algorithms iterate, refining their estimates and suppressing false color in a second pass. The result is a full RGB image that preserves edges crisply and keeps colors clean.

Antialiasing filters and their interaction with demosaicing

Many sensors include an optical low-pass filter, also called an antialiasing filter, directly over the sensor stack. It slightly blurs incoming detail to prevent the fine, repeating patterns that cause moire and false color during demosaicing. There is a genuine trade-off here: the filter reduces artifacts but also softens the image marginally, which is why some cameras omit it to maximize sharpness and rely on the demosaicing algorithm and higher resolution to manage moire instead. Understanding this helps explain why two cameras with similar megapixel counts can render fine detail differently, and why output sharpening after conversion is a normal part of the workflow.

Why this matters for your conversions

Understanding demosaicing changes how you judge your output. If you see colored fringing or zipper patterns along edges, that is a demosaicing artifact, not a focus problem. If fine fabric shows rainbow moire, the interpolation is struggling with a pattern near the sensor's resolution limit. Knowing this helps you choose good software and apply sensible output sharpening rather than over-correcting.

It also reinforces why you should preserve your RAW files. Because demosaicing happens at conversion time, a better algorithm in the future can re-develop your old RAW files with cleaner results, something impossible with an already-demosaiced JPEG. For maximum quality on a master you intend to edit, develop into a 16-bit TIFF using the RAW to TIFF converter, as explained in RAW to TIFF for editing, so the freshly demosaiced detail survives heavy retouching. If your finished file is bound for print, the JPG to TIFF converter moves it into a lossless container.

From mosaic to masterpiece

Demosaicing is the quiet miracle behind every digital color photo: the reconstruction of a full RGB image from a sensor that only ever measured one color per pixel. The quality of that reconstruction shapes the sharpness, color accuracy and artifact-freedom of your final image, which is why good conversion software and preserved RAW files matter so much. Put the theory to work with the free RAW to JPG converter, and you will see your sensor's data turned into clean, colorful images the way it was meant to be.