Skip to content

[Docmentation] How to find out the Bayer pattern from the CFA layout #714

Open

Description

@astrorafael

I'm reading the excellent picamera documentation (thank you so much!) and I have now a better idea of how the sensor works. I'd like to perform some RAW Bayer data captures myself, so began reading section 4.5 Raw Bayer data captures

At some point, the example code states that the OV5647 sensor Bayer pattern is BGGR and then, it shows the equivalent
pixel CFA as

GBGBGBGBGBGBGB
RGRGRGRGRGRGRG
GBGBGBGBGBGBGB
RGRGRGRGRGRGRG

I simply do not get how the BGGR pattern is deducted from the layout.

For instance, reading 2x2 from top, left I would read GBRG
For instance, reading 2x2 from bottom, left I would read RGGB

I would be very grateful if you could expand the comments so that the BGGR pattern can be easily seen from the layout depicted.

Activity

  1. 6by9 commented on Jan 26, 2022

    @6by9
    Collaborator

    It is contradictory.
    If it is BGGR, then the layout would be

    BGBGBGBGBGBGBG
    GRGRGRGRGRGRGR
    

    The layout illustrated would be GBRG.

    As noted just after that,

    # Please note that if you use vflip or hflip to change the orientation
    # of the capture, you must flip the Bayer pattern accordingly
    

    so you need to know which sensor you are dealing with, and the flips in effect in order to be able to know the Bayer order.

    Or you can look at offset 268 (if I've counted correctly) into the header which contains the Bayer order:
    0 - RGGB
    1 - GBRG
    2 - BGGR
    3 - GRBG
    dcraw uses this header to get the order - https://github.com/6by9/dcraw/blob/master/dcraw.c#L6466

  2. astrorafael commented on Jan 27, 2022

    @astrorafael
    Author

    Ok, so this is a typo in the example CFA layout in the documentation. Good to know. Should be trivial to fix it quickly.

    I have also downloaded the OV 5647 datasheet and on page 25, figure 3-1 shows the chip CFA pattern with the BG/GR patterns as expected,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions