Author Topic: Pixelmath question about Shadows & Red channel  (Read 2476 times)

Offline mcbbcn

  • PixInsight Enthusiast
  • **
  • Posts: 78
    • View Profile
Pixelmath question about Shadows & Red channel
« on: 2012 November 13 16:56:20 »
Hi,

As a newbie, there is always the potential that I'm asking the wrong question, but I have to give it a try.  :laugh:

If I wanted to increase the red signal by 15% in the shadow point of an image, what would the Pixelmath function look like?

Also, I would like to know what the pixel math formula would look like if I wanted to apply it to the midpoint or highlights of the Red channel.

Thanks in advance for your help,

M.

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
    • View Profile
Re: Pixelmath question about Shadows & Red channel
« Reply #1 on: 2012 November 13 22:07:46 »
Why are you not using HistogramTransform for this? You can do this graphically with this tool.
Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline mcbbcn

  • PixInsight Enthusiast
  • **
  • Posts: 78
    • View Profile
Re: Pixelmath question about Shadows & Red channel
« Reply #2 on: 2012 November 13 22:54:36 »
Hi Georg,

I use HT all the time but I wanted to see if I could be more precised with my values and increase the red signal for the shadows 15%.  Where I use HT, I slide the midtones for the Red Channel but I can't I can't slide the shadows (left arrow of the HT) to the left as it's set to zero and this is one of the benefits of how this tool works.  Still, I wanted to check if I could push the boundaries by increasing the signal by a specific amounts for shadows, midtones & highlights separately and for a specific color channel.  If I can't do it using Pixelmath or any other Pixinsight tool, that is fine, I'm just exploring and learning what I can do with this system.

Thanks for your help,

M.

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
    • View Profile
Re: Pixelmath question about Shadows & Red channel
« Reply #3 on: 2012 November 13 23:27:33 »
It is certainly possible to do with PixelMath. I am away from my PI system, so i cannot figure it out right now. Maybe someone else can. Or the slightly outdated PM reference http://pixinsight.com/tutorials/PixelMath/en.html can help.
Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline mcbbcn

  • PixInsight Enthusiast
  • **
  • Posts: 78
    • View Profile
Re: Pixelmath question about Shadows & Red channel
« Reply #4 on: 2012 November 14 10:18:17 »
Hi Georg,

Thanks for the PM reference.  I spent some time looking at it, and I found how to increase red signal but it's linear for the whole image, I don't seem to be able to split it by shadows, midtones & highlights...I'll keep researching, I'm sure something will pop up at some point...I'm sure there is some way to specify the intensity of the pixel under an iiF condition where the intensity will be something like if pixel value is less than this intensity (then it's a shadow) & then apply the signal increase...I'm sure there is a way to do it.

Best regards,

M.

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7089
    • View Profile
    • http://pixinsight.com/
Re: Pixelmath question about Shadows & Red channel
« Reply #5 on: 2012 November 14 11:32:28 »
This is relatively easy with PixelMath, but you need multiple expressions and symbols.

Let's define the 'shadows', 'midtones' and 'highlights' sets as a function of two variables, a and b, as follows:

x pertains to shadows if 0 <= x < a
x pertains to midtones if a <= x < b
x pertains to highlights if b <= x < 1

where we are working in the normalized real range [0,1] (0=black and 1=white). Now assume that we want to multiply the shadows set by a constant k1, the midtones set by k2, and the highlights set by k3. This allows us to implement a three-step linear function. The PixelMath implementation is the following:

1. Uncheck the ''Use a single RGB/K expression" option, so we can specify three per-channel expressions.

2. Uncheck the ''Rescale result" option.

3. Define a variable L and five constants: a, b, k1, k2 and k3. For example, we can write this in the Symbols slot of PixelMath:

L, a=0.25, b=0.60, k1=0.90, k2=1.02, k3=0.95

4. Enter the following expressions:

R/K:
      L = CIEL( $T ); $T*iif( L < a, k1, iif( L < b, k2, k3 ) )
G:
      $T
B:
      $T


These PixelMath expressions implement hard sets, i.e. sets without intersections. An improvement is to implement fuzzy sets, where a pixel can be a member of more than one set at the same time, in different degrees. This implementation is more complex but more useful and flexible. Any takers?  >:D

Another way to implement this color correction is with the CurvesTransformation tool, applying per-channel curves with a luminance mask.

Let me know if this helps.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline mcbbcn

  • PixInsight Enthusiast
  • **
  • Posts: 78
    • View Profile
Re: Pixelmath question about Shadows & Red channel
« Reply #6 on: 2012 November 14 12:22:12 »
 ;) Que bueno eres Juan!!!

I'm definitely not a taker for the fuzzy models  :-[ , but I really appreciate the information on the straight linear models.  It's quite a learning process and gratifying one.

I played a bit with Curves Transformation (CT) where I would overlap the Red signal and the luminance signal to get what an approximate result, so it totally resonates with me the tip on CT.

I was never too good with math, but I was not too bad with computer programming and the above expression, specially the 2nd half of the expression breaks down as follows (if I'm correct):

If L < a, then apply K1
elseif L < b then apply K2
  else apply K3
  endif
endif

Cool beans like the say in Oregon!  :P

Thanks again for all your help,

M.
« Last Edit: 2012 November 14 12:39:52 by mcbbcn »