473,804 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(ma sk) =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 4280
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
6702
by: Oracle3001 | last post by:
Hi All, I am trying to use JAI to build a histogram of an image i have. I have posted the code below, and the error I get at runtime. I have taken the code from the offical java examples, so I am really puzzled why it doesn't work public PlanarImage thresholding (PlanarImage source) { // set up the histogram int bins = { 256 }; double low = { 0.0D };
1
3075
by: bleh | last post by:
....to include a removeData(datatoremove) function, to mirror the existing addData(datatoadd) function. If anybody knows of somewhere where this has been done already, if you could point me in that direction I'd be much obliged... TIA
1
4167
by: Andre | last post by:
Hi, I'm trying to plot a histogram on some data that I receive at runtime. I'm trying to measure distances between two points, and these distances can be from the range 1 to 5000000. I want to use a logarithmic scale with a range -2^29 to +2^29. How can I determine at any point in time which strata (i.e which cohort or portion of scale) the value belongs to (without using the square or square-root functions)? I could have mask-bits of...
27
2631
by: ext_u | last post by:
Ok I thought I would try to take the program one thing at a time. (If you remember my last post I am trying to make a histogram with data on the size of each word) Anways first .. I obviously need to determine what a word actually is. I wrote this program on my own without looking at the book or any other resource once. #include <stdio.h> main() {
12
2855
by: KraftDiner | last post by:
Hi, I wrote a C++ class that implements an n dimensional histogram in C++, using stl maps and vectors. I want to code this up now in Python and would like some input from this group. The C++ class was VERY simple.. std::map<std::vector<unsigned short>, unsigned long> histo; Say for example I want a 3D histogram then std::vector<unsigned short> would contains
5
11772
by: Enigma Curry | last post by:
I'm playing around with matplotlib for the first time. I'm trying to make a very simple histogram of values 1-6 and how many times they occur in a sequence. However, after about an hour of searching I cannot make the histogram stay within the bounds of the grid lines. Here is my example: pylab.grid() x_values= pylab.hist(x_values,6)
5
2923
by: arnuld | last post by:
this is a programme that counts the "lengths" of each word and then prints that many of stars(*) on the output . it is a modified form of K&R2 exercise 1-13. the programme runs without any compile-error BUT it has a semantic BUG: what i WANT: I want it to produce a "horizontal histogram" which tells how many characters were in the 1st word, how many characters were in the second word by writing equal number of stars, *, at the...
12
4501
by: arnuld | last post by:
i was able to create a solution for a Horizontal-Histogram. i was completely unable to understand this Vertical-Histogram phenomenon. even though i have looked at the solution at this page: http://clc-wiki.net/wiki/K%26R2_solutions:Chapter_1:Exercise_13 still i am not able to make sense of many-many things like (on the same page) for my solution i have written this in documentation,to give reader some hint about what i thought before...
1
4639
by: avenger3200 | last post by:
Hello everyone, I am trying to make a histogram for a project in my class and I really need some help. Here is the question that my instructor provided: Create 1000 Random numbers between 0-100. Create a histogram of the values as a list. Make the bin range 10. Your book goes through a more complicated, but similar exercises. Here is the code that I have so far: import random list =
0
9714
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10600
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10351
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6866
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5534
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4311
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3834
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.