Friday, July 17, 2015

How to Optimize Color Performance for USB Cameras

Optimizing color performance for USB microscope cameras is just as important as setting up the microscope properly. This post was created with Lumenera microscope cameras in mind, but applies to many other microscopy cameras as well.

Once the camera, illumination source, and optics have been configured, the application software should be used to display the camera image and manipulate the camera settings. When you first start the camera control software, refer to the live video preview from the camera, and begin by adjusting the settings for Exposure and Gain. It is important to manipulate these two setting first, regardless of how the colors appear in the image on the monitor.

Step 1 - Exposure & Gain Adjustments

It is important for the image to be properly exposed before making adjustments to any other camera properties. Verify that the camera gain is set between a value of 1 and 3 to begin. Next, adjust the exposure to increase or decrease the intensity of the scene. This can be accomplished by moving the exposure slider control, typing a specific exposure value, or enabling the Continuous Auto Exposure control. If the Auto Exposure Control is used, choose an average pixel intensity value in the range of 150 to 200 to begin.

Increasing the camera's exposure time will result in the frame rate performance being reduced. For example, if each frame requires 100ms of exposure, then the camera will only be able to deliver 10 frames per second (fps), and an exposure time of 200ms will result in only 5fps. Therefore it is generally preferable to keep the camera operating at shorter exposure times. If the illumination level cannot be increased, then the camera gain may need to be increased. The gain adjustment is an amplification of the signal from the sensor chip. Too much gain being applied will result in the image developing the appearance of electronic noise in the output.

Step 2 - White Balance

Once the camera settings are providing a live preview image with suitable brightness, the next step is to balance the camera's red, green and blue channel output for the light source. A correct white balance can only be obtained on a camera where the output is below the maximum intensity. For this step, place a white card in front of the lens. If the camera is used on a microscope with transmitted light, use the background light source for the white balance operation, by removing the sample from the field of view. Click on the White Balance function in the application software. The live preview image should now show a grey result. Replacing the sample in the field of view, or removing the white card from in front of the lens should result in the live preview image showing colors that look accurate - however, there may be further fine-tuning required to obtain the best results.

Image before white balance (left) and after white balance (right).

Be aware that many microscope illumination sources will vary in color temperature as the intensity is adjusted. The ratio of red, green and blue wavelengths in the lamp will change as the power level increases or decreases, or if optical filters are added to the light path. A new white balance adjustment may be required each time the lamp intensity is altered. For this reason, it is recommended that the camera's exposure slider be used as the preferred adjustment when the amount of light reaching the camera varies. Also check the monitor settings, as individual display monitors can vary greatly.

Step 3 - Further Adjustments

Color Correction Matrix (CCM)

A camera's response varies with different illumination sources, due to the fact that artificial lighting cannot produce a full spectrum of light. This means that they do not produce an even amount of light across all possible color frequencies. The purpose of a color correction matrix is to allow the camera to reproduce the color of the scene as faithfully as possible by compensating for the missing color frequencies in the light source. Sunlight is the only full spectrum illumination source.

Each camera supports several CCMs, depending on the application software. The basic ones include: incandescent, fluorescent, halogen and daylight. Each CCM is tuned for the spectral response of the light source, to provide the optimal color performance that matches the specific sensor characteristics in each camera model. In certain situations, the illumination used may not be accurately represented by any of the default CCMs, so an option is available to define a custom color correction matrix.

Since the appearance of the camera image is impacted by so many configuration settings (including the monitor), select a CCM that produces the color response that you desire, rather than relying solely on the name of the CCM that matches your lamp type.


Setting a suitable gamma correction value is based on the type and quality of the display monitor, in addition to the target scene and illumination. Gamma correction is implemented as a look-up table on-board the Lumenera camera, where the intensity values are altered in real-time, based on the numerical value of this setting. A default value of 1.0 is suitable for most flat-screen monitors. This value can be adjusted based on the monitor performance, until it provides the best color and separation of the range of intensity values.

For example, if insufficient detail is discernible in the darker regions of a scene, this normally means that the gamma value should be increased. This will brighten up these regions and provide images with an improved color performance.


This parameter alters the manner in which output colors are presented. Saturation is a characteristic of the observation of color. Saturated colors are called strong and vivid. De-saturated colors are referred to as weak or washed out. By default, the camera does not apply any saturation. Values greater than the default value make the images more saturated in color, i.e. the colors become more vibrant, while values less than the default setting make the images less saturated. Reducing the saturation setting to the minimum value removes all of the color information from the images, thus producing a monochrome result.

For example, increasing saturation will make red areas more red, green areas greener, etc. There is a limit to this, beyond which incorrect hues are introduced. Normally, saturation will only need to be adjusted in the range of +/-30% to achieve optimal response from the camera. Values outside of this range will affect the image dramatically and result in poor color performance.

Contrast, Hue, Brightness

It is recommended that contrast, hue and brightness be left at their default values at all times. Even subtle alterations to the hue will produce an output from the camera with wildly varied colors. If you are having any difficulties in obtaining an accurate color response from your camera, verify that these settings are reset (Contrast = 0, Huge = 0, Brightness = 0).

Demosaicing Method

Most color camera sensors use a monochrome sensor with a color filter mask of red, green or blue over each pixel to capture color information. The typical layout of this arrangement is known as a Bayer filter. The raw images returned from the camera consist only of intensity measurements taken at each pixel. To extract the color information out of the images, a demosaicing algorithm is used to merge the values of neighboring pixels to determine the appropriate missing color values for each pixel location. The number of pixels and the demosaicing method used both determine the accuracy of the color interpretation for each algorithm.

Typically, the camera will use a faster, but lower quality, demosaicing method for the live video preview as the video refresh rate takes precedence over the finest details being resolved. The application software will use the highest quality demosaicing method when capturing an image from the camera.

In most cases, setting the appropriate CCM and demosaicing method along with a proper white/color balance will produce excellent results. There are occasions where it may be necessary to increase the gamma and saturation to improve the color performance of the images and to make the colors more vibrant.

This post is the final part of a 3-part post that also covered:

Source: Lumenera White Paper Series