Page 1 of 1
Getting CMYK pixel values in 0 to 100 format.
Posted: 2016-04-20T07:47:51-07:00
by Tripleseven
Hello.
I'm trying to create a tool to analyze an image and getting a count of pixels by color.
I'm using the following script:
convert.exe image.jpg -format %c histogram:info:
results are
50: ( 0, 0, 0,253) #000000FD cmyk(0,0,0,253)
50: ( 0, 0, 0,250) #000000FA cmyk(0,0,0,250)
50: ( 0, 0, 0,248) #000000F8 cmyk(0,0,0,248)
50: ( 0, 0, 0,245) #000000F5 cmyk(0,0,0,245)
i then use this data in an external program to build a "color map", that gives me a area percentage by color.
It returns the information i need, except that cmyk values come in a 0 to 255 format, that i'm not used to work with.
How can i modify the script so that color values come in their intervals:
rgb: 0 to 255
grayscale: 0 to 255
cmyk: 0 to 100
...
Using ImageMagick 6.9.0-6 Q16 x86, in windows
Thanks
Re: Getting CMYK pixel values in 0 to 100 format.
Posted: 2016-04-20T08:23:15-07:00
by snibgo
As far as I know, there is no mechanism for changing the %c format. Your software that reads the data can multiply the numbers by 100.0/255.0.
Annoyingly, the %c numbers are relative to Quantum, which might be 255 or 65535 or 2^32-1 or 2^64-1. If you precede the format with "-depth 16", it will always be 65535.
Re: Getting CMYK pixel values in 0 to 100 format.
Posted: 2016-04-20T09:51:29-07:00
by Tripleseven
snibgo wrote:As far as I know, there is no mechanism for changing the %c format. Your software that reads the data can multiply the numbers by 100.0/255.0.
Annoyingly, the %c numbers are relative to Quantum, which might be 255 or 65535 or 2^32-1 or 2^64-1. If you precede the format with "-depth 16", it will always be 65535.
Thanks for you reply.
I'd already tried to multiply the numbers by 255/100, but rounding to the nearest integer sometimes results in having the same value for different colors.
For the sake of accuracy, i would like to have exact CMYK values, but maybe there's no way to do it with IM.
Thanks
Re: Getting CMYK pixel values in 0 to 100 format.
Posted: 2016-04-20T09:58:56-07:00
by fmw42
Whatever software you are using that has 0 to 100 as integers for CMYK is giving you less accuracy than if 0 to 255. If you need to scale down to 0 to 100 integers, then you will have to scale and combine bins. That is a scripting job. I believe snibgo is correct. One has no control over the "%c" histogram format.
Re: Getting CMYK pixel values in 0 to 100 format.
Posted: 2016-04-20T10:57:09-07:00
by snibgo
Tripleseven wrote:I'd already tried to multiply the numbers by 255/100...
I hope you mean you tried multiplying by 100/255.
Tripleseven wrote:... but rounding to the nearest integer sometimes results in having the same value for different colors.
Then don't round to integers.
If there are 256 possible input values and only 100 possible output values, obviously some inputs will have the same outputs.
Re: Getting CMYK pixel values in 0 to 100 format.
Posted: 2016-04-21T02:00:15-07:00
by Tripleseven
snibgo wrote:
I hope you mean you tried multiplying by 100/255.
Sorry, i meant 100/255
snibgo wrote:
Then don't round to integers.
If there are 256 possible input values and only 100 possible output values, obviously some inputs will have the same outputs.
I know. It would just be easier to match the colors with the ones in the artwork. The drawing program we use (Corel) only allows CMYK colors in 0-100 integers range.
Thanks for all your help