Author Topic: Functions to address a pixel's RGB components  (Read 2117 times)

Offline apintole

  • Newcomer
  • Posts: 6
Functions to address a pixel's RGB components
« on: 2016 March 07 22:56:54 »
I'm new to PI. Now I'm trying to imitate on PI different steps of image processing I have been using on other programs before. Among Pixelmath's functions (to be seen in the drop-down list of PM's editor) I didn't find a function which addresses a pixel's red value - or green value or blue value. How could I use PM to realize a shift in colour space of a certain pixel like this (may be there are more appropriate means to do this than PM. This is meant only as an example of liberally manipulating colour channels):

new_red_value(x, y)   := a_11*red_value(x, y) + a_12*green_value(x, y) + a_13*blue_value(x, y)
new_green_value(x, y) := a_21*red_value(x, y) + a_22*green_value(x, y) + a_23*blue_value(x, y)
new_blue_value(x, y)  := a_31*red_value(x, y) + a_32*green_value(x, y) + a_33*blue_value(x, y)

where <a_ij> is a matrix of real (=floating point) coefficients.

Thank you for help

Heinrich

Offline RickS

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1298
Re: Functions to address a pixel's RGB components
« Reply #1 on: 2016 March 08 00:44:12 »
Not sure exactly what you're trying to do but you can untick the "Use a single RGB/K expression" in PixelMath and provide individual expressions for the R, G and B channels.  If you want to do colour manipulation it may also be worth considering using ChannelExtraction to split the RGB image into say the CIE L*c*h* colour space, manipulate the h* component and then recombine with ChannelCombination.

Cheers,
Rick.

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: Functions to address a pixel's RGB components
« Reply #2 on: 2016 March 08 06:03:00 »
Hello Heinrich

As Rick said, you need to uncheck the  "Use a single RGB/K expression" option. Then, you should use the wildcard $T to name the image that is going to be adjusted, and the square brackets to call a particular channel by its number. You don't need to enter the left side of the equation.

Example:
a_11*$T[0] + a_12*$T[1] + a_13*$T[2]
a_21*$T[0] + a_22*$T[1] + a_23*$T[2]
a_31*$T[0] + a_32*$T[1] + a_33*$T[2]
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com