The following is a raw Bayer image from a Raspberry Pi's camera (v.2):-

raw Bayer

It was taken in complete darkness, so the image simply represents all of the various noises that accumulate on a CMOS photo sensor. The command was raspistill --nopreview --ISO 800 --raw -o noise.jpg.

The data was imported into GIMP as greyscale (256 shades/byte) so we have one grey block per byte (not per pixel as the Bayer data is 10 bit). It kinda shows the values of the individual bytes. You can see that there are strips of colour separated by much darker regions. If we then perform a graphic equalisation on the image, we get:-

enhanced Bayer

You can see that the dark regions do contain information.

Q. Given that sensor noise affects all sensor sites equally/randomly, why does the raw unprocessed Bayer data have such prominent vertical stripes?


3 Answers 3


They don't.

You're interpreting the raw data wrong. According to the PiCamera documentation, the Pi's 10-bit raw data is encoded as 5 bytes in the following manner:

The Pi's Bayer array is BGGR. So the first four bytes contain the most significant bits (bits 10–3) of the blue, green1, green2, and red sensels, respectively. The fifth byte of data packs the least-most significant bits of each of the sensels into that single byte. But that means blue's low bits are shifted by 6 bits (equivalent to multiplying by 64), green1's low bits are shifted by 4 bits (same as multiplying by 16), green2's low bits are shifted by 2 bits (multiplying by 4).

So, if you just try to view the raw data in a regular image viewer (which you shouldn't), you'll see a each 5-byte block as a row of 5 pixels:

  • a pixel representing the raw blue top 8 bits
  • a pixel representing the raw green1 top 8 bits
  • a pixel representing the raw green2 top 8 bits
  • a pixel representing the raw red top 8 bits
  • a pixel representing the lowest 2 bits of each of the BGGR sensels, in binary weighted order.

Thus, when interpreted (i.e., viewed) as a single pixel, that 5th byte highly magnifies the low-order bits of blue's data, and also magnifies green1's low-order bits.

Because you took a mostly dark image, the first 4 bytes of data, representing the high-order bits of each of the BGGR sensels, is mostly black / dark gray. There are probably several nonzero values in the data, but not much beyond probably bit 3 or 4. Most of the noise was in bits 1 and 2 for each sensel, which all just happen to be packed into that 5th byte of the raw data.

So, to your question, "Why do Bayer images of total darkness contain stripes?", they don't. The vertical stripes are just an accident of showing an array of data structures as an image. The raw data is not meant to be viewed directly, without parsing or processing it first. I suggest using a utility such as raspiraw, or use Picamera and follow their Raw Bayer data captures guide.


Your premise is wrong and lies already in the definition of noise. if it would affect all sensor sites equally, it wouldn't be noise but only an offset.

Noise means that some more-or-less random value is added to the signal, different for each sensor site. That's what makes it so hard to remove. see What is noise in a digital photograph? for an explanation of the different noise types in a digital sensor.

If the images really show one block per byte of a file with 10 bits per pixel, iterpreting it becomes kind of difficult, it would be more interesting to see a correct raw conversion pre-demosaicing like dcraw -E does. This would show the actual noise pattern, as the current image is simply an artifact of the raw file layout according to @scottbb 's comment.

  • \$\begingroup\$ I've clarified the question to focus on the presence of the vertical stripes. I was clumsy with my equally random comment... \$\endgroup\$
    – Paul Uszak
    Jun 3, 2020 at 14:52

Given that sensor noise affects all sensor sites equally/randomly, why does the raw unprocessed Bayer data have such prominent vertical stripes?

As @scottbb already explained the RAW format layout and why this creates the striped (in the chat session), you should know now that these are just low level "noisy bits" from four sensor sites (BGGR) combined into 8-bit values and displayed as such - they would have quite random values.

As for graphically equalizing using GIMP, as you're doing is amplifying the low level signals in the JPEG all the way up to maximum spreads. That will seem very much like noise, unless there was a very strong pattern there to start with. Equalization is a pretty extreme adjustment and I've never found a good use for it personally.

As you shot in the dark, what you're basically seeing is noise amplified.

If you want to see what the sensor actually detects as a proper image then you need to convert the RAW image normally and adjust the tone curve or exposure in post (using a RAW converter, not GIMP, which won't treat the pixel group data properly).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.