I am very interested in the shadow/highlight filter in photoshop. Does anybody has any ideas about the algorithm behind the shadow/highlight filter?
I hope this is what you want
I made a little 10-step wedge of various shades of black-white and went through the various values of Shadow in the Shadow and Highlight settings for you and animated the movie so you can see how the histogram is moving…
You can see as the Amount increases, the more the second histogram bar moves to the right. As the Tone increases, so more and more different shadow tones are affected.
It is not accurate but imitates well.
lumR = 0.299;
lumG = 0.587;
lumB = 0.114;
// we have to find luminance of the pixel
// here 0.0 <= source.r/source.g/source.b <= 1.0
// and 0.0 <= luminance <= 1.0
luminance = sqrt( lumR*pow(source.r,2.0) + lumG*pow(source.g,2.0) + lumB*pow(source.b,2.0));
// here highlights and and shadows are our desired filter amounts
// highlights/shadows should be >= -1.0 and <= +1.0
// highlights = shadows = 0.0 by default
// you can change 0.05 and 8.0 according to your needs but okay for me
h = highlights * 0.05 * ( pow(8.0, luminance) - 1.0 );
s = shadows * 0.05 * ( pow(8.0, 1.0 - luminance) - 1.0 );
output.r = source.r + h + s;
output.g = source.g + h + s;
output.b = source.b + h + s;
Click here to cancel reply.