469,347 Members | 19,798 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,347 developers. It's quick & easy.

pil, histogram, mask

How does one do a histogram on only a part of an image?
This is what I found in the PIL documentation about histogram( ):

"""
im.histogram(mask) =list

Returns a histogram for those parts of the image where the mask image
is non-zero. The mask image must have the same size as the image, and
be either a bi-level image (mode "1") or a greyscale image ("L").
"""

But I don't quite understand what "mask image is non-zero" mean. Does
it mean non-white? For instance how would I get a histogram from the
border of an image where the border is, say, 5% in width and height of
the width and heigth of the full image? Do I need to prepare a mask
image that is white in the middle and non-white at the edges? I should
maybe add that I don't need the histogram really, only the mean color
value, but as far as I can see the 'mean' attribute only applies to an
image and a mask can not be specified.

In case I overlooked something in the docs (which is easily possible)
please point me to the appropriate page.
Jan 31 '07 #1
2 4063
Daniel Nogradi
I don't need the histogram really, only the mean color
value, but as far as I can see the 'mean' attribute only applies to an
image and a mask can not be specified.
You can slice parts of the image, and then use the
ImageStat.Stat(im).mean
On it.

Bye,
bearophile

Feb 1 '07 #2
I don't need the histogram really, only the mean color
value, but as far as I can see the 'mean' attribute only applies to an
image and a mask can not be specified.

You can slice parts of the image, and then use the
ImageStat.Stat(im).mean
On it.

Bye,
bearophile
Okay, I'll try that, thanks a lot.
Feb 1 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Oracle3001 | last post: by
1 post views Thread by bleh | last post: by
1 post views Thread by Andre | last post: by
27 posts views Thread by ext_u | last post: by
12 posts views Thread by KraftDiner | last post: by
5 posts views Thread by arnuld | last post: by
1 post views Thread by avenger3200 | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.