Wangmaster
Posts: 14
Joined: Wed Nov 27, 2019 2:42 am

Image brightness drops over time

Wed Jan 22, 2020 9:43 am

Hi all, I'm having problems with my PiCamera being unable to take consistent timelapse images.

I'm using a V1 Pi Camera to take a timelapse of fluorescence occurring in a well plate. You can see an example of such an image below. I need the images to remain as consistent as possible to detect small changes in colour of the wells, so I've followed the instructions on the Picamera documentation page and used the same settings as they did. I did an image capture every 2 min for about 7 hours.

Image

I analyzed the colour content of the timelapse images and noticed that the brightness was gradually dipping during the first 100 mins of the footage. I did a diagnostic timelapse where I kept everything constant, yet I still saw the dip, consistently ending at the 100 min mark. You can see the dip in brightness over time in the graph I've attached below, it represents the average RGB values of the images over the course of the diagnostic timelapse. I've isolated all possible causes including the illumination source and the colour of the plate, and I think the culprit is very likely the camera itself.

Image

I'm not sure if there's some Picamera setting I've missed out , or if its due to some kind of distortion from the camera heating during use.

Has anyone experienced this issue before and can advise?

njh
Posts: 51
Joined: Wed Aug 09, 2017 2:07 pm

Re: Image brightness drops over time

Wed Jan 22, 2020 11:54 am

No advice I'm afraid, just more questions...
- How did you measure R,G,B levels - just in a region or averaged over the entire image?
- What do the two lines mean (are they G and B levels?)
- Could the caption/timestamp be affecting the measurements?
- Maybe you could post some more images at (say) 10 minute intervals during the first 120 minutes?

It might also be useful to try a couple of things:
- What happens if you switch everything on 1 hour in advance of starting?
- Does the ramp happen faster if you take pictures at a different rate, say 1 per minute?
- What happens if you take 50 images quickly at the start (and discard them), before starting the slow sequence?

At a first guess, I doubt it is a "warming up" effect as I'd expect that to be more exponential, and your graph shows a straight line...

[Edit: removed some assumptions I made]

Wangmaster
Posts: 14
Joined: Wed Nov 27, 2019 2:42 am

Re: Image brightness drops over time

Wed Jan 22, 2020 2:03 pm

Thanks for your reply!

Note that im currently running a few diagnostics tests to narrow down the problem, by changing the capture rate etc like you suggested. I posted here hoping its caused by something obvious i missed out, but sounds like it isnt...

- The RGB was taken whole-image average, but it really didnt matter because the dip was seen everywhere i sampled on the image.
- The lines represent R, G and B levels, the R was just hidden by the B since they were both close to zero. The light source i used was green, and the diagnostic i ran didnt have the orange spots in the attached image, which was why the graph was dominated by green.

I will try a few solutions, hopefully they will work, or at least tell me more about the problem:

- I ran the whole 7 hour timelapse with video preview on, maybe that "exhausts" the camera somehow or heats it up enough to change image quality. This would explain the 100min mark as the point at which the temperature stabilizes.
- I'll try leaving the camera on an hour in advance, which i believe should kill the dip but seems impractical as a permanent solution.
- Im currently varying the capture rate to see if it affects the 100min mark.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7885
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Image brightness drops over time

Wed Jan 22, 2020 2:58 pm

Assuming you're capturing JPEG files, then you have the exposure time and analogue gain in the EXIF metadata.
The quickest way is to extract the values is to use "strings foo.jpg | grep exp"
For a random capture I have I get

Code: Select all

ev=-1 mlux=-1 exp=7752 ag=256 focus=255 gain_r=1.683 gain_b=0.980 greenness=-10 ccm=10118,-4474,-1512,-1324,5946,-512,838,-4430,7694,0,0,0 md=0 tg=250 255 oth=0 0 b=0 f=250 255 fi=0 ISP Build Date: Mar  3 2017, 13:46:13 VC_BUILD_ID_VERSION: 9ae30f71c7ef4239e9d5b56346c0842f3ef56736 (clean) VC_BUILD_ID_USER:  VC_BUILD_ID_BRANCH: master 
exp = exposure time in usec. ag = analogue gain * 256. gain_r and gain_b are the white balance gains. f is the digital gain (broken down into two pieces) * 256.

All those numbers should stay the same. If any of them are changing, then either you haven't locked them, or there may be an underlying issue.
I vaguely recall one of the sensors appeared to have a rounding issue on exposure so that each time you set it to the current value a rounding error meant it actually decreased by one step. The metadata should confirm if that is what you are seeing.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Wangmaster
Posts: 14
Joined: Wed Nov 27, 2019 2:42 am

Re: Image brightness drops over time

Thu Jan 23, 2020 2:30 am

Thanks 6by9, I checked the jpg metadata and there was indeed a drop in exposure corresponding to the dip I observed. Analog gains were fine.

Previously I followed the following line in the documentation, it may have caused the problem:

Code: Select all

camera.shutter_speed = camera.exposure_speed
camera.exposure_mode = 'off'
I'll try setting the shutter speed to a constant and report back on the results.

Wangmaster
Posts: 14
Joined: Wed Nov 27, 2019 2:42 am

Re: Image brightness drops over time

Thu Jan 23, 2020 5:47 am

I realized I'm having the same problem as in the link below:

https://raspberrypi.stackexchange.com/q ... amera-1-13

A bug in the Picamera module results in camera.exposure_speed constantly decaying over captures despite exposure_mode being "off" and shutter_speed set to a constant. This directly resulted in the image darkening over time. I'm using the latest Picamera version.

Resetting shutter_speed before every capture 'fixes' the problem, though its hardly elegant.

Return to “Camera board”