Author Topic: PixelMath with non-RGB channels  (Read 169 times)

Offline wadeh237

  • Newcomer
  • Posts: 35
    • View Profile
PixelMath with non-RGB channels
« on: 2019 August 22 06:07:09 »
Is it possible to manipulate channels in the various CIE color spaces with PixelMath?

I can see that there are functions to read them, but I don't seen an obvious way to write them into the output image.

Thanks,
-Wade

Offline sharkmelley

  • PTeam Member
  • PixInsight Addict
  • ***
  • Posts: 239
    • View Profile
    • Mark Shelley Astrophotography
Re: PixelMath with non-RGB channels
« Reply #1 on: 2019 August 22 07:30:48 »
Quote from: wadeh237
Is it possible to manipulate channels in the various CIE color spaces with PixelMath?

I can see that there are functions to read them, but I don't seen an obvious way to write them into the output image.

Take a look at the ChannelExtraction and ChannelCombination processes.  They might allow you to achieve what you want.

Mark
Takahashi Epsilon 180ED
H-alpha modified Sony A7S
http://www.markshelley.co.uk/Astronomy/

Offline wadeh237

  • Newcomer
  • Posts: 35
    • View Profile
Re: PixelMath with non-RGB channels
« Reply #2 on: 2019 August 22 08:20:35 »
The ChannelExtraction and ChannelCombination processes definitely get the job done.  I was just hoping that there might be a way to do interesting things in PixelMath, without having to split the channels first and recombine them later.  I figured that since there are specific functions to get the data in PixelMath, that perhaps there was a way to write them into the correct channels on output.

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7036
    • View Profile
    • http://pixinsight.com/
Re: PixelMath with non-RGB channels
« Reply #3 on: 2019 August 22 08:29:46 »
Hi Wade,

Besides channel extraction/combination, you can do this very easily with JavaScript. For example, this little script applies a gamma curve to the CIE L* component of the active image:

Code: [Select]
#include <pjsr/ColorSpace.jsh>
#include <pjsr/ImageOp.jsh>

function GammaToCIEL( image, gamma )
{
   image.colorSpace = ColorSpace_CIELab;
   image.pushSelections();
   image.selectedChannel = 0; // CIE L*
   image.apply( gamma, ImageOp_Pow );
   image.popSelections();
   image.colorSpace = ColorSpace_RGB;
}

function main()
{
   let window = ImageWindow.activeWindow;
   if ( window.isNull )
      throw new Error( "No active image." );
   window.currentView.beginProcess();
   GammaToCIEL( window.currentView.image, 1.8 );
   window.currentView.endProcess();
}

main();

Since the transformation is performed in a colorimetrically defined color space with lightness/color separation, color hues are preserved as far as the applied transformation does not generate out-of-gamut colors.

I think the script is pretty self-describing; let me know if you need more information.

New PixelMath functions to perform these tasks are also in the to-do list for a future version of the PixelMath tool (namely fromCIEXYZ(), fromCIELab() and fromCIELch()).
Juan Conejero
PixInsight Development Team
http://pixinsight.com/