frequency count or number of occurences of a number in an array
Paul Hankin
paul.hankin at gmail.com
Wed Mar 12 07:26:33 EDT 2008
On Mar 12, 10:26 am, Larry <larry.cebu... at gmail.com> wrote:
> I'm new to Python. I have a file (an image file actually) that I need
> to read pixel by pixel. It's an 8-bit integer type. I need to get the
> statistics like mean, standard deviation, etc., which I know a little
> bit already from reading numpy module. What I want to know is how to
> get the number of occurences of numeric element in an array. Say,
Something like this should do the job:
histogram = [0] * 256
for x in my_array:
histogram[x] += 1
--
Paul Hankin
More information about the Python-list
mailing list