Author Topic: Batch Process MergeCFA ?  (Read 606 times)

Offline MikeOates

  • PixInsight Addict
  • ***
  • Posts: 278
Batch Process MergeCFA ?
« on: 2019 July 02 06:04:16 »
I am processing individual CFA layers after using SplitCFA. But how can I combine them again as merge CFA does not allow batch mode and it takes an awful long time to merge each image sub separately? Note: I am not just putting the same CFA layers back in, but changing them about a bit.

For example using a DSLR with OIII filter, the red channel is just noise, while both green and the blue have good signal. I want to be able to copy the blue channel to the red, then proceed with Debayer, StarAlignment and Integration. If this is done before debayering the noise in the red channel in not mixed in with the data.

Thanks,

Mike

Offline bulrichl

  • PixInsight Guru
  • ****
  • Posts: 524
Re: Batch Process MergeCFA ?
« Reply #1 on: 2019 July 02 07:34:19 »
Hi Mike,

you need not split and merge, this task is most suitable for PixelMath.

If the image in question is the current view, the following PixelMath equation will do the job:

Code: [Select]
iif(x()%2 == 0 && y()%2 == 0, pixel($T,x()+1,y()+1), $T)

The utilization of an image container will let you convert many images at once.

Bernd

Offline MikeOates

  • PixInsight Addict
  • ***
  • Posts: 278
Re: Batch Process MergeCFA ?
« Reply #2 on: 2019 July 02 15:55:47 »
Bernd,

Thank you so much for taking the time to post that solution. I presume it's for the exact example I stated above?

The problem is I have no idea what you have written, I feel so ignorant and I have no idea what those symbols mean, so I will not be able to change it to suit other tasks.

Where can I find out more info on PixelMath in how you can manipulate either the CFA array (RGGB) or even a debayered image with RGB pixels?

Regards,

Mike

Offline bulrichl

  • PixInsight Guru
  • ****
  • Posts: 524
Re: Batch Process MergeCFA ?
« Reply #3 on: 2019 July 02 17:49:25 »
Mike,

this PixelMath equation replaces each red pixel value by the neighboring lower right blue pixel value:

  R1 G1 R2 G2           B1 G1 B2 G2
  G3 B1 G4 B2    -->    G3 B1 G4 B2
  R3 G5 R4 G6           B3 G5 B4 G6
  G7 B3 G8 B4           G7 B3 G8 B4


If this is not the conversion that you intended, the equation can be modified.

Short explanation:
The current horizontal pixel coordinate x() runs from 0 to w-1 and the current vertical pixel coordinate runs from 0 to h-1 (w: image width, h: image height). The expression

Code: [Select]
x()%2 == 0 && y()%2 == 0
checks whether the current horizontal AND the current vertical pixel coordinates are divisible by 2 without remainder (i.e. whether x and y are even). In a bayer matrix with RGGB pattern, this condition is met for all red pixels. In this case, the replacement by the neighboring lower right blue pixel value is executed, otherwise the pixel values remain unchanged.

I am not an expert in PixelMath, but other users of this forum are, e.g.
David Ault (dnault42) has some examples of PixelMath expressions on his website, http://trappedphotons.com/ and Gerald Wechselberger (oldwexi) has much experience with the application of PixelMath, see http://www.werbeagentur.org/oldwexi/PixInsight/PixInsight.html

Bernd

Offline MikeOates

  • PixInsight Addict
  • ***
  • Posts: 278
Re: Batch Process MergeCFA ?
« Reply #4 on: 2019 July 04 09:19:09 »
Bernd,

Thank you again for even more information. Yes the function is what I want to do. I need a bit of time to try this out, and I will get back here with my success or more questions in due course.

Regards,

Mike