Page 2 of 3
Re: Telling the difference between color and grayscale image
Posted: 2017-08-08T10:15:21-07:00
by snibgo
divptl wrote:My Gray scale image has colors in it but i need to have some short of way to figure out it is gray scale image.
That doesn't make sense. How can a grayscale image have colours?
Please show an example image. Also say what version IM you use, on what platform.
Re: Telling the difference between color and grayscale image
Posted: 2017-08-08T10:19:40-07:00
by fmw42
I suspect he means that his image is mostly gray shades, but contains a little color. But I would agree, it would be nice to see an example.
Re: Telling the difference between color and grayscale image
Posted: 2017-08-08T10:41:11-07:00
by divptl
Sorry but i can't share images as it's company's patent . Basically i have patent of say shirt mostly in black and white but say in the pocket of it there is rose picture from IM sample. I need to separate this image from actual normal color picture.
Re: Telling the difference between color and grayscale image
Posted: 2017-08-08T10:51:00-07:00
by fmw42
Re: Telling the difference between color and grayscale image
Posted: 2017-08-08T11:06:15-07:00
by divptl
Thank you.
Any way to tell if its graphic vs picture ?
Re: Telling the difference between color and grayscale image
Posted: 2017-08-08T15:51:17-07:00
by fmw42
Picture usually has many more colors. Graphic often has only a few. The only way of getting such information is from the histogram or from the number of unique colors.
This will give you a list of colors:
Code: Select all
convert logo: -depth 8 -unique-colors txt:
This will give you the number of colors (unix syntax)
Code: Select all
convert logo: -depth 8 -unique-colors txt:- | tail -n +2 | wc -l
256
However, there is no guarantee that you would not have a picture with only a few colors or a graphic with lots of colors.
Re: Telling the difference between color and grayscale image
Posted: 2017-08-09T08:22:29-07:00
by divptl
if i want to check for gray scale in border (all 4 sides of the image) of the image is it possible ?
Re: Telling the difference between color and grayscale image
Posted: 2017-08-09T09:31:50-07:00
by fmw42
crop the border edges one at a time and check with the saturation as described earlier.
Re: Telling the difference between color and grayscale image
Posted: 2017-08-09T11:03:39-07:00
by divptl
Is there a way to do this same logic for Border only ? I am sorry for being pain but there are way too many fallout so i am thinking to go based on border of picture.
Re: Telling the difference between color and grayscale image
Posted: 2017-08-09T11:06:02-07:00
by divptl
Sorry i didnot see that message . How do i corp and check for the colors at the same time . say 2% of the picture is my border.
Re: Telling the difference between color and grayscale image
Posted: 2017-08-09T11:08:42-07:00
by fmw42
Read my post above: It says, crop the border edges one at a time and check with the saturation as described earlier. For example:
Code: Select all
convert image -gravity north -crop 100x10% +repage -colorspace HCL -channel green -separate +channel -format "%[fx:100*mean]\n" info:
convert image -gravity east -crop 10x100% +repage -colorspace HCL -channel green -separate +channel -format "%[fx:100*mean]\n" info:
convert image -gravity south -crop 100x10% +repage -colorspace HCL -channel green -separate +channel -format "%[fx:100*mean]\n" info:
convert image -gravity west -crop 110x100% +repage -colorspace HCL -channel green -separate +channel -format "%[fx:100*mean]\n" info:
That will test each border of 10% thickness.
Re: Telling the difference between color and grayscale image
Posted: 2017-08-15T06:00:07-07:00
by divptl
fmw42 wrote: ↑2017-08-08T15:51:17-07:00
Picture usually has many more colors. Graphic often has only a few. The only way of getting such information is from the histogram or from the number of unique colors.
This will give you a list of colors:
Code: Select all
convert logo: -depth 8 -unique-colors txt:
This will give you the number of colors (unix syntax)
Code: Select all
convert logo: -depth 8 -unique-colors txt:- | tail -n +2 | wc -l
256
However, there is no guarantee that you would not have a picture with only a few colors or a graphic with lots of colors.
what is the syntax for windows for "
Code: Select all
convert logo: -depth 8 -unique-colors txt:- | tail -n +2 | wc -l
"
Re: Telling the difference between color and grayscale image
Posted: 2017-08-15T06:31:14-07:00
by snibgo
I would use this instead:
Code: Select all
convert logo: -depth 8 -unique-colors -format %w info:
or:
Code: Select all
convert logo: -depth 8 -format %k info:
Re: Telling the difference between color and grayscale image
Posted: 2017-08-15T07:16:37-07:00
by divptl
how do i do this for all image in DIR and Move the file if it's > threshold ?
Re: Telling the difference between color and grayscale image
Posted: 2017-08-15T07:32:59-07:00
by snibgo
You would write a script.