Page 2 of 2
Re: Hue / Saturation / Luminosity / Selective color
Posted: 2015-11-18T15:04:15-07:00
by snibgo
Your command converts RGB (3 channel) input to CMYK (4 channel), then converts that to gray (3 channel). I don't know why you go via CMYK.
On v6.9.2-5:
Code: Select all
convert im3.png -colorspace Gray im4.png -clut x1.png
convert im3.png -colorspace CMYK -colorspace Gray im4.png -clut x2.png
x1.png and x2.png are identical.
EDIT: My copy-paste removed the "-colorspace Gray" in the first command.
Re: Hue / Saturation / Luminosity / Selective color
Posted: 2015-11-18T15:12:30-07:00
by varape
Re Snibgo.
Thanks for the information.
At start we tested it without CMYK before the greyscale and the result was not as good.
So we decided to use cmyk before and the result was clearly better.
So i dont know why we have a difference on this and not you but we do have a difference on our side.
Can you please post the image generated on your side ?
Thanks
Re: Hue / Saturation / Luminosity / Selective color
Posted: 2015-11-18T15:30:06-07:00
by snibgo
Sure:
Code: Select all
f:\web\im>%IM%convert im3.png -colorspace CMYK -colorspace Gray im4.png -clut clt_x1.png
f:\web\im>%IM%convert im3.png -colorspace Gray im4.png -clut clt_x2.png
f:\web\im>%IM%compare -metric RMSE clt_x1.png clt_x2.png NULL:
0 (0)
The files are:
Re: Hue / Saturation / Luminosity / Selective color
Posted: 2015-11-18T16:55:19-07:00
by varape
Thanks so much to have post the results here !
So in fact you get exactly the same result than us on the online server.
But not the same that the one we generated on local and that we are trying to get.
We are also going to test again the CMYK conversion, if the code is simpler, clearly better for server ressource.
But i really dont understand why on local we have a different result. That maybe means also that finally the result on local we get is not the good "normal" one we should get. So strange...
Re: Hue / Saturation / Luminosity / Selective color
Posted: 2015-11-18T18:42:25-07:00
by fmw42
His results seem to match your "perfect" results as far as I can see.
I get the same results as your "perfect" result from both of these without CMYK. Note I could not recompile IM 6.8.8.3 with PNG. So I converted your images to TIF and processed the TIF
Code: Select all
convert infile.tif -colorspace gray gradient.tif -clut -resize 602x602 -background white -gravity center outfile1.tif
im6883 convert infile.tif -colorspace gray gradient.tif -clut -resize 602x602 -background white -gravity center outfile2.tif
http://www.fmwconcepts.com/misc_tests/c ... tfile1.tif
http://www.fmwconcepts.com/misc_tests/c ... tfile2.tif
What API are you using? Is it Imagick? If so, try checking your phpinfo.php file and see if it tells you what version of IM it thinks you are using. Also check your version of Imagick and also be sure you have the same version of libpng on both systems. Perhaps you should post the API code you are using -- there might be an error in your commands. Might you have more than one version of Imagemagick on your system.
try
or
in a PHP exec(command).
To see if it is your API commands or an issue with PNG, try using TIF as I did. Does that work better or the same.
Re: Hue / Saturation / Luminosity / Selective color
Posted: 2015-11-18T18:51:47-07:00
by varape
Hello Fred
Ok, we check all this and come to you tomorrow.
But for the results of Snibgo, no it's not at all like the perfect result we posted.
Look the image below, you will see the green cross that show the difference of colors.
The top image is the perfect result we would like
The bottom image is the Snibgo one.
Thanks
Re: Hue / Saturation / Luminosity / Selective color
Posted: 2015-11-18T19:05:00-07:00
by fmw42
OK. Thanks. I see now. My (tif) results (using -colorspace CMYK or not) are the same as snibgo's and thus not your "perfect" result. I cannot say why that is happening except for the things you should check about versions of PNG and your API. Which API is it -- Imagick? If so, check to see if you have more than one version of IM on your system, if your libpng versions are the same and if your API code is correct. For the latter, try using PHP exec() or command line on both systems. Is that any better?
Re: Hue / Saturation / Luminosity / Selective color
Posted: 2015-11-18T19:09:38-07:00
by snibgo
My results, like Fred's, are
not identical to the "perfect" results. This can be seen in the cyan, yellow and magenta "pipes" at the left and bottom. Our yellow pipe has become white, where the "perfect" result has a light gray. I don't know why this is.
To get a result that seems "perfect", use "-grayscale Rec709Luminance" instead of "-colorspace Gray". (The documentation
http://www.imagemagick.org/script/comma ... #grayscale say these are the same, but it seems they are not the same.)
Re: Hue / Saturation / Luminosity / Selective color
Posted: 2015-11-18T19:18:48-07:00
by fmw42
To get a result that seems "perfect", use "-grayscale Rec709Luminance" instead of "-colorspace Gray". (The documentation
http://www.imagemagick.org/script/comma ... #grayscale say these are the same, but it seems they are not the same.)
Good catch snibgo! I was just in the process of checking out the linear vs nonlinear issue when I saw your post. (Though I was (wrongly) trying to go the other way to make the old linear equivalent to the new non-linear gray using -set colorspace RGB and that did not seem to work). See
viewtopic.php?f=4&t=21269 for a discussion of linear vs non-linear and the IM versions where things changed.
Aside: -colorspace gray currently should be the equivalent of Rec709Luma (not luminance) and used to be equivalent to Rec601luma and Rec601luminance at various times.
In the old 6.8.8.3 system, grayscale was linear (and probably equivalent to Rec601Luminance). So as you found out, to replicate that you need to use a linear grayscale in the current system to match the older system. I am pretty sure that -colorspace CMYK has nothing to do with this. IM will/should convert to the same grayscale image from RGB or from CMYK.
So try
Code: Select all
convert infile.png -grayscale rec709luminance gradient.png -clut -resize 602x602 -background white -gravity center outfile4.png
convert infile.png -grayscale rec601luminance gradient.png -clut -resize 602x602 -background white -gravity center outfile5.png
There will be slight difference, so try both to see which matches better.
The odd thing is that my im6883 result should
not have matched my current IM (6926) result above and that was puzzling me.
Re: Hue / Saturation / Luminosity / Selective color
Posted: 2015-11-18T21:24:34-07:00
by snibgo
A quick test with hald:10 shows that, yes, "-colorspace Gray" is equivalent to "grayscale Rec709Luma", and no other.
Fred, can you correct
http://www.imagemagick.org/script/comma ... #grayscale ?
Re: Hue / Saturation / Luminosity / Selective color
Posted: 2015-11-19T00:03:05-07:00
by fmw42
Yes, I will try to do that tomorrow.
Re: Hue / Saturation / Luminosity / Selective color
Posted: 2015-11-20T08:47:13-07:00
by varape
Hey Guys you simply rocks !
We did the test on local and online and it's just perfect
So much tanks to have took time to help people that needs it.
This forum is great, Fred, Snigbo, you are the best !
Just a thing to contribute, we tried the -grayscale but it seems to doesn't exists in 6.8.3-3 (on our local it didn't works).
Thanks again for you help; you rock !
Re: Hue / Saturation / Luminosity / Selective color
Posted: 2015-11-20T11:02:27-07:00
by fmw42
The -grayscale was introduce after 6.8.3-3 (about 6.8.3-10), so that when the grayscale linear was change to grayscale non-linear, there would be a way to go back to the linear format in more current versions of IM. In 6883, it is always linear and you must use -colorspace RGB to make grayscale images non-linear as directed in the Colorspace link I mentioned. But I had tried that briefly with no success. Then I saw user snigbo's post and realized that we needed to go in the other direction, so I did not follow up to try to make it work the other way as you seem to be trying.