Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
snibgo
Posts: 12159 Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK
Post
by snibgo » 2017-08-08T10:15:21-07:00
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.
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2017-08-08T10:19:40-07:00
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.
divptl
Posts: 20 Joined: 2017-08-07T14:00:24-07:00
Authentication code: 1151
Post
by divptl » 2017-08-08T10:41:11-07:00
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.
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2017-08-08T10:51:00-07:00
divptl
Posts: 20 Joined: 2017-08-07T14:00:24-07:00
Authentication code: 1151
Post
by divptl » 2017-08-08T11:06:15-07:00
Thank you.
Any way to tell if its graphic vs picture ?
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 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.
divptl
Posts: 20 Joined: 2017-08-07T14:00:24-07:00
Authentication code: 1151
Post
by divptl » 2017-08-09T08:22:29-07:00
if i want to check for gray scale in border (all 4 sides of the image) of the image is it possible ?
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2017-08-09T09:31:50-07:00
crop the border edges one at a time and check with the saturation as described earlier.
divptl
Posts: 20 Joined: 2017-08-07T14:00:24-07:00
Authentication code: 1151
Post
by divptl » 2017-08-09T11:03:39-07:00
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.
divptl
Posts: 20 Joined: 2017-08-07T14:00:24-07:00
Authentication code: 1151
Post
by divptl » 2017-08-09T11:06:02-07:00
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.
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2017-08-09T11:08:42-07:00
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.
divptl
Posts: 20 Joined: 2017-08-07T14:00:24-07:00
Authentication code: 1151
Post
by divptl » 2017-08-15T06:00:07-07:00
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
"
snibgo
Posts: 12159 Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK
Post
by snibgo » 2017-08-15T06:31:14-07:00
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:
divptl
Posts: 20 Joined: 2017-08-07T14:00:24-07:00
Authentication code: 1151
Post
by divptl » 2017-08-15T07:16:37-07:00
how do i do this for all image in DIR and Move the file if it's > threshold ?
snibgo
Posts: 12159 Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK
Post
by snibgo » 2017-08-15T07:32:59-07:00
You would write a script.