subj.
For example, I cut the picture on the tiles, and I want to know which of them are empty? (transparent, or the same color). Thanks for the replies.
How to check for empty (mono-color) image?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to check for empty (mono-color) image?
get the standard-deviation from the verbose statistics for each tile. If the standard deviation is 0, then the image is one color. You may have to look channel by channel including the alpha channel.
Alternate is to use string formats. See http://www.imagemagick.org/script/escape.php
convert image -format "%[standard_deviation]" info:
returns values between 0 and QuantumRange (255 for 8-bit or 65535 for 16-bit IM compiles0
or
convert image -format "%[fx:u.standard_deviation]" info:
returns values between 0 and 1
Alternate is to use string formats. See http://www.imagemagick.org/script/escape.php
convert image -format "%[standard_deviation]" info:
returns values between 0 and QuantumRange (255 for 8-bit or 65535 for 16-bit IM compiles0
or
convert image -format "%[fx:u.standard_deviation]" info:
returns values between 0 and 1
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: How to check for empty (mono-color) image?
Number of colors %k will also do this! If you have one unique color then it will be 1
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: How to check for empty (mono-color) image?
Not work for me. I also tryfmw42 wrote:convert image -format "%[standard_deviation]" info:
Code: Select all
identify -format %[standard-deviation]
Code: Select all
$ identify -format %[standard-deviation] 1.png
11571.2
$ identify -format %[standard-deviation] 2.png
7529.32
I see no difference in eog or gimp, but when I upload image i saw this (white lines in top of image):
http://pic.lg.ua/s/g/0YCfF/DYPSF
Yes, it is!anthony wrote:Number of colors %k will also do this! If you have one unique color then it will be 1
And new question: how can I diff "white mono-color image" from "gray mono-color image" ?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to check for empty (mono-color) image?
see -compose minus or -compose different or compare
http://www.imagemagick.org/Usage/compose/#minus
http://www.imagemagick.org/Usage/compose/#difference
http://www.imagemagick.org/Usage/compare/
Can you be more specific about what type of compare you want -- what kind of result -- an image or a number
http://www.imagemagick.org/Usage/compose/#minus
http://www.imagemagick.org/Usage/compose/#difference
http://www.imagemagick.org/Usage/compare/
Can you be more specific about what type of compare you want -- what kind of result -- an image or a number
Re: How to check for empty (mono-color) image?
Excuse me for the delay in replying.
I need the result - a number.
That's what I found:
But I still want to do this without "sed" expression any advice?
I need the result - a number.
That's what I found:
Code: Select all
alpha=`convert $f -resize 1x1 txt: | sed '1d' | sed 's/\([^)]*\).*/\1/' | sed 's/,/ /g' | awk '{print $NF}'`
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: How to check for empty (mono-color) image?
Just crop a single pixel from the image and output a TXT: image.graceman9 wrote:And new question: how can I diff "white mono-color image" from "gray mono-color image" ?
Code: Select all
convert image.png -crop 1x1+0+0 txt:
OR just get IM to print the images 0,0 color using -format and info:
Code: Select all
convert image.png -format "%[pixel:s]" info:
With one image you can also -print (only outputs its formatted string once, not once per image.
Code: Select all
convert image.png -print "%[pixel:s]" null:
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/