How to check image color or back and white
How to check image color or back and white
Hi
i need check image color (don't accept back and white)
how to check it?
i need check image color (don't accept back and white)
how to check it?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to check image color or back and white
vanquang wrote:Hi
i need check image color (don't accept back and white)
how to check it?
Please clarify? Do you mean you don't want any image that is totally black or totally white? Or do you mean you don't want any image that has even 1 black or 1 white pixel?
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: How to check image color or black and white
For methods of sorting images into categories see...
Image Comparing, Sorting Images by Type
http://www.imagemagick.org/Usage/compare/#type_general
Whcih is also closely related to generating Image Metrics, for sorting before comparisons or database storage
http://www.imagemagick.org/Usage/compare/#metrics
What about line drawings or text? These are typically not truely black and white but mostly black and white with grey anti-aliasing pixels.For example...
Or even... mostly two color gradient images (red on white with anti-aliasing) such as this.
or images with large expanses of pure black or white, or a specific color?
or just a small segment of pure color -- this rose image as an area of pure white!
Also what about greyscale images?
Or images with little 'energy' in the form of edges, only smooth color gradients
What about transparency?
Or even animations (simple or of real images)
Basically you need to define exactly what you want to include or exclude!
Then we can work out something that can detect such images.
While we are on this topic, does anyone have any other basic 'types' of images?
Note I have ignored 'real world photos' which typically do not fit in the above basic groups, but has large numbers of image sub-categories in and of itself (faces, groups, seascapes, buildings, etc)!
Image Comparing, Sorting Images by Type
http://www.imagemagick.org/Usage/compare/#type_general
Whcih is also closely related to generating Image Metrics, for sorting before comparisons or database storage
http://www.imagemagick.org/Usage/compare/#metrics
What about line drawings or text? These are typically not truely black and white but mostly black and white with grey anti-aliasing pixels.For example...
Or even... mostly two color gradient images (red on white with anti-aliasing) such as this.
or images with large expanses of pure black or white, or a specific color?
or just a small segment of pure color -- this rose image as an area of pure white!
Also what about greyscale images?
Or images with little 'energy' in the form of edges, only smooth color gradients
What about transparency?
Or even animations (simple or of real images)
Basically you need to define exactly what you want to include or exclude!
Then we can work out something that can detect such images.
While we are on this topic, does anyone have any other basic 'types' of images?
Note I have ignored 'real world photos' which typically do not fit in the above basic groups, but has large numbers of image sub-categories in and of itself (faces, groups, seascapes, buildings, etc)!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: How to check image color or back and white
when i use ImageMagick check an image (not compare image)fmw42 wrote:vanquang wrote:Hi
i need check image color (don't accept back and white)
how to check it?
Please clarify? Do you mean you don't want any image that is totally black or totally white? Or do you mean you don't want any image that has even 1 black or 1 white pixel?
if check image:
return true
if check then return false
how to implement it?
Re: How to check image color or black and white
when use "-format", "%k", i get an number (eg:2064) is mean?anthony wrote:For methods of sorting images into categories see...
Image Comparing, Sorting Images by Type
http://www.imagemagick.org/Usage/compare/#type_general
Whcih is also closely related to generating Image Metrics, for sorting before comparisons or database storage
http://www.imagemagick.org/Usage/compare/#metrics
What about line drawings or text? These are typically not truely black and white but mostly black and white with grey anti-aliasing pixels.For example...
Or even... mostly two color gradient images (red on white with anti-aliasing) such as this.
or images with large expanses of pure black or white, or a specific color?
or just a small segment of pure color -- this rose image as an area of pure white!
Also what about greyscale images?
Or images with little 'energy' in the form of edges, only smooth color gradients
What about transparency?
Or even animations (simple or of real images)
Basically you need to define exactly what you want to include or exclude!
Then we can work out something that can detect such images.
While we are on this topic, does anyone have any other basic 'types' of images?
Note I have ignored 'real world photos' which typically do not fit in the above basic groups, but has large numbers of image sub-categories in and of itself (faces, groups, seascapes, buildings, etc)!
i don't know it.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: How to check image color or back and white
See... Compare, Sorting Images by Type, Gray-scale vs Colorvanquang wrote:if check image:
return true
if check then return false
how to implement it?
http://www.imagemagick.org/Usage/compar ... _greyscale
Basically you convert the image to HSL and then output verbose information ("identify" statistics).
In HSL space Saturation define how colorful pixels are, and this is returned in the 'Green' channel statistics.
For example...
Code: Select all
convert rose_grey.gif -colorspace HSL -verbose info:
Code: Select all
...
Green:
min: 0 (0)
max: 0 (0)
mean: 0 (0)
standard deviation: 0 (0)
kurtosis: 0
skewness: 0
...
The original color rose image on the other hand generated...
Code: Select all
Green:
min: 2 (0.00636301)
max: 255 (1)
mean: 101.764 (0.399074)
standard deviation: 71.0352 (0.278569)
kurtosis: -1.0037
skewness: 0.44952
and that the image was very colorful in general too (mean is 39.9%) -- not even mostly grayscale (white background)!
Other statistics show how the color ratios was distributed about that mean.
Another method is to compare a grayscale version of the image with the original input image and see how different they are. This will let you find what pixels (areas) in the input image are colorful and by how much!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: How to check image color or back and white
when use "-format", "%k", i get an number (eg:2064) is mean?anthony wrote:See... Compare, Sorting Images by Type, Gray-scale vs Colorvanquang wrote:if check image:
return true
if check then return false
how to implement it?
http://www.imagemagick.org/Usage/compar ... _greyscale
Basically you convert the image to HSL and then output verbose information ("identify" statistics).
In HSL space Saturation define how colorful pixels are, and this is returned in the 'Green' channel statistics.
For example...Code: Select all
convert rose_grey.gif -colorspace HSL -verbose info:
Max is 0 so no color was present at all! -- It is a perfect grayscale (or black and white) imageCode: Select all
... Green: min: 0 (0) max: 0 (0) mean: 0 (0) standard deviation: 0 (0) kurtosis: 0 skewness: 0 ...
The original color rose image on the other hand generated...Showing there was at least one pure color pixel (max = 100%) -- not pure grayscaleCode: Select all
Green: min: 2 (0.00636301) max: 255 (1) mean: 101.764 (0.399074) standard deviation: 71.0352 (0.278569) kurtosis: -1.0037 skewness: 0.44952
and that the image was very colorful in general too (mean is 39.9%) -- not even mostly grayscale (white background)!
Other statistics show how the color ratios was distributed about that mean.
Another method is to compare a grayscale version of the image with the original input image and see how different they are. This will let you find what pixels (areas) in the input image are colorful and by how much!
i don't know it.
because i use in vbscript, please send
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to check image color or back and white
You are getting the number of shades of gray as 2064 from %k (unique colors or shades of gray)
try
convert rose: -format "%[colorspace]" info:
RGB
convert rose: -type grayscale -format "%[colorspace]" info:
Gray
This only works if your image is pure grayscale. Otherwise, you need to do as Anthony suggests and use the saturation image and threshold to test if low enough saturation that you would consider it gray.
try
convert rose: -format "%[colorspace]" info:
RGB
convert rose: -type grayscale -format "%[colorspace]" info:
Gray
This only works if your image is pure grayscale. Otherwise, you need to do as Anthony suggests and use the saturation image and threshold to test if low enough saturation that you would consider it gray.
Re: How to check image color or back and white
in vb script:
return (w,h,type) only:
not return:
Green:
min: 0 (0)
max: 0 (0)
mean: 0 (0)
standard deviation: 0 (0)
kurtosis: 0
skewness: 0
Code: Select all
Set img = CreateObject("ImageMagickObject.MagickImage.1")
reponse.write img.convert(fullpath,"-colorspace","HSL","-verbose")
Code: Select all
57,200,JPEG
Green:
min: 0 (0)
max: 0 (0)
mean: 0 (0)
standard deviation: 0 (0)
kurtosis: 0
skewness: 0
-
- Posts: 1
- Joined: 2012-02-22T06:30:24-07:00
- Authentication code: 8675308
Re: How to check image color or back and white
hello,
I guess this should be right post where i should put my question since i'm currently in search of a good method on how to determine if an image is more color than B/W.
I would like to use some kind of threshold but based on the different properties of the image (size, dpi, width, height, ...) so that i can determine whether i should take the color or the B/W image.
Is it possible to give me 1 (or more) command lines which i can use (returning their info) so that i can use it towards the threshold settings ?
Thanks in advance !
Wim
I guess this should be right post where i should put my question since i'm currently in search of a good method on how to determine if an image is more color than B/W.
I would like to use some kind of threshold but based on the different properties of the image (size, dpi, width, height, ...) so that i can determine whether i should take the color or the B/W image.
Is it possible to give me 1 (or more) command lines which i can use (returning their info) so that i can use it towards the threshold settings ?
Thanks in advance !
Wim
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to check image color or back and white
try testing the mean (average) saturation of the image.
convert image -colorspace HSL -channel g -separate +channel -format "%[fx:mean]" info:
When the image is perfectly grayscale, the saturation result will be zero. The larger the resulting number (in range 0 to 1) the more color is involved. So you can decide on some threshold value for your decision about how much color to allow while still be nearly grayscale.
You can test this by using -modulate to adjust the saturation for an image. See http://www.imagemagick.org/script/comma ... p#modulate and http://www.imagemagick.org/Usage/color_mods/#modulate
convert logo: -modulate 100,X,100 -colorspace HSL -channel g -separate +channel -format "%[fx:mean]" info:
when X=0, you get totally grayscale and the result is 0
when you increase X towards 100, you get a larger result as more color is allowed in the image.
convert image -colorspace HSL -channel g -separate +channel -format "%[fx:mean]" info:
When the image is perfectly grayscale, the saturation result will be zero. The larger the resulting number (in range 0 to 1) the more color is involved. So you can decide on some threshold value for your decision about how much color to allow while still be nearly grayscale.
You can test this by using -modulate to adjust the saturation for an image. See http://www.imagemagick.org/script/comma ... p#modulate and http://www.imagemagick.org/Usage/color_mods/#modulate
convert logo: -modulate 100,X,100 -colorspace HSL -channel g -separate +channel -format "%[fx:mean]" info:
when X=0, you get totally grayscale and the result is 0
when you increase X towards 100, you get a larger result as more color is allowed in the image.
-
- Posts: 3
- Joined: 2014-10-03T13:38:58-07:00
- Authentication code: 6789
Re: How to check image color or back and white
My images keep coming out in black and white with ImageMagick? I'll try the suggestions here and report back my results. Thanks
Juliet
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to check image color or back and white
Please clarify. It is not clear what your issue is. You seem to have added a new post to an old topic, which may or may not be relevant to the old topic. In the future, please create a new post even if similar to an old one. And always provide your IM version and platform.JulietLindl wrote:My images keep coming out in black and white with ImageMagick? I'll try the suggestions here and report back my results. Thanks
Please read viewtopic.php?f=1&t=9620, which is the top link on the User's forum.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to check image color or back and white
fmw42 wrote:try testing the mean (average) saturation of the image.
convert image -colorspace HSL -channel g -separate +channel -format "%[fx:mean]" info:
Due to HSL being a double hexcone model, this colorspace does not work properly for measuring saturation for L>50% as it approaches the top peak. There white is going to be indetermined saturation and turns out is interpreted as high saturation. In its place, use HCL, HCLp, HSI or HSB above. These are all single hexcone type models and should work fine in the above equation.
Reference: https://en.wikipedia.org/wiki/HSL_and_HSV