shusheer
Posts: 18
Joined: Wed Oct 28, 2015 3:36 pm

NoIR images randomly pink

Mon Dec 28, 2015 10:06 pm

Hi All,

I am capturing images using raspistill on a NoIR camera. Every now and again images under "reasonable" (indoor) lighting seem to go pink for just one or a few frames. I assume this is some kind of issue with the AWB, so I have tried setting this to off, and also using --stats which is supposed to calculate white balance from the captured image rather than heuristics. For some reason it appears to be approximately the same "amount" pink whenever it happens as well, but that could just be my eyes.

Normal:
normal.jpg
normal.jpg (50.19 KiB) Viewed 1687 times
Pink:
pink.jpg
pink.jpg (50.09 KiB) Viewed 1687 times
Here is the line for my raspistill capture - it's in a bash loop, with $2 being the shutter speed, chosen elsewhere in the script, so I get roughly consistent exposure levels over time (hence forcing the -ev -24 and ISO 100 as well):

raspistill -set -ss $2 -vf -hf -ev -24 -ISO 100 -awb off -awbg 1.0,1.0 -drc high --stats -n -q 10 -t 100 -w 648 -h 486 -o /dev/shm/img.jpg

Attached are also two shots taken of exactly the same scene, seconds apart and with the same exposure, showing the effect. The room lighting is tungsten/halogen lamps, so it can't be anything to do with e.g. 50Hz flicker of fluorescent or LED lighting or similar.

I have not noticed anything similar on my normal (non-NoIR) camera, so I'm wondering if this is something screwy with the white-balance algorithm on IR images?

aron
Posts: 4
Joined: Sat Feb 23, 2013 6:08 pm

Re: NoIR images randomly pink

Wed Dec 30, 2015 8:34 am

Are there any IR sources in the room? For example a TV remote?

User avatar
Gavinmc42
Posts: 2108
Joined: Wed Aug 28, 2013 3:31 am

Re: NoIR images randomly pink

Wed Dec 30, 2015 11:43 am

Yep, that is the standard pink image which happens when there is IR light.
Tungsten/halogen are IR sources, everything white has gone pink, that's IR from your lights.
I have used NOIR cameras inside with fluorescent lighting, not much colour shifting then.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

shusheer
Posts: 18
Joined: Wed Oct 28, 2015 3:36 pm

Re: NoIR images randomly pink

Thu Dec 31, 2015 5:45 pm

Hi Gavin and Aron,

Unfortunately I'm fairly sure this is NOT some "normal pink from IR sources" - the room lights are indeed tungsten, so there is absolutely loads of IR in the room as well as vis, but it is very consistent in level. No other IR emitters.

Also this effect is only very occasional - perhaps 5% of stills - but I see it (occasionally, randomly) when running a repeated loop of raspistill using exactly the same camera parameters. I also have several Pis with NoIR cameras and have run them in parallel, with synchronised triggering, and this effect generally only happens in one camera at once (occasionally 2 at once, as uncorrelated random events would expect).

Thus I am quite convinced that this is simply a white-balance issue - particularly as you can run both images through GIMP or photoshop and change the color levels to make the images practically identical.

Has anyone else seen this effect *occasionally* (as opposed to the usual IR camera effect of making colors washed out and weird, but consistently)?

shusheer
Posts: 18
Joined: Wed Oct 28, 2015 3:36 pm

Re: NoIR images randomly pink

Mon Jan 04, 2016 10:27 am

Hi All,

Some progress to report on this.

It appears that the dynamic range compression option (-drc high) triggers a recalculation of white-balance in the same way as adding a stats pass (-st or --stats) - i.e. this prevents the setting of fixed white balance gains.

I have not found any documentation anywhere saying that setting DRC will clobber your fixed AWB settings, so it may be helpful if this is added (in much the same way --stats has this mentioned somewhere, but I can't seem to find that reference now).

However this doesn't actually fix the reported problem, other than giving me a work-around (awb off and removing -drc and -st) - what this does do is home in on where the white-balance algorithm may have an error, in that it's something to do with AWB, DRC and/or stats (in fact it appears to happen without AWB=off or stats or DRC, which implies that it's an issue with the basic AWB algorithm having some kind of instability).

PiGraham
Posts: 3401
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: NoIR images randomly pink

Mon Jan 04, 2016 10:50 am

Just a guess, but if the scene has lots of IR it will push the image toward a limit of AWB correction. Try using the IR blocking filter that came with the NOIR camera. Do you get a stable result?

Since some of your images achieve a reasonable colour balance we could call this behaviour a bug, even if you are operating outside conditions that the camera and correction algorithms were designed and tested for.

Many commercial day/night cameras with IR illuminators switch the IR blocking filter in and out to suit light levels and switch to monochrome output in low light.

Really, if you want good colour images, don't allow lots of IR onto the sensor.

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

Re: NoIR images randomly pink

Mon Jan 04, 2016 11:18 am

shusheer wrote:It appears that the dynamic range compression option (-drc high) triggers a recalculation of white-balance in the same way as adding a stats pass (-st or --stats) - i.e. this prevents the setting of fixed white balance gains.

I have not found any documentation anywhere saying that setting DRC will clobber your fixed AWB settings, so it may be helpful if this is added (in much the same way --stats has this mentioned somewhere, but I can't seem to find that reference now).
You're right - if DRC is enabled, it will run a stats pass. The reason it isn't documented is that I wasn't aware of it! That algorithm was developed by a different team who often did quirky things, and this seems to be one of them. I haven't checked, but I'm guessing that it is using the hardware block to implement at least part of the dynamic range manipulation, and so needs the stats to work out the ranges. I'm not going into that code to make mods - it's just too scary!
shusheer wrote:However this doesn't actually fix the reported problem, other than giving me a work-around (awb off and removing -drc and -st) - what this does do is home in on where the white-balance algorithm may have an error, in that it's something to do with AWB, DRC and/or stats (in fact it appears to happen without AWB=off or stats or DRC, which implies that it's an issue with the basic AWB algorithm having some kind of instability).
I've just looked back at your original command:
raspistill -set
-ss $2 -ev -24 -ISO 100 throw everything into the mix. ev -24 will do almost nothing as you have specified shutter speed and ISO (gain). (There is a small amount of variation on gain allowed during preview, but not capture)
-awb off -awbg 1.0,1.0 -drc high --stats again conflicts. stats or drc will override AWB mode.
-n -q 10 fine.
-t 100 seems very short if you were wanting AWB to run. Then again you've locked shutter speed and ISO so those don't have to adapt, and AWB off or stats pass mean that AWB doesn't have to adapt during preview, so you may get away with it.
-w 648 -h 486 -o /dev/shm/img.jpg

The AWB algorithm is working on a probability function tuned for non-IR illuminated images, not a simple grey-world model. Under most conditions that gives better results, but with significant IR then the required solution may be outside the ranges that it has been told are permitted.
All automatic algorithms are fallible given enough variables.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

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

Re: NoIR images randomly pink

Mon Jan 04, 2016 11:21 am

so I have tried setting this to off, and also using --stats which is supposed to calculate white balance from the captured image rather than heuristics
Not quite accurate.
It runs the same AWB algorithm as normal but rather than taking stats and settings from the frames whilst preview is running, it recalculates purely on the stats of the capture image. It's the same algorithm, so it will produce the same results. Where it does have an impact is if you have a flash or other significant changes at the point of capture, as that has the potential to significantly change the colours.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “Camera board”

Who is online

Users browsing this forum: No registered users and 11 guests