Author Topic: How to work directly on RGB channels in pixel math ?  (Read 5459 times)

Offline Philippe B.

  • PixInsight Old Hand
  • ****
  • Posts: 399
    • CIEL AUSTRAL
How to work directly on RGB channels in pixel math ?
« on: 2010 September 02 00:38:40 »
Hello
Sorry for this stupid question (I didn't find full answer in the forum archive)

I would like to work in PIXEL MATH directly on the RGB channels and mix something like this :

For exemple, I have 2 images : image1 = RGB, image 2 = grey (Halpha)

image1(R) = 50% image1(R) + 50% image2(grey Ha)
image1(G) = image1(G)
image1(B) = 75% image1(B) + 25% image2(grey Ha)

Can I do that directly in Pixel math ou do I need to separate channels, make Pixel math for each channel, then recombine RGB (or LRGB) ?

More if I have for example 4 images (Halpha, OIII, Hbeta, SII) and I want to mix some of them together to have a different RGB rendering than a single SHO lut I don't like.

Thanks
Best

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: How to work directly on RGB channels in pixel math ?
« Reply #1 on: 2010 September 02 01:35:31 »
Hi Philippe,

Quote
image1(R) = 50% image1(R) + 50% image2(grey Ha)
image1(G) = image1(G)
image1(B) = 75% image1(B) + 25% image2(grey Ha)

Disable the Use a single RGB/K expression option of PixelMath, and enter the following expressions for the R/K, G and B channels, respectively:

0.5*image1[0] + 0.5*image2[0]
image1[1]
0.75*image1[2] + 0.25*image2[0]

Leave empty both the A (alpha) expression and the Symbols slot. On the expressions above, note that the square brackets allow you to reference a particular channel of an image by its index. Channel indices are numbered starting from 0, where the nominal channels are 0=red/gray, 1=green and 2=blue (when applicable).

You normally will have to disable the Rescale result option of PixelMath when you're performing these combinations, but you can try out to see which option gives you the best results.

To apply this PixelMath instance, you have several ways. The simplest way is applying PixelMath to your original RGB image. If you do so, the resulting RGBHa combined image will replace your original RGB image.

Another way is creating a new RGB image with Image > New. You should create a RGB color image of the appropriate dimensions. You normally will set the same dimensions of one of the RGB or Ha frames (the Set As Active Image button is a handy shortcut), but note that PixelMath will interpolate source data automatically to match its destination, so you can specify any arbitrary dimensions. Once you have the new RGB image created, just apply the PixelMath instance to it.

A third way is telling PixelMath to create the resulting image. Open the Destination section and enable the Create new image option.  Now apply the PixelMath instance to your RGB image, and you're done. Finally, you can also specify the width and height in pixels, select the RGB color space, and a sample format (usually 32-bit floating point). In this case you can apply the process globally (press F6, or click the blue sphere icon).

Quote
More if I have for example 4 images (Halpha, OIII, Hbeta, SII) and I want to mix some of them together to have a different RGB rendering than a single SHO lut I don't like.

Same as above, basically. In this case you have four images. For example, this is a 'natural color' (so to say) palette that you could try:

0.5*SII + 0.5*Halpha
0.15*Halpha + 0.85*OIII
0.5*Hbeta + 0.5*OIII

respectively for red, green and blue. Note that since the four frames are grayscale images, you actually don't need to specify channel indices, as 0 is always the default index for grayscale operand images.

Similarly, the expression at the beginning of this post can be replaced by this simpler form:

0.5*image1 + 0.5*image2
image1
0.75*image1 + 0.25*image2

because the default indices are being used with image1 for each RGB channel, and image2 is a grayscale image.
« Last Edit: 2010 September 02 01:42:24 by Juan Conejero »
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Philippe B.

  • PixInsight Old Hand
  • ****
  • Posts: 399
    • CIEL AUSTRAL
Re: How to work directly on RGB channels in pixel math ?
« Reply #2 on: 2010 September 02 03:14:10 »
Thanks you very much Juan  :)

Offline Niall Saunders

  • PTeam Member
  • PixInsight Jedi Knight
  • *****
  • Posts: 1456
  • We have cookies? Where ?
Re: How to work directly on RGB channels in pixel math ?
« Reply #3 on: 2010 September 02 05:38:44 »
Quote
Another way is creating a new RGB image with Image > New. You should create a RGB color image of the appropriate dimensions. You normally will set the same dimensions of one of the RGB or Ha frames (the Set As Active Image button is a handy shortcut), but note that PixelMath will interpolate source data automatically to match its destination, so you can specify any arbitrary dimensions. Once you have the new RGB image created, just apply the PixelMath instance to it.

Of course, you can also just create a 'clone' of your 'original' RGB image - by dragging the 'name-tab' at the left-side of the image window over to a clear area on your WorkSpace. Double-click the name-tab of the new cloned image and re-name it to something useful.

Now you can use this new image as the 'target' for your PixMath operation.

Perhaps not so obvious is that the PixMath 'target' must have the correct number of colour planes to suit the process that you are trying to apply. If it doesn't, remember you can convert from 'Greyscale' to 'RGB' and vice versa from the Image menu.
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