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

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

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

karenacollins
Administrator
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

Reply | Threaded
Open this post in threaded view
|

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

ghawkins
Thankis, Karen.
Reply | Threaded
Open this post in threaded view
|

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

ghawkins
Hi Karen,

Please, can you clarify the calculation of the luminosity image pixels?

The description above indicates the luminosity image pixels are the sum of all 4 sub-pixels within the Bayer encoded image.  However, it would be more representative if it was RED + BLUE + (GREEN1 + GREEN)/2.

Also, the Lumosity image is twice the size of the extracted r, ,g, b images.  Is this because the result is stored as a 32-bit rather than 16-bit image?

Best regards,

Gary
Reply | Threaded
Open this post in threaded view
|

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

karenacollins
Administrator
Correct on the difference in the luminosity image file size.

I've added a feature request to either change to, or allow the user to select luminosity = RED + BLUE + (GREEN1 + GREEN2)/2.

Karen
Reply | Threaded
Open this post in threaded view
|

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

ghawkins
Hi Karen,

Many thanks.

Gary
Reply | Threaded
Open this post in threaded view
|

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

ghawkins
In addition, could I request that the filenames for debayered images are appended with _TB, _TG, _TR, and _Lum?  That way, there's less chance of getting files confused if they are copied out of their respective folders.

Best regards,

Gary
Reply | Threaded
Open this post in threaded view
|

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

ghawkins
I think I've identified an issue with debayering.  The dates in the FITs header (DATE-END, DATE-AVG, DATE-OBS) of the debayered images is one fixed value across all images. I've tried it on two sets of images and got the same result. It also looks like some other FITs header parameters are not carrying across correctly like OBJCTAZ and OBJCTALT.  Further, several FITS header parameters are removed in the debayer images - not sure if this is right or wrong.  Should COLORTYP in the debayered images be set to something other than RGGB?
Reply | Threaded
Open this post in threaded view
|

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

karenacollins
Administrator
Gary, I've added these two items to our to-do list. Why the T as part of the file name suffixes, instead of just _R, _B, _G?
Reply | Threaded
Open this post in threaded view
|

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

ghawkins
I'm used to tri-color designation from the AAVSO, so tri-color green, TG, etc :).

Either way works, so long as the color type is added to the filename, in case files are copied into the same folder.
Reply | Threaded
Open this post in threaded view
|

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

ghawkins
Hi Karen,

Any update on when the flux calculation will be updated?  I'm hoping to do some measurements that would take advantage of this feature.

Best regards,

Gary