PixInsight Forum

PixInsight => Release Information => Topic started by: Juan Conejero on 2014 June 07 04:13:07

Title: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: Juan Conejero on 2014 June 07 04:13:07
Hi all,

Today I have released version 1.36 of the BatchPreprocessing script with support for the Bayer drizzle algorithm. New versions of the Debayer, ImageCalibration, ImageIntegration and ImageRegistration modules have also been released with bug fixes and improvements to support this feature.

Bayer drizzle was devised by David Coffin, the author of dcraw (http://www.cybercom.net/~dcoffin/dcraw/). It is just a drizzle integration process, but applied to CFA (Color Filter Array (http://en.wikipedia.org/wiki/Color_filter_array)) data. This applies to frames acquired with DSLR and one-shot color CCD cameras. The idea behind Bayer drizzle is pretty straightforward: with a sufficient number of dithered frames, the drizzle integration algorithm can be applied to fill the existing holes in the red, green and blue channels of multiple CFA Bayer images to form a demosaiced RGB color image directly from calibrated raw data without interpolation. Note that this process is very different from demosaicing algorithms such as VNG, AHD, etc., which interpolate CFA frames to generate RGB pixel sample values.

For detailed information on the DrizzleIntegration tool and some interesting discussions about drizzle and Bayer drizzle, see the original announcement thread (http://pixinsight.com/forum/index.php?topic=7151.0). With the newly released tools and scripts, this is an outline of the procedure to perform a Bayer drizzle integration in PixInsight:

1. Use the BatchPreprocessing script to calibrate your raw data as usual. On the Lights page of BatchPreprocessing, select:

- Generate Bayer drizzle data on the Image Registration section.
- Bayer drizzle on the DeBayer section.

(http://forum-images.pixinsight.com/20140607/BPP/bpp-bayer-drizzle.jpg)

2. Run the BatchPreprocessing script.

3. On the script's output directory you'll find two new sub-directories with the data required to perform a Bayer drizzle process:

<output-dir>/calibrated/light/bayer

This directory contains the FITS files that the DrizzleIntegration tool will use to generate the final drizzled image. These files are RGB images with the CFA components split in separate channels. These images are calibrated (and optionally cosmetized) raw data; they have not been demoisaiced or registered.

<output-dir>/registered/bayer

This directory contains the .drz files that you'll have to use with the ImageIntegration tool to prepare the Bayer drizzle process, as described in the following steps.

4. After BatchPreprocessing, open the ImageIntegration tool and add the registered images that you have on the  <output-dir>/registered directory.

5. Click the Add Drizzle Files button and select the .drz files on the <output-dir>/registered/bayer directory (see step 3)

6. Carry out your integration as usual: Optimize pixel rejection parameters to achieve the necessary rejection of spurious features with a minimal impact on the final SNR improvement.

7. After ImageIntegration, open the DrizzleIntegration tool. Select the same .drz files on the <output-dir>/registered/bayer directory. Unless you have a really huge amount of data available, set scale = 1 and drop shrink = 1.0. Execute globally and carefully inspect the result.

Keep in mind that you really need many and dithered images to apply Bayer drizzle. Say a minimum of 20 - 30 images, the more the better of course. This is because CFA images lack data as a result of the Bayer pattern: a 75% of the data is missing on the red and blue channels, while a 50% of pixels are pure black on the green channel. The drizzle algorithm will attempt to fill all of these gaps by projection of many different, well dithered images. If you've got good data, the result will be a naturally demosaiced image without any interpolation.
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: Ignacio on 2014 June 07 08:16:49
Great, Juan! I will give it a try right away on my recent Omega Cent data (22 dithered frames), and post comparisons of regular integration, drizzled 2x, and bayer drizzle.

I tried to do this process manually, but got stuck in what you mean by CFA, separate RGB channel, image format (after calibration). Could you elaborate on that? Are these RGB images with the three separate color panes with lots of zeros in them?

Thanks again,
Ignacio
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: whwang on 2014 June 07 08:26:59
Is it possible to integrate all these into a one-step script?
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: Ignacio on 2014 June 07 11:34:18
Ok, so I did a first try on the Omega Cent data (22 frames, reasonably dithered), and compared standard vs drizzle 2x vs bayer drizzle 1x. The image attached, is the same small crop of the frame, in that order. Note the obvious better smoothness of star edges  in the drizzle 2x case, but a somewhat loss of contrast (due higher noise and auto STF).

The bayer drizzle case shows strong color pixelation. In fact, if one looks at the histogram, the R and B curves are all spread out, while the G looks fairly good. This must be a result of the sparsity of the R and B color samples.

It seems to me, that there is need for some form of normalization step at the end, like a pixel level equalization depending on how much color information ends up in that final pixel location.  For instance, in the extreme case that a pixel, by chance ends up with no R data, then one could interpolate that data from neighboring R pixels (and maybe from luminance too) to fill the information hole.  This is the extreme case, but it applies to every case.

I know this sound like going back to debayering interpolation, and in a way it is, but at a stage where there is better SNR to carry it out. Am I making any sense?

Ignacio
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: pfile on 2014 June 07 13:03:37
almost seems like something went wrong with the bayer drizzle case? looks completely 'undebayered'…

rob
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: Ignacio on 2014 June 07 13:28:32
If you look at each color channel of the final stack, all pixels have non-zero values in all channels, so it seems that the algorithm did its job, by correctly registering each undebayered color pane from each sub, and stacking them.

Also, I would expect that the algorithm contemplates partial projection of pixels on the final grid, right?

Ignacio
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: whwang on 2014 June 08 06:26:53
Hi,

I do think that image normalization may have something to do with this.
This is indeed quite common for the Bayer-drizzle produced by DSS.
I often encounter this when the images are taken under variable condition
(i.e., variability in background brightness).  You can imaging that in a
2x2 pixel grid, one pixel may contain data that come from images with
higher background brightness (on average) while another pixel may contain
data from images with lower background brightness.  This produces what
you see.

This will not happen on normal de-Bayered images, since all the pixels
are interpolated.  So this is indeed the signature of Bayer drizzle.  To make
it go away, very careful image normalization is required.  Indeed, the same
can happen on standard drizzle of gray-scale images too, if the images
were taken under variable sky condition.

Cheers,
Wei-Hao
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: Ignacio on 2014 June 08 07:22:20
Changing sky conditions may contribute to this, but I think is a second order effect. There is something about how the average of the pixel on the final grid is computed, based on the amount of data samples on each color that projects on that pixel.

I don't know the internals of the implementation, but I will through an idea: given a color channel, any given pixel on the final grid may receive a bunch of partial sample contributions from different subs. The number representing that amount of samples must be real, not integer, due to partial projections, and always smaller or equal to the total number of subs. An it should vary from pixel to pixel. Is this the number used to compute the stack average for each pixel? If the number of dithered subs is very large, then this denominator will be very similar for all pixels in a given color channel. But when that number is in the 20-30 range, my guess is that this effect will be noticeable.

Ignacio
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: NGC7789 on 2014 June 08 07:53:28
For what it's worth, I see the same grid pattern in my first attempt. I have 80 subs in my stack. I don't know if that counts as "very large" but it's more than 20-30. I haven't had time to play with setting much though.

-Josh
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: whwang on 2014 June 08 12:37:51
Hi,

With no disrespect, I think the need of "many" dithered exposures is exaggerated here.

In the most ideal case, where we can accurately control the position of each dither, we will
only need 4 exposures to fill the holes in the Bayer CFA.  For G, even just 2 exposures
will be sufficient.  Of course, in amateur astrophotography, accurately controlling the dither
positions is usually not possible and the dither steps are usually random.  However, even
given this random nature, we still don't need much more exposures than 4.

In my experience, with either DSS's Bayer drizzle or my own drizzle program for CCD images,
8 exposures are quite sufficient.  I can even get away with just 4 exposures from time to time.
(When there are just 4 exposures, and when the result doesn't look good, it is usually because
of the lack of exposure time (low S/N), not because of insufficient number of exposures and
the drizzle-related artifact).

Cheers,
Wei-Hao
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: Juan Conejero on 2014 June 08 12:42:38
Quote
For what it's worth, I see the same grid pattern in my first attempt. I have 80 subs in my stack.

The current version of the DrizzleIntegration tool (released yesterday as an update) has a little bug that is causing this problem. I am preparing an update with a bug fix for all platforms right now. It should be ready in ten minutes. Sorry for the trouble.
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: Juan Conejero on 2014 June 08 13:00:38
Bug fix released. Bayer drizzle should work perfectly now. And yes, with 20 - 30 dithered images the result should be quite good. Even with 10 images or so the results are pretty decent.

Thank you for your help.
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: Ignacio on 2014 June 08 15:59:42
Ok, Juan, I tried the new version and it worked very well! Attached is the comparison crop of standard, drizzle 2x, and bayer drizzle 1x. This is what I have found so far, looking at this particular case:

Comparing Standard Integration (using VNG during debayering) with Bayer Drizzle 1x Integration (no debayering):

Both integration files were color calibrated and linearly fitted against each other.

1. Noise levels as reported by NoiseEvaluation script were 50-60% higher for the bayer drizzle R and B channels, and 25% for the G channel.
2. CBNR for the luminance was almost identical in both cases.
3. Median FWHM was 7% wider with bayer drizzle. But upon visual inspection, star edges look more natural.
4. Upon several iterations of color saturation (Curve S), the bayer drizzle integration behaves a lot better, showing much less color noise visually than the standard integration (see attached image). I find this hard to reconcile with the numerical noise estimates. Juan?

Ignacio

Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: Tromat on 2014 June 09 05:26:27
Hi,

and thanks for that new wonderful tool. A while ago I tried bayer drizzle with DSS but it wasn't successful as I had always the bayer pattern visible. It was the same with the first realease of the bayder drizzle implementation in PI but now it works like a charm :)

I managed to bayer drizzle a picture with only 10 DSLR subs. The background noise appears to be thiner, almost like a mono CCD noise. I still have to see how this behave with a full process, especially after TGVNoise reduction. I guess that the noise will be easier to manage.

(https://dl.dropboxusercontent.com/u/33678863/Astro/Divers/M101_anim_bayer_driz.gif)
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: georg.viehoever on 2014 June 09 08:50:06
Here is my attempt with 72 wide field shots. Not sure if I see any significant difference between Bayer Drizzle and traditional integration...
Georg
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: whwang on 2014 June 09 09:22:16
1. Noise levels as reported by NoiseEvaluation script were 50-60% higher for the bayer drizzle R and B channels, and 25% for the G channel.
4. Upon several iterations of color saturation (Curve S), the bayer drizzle integration behaves a lot better, showing much less color noise visually than the standard integration (see attached image). I find this hard to reconcile with the numerical noise estimates. Juan?

Hi,

Let me comment on this one.  Unless something is fundamentally wrong in the data processing, images
(drizzle or not) made with the same amount of raw data should contain the same amount of information and noise.  The result that you see slightly lower noise level in the non-Bayer-drizzle version is caused by the interpolation, which acts like blurring the image a little bit.  In other words, the lower noise in the interpolated image is just an artifact or dilution.  You Bayer-drizzled image is as good as the other one.

Cheers,
Wei-Hao
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: Astrocava on 2014 June 09 13:02:53
Here is my attempt with 72 wide field shots. Not sure if I see any significant difference between Bayer Drizzle and traditional integration...
Georg

I don't see any difference too. Have you tried to substract one from the other?
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: NGC7789 on 2014 June 09 13:16:21
I got a similar result with my widefield shots. Couldn't tell the difference. What is interesting though is that when I choose scale of 2 I couldn't tell the difference either except it is twice as big of course. Is drizzle more about fancy upscaling (i.e. larger output) rather than higher resolution (i.e. more detail revealed) or am I missing something because my data aren't sufficient to reveal the power of the tool?
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: Ignacio on 2014 June 09 13:28:49
1. Noise levels as reported by NoiseEvaluation script were 50-60% higher for the bayer drizzle R and B channels, and 25% for the G channel.
4. Upon several iterations of color saturation (Curve S), the bayer drizzle integration behaves a lot better, showing much less color noise visually than the standard integration (see attached image). I find this hard to reconcile with the numerical noise estimates. Juan?

Hi,

Let me comment on this one.  Unless something is fundamentally wrong in the data processing, images
(drizzle or not) made with the same amount of raw data should contain the same amount of information and noise.  The result that you see slightly lower noise level in the non-Bayer-drizzle version is caused by the interpolation, which acts like blurring the image a little bit.  In other words, the lower noise in the interpolated image is just an artifact or dilution.  You Bayer-drizzled image is as good as the other one.

Cheers,
Wei-Hao

I concur that debayer interpolation acts as a low-pass filter, and I was not surprised to see higher noise on the bayer-drizzle sample. What was a bit disconcerting was the slightly better FWHM, and the much worse color noise when saturated. This may have to do with specifics of VNG interpolation.

In any case, this is very good news to me, because what I was looking for most of all with this new approach, was to avoid the color bleeding I get in stars when doing the standard workflow. I still have to fully process the Omega Cen bayer-drizzle data, but I like what I saw so far.

Ignacio
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: whwang on 2014 June 09 13:42:07
I got a similar result with my widefield shots. Couldn't tell the difference. What is interesting though is that when I choose scale of 2 I couldn't tell the difference either except it is twice as big of course. Is drizzle more about fancy upscaling (i.e. larger output) rather than higher resolution (i.e. more detail revealed) or am I missing something because my data aren't sufficient to reveal the power of the tool?

I got a similar result with my widefield shots. Couldn't tell the difference. What is interesting though is that when I choose scale of 2 I couldn't tell the difference either except it is twice as big of course. Is drizzle more about fancy upscaling (i.e. larger output) rather than higher resolution (i.e. more detail revealed) or am I missing something because my data aren't sufficient to reveal the power of the tool?

Hi,

I don't have a PI example yet, as I have been too busy since the release of
the PI drizzle tools.  However, I hope my DSS example here can convince you
that Bayer drizzle is not just a fancy but useless thing.  It does help to bring out
the high resolution an image is supposed to have.
(original TIFF is here:http://www.asiaa.sinica.edu.tw/~whwang/misc/fig20-2.2.tif)

Of course, to achieve this, your image really has to be very sharp from the
beginning. 

Cheers,
Wei-Hao
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: Ignacio on 2014 June 11 11:05:53
I did this comparison of fully processed data from my recent OmegaCent session (22 dithered frames), using bayer drizzle 1x vs drizzle 2x integration (reduced back to original resolution at the end). Not very scientific as both processes are not exactly the same but similar (both done on a best effort basis).

Based on this I can say that deconvolution behaved better with the bayer drizzled data (easier to parametrize and less color bleeding in stars). The final result shows sharper and better colored stars, but less of them in the background. This last thing may be the result of the somewhat different processing of background noise. I speculate that the luminance PSF used during deconvolution is more consistent with the PSF of each individual color channel, in the bayer drizzle case.

FWIW, I also tried bayer drizzle on a different data set (30 dihtered frames), and got color pixelation in some parts of the frame (??).

Ignacio

Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: whwang on 2014 June 11 19:05:28
Hi Ignacio,

From your examples, I see that the Bayer-drizzled image is better than the normal-drizzled image
in all aspects. (The difference in background faint stars should be some processing artifact.) This confirms my thinking that Bayer CFA images should NOT be drizzled.  Instead, Bayer-drizzle is the right way to go for Bayer CFA images.

Cheers,
Wei-Hao
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: fulatoro on 2014 June 13 16:20:20
Having issues getting DrizzleIntegration working. I ran the BatchProcessing script according the instructions, but when I run DrizzleIntegration and add the drz files, I get the following error:

* Parsing drizzle data file 22 of 22:
D:/GDRIVE/Astrophotography/Lights/M51-Baader/ppDrizzle2/registered/bayer/Whirlpool Galaxy (M51)_300sec_1x1__frame9_c_d_r_b.drz
*** Error: No location vector definition.
*** Error: No image could be integrated.
<* failed *>
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: fulatoro on 2014 June 13 16:40:03
Never mind...I forgot to enable "Generate Drizzle data" during integration.

Moussa
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: rockyraccoon on 2014 July 04 17:36:27
The script errors out, if no darks/bias/flats are selected.
I don't understand why any of those would be necessary to drizzle an image (I would expect warnings, but no errors)
 but the script just quits with the following messages in the console:
Code: [Select]
run --execute-mode=auto "/Applications/PixInsight.app/Contents/src/scripts/BatchPreprocessing/BatchPreprocessing.js"

Processing script file: /Applications/PixInsight.app/Contents/src/scripts/BatchPreprocessing/BatchPreprocessing.js


run --execute-mode=auto "/Applications/PixInsight.app/Contents/src/scripts/BatchPreprocessing/BatchPreprocessing.js"

Processing script file: /Applications/PixInsight.app/Contents/src/scripts/BatchPreprocessing/BatchPreprocessing.js

*********************************************************************
* Begin calibration of light frames
*********************************************************************

* Searching for a master dark frame with exposure time = 120s -- best match is a master dark frame of unknown exposure time.

*********************************************************************
* Begin calibration of light frames
*********************************************************************

* Searching for a master dark frame with exposure time = 120s -- best match is a master dark frame of unknown exposure time.

Interestingly the script claims best match for a dark frame that doesn't really exist.
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: gvanhau on 2014 September 03 18:21:51
Hello
I could finally test it.

The results are very good in my  modest opinión.
I attached a zoom 3:1 of a crop of a normal integrated image (left) and the same but Bayer drizzle integration on the right of a set of 24 pictures I took using a 24mm Lens on an canon 450D camera of the galactic center.
The stars in the Bayer drizzle image are rounder, showing an increase in resolution.
I dont see a increment in noise

Thanks Juan (and team) for this excelent tool.

Geert
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: james7 on 2014 September 30 22:27:18
Am I correct in assuming that the only way you can currently use the Bayer Drizzle is with the BatchPreprocessing script? That is, there is no tool specifically to produce a set of files that have been reconstructed into RGB images using the Bayer Drizzle technique.
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: Juan Conejero on 2014 October 24 00:59:55
Am I correct in assuming that the only way you can currently use the Bayer Drizzle is with the BatchPreprocessing script? That is, there is no tool specifically to produce a set of files that have been reconstructed into RGB images using the Bayer Drizzle technique.

Yes, you're correct. We plan on releasing new tool versions to support Bayer drizzle outside BatchPreprocessing. They will be released as updates to the upcoming version 1.8.3 of PixInsight.
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: NKV on 2015 January 14 21:32:23
We plan on releasing new tool versions to support Bayer drizzle outside BatchPreprocessing. They will be released as updates to the upcoming version 1.8.3 of PixInsight.
Juan, please do it faster.
Because BatchPreprocessing don't provide full of power manual calibration and do it wrong. For example: BatchPreprocessing calibrate MasterFlat which already calibrated . Impossible to disable calibrate it.
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: bitli on 2015 January 14 22:38:24
I am afraid that this is an old known issue:
http://pixinsight.com/forum/index.php?topic=6936.msg47052#msg47052
But I never got an answer - the problem with BatchPreprocessing is that it is useless to use complex algorithms and 32 bit  images if we cannot be sure that the basic math is correct (or understand why it would do things differently).
-- bitli
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: Juan Conejero on 2015 January 18 14:29:55
For example: BatchPreprocessing calibrate MasterFlat which already calibrated . Impossible to disable calibrate it.

We haven't seen this problem, and I am unable to reproduce it with any of our test data sets. Can you put a repeatable example of this problem?
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: vicent_peris on 2015 January 26 09:53:14
We plan on releasing new tool versions to support Bayer drizzle outside BatchPreprocessing. They will be released as updates to the upcoming version 1.8.3 of PixInsight.
Juan, please do it faster.
Because BatchPreprocessing don't provide full of power manual calibration and do it wrong. For example: BatchPreprocessing calibrate MasterFlat which already calibrated . Impossible to disable calibrate it.

Hi Nikolay,

You mean that, when using a master flat frame (checking the "Use master flat" option), the master flat frame is again bias and dark subtracted?


Best regards,
Vicent.
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: NKV on 2015 March 11 10:49:10
We haven't seen this problem, and I am unable to reproduce it with any of our test data sets. Can you put a repeatable example of this problem?
OK, I prepare set of files.

You mean that, when using a master flat frame (checking the "Use master flat" option), the master flat frame is again bias and dark subtracted?
Yes.

We plan on releasing new tool versions to support Bayer drizzle outside BatchPreprocessing. They will be released as updates to the upcoming version 1.8.3 of PixInsight.
Hi, Juan.
Independent Bayer drizzle possible right now.
Please check my new module CFA2RGB (http://pixinsight.com/forum/index.php?topic=8319)
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: Rod771 on 2015 October 23 05:38:52
Guys, I keep coming back to this when process my under sampled data.

I must have missed something? When generating a bayer drizzle image, when do you use the files in <output-dir>/calibrated/light/bayer. ? It says the Drizzle integration tool will use thm , however Step 7 in the OP says "After ImageIntegration, open the DrizzleIntegration tool. Select the same .drz files on the <output-dir>/registered/bayer directory" These are the registered file that Image Intergration used. Just confused a bit.

Cheers

Rod
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: jkmorse on 2015 October 23 07:31:52
Rod,

Yes, they are the same .drz files that you added in the Image Integration step.  Image Integration updates the ones that were produced as a part of Star Alignment so after Image Integration you should have an entirely new set that are in the same folder that you used to populate the Image Integration tool.  Load them into Drizzle and watch the magic happen  :D

Best,

Jim
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: Rod771 on 2015 October 23 17:02:54
Thanks Jim

So to confirm , the files exported to <output-dir>/calibrated/light/bayer  during BPP are never selected in Image Integration or Drizzle Integration. Only use files in <output-dir>/calibrated/registered/bayer.
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: Alejandro Tombolini on 2015 October 23 18:47:00
Hi Rod, here (http://pixinsight.com.ar/en/docs/180/pixinsight-bpp--13-bayer-drizzle.html) there is a summary of the steps that may help
Saludos, Alejandro
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: jkmorse on 2015 October 24 09:46:55
Rod,

That sounds right but I have to confess I have never used BPP.  I want total control so do all the steps manually.

Sorry,

Jim
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: whwang on 2015 October 27 18:38:13
Hi Juan,

In this thread:
http://pixinsight.com/forum/index.php?topic=7151.0
you instructed that we should select the "generate drizzle data" option in the ImageIntegration tool.  On the other hand, for Bayer Drizzle here, you did not instruct to do so.  May I ask why is there such a difference?  I guess what I am trying to understand is what this "generate drizzle data" actually does.

Cheers,
Wei-Hao
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: Juan Conejero on 2015 October 29 08:10:54
Hi Wei-Hao,

Quote
On the other hand, for Bayer Drizzle here, you did not instruct to do so.

I forgot to mention it. Yes, the ImageIntegration tool must always update the .drz files with rejection and normalization data, so the generate drizzle data option has to be enabled also in the case of Bayer drizzle. Note that ImageIntegration enables this option automatically when you select drizzle files (by clicking the Add Drizzle Files button), so in general one doesn't need to care about this.

Quote
what this "generate drizzle data" actually does

A drizzle data file (with the .drz suffix) stores all the data required to perform a drizzle integration process:

1. The full file path of the source drizzle image (calibrated, de-Bayered, but not registered). This is the image that will be integrated with DrizzleIntegration.

2. The full file path of the registration target image (calibrated, de-Bayered and registered). This is the image that should be integrated with ImageIntegration to compute normalization parameters, image weights, and pixel rejection data. This image will not be used in the final drizzle integration process.

3. The geometry of the reference registration image. This defines the geometry of the final drizzle-integrated image (multiplied by the drizzle output scale).

4. The geometrical transformations necessary to register the image. This may include a projective transformation matrix and/or surface spline control points and parameters, if local distortion correction is being used. These transformations are applied by DrizzleIntegration to compute the geometry of each 'drop' that 'rains' over the drizzle-integrated image

5. The coordinates of each rejected pixel. In the next version of the ImageIntegration module this will be more complex, since we'll implement a fuzzy-logic rejection feature. For now, rejection is a purely binary process (rejected/not_rejected).

6. Image normalization parameters, including estimates of statistical location and scale.

7. Image weighting parameters. These are normally based on noise estimates computed during the image calibration phase (and stored as XISF properties and FITS keywords in the image), but can also be generated from statistical parameters or image properties/keywords by ImageIntegration.

Drizzle data files are created by the StarAlignment process with items 1, 2, 3 and 4. The ImageIntegration process updates drizzle files with items 5, 6 and 7.

In the case of Bayer drizzle, the trick consists of replacing item 1 with the path to the calibrated Bayer image, that is, the image after calibration but *before* applying the de-Bayering process. However, drizzle cannot use the monochrome CFA data directly (mainly because color planes would get intermixed without sense), so the CFA must be split into three separate R, G and B planes, with black pixels replacing the lacking data in each plane, and conveniently packed as an RGB image. This is what we call a separate RGB Bayer image. Then the drizzle process can be applied unmodified, as if it was working with a normal RGB image. The BatchPreprocessing script does this automatically, including generation of separate RGB Bayer data under the hood. The same task can also be implemented manually, with the help of Nikolay's SplitCFA tool to automate part of the process, but it is somewhat tedious.

Right now the Bayer drizzle method can only be implemented as an automatic process using the BatchPreprocessing script. An optimal implementation of Bayer drizzle requires a tight integration with a preprocessing pipeline, such as BPP. This will also be implemented outside BPP, probably as a standalone tool, but we have other priorities at present.

Hope this clarifies what this drizze data stuff is all about.
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: whwang on 2015 October 29 13:55:24
Thanks for the clarification and explanation.  Now I understand the whole thing better.

Cheers,
Wei-Hao
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: IanL on 2015 November 06 11:44:12
Note that there is now a new BayerDrizzlePrep script available for testing here:

http://pixinsight.com/forum/index.php?topic=9218.0 (http://pixinsight.com/forum/index.php?topic=9218.0)

This should make it possible to perform stand-alone Bayer drizzling more easily, without the need for the BPP script.
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: whwang on 2017 September 19 02:08:19
Hi,

I see that in the latest Batch Processing Script (1.46) there is no longer a Bayer drizzle check box.
How can Bayer drizzle be applied now?

Cheers,
Wei-Hao
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: mcgillca on 2017 September 19 04:49:58
Hi,

I see that in the latest Batch Processing Script (1.46) there is no longer a Bayer drizzle check box.
How can Bayer drizzle be applied now?

Cheers,
Wei-Hao

Dear Wei-Hao,

In the release post for 1.8.5, there is this comment:

* DrizzleIntegration can now work with monochrome CFA frames directly. That is, Bayer drizzle is now supported directly without needing to create RGB Bayer images anymore. The BatchPreprocessing script has also been updated accordingly.

I'm guessing that this is the answer - however, I think you need to create the RGB bayer images still so you can carry out the standard integration to allow pixel rejection BEFORE you do the drizzle integration.

I hope Juan can give us the definitive answer, since the above is just a guess - it would be useful to find out the complete workflow. I think it is:

1) BPP for most of the work, with the drizzle option selected.
2) LN to set up the LN files.
3) Image integration with the LN files and drizzle files (taken from the registered images folder, rather than the registered debayer folder?)
4) Drizzle integration with the LN files and the drizzle files again.

Can anyone confirm this is correct?

Thank you,

Colin

Colin
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: Juan Conejero on 2017 September 19 06:55:36
Hi Wei-Hao / Colin,

As Colin has pointed out, drizzle works now for CFA frames just as it has always worked for monochrome CCD frames. Enable generation of drizzle files in BPP (it is now enabled by default), then proceed with calibration, debayering, and registration in BPP, as usual. Update the .drz files with ImageIntegration, also as usual. Then use DrizzleIntegration with the CFA option enabled. Since version 1.8.5 of PixInsight, Bayer drizzle is applied in a completely automatic way directly on the monochrome CFA frames, so RGB Bayer images are no longer needed.

Quote
1) BPP for most of the work, with the drizzle option selected.
2) LN to set up the LN files.
3) Image integration with the LN files and drizzle files (taken from the registered images folder, rather than the registered debayer folder?)
4) Drizzle integration with the LN files and the drizzle files again.

LocalNormalization *must not* be used 'blindly' on a regular basis, and definitely *must not* be used without a correct understanding of the LN algorithm, its limitations and potential issues. As most inverse problems, local normalization is powerful but inherently ill-posed, so it must be applied along with a critical analysis of its performance for each particular data set. Please wait until I complete a new tutorial on the LN tool.
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: whwang on 2017 September 19 20:35:58
Juan, Collin,

Thank you.  I like the new way it works!

Cheers,
Wei-Hao
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: jtrezzo on 2017 November 28 23:17:06
I can't seem to get this to work. I keep getting "Missing CFA source file path when I try to run DrizzleIntegration" with CFA images box checked.
 
I calibrated lights, ran StarAlignment with drizzle data box checked, did Image Integration, then tried the DrizzleIntegration. I also tried doing Debayer before StarAlignment. No luck.
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: Warhen on 2017 December 05 11:42:12
Hi JT, If taking a manual track (no BPP), you'd definitely have to debayer before alignment, this is an always whether working with drizzle or not. When you mentioned ImgInt afterwards, you didn't confirm that you also had Generate Drizzle Data there as well, since ImgInt needs to update the xdrz files produced by SA. That may not be your entire answer, but they are significant points. Good luck!
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: Alfredo Beltran on 2017 December 05 12:47:22
Warren

Could you please elaborate why does the debayering needs to be done prior to the drizzle integration? I’m confused, since Bayer Drizzle is supposed to not require an interpolation process.

Thanks,

Alfredo
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: dld on 2017 December 06 04:13:00
Hello PI fans,

I have exactly the same question with Alfredo. Maybe due to my noobness :o I may have missed a post/tutorial answering my question.

Thanks!
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: Alfredo Beltran on 2017 December 08 19:20:39
I can't seem to get this to work. I keep getting "Missing CFA source file path when I try to run DrizzleIntegration" with CFA images box checked.
 
I calibrated lights, ran StarAlignment with drizzle data box checked, did Image Integration, then tried the DrizzleIntegration. I also tried doing Debayer before StarAlignment. No luck.

I’m having exactly the same issue when using the BPP. To the Gurus: Any ideas why is this happening?

Thanks in advance.

Alfredo
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: sharkmelley on 2017 December 09 11:13:49
Quote from: Alfredo Beltran
Could you please elaborate why does the debayering needs to be done prior to the drizzle integration? I’m confused, since Bayer Drizzle is supposed to not require an interpolation process.

You still need to perform the StarAlignment to generate registered images and StarAlignment requires debayered files.

Mark
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: sharkmelley on 2017 December 09 11:23:18
To perform Bayer Drizzle:

If you are using BPP then make sure you select "Generate drizzle data" in the Image Registration section and "CFA images" in the Global Options section.

If you are not using BPP then:

In either case you now have a set of registered files and drizzle files:

The error "Missing CFA source file path" in DrizzleIntegration is because you forgot to select the "CFA images" in the Global Options section of BPP so the debayering step in BPP did not happen - at least that is how I managed to reproduce the error.  If you're not using BPP then it's because you performed StarAlignment on non-debayered files.

The error "Missing required LocationEstimates element" in DrizzleIntegration is because you forgot to update the drizzle files using ImageIntegration.

An error similar to "calibrated/light/DSC00429_c.xisf: No such file" in DrizzleIntegration is because you have moved or deleted the calibrated lights.

Mark
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: Warhen on 2017 December 09 16:12:47
Mark, Thank you for ArcsinhStretch! It will be detailed in my book's second edition. Afredo/DLD, Mark explains the error well. But, in general, debayering must occur (not only before Drizzle, but) before alignment. The matrix's info has to be decoded before the transformation that occurs during registration- got it?! As Mark explains Drizzle, it's a bit mysterious to those of us 'not under the hood.'  Debayer collects the matrix offset info to pass on to StarAlignment, which generates the Drizzle files. ImgInt then updates these xdrz files for DrizzleIntegration. This took me a bit to get too! Yes, the Debayer process is used in the proper sequence, but as you say, it's DI that produces the final, uninterpolated color image. The good news is, OSC/CFA Drizzle is now easier than ever with either BPP or the manual track.
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: Alfredo Beltran on 2017 December 10 17:30:34
Thanks for your detailed process Mark, and Warren for your explanation.

I figured out that my problem was that I had set the CFA Pattern to Auto in the BPP. When I switched it to RGGB, the issue was solved and the script worked with no issues at all.

What I did see is that if I set Drizzle Scale to 1 and and drop shrink also as 1.0 (as suggested by Juan in post #1) then I don't see  difference between the regular debayered image and the one with Bayer Drizzle. But when I set Scale to 2, then I can definitely see an increase in resolution, as you can see in the comparison made in the attached image. So, the question is: should I see an increase in resolution if I set scale to 1.0 in Bayer Drizzle?

Also, I can see some patterns of the CFA matrix on the 2x Bayer drizzle image. Should this be present?

Regards,

Alfredo
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: sharkmelley on 2017 December 12 01:52:03
Quote from: Alfredo Beltran
What I did see is that if I set Drizzle Scale to 1 and and drop shrink also as 1.0 (as suggested by Juan in post #1) then I don't see  difference between the regular debayered image and the one with Bayer Drizzle. But when I set Scale to 2, then I can definitely see an increase in resolution, as you can see in the comparison made in the attached image. So, the question is: should I see an increase in resolution if I set scale to 1.0 in Bayer Drizzle?

Also, I can see some patterns of the CFA matrix on the 2x Bayer drizzle image. Should this by present?

I would usually expect to see a slight increase in detail in a x1 Bayer Drizzle.  The pattern in the x2 Bayer Drizzle is possibly because you don't have sufficiently even coverage - take a look at the weights image produced by DrizzleIntegration and zoom in at full scale to see if this is the case.

Mark
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: jtrezzo on 2017 December 12 19:47:06
Thank you Mark and Warren for your responses. Unfortunately I am still having the issue for some reason. I am debayering right after calibrating the light frames (with RGGB set for my camera, VNG demosaicing), then I run subframe selector, then star alignment (with generate drizzle data checked). After this I run image integration with the drizzle data files added so they're updated, and then try drizzle integration. Then I get Error: Missing CFA source file path. I am completely stumped as to what I am doing wrong, as I have followed all the steps written previously. It seems like somewhere in the mix it is not recognizing that they are CFA files? I don't know.
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: sharkmelley on 2017 December 12 22:33:49
Quote from: jtrezzo
Thank you Mark and Warren for your responses. Unfortunately I am still having the issue for some reason. I am debayering right after calibrating the light frames (with RGGB set for my camera, VNG demosaicing), then I run subframe selector, then star alignment (with generate drizzle data checked). After this I run image integration with the drizzle data files added so they're updated, and then try drizzle integration. Then I get Error: Missing CFA source file path. I am completely stumped as to what I am doing wrong, as I have followed all the steps written previously. It seems like somewhere in the mix it is not recognizing that they are CFA files? I don't know.

I notice from another thread that you are starting with raw FITS files from QHY247C.  Is this still the case?  The only thing I can think of is maybe the information about Bayer pattern "RGGB" is not being found by DrizzleIntegration for some reason or there is some other reason that DI is upset by working with raw FITS files.  For instance, I wonder if some header keyword needs to set within those files?

Mark
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: Alfredo Beltran on 2017 December 13 04:09:58

Quote from: jtrezzo
Then I get Error: Missing CFA source file path.

Just select your CFA pattern instead of Auto. It should work.
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: jtrezzo on 2017 December 15 20:06:36
Quote from: jtrezzo
Thank you Mark and Warren for your responses. Unfortunately I am still having the issue for some reason. I am debayering right after calibrating the light frames (with RGGB set for my camera, VNG demosaicing), then I run subframe selector, then star alignment (with generate drizzle data checked). After this I run image integration with the drizzle data files added so they're updated, and then try drizzle integration. Then I get Error: Missing CFA source file path. I am completely stumped as to what I am doing wrong, as I have followed all the steps written previously. It seems like somewhere in the mix it is not recognizing that they are CFA files? I don't know.

I notice from another thread that you are starting with raw FITS files from QHY247C.  Is this still the case?  The only thing I can think of is maybe the information about Bayer pattern "RGGB" is not being found by DrizzleIntegration for some reason or there is some other reason that DI is upset by working with raw FITS files.  For instance, I wonder if some header keyword needs to set within those files?

Mark

Yes I am using raw FITS. A keyword header is was what I was thinking too, but I have no idea what to add or how to add it. I have been selecting the pattern manually instead of using Auto too, both in Debayer and when I try DrizzleIntegration. Both RGGB.
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: sharkmelley on 2017 December 16 00:31:16
Quote from: jtrezzo
Quote from: sharkmelley

I notice from another thread that you are starting with raw FITS files from QHY247C.  Is this still the case?  The only thing I can think of is maybe the information about Bayer pattern "RGGB" is not being found by DrizzleIntegration for some reason or there is some other reason that DI is upset by working with raw FITS files.  For instance, I wonder if some header keyword needs to set within those files?

Mark

Yes I am using raw FITS. A keyword header is was what I was thinking too, but I have no idea what to add or how to add it. I have been selecting the pattern manually instead of using Auto too, both in Debayer and when I try DrizzleIntegration. Both RGGB.

How frustrating.  There is also no keyword solution.  Here (https://pixinsight.com/forum/index.php?topic=11466.0) Juan says the following about FITS files:
Quote
"PixInsight 1.8.5 implements a new automatic CFA pattern detection mode in the Debayer tool and the BatchPreprocessing script (which uses Debayer internally). This mode works perfectly for DSLR raw files. However, FITS files cannot store information on CFA patterns, so you have to select the Bayer pattern of your camera manually in the BPP script. The same is true for the Debayer tool if you use it directly."

You say you are setting the CFA pattern manually at each step, so I can't see what else you can do.  I assume you have already tried BPP for your Bayer Drizzle pipeline? I ask because earlier in this very thread (https://pixinsight.com/forum/index.php?topic=7184.msg58989#msg58989) Juan says:

Quote
Right now the Bayer drizzle method can only be implemented as an automatic process using the BatchPreprocessing script. An optimal implementation of Bayer drizzle requires a tight integration with a preprocessing pipeline, such as BPP.

Has anyone successfully Bayer Drizzled FITS files with PI 1.8.5.  If so, what did you do?

Mark
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: Juan Conejero on 2017 December 16 01:12:35
Hi all,

Sorry for having been without attending this forum for so long. Unfortunately, I have other problems that have been occupying most of my time during these weeks. I chime in here briefly because I see that something very important is being overlooked:

Quote
Has anyone successfully Bayer Drizzled FITS files with PI 1.8.5.  If so, what did you do?

When I announced version 1.8.5 of PixInsight (https://pixinsight.com/forum/index.php?topic=11281.0) I included the following among the list of new features:

DrizzleIntegration can now work with monochrome CFA frames directly. That is, Bayer drizzle is now supported directly without needing to create RGB Bayer images anymore. The BatchPreprocessing script has also been updated accordingly.

So yes, Bayer drizzle (or, more generically and correctly, CFA drizzle) can now be performed directly with the DrizzleIntegration tool. There is no need to generate RGB Bayer images as in previous versions. Just check the "Enable CFA drizzle" option and read the corresponding tool tip.

If you use BPP to calibrate and align your data, then ImageIntegration manually to optimize integration and rejection parameters, as usual, DI will perform a Bayer drizzle procedure by just activating its "Enable CFA drizzle" option.

As for the Bayer pattern / FITS problem, this is just what FITS is: an endless source of interoperability problems and deficient implementations. The FITS format does not define a standard way to include information about CFA patterns in FITS files. We can't do anything to fix this. So you have to select your Bayer pattern manually.
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: jtrezzo on 2017 December 31 11:07:45

Hi all,

Sorry for having been without attending this forum for so long. Unfortunately, I have other problems that have been occupying most of my time during these weeks. I chime in here briefly because I see that something very important is being overlooked:

Quote
Has anyone successfully Bayer Drizzled FITS files with PI 1.8.5.  If so, what did you do?

When I announced version 1.8.5 of PixInsight (https://pixinsight.com/forum/index.php?topic=11281.0) I included the following among the list of new features:

DrizzleIntegration can now work with monochrome CFA frames directly. That is, Bayer drizzle is now supported directly without needing to create RGB Bayer images anymore. The BatchPreprocessing script has also been updated accordingly.

So yes, Bayer drizzle (or, more generically and correctly, CFA drizzle) can now be performed directly with the DrizzleIntegration tool. There is no need to generate RGB Bayer images as in previous versions. Just check the "Enable CFA drizzle" option and read the corresponding tool tip.

If you use BPP to calibrate and align your data, then ImageIntegration manually to optimize integration and rejection parameters, as usual, DI will perform a Bayer drizzle procedure by just activating its "Enable CFA drizzle" option.

As for the Bayer pattern / FITS problem, this is just what FITS is: an endless source of interoperability problems and deficient implementations. The FITS format does not define a standard way to include information about CFA patterns in FITS files. We can't do anything to fix this. So you have to select your Bayer pattern manually.

Juan, I have specified the Bayer pattern manually throughout all steps and my OSC FITS files still will not work with Bayer/CFA Drizzle. I've tried it with and without debayering, neither work.
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: Don on 2018 March 04 09:01:11
I was having the same problem as JT.  I found the step in my processing that caused Drizzle Integration to fail with the "Missing CFA source file path" error when "Enable CFA drizzle" is selected.

If the SubFrameSelector script is used between debayering and star alignment to copy approved files to a folder, the .XDRZ files created by Star Alignment in the next step, and later updated by Image Integration, will not contain the <CFASourceImage> tag.  You cannot run Drizzle Integration and select the "Enable CFA drizzle" option with these files.  Drizzle Integration works, but only if you do not select the "Enable CFA drizzle" option.

At least that is what I have experienced with my CFA images, running PixInsight 01.08.05.1352.

Don
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: acmalko on 2018 March 29 10:41:32
I was having the same problem as JT.  I found the step in my processing that caused Drizzle Integration to fail with the "Missing CFA source file path" error when "Enable CFA drizzle" is selected.

If the SubFrameSelector script is used between debayering and star alignment to copy approved files to a folder, the .XDRZ files created by Star Alignment in the next step, and later updated by Image Integration, will not contain the <CFASourceImage> tag.  You cannot run Drizzle Integration and select the "Enable CFA drizzle" option with these files.  Drizzle Integration works, but only if you do not select the "Enable CFA drizzle" option.

At least that is what I have experienced with my CFA images, running PixInsight 01.08.05.1352.

Don

Exactly the same for me. I often use Subframe Selector for weighting (with FITS keyword) and can't "enable CFA Drizzle" .
It's OK without Subframe Selector step

Thanks, it helped me
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: johnpane on 2018 March 29 12:27:01
I reported this as a bug last November and did not receive any reply. However, I discovered a SubframeSelector process that will apparently replace the script, and the process does preserve the PCL:CFASourceFilePath property. See  https://pixinsight.com/forum/index.php?topic=11820.0 (https://pixinsight.com/forum/index.php?topic=11820.0)
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: GregW on 2019 January 21 15:52:25
Is there a fix yet for the subframe selector script? Mine crashes every time we try it. However the subframe selector process works okay but it is not nearly as useful
Title: Re: New Version of BatchPreprocessing Script with Bayer Drizzle Support
Post by: GregW on 2019 January 28 20:23:19
I actually got a bunch of new stuff today under script with an update to 1457.
So long,
And thanks for all the scripts