Login  Register

Extracting individual color pixels from DLSR (or other Bayer pattern) color images to run photometry in each color

Posted by karenacollins on Mar 07, 2022; 11:15am
URL: http://astroimagej.170.s1.nabble.com/Extracting-individual-color-pixels-from-DLSR-or-other-Bayer-pattern-color-images-to-run-photometry-ir-tp1857.html

DLSR (and other cameras) often produce color images using a Bayer pattern that keeps all of the color information within one otherwise monochrome 8 or 16 bit image.

To extract light curves from each color, first load the image sequence from the camera into AIJ by either a drag and drop of the folder containing the images on the AIJ toolbar, or use AIJ_Toolbar > File > Import > Import Image Sequence.

Next, use the option Image_Display_Menus > Color > "Debayer to single color/luminosity 1/4 size stack(s)" to separate the colors into 3 separate stacks. An option panel will be presented first (see below for option descriptions). Each resulting image stack size will be 1/4 the original size since each Bayer "super-pixel" contains individual R, G, G, and B pixels (there are two G pixels per super-pixel) in a 2x2 pattern.

The R stack and B stack pixels are extracted exactly as they are in the original file. The G stack pixels are the average of the two G pixels in each Bayer super-pixel.

The resulting stack names will have suffixes (RED), (GREEN), and (BLUE) to identify the contents. There is optionally a (LUMINOSITY) stack too (see more below).

There are 4 Bayer patterns identified as RGGB, BGGR, GRBG, and GBRG. These describe the order of the pixels in the original 2x2 pixel "super-pixel" in the Bayer image.

Camera control software such as ZWO ASIAIR will produce FITS images compatible with AIJ. The software will sometimes add a FITS header keyword that identifies the Bayer pattern in keyword BAYERPAT and the value will be one of the 4 patterns listed above. If this keyword is found, it will be used as the default Bayer pattern in the option panel, but the user may override it as needed.

AIJ also supports three other Bayer pattern-related FITS header keywords. If found, the corresponding adjustments will be made automatically. The supported keywords are ROWORDER, XBAYROFF, YBAYROFF.

You may also specify which image stacks you desire to extract, including Red, Green, Blue, and Luminosity. The luminosity image pixels are the sum of all 4 sub-pixels within the Bayer encoded image.

Once the individual color image stacks have been extracted, run Multi-Aperture as usual on each stack to produce light curves for each color.

If you have calibration images such as bias images and dark images, you may want to process your original images through the Data Processor module first. Then, load the calibrated images that were saved by DP back into AIJ as using the drag and drop or import methods mentioned above.

The development of this capability in AIJ was enabled by significant help from Han K (ASTAP author) and AIJ and ASTAP user Bill Tschumy. The long post that details the development process is  here. You may find useful info there.

If you are unsure of your camera's Bayer pattern, one option is to photograph your computer screen using your camera (using an appropriate exposure time that will not saturate or underexpose in any color) while displaying the red, green, and blue stripped image below (credit to Han K). Then load the image in AIJ and use the AIJ debayer option to extract the 3 individual images corresponding to each color. Try the extraction with different Bayer pattern options (RGGB, BGGR, GRBG, and GBRG) until you find the correct option that gives a (RED) image which has a red strip with a higher average ADU compared to the green and blue strips, and at the same time the (GREEN) image has the highest values in the green strip and the (BLUE) image has the highest values in the blue strip.

Karen