cv.Retina - MATLAB File Help Go to online doc for cv.Retina
cv.Retina

A biological retina model for image spatio-temporal noise and luminance changes enhancement

Class which allows the Gipsa/Listic Labs model to be used with OpenCV.

This retina model allows spatio-temporal image processing (applied on still images, video sequences).

As a summary, these are the retina model properties:

USE: this model can be used basically for spatio-temporal video effects but also for:

For more information, refer to the following papers [Benoit2010] and [Herault2010].

Retina class overview

Introduction

This class provides the main controls of the Gipsa/Listic labs human retina model. This is a non separable spatio-temporal filter modelling the two main retina information channels:

This model originates from Jeanny Herault work [Herault2010]. It has been involved in Alexandre Benoit phd and his current research [Benoit2010], [Benoit2014]. He currently maintains this module within OpenCV. It includes the work of other Jeanny's phd student such as [Chaix2007] and the log polar transformations of Barthelemy Durette described in Jeanny's book.

More into details here is an overview of the retina properties that are implemented here:

Regarding luminance and details enhancement:

The former behavior compresses luminance range and allows very bright areas and very dark ones to be visible on the same picture with lots of details. The latter reduces low frequency luminance energy (mean luminance) and enhances mid-frequencies (details). Applied all together, retina well prepares visual signals prior high level analysis. Those properties are really interesting with videos where light changes are dramatically reduced with an interesting temporal consistency.

Regarding noise filtering :

Use

This model can be used as a preprocessing stage in the aim of:

Note:

Use case illustrations

Image preprocessing using the Parvocellular pathway (parvo retina output)

As a preliminary presentation, let's start with a visual example. We propose to apply the filter on a low quality color jpeg image with backlight problems. Here is the considered input... "Well,i could see more with my eyes than what i captured with my camera..."

image

Below, the retina foveal model applied on the entire image with default parameters. Details are enforced whatever the local luminance is. Here there contours are strongly enforced but the noise level is kept low. Halo effects are voluntary visible with this configuration. See parameters discussion below and increase HorizontalCellsGain near 1 to remove them.

image

Below, a second retina foveal model output applied on the entire image with a parameters setup focused on naturalness perception. "Hey, i now recognize my cat, looking at the mountains at the end of the day!". Here contours are enforced, luminance is corrected but halos are avoided with this configuration. The backlight effect is corrected and highlight details are still preserved. Then, even on a low quality jpeg image, if some luminance's information remains, the retina is able to reconstruct a proper visual signal. Such configuration is also useful for High Dynamic Range (HDR) images compression to 8bit images as discussed in [Benoit2010] and in the demonstration codes discussed below. As shown at the end of the page, parameter changes from defaults are:

image

As observed in this preliminary demo, the retina can be settled up with various parameters, by default, as shown on the figure above, the retina strongly reduces mean luminance energy and enforces all details of the visual scene. Luminance energy and halo effects can be modulated (exaggerated to cancelled as shown on the two examples). In order to use your own parameters, you can use at least one time the cv.Retina.write method which will write a proper XML file with all default parameters. Then, tweak it on your own and reload them at any time using method cv.Retina.setup. These methods update a RetinaParameters member structure that is described hereafter. XML parameters file samples are shown at the end of the page.

Tone mapping processing capability using the Parvocellular pathway (parvo retina output)

This retina model naturally handles luminance range compression. Local adaptation stages and spectral whitening contribute to luminance range compression. In addition, high frequency noise that often corrupts tone mapped images is removed at early stages of the process thus leading to natural perception and noise free tone mapping.

Compared to the demos shown above, setup differences are the following ones:

Have a look at the end of this page to see how to specify these parameters in a configuration file.

The following two illustrations show the effect of such configuration on 2 image samples.

Motion and event detection using the Magnocellular pathway (magno retina output)

Spatio-temporal events can be easily detected using magno output of the retina (use the cv.Retina.getMagno method). Its energy linearly increases with motion speed.

An event blob detector is proposed with the cv.TransientAreasSegmentationModule class also provided in the bioinspired module. The basic idea is to detect local energy drops with regard of the neighborhood and then to apply a threshold. Such process has been used in a bag of words description of videos on the TRECVid challenge [Benoit2014] and only allows video frames description on transient areas.

We present here some illustrations of the retina outputs on some examples taken from CDNET with RGB and thermal videos.

NOTE: here, we use the default retina setup that generates halos around strong edges. Note that temporal constants allow a temporal effect to be visible on moting objects (useful for still image illustrations of a video). Halos can be removed by increasing retina Hcells gain while temporal effects can be reduced by decreasing temporal constant values. Also take into account that the two retina outputs are rescaled in range [0:255] such that magno output can show a lot of "noise" when nothing moves while drawing it. However, its energy remains low if you retrieve it using cv.Retina.getMagnoRAW getter instead.

Literature

For more information, refer to the following papers:

This retina filter code includes the research contributions of phd/research collegues from which code has been redrawn by the author:

Retina programming interfaces

The proposed class allows the Gipsa (preliminary work) / Listic labs retina model to be used. It can be applied on still images, images sequences and video sequences.

Setting up Retina

Managing the configuration file

When using the cv.Retina.write and cv.Retina.load methods, you create or load a XML file that stores Retina configuration.

The default configuration is presented below.

<?xml version="1.0"?>
<opencv_storage>
<OPLandIPLparvo>
    <colorMode>1</colorMode>
    <normaliseOutput>1</normaliseOutput>
    <photoreceptorsLocalAdaptationSensitivity>7.5e-01</photoreceptorsLocalAdaptationSensitivity>
    <photoreceptorsTemporalConstant>9.0e-01</photoreceptorsTemporalConstant>
    <photoreceptorsSpatialConstant>5.7e-01</photoreceptorsSpatialConstant>
    <horizontalCellsGain>0.01</horizontalCellsGain>
    <hcellsTemporalConstant>0.5</hcellsTemporalConstant>
    <hcellsSpatialConstant>7.</hcellsSpatialConstant>
    <ganglionCellsSensitivity>7.5e-01</ganglionCellsSensitivity>
</OPLandIPLparvo>
<IPLmagno>
    <normaliseOutput>1</normaliseOutput>
    <parasolCells_beta>0.</parasolCells_beta>
    <parasolCells_tau>0.</parasolCells_tau>
    <parasolCells_k>7.</parasolCells_k>
    <amacrinCellsTemporalCutFrequency>2.0e+00</amacrinCellsTemporalCutFrequency>
    <V0CompressionParameter>9.5e-01</V0CompressionParameter>
    <localAdaptintegration_tau>0.</localAdaptintegration_tau>
    <localAdaptintegration_k>7.</localAdaptintegration_k>
</IPLmagno>
</opencv_storage>

Here are some words about all those parameters, tweak them as you wish to amplify or moderate retina effects (contours enforcement, halos effects, motion sensitivity, motion blurring, etc.)

Basic parameters

The simplest parameters are as follows:

Note: using color requires color channels multiplexing/demultipexing which also demands more processing. You can expect much faster processing using gray levels: it would require around 30 product per pixel for all of the retina processes and it has recently been parallelized for multicore architectures.

Photo-receptors parameters

The following parameters act on the entry point of the retina (photo-receptors) and has impact on all of the following processes. These sensors are low pass spatio-temporal filters that smooth temporal and spatial data and also adjust their sensitivity to local luminance, thus, leads to improving details extraction and high frequency noise canceling.

Horizontal cells parameters

This parameter set tunes the neural network connected to the photo-receptors, the horizontal cells. It modulates photo-receptors sensitivity and completes the processing for final spectral whitening (part of the spatial band pass effect thus favoring visual details enhancement).

NOTE: Once the processing managed by the previous parameters is done, input data is cleaned from noise and luminance is already partly enhanced. The following parameters act on the last processing stages of the two outing retina signals.

Parvo (details channel) dedicated parameter

Note: this parameter can correct eventual burned images by favoring low energetic details of the visual scene, even in bright areas.

IPL Magno (motion/transient channel) parameters

Once image's information are cleaned, this channel acts as a high pass temporal filter that selects only the signals related to transient signals (events, motion, etc.). A low pass spatial filter smooths extracted transient data while a final logarithmic compression enhances low transient events thus enhancing event sensitivity.

Demos and experiments

First time experiments

Here are some code snippets to shortly show how to use Retina with default parameters (with halo effects). Next section redirects to more complete demos provided with the main retina class.

Here is presented how to process a webcam stream with the following steps:

See retina_demo.m MATLAB sample.

More complete demos

Note: Complementary to the following examples, have a look at the Retina tutorial in the tutorial/contrib section for complementary explanations.

References

[Benoit2010]:

Benoit A., Caplier A., Durette B., Herault, J.; "Using Human Visual System Modeling For Bio-inspired Low Level Image Processing", Elsevier, Computer Vision and Image Understanding 114 (2010), pp. 758-773, DOI

[Benoit2014]:

Strat S.T., Benoit A., Lambert P.; "Retina enhanced bag of words descriptors for video classification". In Proceedings of the 22nd European Signal Processing Conference (EUSIPCO), 2014, pp. 1307-1311.

[Herault2010]:

Jeanny Herault; "Vision: Images, Signals and Neural Networks: Models of Neural Processing in Visual Perception" (Progress in Neural Processing), ISBN: 9814273686. WAPI (Tower ID): 113266891.

[Chaix2007]:

B. Chaix de Lavarene, D. Alleysson, B. Durette, J. Herault (2007). "Efficient demosaicing through recursive filtering". IEEE International Conference on Image Processing ICIP 2007.

[Meylan2007]:

Meylan L., Alleysson D., and Susstrunk S., "A Model of Retinal Local Adaptation for the Tone Mapping of Color Filter Array Images", Journal of Optical Society of America, A, Vol. 24, N. 9, September, 1st, 2007, pp. 2807-2816

See also
Class Details
Superclasses handle
Sealed false
Construct on load false
Constructor Summary
Retina Constructor from standardized interface to create a Retina instance 
Property Summary
id Object ID 
Method Summary
  activateContoursProcessing Activate/desactivate the Parvocellular pathway processing (contours information extraction) 
  activateMovingContoursProcessing Activate/desactivate the Magnocellular pathway processing (motion information extraction) 
  addlistener Add listener for event. 
  applyFastToneMapping Method which processes an image in the aim to correct its luminance correct backlight problems, enhance details in shadows 
  clear Clears the algorithm state 
  clearBuffers Clears all retina buffers 
  delete Destructor 
  empty Checks if detector object is empty 
  eq == (EQ) Test handle equality. 
  findobj Find objects matching specified conditions. 
  findprop Find property of MATLAB handle object. 
  ge >= (GE) Greater than or equal relation for handles. 
  getDefaultName Returns the algorithm string identifier 
  getInputSize Retreive retina input buffer size 
  getMagno Accessor of the motion channel of the retina (models peripheral vision) 
  getMagnoRAW Accessor of the motion channel of the retina (models peripheral vision) 
  getOutputSize Retreive retina output buffer size that can be different from the input if a spatial log transformation is applied 
  getParameters Retrieve the current retina parameters values in a structure 
  getParvo Accessor of the details channel of the retina (models foveal vision) 
  getParvoRAW Accessor of the details channel of the retina (models foveal vision) 
  gt > (GT) Greater than relation for handles. 
Sealed   isvalid Test handle validity. 
  le <= (LE) Less than or equal relation for handles. 
  listener Add listener for event without binding the listener to the source object. 
  load Loads algorithm from a file or a string 
  lt < (LT) Less than relation for handles. 
  ne ~= (NE) Not equal relation for handles. 
  notify Notify listeners of event. 
  printSetup Outputs a string showing the used parameters setup 
  run Method which allows retina to be applied on an input image 
  save Saves the algorithm parameters to a file 
  setColorSaturation Activate color saturation as the final step of the color demultiplexing process 
  setup Try to open an XML retina parameters file to adjust current retina instance setup 
  setupIPLMagnoChannel Set parameters values for the Inner Plexiform Layer (IPL) magnocellular channel 
  setupOPLandIPLParvoChannel Setup the OPL and IPL parvo channels (see biologocal model) 
  setupParameters Pass retina parameters to adjust current retina instance setup 
  write Write xml/yml formatted parameters information 
Event Summary
ObjectBeingDestroyed Notifies listeners that a particular object has been destroyed.