Page 1 of 1
Alpha Channel Curve with RGB colorspace?
Posted: 2013-06-09T14:44:35-07:00
by Aylon
Hi All,
Sorry I am a complete newbie with IM and although I got around ok until now here my first question as I googled without success for an answer for this one...
I am trying to recreate the look in this tutorial with IM:
http://www.tutorialized.com/view/tutori ... look/72540
I get the three curves applied without a problem to the R & G & B channels, but I do not understand how to (simultaneously) work on the Alpha/Values-channel as this is of course not created by the -separate command?
What I do is currently:
1. separate images into R G B channels -> convert input.jpg -set colorspace RGB -separate output.jpg
2. apply curve to each -> e.g. convert tmpFile_red.jpg + -fx "CURVEEQUATION" tmpFile_red.jpg
3. combine all three images back into one -> convert tmpFile_red.jpg tmpFile_green.jpg tmpFile_blue.jpg -set colorspace RGB -combine output.jpg
Missing part is the additional curve on the "Values"-channel which as per Gimp is defined as: "The curve represents the Value, i.e. the brightness of pixels as you can see them in the composite image."
How can i work on this channel and then combine all four into the desired output?
Many thanks for any feedback or help!
Re: Alpha Channel Curve with RGB colorspace?
Posted: 2013-06-09T14:55:48-07:00
by snibgo
The tutorial is misleading. In Gimp, "alpha" refers to transparency and "value" refers to the greyness of the image. They are not the same thing. The tutorial applies a curve to the value.
I don't know how Gimp calculates the value.
IM can calculate the greyness in many different ways. One is by using the L channel of the Lab colorspace. You can do this after your 3 steps ...
Code: Select all
convert tmp.png -colorspace Lab channel R -fx "EQUATION" -colorspace sRGB output.jpg
... or within your step 3 ...
Code: Select all
convert tmpFile_red.jpg tmpFile_green.jpg tmpFile_blue.jpg -set colorspace RGB -combine -colorspace Lab channel R -fx "EQUATION" -colorspace sRGB output.jpg
Re: Alpha Channel Curve with RGB colorspace?
Posted: 2013-06-09T15:04:01-07:00
by fmw42
rather than using -fx, you can achieve something similar using -sigmoidal-contrast
see
http://www.imagemagick.org/Usage/color_mods/#sigmoidal
The Value curve may be applied to the global image after recombining the RGB channels. It is not clear to me what they are doing with a gray channel along with the R,G,B. Adjust the gray, may be adjusting the L in LAB or Y in YIQ/YUV/YCbCr.
Re: Alpha Channel Curve with RGB colorspace?
Posted: 2013-06-10T14:42:42-07:00
by Aylon
Many thanks snibgo and fmw42!
I tried the first option suggested by snibgo, but that unfortunately does not bring the desired result. I tried also with the colorspaces and channels suggested by fmw42, but again to no avail.
I got nearest to the gimp-original by changing step 2 and applying the "value"-channel -fx "EQUATION" to each individual channel after the R G B -fx:
2. apply curve to each -> e.g. convert tmpFile_red.jpg -fx "REDCURVEEQUATION" -fx "VALUEEQUATION" tmpFile_red.jpg
and then combine the pictures as previously.
Many thanks to both of you and especially fmw42! Your scripts helped a lot in my journey so far. Thank you for sharing these!
That said, to your comment on the -sigmoidal-contrast, I fear I am not there yet as I looked at them before going down the -fx route. I did not yet understand how to translate my curve values/equations in into the -sigmoidal-contrast set-up... and I did not have enough time to play around with it. I ll see if I get there!
Re: Alpha Channel Curve with RGB colorspace?
Posted: 2013-06-10T17:54:11-07:00
by fmw42
That said, to your comment on the -sigmoidal-contrast, I fear I am not there yet as I looked at them before going down the -fx route. I did not yet understand how to translate my curve values/equations in into the -sigmoidal-contrast set-up... and I did not have enough time to play around with it. I ll see if I get there!
Your curve equations are probably more accurate. -sigmoidal-contrast will in general be a symmetric S-shaped curve, although you can offset it. You can specify -channel X before -sigmoidal-contrast to work on only one channel at a time.
The other option might be to use my curves script and specify break points to match those used in GIMP. But at this time there is no channel control. So you would have to separate channels and apply curves to each one separately and then recombine channels. I plan to add a channel option at some point when I have time to make that a bit easier.
I think I (and perhaps snibgo) just do not know enough about GIMP (internals) and what it is doing with a grayscale channel in addition to the RGB channels that can be selected and a Value control as you show in that link to the processing tutorial. So it is hard to know how to replicate that in IM.
Re: Alpha Channel Curve with RGB colorspace?
Posted: 2013-06-11T22:09:22-07:00
by snibgo
I created a colour file, opened it in Gimp (v2.8.2), Image > Mode > RGB, Colors > Curves, and examined the histogram counts for R, G, B and Value. The "Value" channel seems to the max(R,G,B) for each pixel. So it corresponds to IM's Brightness.
Code: Select all
%IM%convert -size 100x100 ^
xc:rgb(10,10,10) ^
xc:rgb(235,15,15) ^
xc:rgb(20,25,235) ^
xc:rgb(245,245,245) ^
+append value.png
I think my sample file rules out the other possibilities.
Thus, replicating a Gimp Value curve is probably best done in HSB colorspace.
Re: Alpha Channel Curve with RGB colorspace?
Posted: 2013-06-11T22:38:38-07:00
by fmw42
snibgo wrote:The "Value" channel seems to the max(R,G,B) for each pixel. So it corresponds to IM's Brightness.
That would make sense in hind-sight, since HSB is what others call HSV (where V is value), see
http://en.wikipedia.org/wiki/HSL_and_HSV