"Lux Zhang" on wrote...
| Hi,
| there is a black-white image, black as backgroud, white image is in
| irregular shape.
| how to calculte the white area on this image?
|
get a 'grey percentage' for pure black and white image that percentage
would be the percentage of white ;-)
Does not matter how the pixels ar arranged.
Here I create a image as you describe, and get the info on it.
convert rose: -threshold 50% +matte -colorspace Gray
-verbose info:
...
Channel statistics:
Gray:
Min: 0 (0)
Max: 1 (1)
Mean: 0.195652 (0.195652)
Standard deviation: 0.396702 (0.396702)
Colors: 2
Histogram:
2590: ( 0, 0, 0) #000000 black
630: (255,255,255) #FFFFFF white
...
Which means 19.6% of the image is white
and for more exactness 630 white pixels and 2590 black pixels
All quite simple..
Alternatively, an easier to parse output, is the histogram comment...
convert rose: -threshold 50% +matte -colorspace Gray \
-format %c histogram:info:-
2590: ( 0, 0, 0) #000000 black
630: (255,255,255) #FFFFFF white
See
http://www.imagemagick.org/Usage/files/#histogram
http://www.imagemagick.org/Usage/basics/#identify
Anthony Thyssen ( System Programmer ) <[EMAIL PROTECTED]>
-----------------------------------------------------------------------------
We will encourage you to develop the three great virtues of
a programmer : laziness, impatience and hubris.
--- Larry Wall - "Programming Perl"
-----------------------------------------------------------------------------
Anthony's Home is his Castle http://www.cit.gu.edu.au/~anthony/
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users