Author Topic: Debayer RGBG  (Read 4001 times)

Offline slackingCamel

  • Newcomer
  • Posts: 21
Debayer RGBG
« on: 2017 May 09 03:47:18 »
i am new to PI, and loving the technicalities and intricacies of it, but i hit a road block i cant seem to get past.
while following a tutorial, i got to the point of debayering my images, turns out RGBG is not common enough. however, this is my only useful camera at this point and i would really like to somehow debayer my images to continue using PI for the rest of the processing. Anyone got any suggestions?

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Debayer RGBG
« Reply #1 on: 2017 May 09 04:42:59 »
Hi and welcome to PixInsight Forum.

These nonstandard Bayer patterns are fully supported in the next version 1.8.5 of PixInsight. They are already implemented now; see this source code to check this out.

Version 1.8.5 is a very complex release with many new features and new and improved tools. I'm working hard on it full time, so it's a matter of weeks. I just ask for a bit of patience.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Niall Saunders

  • PTeam Member
  • PixInsight Jedi Knight
  • *****
  • Posts: 1456
  • We have cookies? Where ?
Re: Debayer RGBG
« Reply #2 on: 2017 May 09 04:52:16 »
Hi there,

When you say "RGBG is not common enough" what, exactly, do you mean by this?

In a standard four-colour Bayer Array (also commonly referred to as a CFA) there are four possible meathids of aligning the CFA to the underlying monochrome pixel array. It is very common to not know how the CFA array has been aligned by the CCD manufacturer, and even if a datasheet is available, there is also then the fact that the actual manufacturer of the imager (of the camera) may have used some undefined offset, image-flip, image-flop or rotation (or a combination of all four transformations). Further, the raw image can also be changed by the image capture software. And, finally, some software packages (like PixInsight) actually offer the user a means of trying to compensate for these transformations at the time the raw image is loaded into PixInsight for processing.

So, all of that sounds scary, doesn't it? After all, if a user cannot know how the CFA is supposed to align to the pixel array, then how can they ever expect to be able to deBayer an image to recover the colour content?

Fortunately, when the CFA sub-matrix (the R, G, B and G elements that you referred to) is in the form of a 2 x 2 grid, you only have four possible choices to consider - and all of these are on offer within the DeBayer Process (and associated BatchDeBayer Script). Only one of these will work 'correctly', and all you have to do is to try all four and determine, empirically, which one is the 'correct' one. Once you have done that then, unless you change imaher or acquisition software, you should not have to change things again (and PixInsight can even memorise a 'Default' selection based on your particular setup).

And the process is not actually that difficult at all - all you need to do is to open a single RAW (un-calibrated) sub-frame. Then, using the DeBayer Process, apply each of the four possible CFA settings to your source image - one at a time. You will, of course, generate four new, colour, images. You can apply a ScreenTransferFunction (STF) to each of these images, and you can zoom in to examine what the images look like.

Typically, I find that two out of the four unages are noticeably 'mosier' than the others - these can be discarded straight away.

Then I would try 'un-linking' the channels in the STF dialogue, and re-applying the STF to the remaining two images. One is usually 'better' than the other in terms of what you might expect your un=processed colour image to look like. Set that method as your CFA selection (and default) and try your new selection on your image set.

Do noy overly concern yourself if your fully calibrated, aligned and stacked 'MasterFrame' doesn't seem to have much colour in it as you start post-processing - this is normal, and subsequent steps will slowly reveal the colours that you have captured.

Another very useful method for empirically determining CFA is to simply put a piece of coloured paper (or see-through film, such as a wrapper from a certain well-known brand of boxed chocolates !!) over you imager (no need to be attached to the OTA for this) and expose to a reasonably 'white' source of light. Now, when applying each of the CFA selections, only one should result in an image approximating the colour of your filter.

Hope this helps but, if I have missed the point of your query entirely, please come back to us with a more detailed question.

Cheers,
Niall Saunders
Clinterty Observatories
Aberdeen, UK

Altair Astro GSO 10" f/8 Ritchey Chrétien CF OTA on EQ8 mount with homebrew 3D Balance and Pier
Moonfish ED80 APO & Celestron Omni XLT 120
QHY10 CCD & QHY5L-II Colour
9mm TS-OAG and Meade DSI-IIC

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Debayer RGBG
« Reply #3 on: 2017 May 09 05:19:01 »
Hi Niall,

Quote
you only have four possible choices to consider

I used to believe the same thing, but oddly, there are some cameras out there using nonstandard CFA patterns such as RGBG:

R G
B G


Note that in this case both green pixels are aligned vertically, so the distribution of color components forms green columns across the entire sensor. For this reason I have extended the Debayer tool to support four additional "atypical" CFA patterns in version 1.8.5, besides the standard RGGB, BGGR, GBRG and GRBG:

G R
G B

G B
G R

R G
B G

B G
R G


This covers all combinations with green pixels aligned vertically. Probably unnecessary (so far I have only seen RGBG), but hey, four for the price of one can't hurt ;)

The BatchPreprocessing script and the DrizzleIntegration tool (which now supports direct CFA drizzle integration, aka "Bayer drizzle", on monochrome CFA frames) are also updated with these four additional patterns.




Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline slackingCamel

  • Newcomer
  • Posts: 21
Re: Debayer RGBG
« Reply #4 on: 2017 May 09 06:18:45 »
thanks guys.
Version 1.8.5 is a very complex release with many new features and new and improved tools. I'm working hard on it full time, so it's a matter of weeks. I just ask for a bit of patience.
really happy to hear that its coming.

Not being pushy... but
how many weeks?


Offline Niall Saunders

  • PTeam Member
  • PixInsight Jedi Knight
  • *****
  • Posts: 1456
  • We have cookies? Where ?
Re: Debayer RGBG
« Reply #5 on: 2017 May 09 12:09:58 »
You are but a "newbie" in the world of PixInsight  ;)

The evidence of this is that you have not yet learned that Jedi Conejero has no concept of time. If it is daylight and he is hungry, but does not yet crave fine red wine, then it is Breakfast Time. If he is a little sleepy, and has consumed food and wine, it may be Afternoon Time. And if the sky is dark, then he is either ready for Bed Time, or he may already actually be asleep.

All notion of 'time', to Juan, is "relativistic" - the PixInsight code is either relatively ready, or it is relatively not. And, remember, all code is never, truly, 'ready' for distribution. But, occasionally, he presses the 'Release' button during compilation (usually in error), and we - as his servants - humbly accept his new offering and make sacrifices at the altar of our astronomy god, "Clearskies".

Don't worry though - if he says that the next release should be available "in a few weeks", just remember that he hails from that fine country, Spain - the country that invented the word "mañana" for a (very good) reason  8)
« Last Edit: 2017 May 10 16:05:00 by Niall Saunders »
Cheers,
Niall Saunders
Clinterty Observatories
Aberdeen, UK

Altair Astro GSO 10" f/8 Ritchey Chrétien CF OTA on EQ8 mount with homebrew 3D Balance and Pier
Moonfish ED80 APO & Celestron Omni XLT 120
QHY10 CCD & QHY5L-II Colour
9mm TS-OAG and Meade DSI-IIC

Offline slackingCamel

  • Newcomer
  • Posts: 21
Re: Debayer RGBG
« Reply #6 on: 2017 May 09 12:53:08 »
yes, i am but a newbie.

And i love a good laugh, thank you sir for that.
i come from the software world, and i know that code is never truly ready and the fluctuations of time are common, however, i have seen his code post, and it looks legit.
We humbly await the "Release", with clear sky season approaching, and a herd of virgin goats ready to sacrifice.

 thanks all.


Offline John_Gill

  • PixInsight Old Hand
  • ****
  • Posts: 368
Re: Debayer RGBG
« Reply #7 on: 2017 May 10 03:18:05 »
@ Niall,

Many thanks for a great laugh about Jedi Conejero ....  :laugh: :laugh: :laugh: :laugh:  it all makes sense now!
APM 107/700 apo on CGX mount
ZWO Optics - Autoguiding
ZWO1600mm and filters
... when there are no clouds ...

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: Debayer RGBG
« Reply #8 on: 2017 May 10 11:36:40 »
   :D
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)