Page 1 of 2
Hue / Saturation / Luminosity / Selective color
Posted: 2015-11-07T16:21:06-07:00
by varape
Hello guys !
My first message here after hours spending on this forum for a lot of incredible
help and ressources
We are working on a script that try to simulate a wood effect (just to be "brown" in fact) color from a greyscale image.
The image is black and white at start.
Then we apply on it a -level 21,244,1.0
(this is ok so) but now we would like to apply (on the global)
hue : 23
Saturation : 29
Luminisoty : +2
(these are photoshop values for the HSL)
How we can do this with ImageMagick ?
An other question by the way
We also would like to apply a modification on a particular color channel, like the "selective color" of Photoshop.
We would like to apply it on the Black channel only with CMYK values as follow :
C = -37%
M = -15%
Y = -4 %
K= 0%
(these are photoshop values)
Someone knows if (and how) we can do this with ImageMagick ?
This is the image that show the result we try to get :
Thanks in advance for your precious help !
Re: Hue / Saturation / Luminosity / Selective color
Posted: 2015-11-07T16:45:15-07:00
by fmw42
Please always provide your IM version and platform, since syntax may be differ.
IM has a function -modulate. See
http://www.imagemagick.org/script/comma ... p#modulate
http://www.imagemagick.org/Usage/color_mods/#modulate
but you have to convert your PS values from Hue 0-360 to IM 0 to 200 (0 is -180 and 200 is +180) with 100 being no change on all three arguments.
For doing CMYK adjustments, if you are on Unix, then see my bash shell script, colorbalance2, at my link below.
Otherwise, you need to convert from sRGB to CMYK (using -colorspace CMYK), and then adjust each channel separately as desired. Then convert back to colorspace sRGB. You can also use profiles to convert between colorspaces. Something like
Code: Select all
convert image -colorspace HSL \
-channel R -evaluate add HH% +channel \
-channel G -evaluate add SS% +channel \
-channel R -evaluate add LL% +channel \
-set colorspace HSL -colorspace sRGB \
result
You will need to convert PS values to IM percents. I do not recall if PS is using percent or 0-255 values.
The above is Unix syntax. If on windows, replace \ with ^ (and if in bat file, double %%). Note that IM does not know about HSL channels and so you have to refer to them as R=Hue, G=Saturation, and B=Lightness.
See
http://www.imagemagick.org/script/comma ... hp#channel
http://www.imagemagick.org/script/comma ... p#evaluate
http://www.imagemagick.org/script/comma ... colorspace
P.S. I do not know if this will be of interest, but also see my unix bash shell script, woodgrain.
Re: Hue / Saturation / Luminosity / Selective color
Posted: 2015-11-07T17:01:16-07:00
by varape
Hello Fred
Thanks for this so fast and awesome answer !
We are going to work on this and see if we can achieve the result we would like. I will post here the result
Thanks once again.
Re: Hue / Saturation / Luminosity / Selective color
Posted: 2015-11-07T17:02:40-07:00
by fmw42
Re: Hue / Saturation / Luminosity / Selective color
Posted: 2015-11-07T20:42:31-07:00
by snibgo
varape wrote:... but now we would like to apply (on the global)
hue : 23 ...
There are many ways of making a grayscale image into colour, depending on the exact effect you are looking for.
I often multiply the three RGB channels each by a different amount. This leaves black untouched, and has the greatest effect at white. An alternative is to add a different percentage to each channel. This will lighten all values, including black. A third is to "-evaluate Pow" to each channel, which affects mid-tones but not black or white. There are other methods.
If you have Photoshop, I suggest you observe the histogram of a black-white gradient when you change the hue. Once you know what PS does, translating this to IM should be easy.
Re: Hue / Saturation / Luminosity / Selective color
Posted: 2015-11-07T21:17:22-07:00
by fmw42
see also
http://www.imagemagick.org/Usage/color_mods/#sepia-tone
http://www.imagemagick.org/Usage/color_mods/#duotone
You can also capture what processing you do in Photoshop with a HALD image and apply it in Imagemagick. See
http://www.imagemagick.org/Usage/color_mods/#hald-clut
Or with a simple 1D grayscale image that you process in Photoshop and then apply in Imagemagick. See
http://www.imagemagick.org/Usage/color_mods/#clut
Re: Hue / Saturation / Luminosity / Selective color
Posted: 2015-11-09T10:01:23-07:00
by varape
Hello guys
Sorry for the late answer, so the IM version we use is : ImageMagick 6.7.7-10 2014-03-08 and the OS is Unix of course
Thanks for the others ways we can use, maybe the duo tone is clearly the simple and the best match. We are going to try.
Just a question, what is the technic that will offer the best speed and the lowest server ressources ?
Thanks again for your help.
Re: Hue / Saturation / Luminosity / Selective color
Posted: 2015-11-09T11:34:49-07:00
by fmw42
Just a question, what is the technic that will offer the best speed and the lowest server ressources ?
You would have to do some timing tests. But my guess is -tint or -clut would be the best.
Re: Hue / Saturation / Luminosity / Selective color
Posted: 2015-11-18T14:07:19-07:00
by varape
Hey Guys !
Thanks for all your feedbacks, we have make a bunch of test and we have a little problem with the result (color speaking).
This is the process we used :
- Original file is PNG
- Then we convert it to CMYK
- then we convert it to greyscale
- then we apply duotone (Clut) with a gradient.
We have made our test on local with debian server, os X 10.11 and ImageMagick 6.8.3-3 2013-02-21
and the result is exactly what we want. We used command line directly on server.
We do nearly the same on the online server on Unix and ImageMagick 6.9.1-9 Q16 x86_64 2015-11-17 and we do not get the same result. (we used php extension, not command line)
Can someone tell us why we do not have the same result and maybe a way to get the same result than on local ?
Look at the image below to see the difference.
Thanks for your help !
Re: Hue / Saturation / Luminosity / Selective color
Posted: 2015-11-18T14:10:48-07:00
by fmw42
Looks to me like the convert to CMYK might be causing the issue. Try without converting to CMYK and see if the results are better or not and report back. Also try using PHP exec on the other server (or direct command line) rather than the PHP API (presumably Imagick?) to see if it is the API.
Also perhaps provide your input image alone and the exact command line you are using and the clut image or how it was created. That way we can test independently and see what might be going on.
Re: Hue / Saturation / Luminosity / Selective color
Posted: 2015-11-18T14:29:12-07:00
by macosxvn
Thank for your response. I think my friend have a mistake or I miss some detail when talk with him.
On my local, I already used php exec to call a command line convert to do this process & same on server. The problem is:
My local is: OS X 10.11 with ImageMagick 6.8.3-3. -> perfect result
The server is : Debian 7 with ImageMagick 6.9.2-6. -> worse result
The convert to CMYK doesn't cause this issue. Because we already tried without converting to CMYK. The result is worse.
Is there any other idea?
----
Edit:
the command line that i used:
# convert infile.png -colorspace cmyk -colorspace gray gradient.png -clut -resize 602x602 -background white -gravity center -format png outfile.png
Re: Hue / Saturation / Luminosity / Selective color
Posted: 2015-11-18T14:34:10-07:00
by varape
Hello Fred !
Always so fast answer
So the answers to your questions are:
- We tried without CMYK before and the result was not good (either on local or online)
- We also used PHP exec
- We also tried command line directly on online server and the result was not good (same result than when it's generated via the php extension)
- The gradient image (clut) has been created by me on photoshop and exported in PNG 24.
- We also tried with a file that was greyscale and then cmyk on photoshop and use it in jpeg CMYK in the online generator (and result is a bit better but still not as good as the one generated in local)
- Finally we tested with different gradient and we do not get the sam result than the good one in local.
You will find below the original image and the gradient.
Re: Hue / Saturation / Luminosity / Selective color
Posted: 2015-11-18T14:46:08-07:00
by snibgo
Your im4.png is 3-channel RGB (not 4-channel CMYK). If you use it as a clut on a CMYK, the results will be wrong, because the clut file doesn't have enough channels.
Please show the command you are using.
Re: Hue / Saturation / Luminosity / Selective color
Posted: 2015-11-18T14:49:51-07:00
by macosxvn
the command line that i used:
# convert infile.png -colorspace cmyk -colorspace gray gradient.png -clut -resize 602x602 -background white -gravity center -format png outfile.png
Re: Hue / Saturation / Luminosity / Selective color
Posted: 2015-11-18T14:50:47-07:00
by varape
Hello Snibgo
Thanks for your message.
if i am not wrong, a PNG file can't be CMYK. And on local even if what you said is correct, the result is what we are looking for.
So i suppose you suggest to use a JPEG CMYK for the gradient.
Is it correct ?