0

I have to suppose I'm given a picture, there shouldnt be any user inputs or calls to media.chose file, so given a picture return the average red value of all the Pixels in that Picture (as an int). If the average calculation results in a non-integer value, then truncate the result. For example, if you average the values 10, 6 and 4, the result would be 6.

pyfunc
  • 65,343
  • 15
  • 148
  • 136
  • possible duplicate of [Read the RGB value of a given pixel in Python, Programatically](http://stackoverflow.com/questions/138250/read-the-rgb-value-of-a-given-pixel-in-python-programatically) – Mizipzor Aug 20 '12 at 08:24

2 Answers2

1

The question is almost answered here

Use PIL to load the image, read it pixel by pixel and do your calculation.

Community
  • 1
  • 1
pyfunc
  • 65,343
  • 15
  • 148
  • 136
0

Python Imaging Library

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358