## PILlow, PiCamera and rogue readings

kramkroc
Raspberry Pi Certified Educator
Posts: 19
Joined: Fri Aug 04, 2017 10:11 am

### PILlow, PiCamera and rogue readings

Hi folks,

getting close to finishing our project for the Space Lab. We're using PIL to calculate the mean brightness of our photos but find that the levels returned tend to be very high for the first picture and do tend to vary under on a theoretically steady light source. We can obviously discard the first image but wanted to know what is happening:

Code: Select all

``````	cam.capture(photoName) # Take photo of Earth
image = Image.open(photoName).convert('L') # convert image to monochrome
lux = ImageStat.Stat(image).mean[0] # calculate mean brightness/lux of image``````
Is the PiCamera (PiNoIR) doing some image adjustment? If so, can we turned it off?

/Mark

Davespice
Forum Moderator
Posts: 1662
Joined: Fri Oct 14, 2011 8:06 pm
Location: The Netherlands

### Re: PILlow, PiCamera and rogue readings

Ah yes, you probably want to start the camera preview some seconds before you capture a photo to allow it to adjust to the light level.
So for example:

Code: Select all

``````cam.start_preview()
time.sleep(5)
cam.capture(photoName) # Take photo of Earth
cam.stop_preview()
image = Image.open(photoName).convert('L') # convert image to monochrome
lux = ImageStat.Stat(image).mean[0] # calculate mean brightness/lux of image``````

kramkroc
Raspberry Pi Certified Educator
Posts: 19
Joined: Fri Aug 04, 2017 10:11 am

### Re: PILlow, PiCamera and rogue readings

Cheers Dave! I'll try it later on, but in the meantime, if capturing pictures in a loop, do you think you should do the preview each time, or is it only for that very first capture? Just wondering how consistent a meter it is if the camera is adjusting to the light each time.

Davespice
Forum Moderator
Posts: 1662
Joined: Fri Oct 14, 2011 8:06 pm
Location: The Netherlands