RidgeRun Auto exposure/Auto white balance library for DM368 and DM365: Difference between revisions

From RidgeRun Developer Wiki
No edit summary
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= Introduction =
= Introduction =
CMOS or CCD sensor video capture quality can be enhance with image processing, like auto white balance (AWB) and auto exposure algorithms (AE):
 
CMOS or CCD sensor video capture quality can be enhanced with image processing, like auto white balance (AWB) and auto exposure (AE) algorithms:
*Auto exposure performs automatic adjustments of the image brightness according to the amount of light that reaches the camera sensor.
*Auto exposure performs automatic adjustments of the image brightness according to the amount of light that reaches the camera sensor.
*Auto white balance automatically compensates color differences based on lighting so white actually appears white.
*Auto white balance automatically compensates color differences based on lighting so white actually appears white.


Some camera sensors don't include auto white balance and/or auto exposure processing, so RidgeRun offers a library with AE and AWB algorithms called '''librraew'''. This library was initially developed for the DM365 platform. The DM365 video processing front end (VPFE) has an H3A module designed to support control loops for auto focus, auto white balance and auto exposure by collecting statistics about the imaging/video data. There are two blocks in this module:
Some camera sensors don't include auto white balance and/or auto exposure processing, so RidgeRun offers a library with AE and AWB algorithms called '''librraew'''. This library was initially developed for the DM365/DM368 (DM36x) platform. The DM36x video processing front end (VPFE) has an H3A engine designed to support control loops for auto focus, auto white balance and auto exposure by collecting statistics about the imaging/video data. There are two blocks in this module:
 
* Auto focus engine  
* Auto focus engine  
* Auto exposure and auto white balance engine  
* Auto exposure and auto white balance engine  


The librraew only use the auto exposure and auto white balance engine. This engine divides the frames into two dimensional blocks of pixels referred as windows. The engine can provide some image/video metrics:  
The librraew library only uses the auto exposure and auto white balance hardware engine. The DM36x does not allow the H3A engine to be used when the color space is YCbCr, which is common if you are using NTSC/PAL composite video input.
* Accumulation of clipped pixels along with all non-saturated pixels in each window per color.
 
The H3A engine divides the frames into two dimensional blocks of pixels referred as windows. The engine provides image/video metrics:  
 
* Accumulation of clipped pixels along with all non-saturated pixels in each window on a per color basis.
* Accumulation of the sum of squared pixels per color.
* Accumulation of the sum of squared pixels per color.
* Minimum and maximum pixels values in each window per color.
* Minimum and maximum pixels values in each window on a per color basis.
The  AE/AWB engine can be configured to use up to 36 horizontal windows with sum + {sum of squares or min+max} output or up to 56 horizontal windows with sum output. The AE/AWB engine can also be configure to use up to 128 vertical windows. The width and height for the windows is programmable.


Currently, librraew has testing has focused on Aptina CMOS sensor mt9p031, but if you provide the appropriate functions for the library, it can works with any sensor. The implementation is a plain C library and can be re-used with and integrated with any application. RidgeRun uses ipiped (see below) for testing and demonstration.
The DM36x H3A engine can be configured to use up to 36 horizontal windows with sum + {sum of squares or min+max} output or up to 56 horizontal windows with sum output. The H3A engine can also be configure to use up to 128 vertical windows. The width and height for the windows is programmable.
 
The librraew library was tested using an Aptina MT9P031 CMOS sensor.  Support for other sensors was added later, thus validating the librraew design.  If you provide the appropriate sensor-specific functions for the library, it can work with any sensor. The implementation is a plain C library and can be re-used with and integrated with any application capable of making C function calls. [https://github.com/RidgeRun/ipiped/wiki Image Pipe Daemon] uses librraew to provide auto exposure/Auto white balance.
 
= License =
 
RidgeRun auto-exposure/auto-white-balance library (C) Copyright 2010 - RidgeRun LLC. 
 
== Evaluation and Development License ==
 
Subject to the terms and conditions of RidgeRun's SDK license, RidgeRun hereby grants to customer a product - based, non - exclusive, non - transferable, non - sublicensable, limited, worldwide license to install and use, for internal purposes only, an unlimited number of copies of the source and object code versions.
 
== Distribution License ==
 
Subject to the terms and conditions of RidgeRun's SDK license, RidgeRun hereby grants to customer a non-exclusive, non-transferable, non-sublicensable, limited, worldwide license to distribute RidgeRun Software in object code format only (no source code) in one product model sold by the customer.
 
= Limitations =
 
There are some not-so-obvious limitations when using the H3A engine:
 
* AWB/AE correction limited to window sampling method listed above.
* Can not use H3A engine with YCbCr color space, which includes NTSC/PAL composite video input.
* Auto exposure can affect the video frame rate with dark images.  Set a maximum exposure limit to keep the frame rate from dropping below an acceptable value.
* Only tested with Linux 2.6.32 and the RidgeRun MT9P031 V4L2 driver.


= Algorithms =
= Algorithms =
== Auto white balance ==
== Auto white balance ==
When an image of a scene is captured by a digital camera sensor, the sensor response at each pixel depends on the scene illumination. Depending of the illumination, a distinct color cast appears over the captured scene. This effect appears in the captured image due to the color temperature of the light. If a white object is illuminated with a low color temperature light source, the object in the captured image will be reddish. Similarly, when the white object is illuminated with a high color temperature light source, the object in the captured image will be bluish. The human eye compensates for color cast automatically through a characteristic known as color constancy, allowing the colors to be independent of the illumination. Auto white balance tries to simulate the color constancy for images capture.
 
When an image of a scene is captured by a digital camera sensor, the sensor response at each pixel depends on the scene illumination. Depending of the illumination, a distinct color cast appears over the captured scene. This effect appears in the captured image due to the color temperature of the light. If a white object is illuminated with a low color temperature light source, the object in the captured image will have a reddish tint. Similarly, when the white object is illuminated with a high color temperature light source, the object in the captured image will appear somewhat blue instead of pure white. The human eye compensates for color cast automatically through a characteristic known as color constancy, allowing the colors to be independent of the illumination. Auto white balance tries to simulate the color constancy for captured images.
    
    
Many AWB algorithms follow a two-stage process:
Many auto white balance algorithms follow a two-stage process:
* Illumination estimation: can be done explicitly by choosing from a known set of possible illuminations or implicitly with assumptions about the effect of such illuminations. The algorithms implemented in librraew use the implicitly estimation.       
* Illumination estimation: this can be done explicitly by choosing from a known set of possible illuminations or implicitly with assumptions about the effect of such illuminations. The algorithms implemented in librraew use implicit estimation.       
* Image color correction: is achieved through an independent gain adjustment of the three color signals. Commonly only the blue and red gains are adjusted.  
* Image color correction: this is achieved through an independent gain adjustment of the three color signals. Commonly only the blue and red gains are adjusted assuming the red gain is fixed.  


== Auto exposure ==
== Auto exposure ==
One of the main problems affecting image quality, leading to unpleasant pictures, comes from improper exposure to light. The exposure is the amount of light that reaches the image sensor. Exposure determines the lightness or darkness of the resulting image. If too much light strikes the image sensor, the image will be overexposed, washed out, and faded. If too little light reaches the camera sensor produces an underexposed image, dark and lacking in details especially in shadow areas. Auto exposure (AE) algorithms adjust the captured image in an attempt to reproduce the most important regions (according to contextual or perceptive criteria) with a level of brightness, more or less in the middle of the possible range.
One of the main problems affecting image quality, leading to disappointing pictures, comes from improper light exposure. The image exposure is the amount of light that reaches the sensor. Exposure determines the lightness or darkness of the resulting image. If too much light strikes the image sensor, the image will be overexposed, washed out, and faded. If too little light reaches the camera sensor produces an underexposed image, dark and lacking in details especially in shadow areas. Auto exposure (AE) algorithms adjust the captured image in an attempt to reproduce the most important regions (according to contextual or perceptive criteria) with an average level of brightness, more or less in the middle of the possible range.


Auto exposure algorithms involves three processes:
Auto exposure algorithms involves three processes:
* Light metering: generally accomplished using the camera sensor itself or an external device as exposure detector.  
* Light metering: this is generally accomplished using the camera sensor itself or an external device as exposure detector.  
* Scene analysis: brightness metering methods used to estimate the scene illumination according to image metrics. Using this value, calculates the brightness adjustments to have the best exposure.
* Scene analysis: brightness metering methods use an estimation of the scene illumination according to image metrics. Using the oerall illumination value, brightness adjustments can be calculated to produce the best exposure.
* Image brightness correction: ensures that the correct amount of light reaches the image sensor, illumination and shutter time parameters are adjusted. The CMOS image sensor parameter is often called exposure time. The exposure time is defined as the amount of time that the sensor integrates light. In other words, it determines how long the sensor photo diodes array is exposed to light.  
* Image brightness correction: this ensures that the correct amount of light reaches the image sensor by adjusting the illumination and shutter time parameters. The image sensor parameter is often called the exposure time. The exposure time is defined as the amount of time that the sensor integrates light. In other words, it determines how long the sensor photo diodes array is exposed to light.  


= Documentation =
= Documentation =
*[[Librraew 1.0]]
* [[Librraew 1.1]] (current version)
*[[Librraew 1.1]]
* [[Librraew 1.0]]
 
= Using the demo version of librraew  =


= Using the demo version of librraew =
You can request a demo version of librraew in order to test the auto-white balance and auto-exposure algorithms to see if the technology meets your needs. This library will allow you to use all the features that comes with the full version of the librraew but with the following limitations:


You can request a demo version of librraew in order to test the auto-white balance and auto-exposure algorithms before you decide to buy it. This library will allow you to use all the features that comes with the full version of the librraew but with the following limitations:
*The algorithm will darken the image periodically.
*After awhile the algorithm will stop working and the image capturing will be done with the last values calculated by the library. In order to test the library again you will need to restart the algorithm.


* The algorithm will be darken the image periodically.
[https://ridgerun.com/downloadcenter.shtml Go to download center]
* After a while the algorithm will stop working and the image capturing will be done with the last values calculated by the library. In order to test the library again you will need to restart the algorithm.
 
[https://ridgerun.com/store/ Go to RidgeRun Store]
<div id="-chrome-auto-translate-plugin-dialog" style="opacity: 1 !important; background-image: initial !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: transparent !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; position: absolute !important; top: 0px; left: 0px; overflow-x: visible !important; overflow-y: visible !important; z-index: 999999 !important; text-align: left !important; display: none; background-position: initial initial !important; background-repeat: initial initial !important; "><div style="max-width: 300px !important;color: #fafafa !important;opacity: 0.8 !important;border-color: #000000 !important;border-width: 0px !important;-webkit-border-radius: 10px !important;background-color: #363636 !important;font-size: 16px !important;padding: 8px !important;overflow: visible !important;background-image: -webkit-gradient(linear, left top, right bottom, color-stop(0%, #000), color-stop(50%, #363636), color-stop(100%, #000));z-index: 999999 !important;text-align: left  !important;"><div class="translate"></div><div class="additional"></div></div>[[Image:]]</div>


= References =  
= References =  
Line 50: Line 84:
# Edmund Y. Lam and George S. K. Fung. Automatic white balancing in digital photography. In Single-Sensor Imaging: Methods and Applications for Digital Cameras. Taylor & Francis Group, LLC, 2009.
# Edmund Y. Lam and George S. K. Fung. Automatic white balancing in digital photography. In Single-Sensor Imaging: Methods and Applications for Digital Cameras. Taylor & Francis Group, LLC, 2009.
# Nitin Sampat, Shyam Venkataraman, Thomas Yeh, and Robert L. Kremens. System implications of implementing auto-exposure on consumer digital cameras. Proc. SPIE. Sensors, Cameras, and Applications for Digital Photography, 3650:100–107, March 1999
# Nitin Sampat, Shyam Venkataraman, Thomas Yeh, and Robert L. Kremens. System implications of implementing auto-exposure on consumer digital cameras. Proc. SPIE. Sensors, Cameras, and Applications for Digital Photography, 3650:100–107, March 1999


[[Category:Whitepaper]]
[[Category:Whitepaper]]

Revision as of 20:03, 30 November 2011

Introduction

CMOS or CCD sensor video capture quality can be enhanced with image processing, like auto white balance (AWB) and auto exposure (AE) algorithms:

  • Auto exposure performs automatic adjustments of the image brightness according to the amount of light that reaches the camera sensor.
  • Auto white balance automatically compensates color differences based on lighting so white actually appears white.

Some camera sensors don't include auto white balance and/or auto exposure processing, so RidgeRun offers a library with AE and AWB algorithms called librraew. This library was initially developed for the DM365/DM368 (DM36x) platform. The DM36x video processing front end (VPFE) has an H3A engine designed to support control loops for auto focus, auto white balance and auto exposure by collecting statistics about the imaging/video data. There are two blocks in this module:

  • Auto focus engine
  • Auto exposure and auto white balance engine

The librraew library only uses the auto exposure and auto white balance hardware engine. The DM36x does not allow the H3A engine to be used when the color space is YCbCr, which is common if you are using NTSC/PAL composite video input.

The H3A engine divides the frames into two dimensional blocks of pixels referred as windows. The engine provides image/video metrics:

  • Accumulation of clipped pixels along with all non-saturated pixels in each window on a per color basis.
  • Accumulation of the sum of squared pixels per color.
  • Minimum and maximum pixels values in each window on a per color basis.

The DM36x H3A engine can be configured to use up to 36 horizontal windows with sum + {sum of squares or min+max} output or up to 56 horizontal windows with sum output. The H3A engine can also be configure to use up to 128 vertical windows. The width and height for the windows is programmable.

The librraew library was tested using an Aptina MT9P031 CMOS sensor. Support for other sensors was added later, thus validating the librraew design. If you provide the appropriate sensor-specific functions for the library, it can work with any sensor. The implementation is a plain C library and can be re-used with and integrated with any application capable of making C function calls. Image Pipe Daemon uses librraew to provide auto exposure/Auto white balance.

License

RidgeRun auto-exposure/auto-white-balance library (C) Copyright 2010 - RidgeRun LLC.

Evaluation and Development License

Subject to the terms and conditions of RidgeRun's SDK license, RidgeRun hereby grants to customer a product - based, non - exclusive, non - transferable, non - sublicensable, limited, worldwide license to install and use, for internal purposes only, an unlimited number of copies of the source and object code versions.

Distribution License

Subject to the terms and conditions of RidgeRun's SDK license, RidgeRun hereby grants to customer a non-exclusive, non-transferable, non-sublicensable, limited, worldwide license to distribute RidgeRun Software in object code format only (no source code) in one product model sold by the customer.

Limitations

There are some not-so-obvious limitations when using the H3A engine:

  • AWB/AE correction limited to window sampling method listed above.
  • Can not use H3A engine with YCbCr color space, which includes NTSC/PAL composite video input.
  • Auto exposure can affect the video frame rate with dark images. Set a maximum exposure limit to keep the frame rate from dropping below an acceptable value.
  • Only tested with Linux 2.6.32 and the RidgeRun MT9P031 V4L2 driver.

Algorithms

Auto white balance

When an image of a scene is captured by a digital camera sensor, the sensor response at each pixel depends on the scene illumination. Depending of the illumination, a distinct color cast appears over the captured scene. This effect appears in the captured image due to the color temperature of the light. If a white object is illuminated with a low color temperature light source, the object in the captured image will have a reddish tint. Similarly, when the white object is illuminated with a high color temperature light source, the object in the captured image will appear somewhat blue instead of pure white. The human eye compensates for color cast automatically through a characteristic known as color constancy, allowing the colors to be independent of the illumination. Auto white balance tries to simulate the color constancy for captured images.

Many auto white balance algorithms follow a two-stage process:

  • Illumination estimation: this can be done explicitly by choosing from a known set of possible illuminations or implicitly with assumptions about the effect of such illuminations. The algorithms implemented in librraew use implicit estimation.
  • Image color correction: this is achieved through an independent gain adjustment of the three color signals. Commonly only the blue and red gains are adjusted assuming the red gain is fixed.

Auto exposure

One of the main problems affecting image quality, leading to disappointing pictures, comes from improper light exposure. The image exposure is the amount of light that reaches the sensor. Exposure determines the lightness or darkness of the resulting image. If too much light strikes the image sensor, the image will be overexposed, washed out, and faded. If too little light reaches the camera sensor produces an underexposed image, dark and lacking in details especially in shadow areas. Auto exposure (AE) algorithms adjust the captured image in an attempt to reproduce the most important regions (according to contextual or perceptive criteria) with an average level of brightness, more or less in the middle of the possible range.

Auto exposure algorithms involves three processes:

  • Light metering: this is generally accomplished using the camera sensor itself or an external device as exposure detector.
  • Scene analysis: brightness metering methods use an estimation of the scene illumination according to image metrics. Using the oerall illumination value, brightness adjustments can be calculated to produce the best exposure.
  • Image brightness correction: this ensures that the correct amount of light reaches the image sensor by adjusting the illumination and shutter time parameters. The image sensor parameter is often called the exposure time. The exposure time is defined as the amount of time that the sensor integrates light. In other words, it determines how long the sensor photo diodes array is exposed to light.

Documentation

Using the demo version of librraew

You can request a demo version of librraew in order to test the auto-white balance and auto-exposure algorithms to see if the technology meets your needs. This library will allow you to use all the features that comes with the full version of the librraew but with the following limitations:

  • The algorithm will darken the image periodically.
  • After awhile the algorithm will stop working and the image capturing will be done with the last values calculated by the library. In order to test the library again you will need to restart the algorithm.

Go to download center

Go to RidgeRun Store

References

  1. Battiato, G. Messina, and A. Castorina. Exposure correction for imaging devices: an overview. In Single-Sensor Imaging: Methods and Applications for Digital Cameras, chapter 12. Rastislav Lukac, October 2008.
  2. Lee J.S., Jung Y.Y, Kim B.S., and Ko S.J. An advanced video camera system with robust af, ae, and awb control. IEEE Transactions on Consumer Electronics, 47:694–699, August 2001
  3. Edmund Y. Lam. Combining gray world and retinex theory for automatic white balance in digital photography. Consumer Electronics, 2005. (ISCE 2005). Proceedings of the Ninth International Symposium on, pages 134–139, June 2005.
  4. Edmund Y. Lam and George S. K. Fung. Automatic white balancing in digital photography. In Single-Sensor Imaging: Methods and Applications for Digital Cameras. Taylor & Francis Group, LLC, 2009.
  5. Nitin Sampat, Shyam Venkataraman, Thomas Yeh, and Robert L. Kremens. System implications of implementing auto-exposure on consumer digital cameras. Proc. SPIE. Sensors, Cameras, and Applications for Digital Photography, 3650:100–107, March 1999