Public Lab Research note

White balancing a 4 channel RAW image?

by Fi156 |

Read more:

What I want to do

In the long run I want to create NDVI-like images from a multi camera setup to monitor crop health from an UAV. At the moment I am evaluating the possibilities of these methods in a theoretical manner.

What I did

I decided to use a dual camera setup and capture RAW image data: Thus I will be able to get a RGB image and the NIR channel for NDVI-like images.

In one camera the UV/NIR Filter was removed (converted to "full spectrum") and I plan to use a standard 720nm filter in front of the lens. Both cameras where triggered simultaneously with a interval enabled Remote shutter (for testing), or by the processing unit of the UAV.

At the moment I am a little bit concerned about the post processing steps:

Numerous notes on Public Lab have shown that white balance is indeed a very important factor.

Therefore I planned to use a white balance target, which reflects in the NIR spectrum equally to the visible spectrum. Since Spektralon(R) is very expensive, I want to go with Bariumsulfate (BaSO4) paint*.

The post processing steps will be something like:

-White balance, exposure equalization and conversion to tif or jpeg as linear images. -Feeding the data into the OpenDroneMap Project -Further processing with tools like Grass or OTB.

*= Thanks to funkycbj:

Further steps

-The UAV will be ready in approx. 2 weeks. -Camera setup will be available for testing in 3-4 days.


Tools like dcraw are able to provide an easy way to calculate a white balance for 3 channel images (RGB).

By digging deeper into the topic, I came across this post: "Unfortunately this way of operation is more didactic than practical, because as we already indicated in the beginning to adjust the white balance after the RAW development is not recommended as demosaicing algorithms are optimised to interpolate an already white balanced image." Taken from:

My biggest problem at the moment: How can I get the white balance factors for a 4 channel image?

I do not think, that it is sufficient to calculate the white balance for both images separately, because the values depends relatively on the other channels...

Any thoughts about the project, or especially on the white balance issue?

near-infrared-camera ndvi white-balance


White balance is important for most single-camera NDVI systems, but could be irrelevant to dual-camera systems. The goal is to capture photos with values in the visible and NIR channels that allow computation of meaningful NDVI values. So for pixels of healthy plants, values in the NIR channel must be several times higher than the values in the visible channel.

The relative brightness of the VIS and NIR channels in a single-camera system can be modified by doing a custom white balance, but this is a bit of a kludge. In dual-camera systems the relative brightness of the VIS and NIR channels can be modified by adjusting the exposure setting of one or both cameras. If the NIR values are not high enough for meaningful NDVI, the exposure of the NIR camera can be changed to make the values higher (brighter). Your calibration targets can be used to do this objectively so that your NDVI results are calibrated. Because you are capturing RAW images, you can adjust the exposure (by a stop or two) during post processing so that your targets are the proper brightness. Then the computed NDVI values should be correct. When the NIR and VIS channels are properly adjusted (calibrated), you can combine them into a single image, although there may be no reason to do that. NDVI or other indices can be calculated from two separate images. False color IR images can also be produced from two separate images. A single four band image might be a nice way to store the data.


This is again a reason why you would want to know the spectral response of most imaging sensors. Without this information it will require field validation if you want to infer any quantitative data from these NDVI values.

Or without knowing the spectral response of the sensor, you can brute force the response of a dual-camera system by shooting through narrow band pass filters to capture only the bands you want to use for NDVI. The wavelengths used for both NIR and VIS could then be similar to those used in legacy NDVI. If you use calibration targets to calibrate the relative intensity of NIR vs VIS, those results could be comparable with legacy NDVI. Narrow band pass filters require longer exposure times so are not so suitable for UAV or kite use, but are easy to use on tripod mounted systems.

Good point, I might use this approach to see if I can get better results on my PRI sensor. Things were funky and this offset in response (difference in transmission of the filters + spectral response) is probably the cause and something I need to address. I'm still working on the full spectral response of the raspberry pi but for now this has taken a back seat.

You must be logged in to comment.