OpenCV  2.4.13.7
Open Source Computer Vision
cv::Retina Class Reference

#include <retina.hpp>

Classes

struct  RetinaParameters
 

Public Member Functions

 Retina (Size inputSize)
 
 Retina (Size inputSize, const bool colorMode, RETINA_COLORSAMPLINGMETHOD colorSamplingMethod=RETINA_COLOR_BAYER, const bool useRetinaLogSampling=false, const double reductionFactor=1.0, const double samplingStrenght=10.0)
 
virtual ~Retina ()
 
Size inputSize ()
 
Size outputSize ()
 
void setup (std::string retinaParameterFile="", const bool applyDefaultSetupOnFailure=true)
 
void setup (cv::FileStorage &fs, const bool applyDefaultSetupOnFailure=true)
 
void setup (RetinaParameters newParameters)
 
Retina::RetinaParameters getParameters ()
 
const std::string printSetup ()
 
virtual void write (std::string fs) const
 
virtual void write (FileStorage &fs) const
 
void setupOPLandIPLParvoChannel (const bool colorMode=true, const bool normaliseOutput=true, const float photoreceptorsLocalAdaptationSensitivity=0.7f, const float photoreceptorsTemporalConstant=0.5f, const float photoreceptorsSpatialConstant=0.53f, const float horizontalCellsGain=0, const float HcellsTemporalConstant=1, const float HcellsSpatialConstant=7, const float ganglionCellsSensitivity=0.7f)
 
void setupIPLMagnoChannel (const bool normaliseOutput=true, const float parasolCells_beta=0, const float parasolCells_tau=0, const float parasolCells_k=7, const float amacrinCellsTemporalCutFrequency=1.2f, const float V0CompressionParameter=0.95f, const float localAdaptintegration_tau=0, const float localAdaptintegration_k=7)
 
void run (const Mat &inputImage)
 
void getParvo (Mat &retinaOutput_parvo)
 
void getParvo (std::valarray< float > &retinaOutput_parvo)
 
void getMagno (Mat &retinaOutput_magno)
 
void getMagno (std::valarray< float > &retinaOutput_magno)
 
const std::valarray< float > & getMagno () const
 
const std::valarray< float > & getParvo () const
 
void setColorSaturation (const bool saturateColors=true, const float colorSaturationValue=4.0)
 
void clearBuffers ()
 
void activateMovingContoursProcessing (const bool activate)
 
void activateContoursProcessing (const bool activate)
 

Protected Member Functions

void _convertValarrayBuffer2cvMat (const std::valarray< float > &grayMatrixToConvert, const unsigned int nbRows, const unsigned int nbColumns, const bool colorMode, Mat &outBuffer)
 
bool _convertCvMat2ValarrayBuffer (const cv::Mat inputMatToConvert, std::valarray< float > &outputValarrayMatrix)
 
void _init (const Size inputSize, const bool colorMode, RETINA_COLORSAMPLINGMETHOD colorSamplingMethod=RETINA_COLOR_BAYER, const bool useRetinaLogSampling=false, const double reductionFactor=1.0, const double samplingStrenght=10.0)
 private method called by constructors, gathers their parameters and use them in a unified way More...
 

Protected Attributes

RetinaParameters _retinaParameters
 
std::valarray< float > _inputBuffer
 buffer used to convert input cv::Mat to internal retina buffers format (valarrays) More...
 
RetinaFilter * _retinaFilter
 the pointer to the retina module, allocated with instance construction More...
 

Detailed Description

a wrapper class which allows the Gipsa/Listic Labs model to be used. This retina model allows spatio-temporal image processing (applied on still images, video sequences). As a summary, these are the retina model properties: => It applies a spectral whithening (mid-frequency details enhancement) => high frequency spatio-temporal noise reduction => low frequency luminance to be reduced (luminance range compression) => local logarithmic luminance compression allows details to be enhanced in low light conditions

USE : this model can be used basically for spatio-temporal video effects but also for : _using the getParvo method output matrix : texture analysiswith enhanced signal to noise ratio and enhanced details robust against input images luminance ranges _using the getMagno method output matrix : motion analysis also with the previously cited properties

for more information, reer to the following papers : 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: http://dx.doi.org/10.1016/j.cviu.2010.01.011 Vision: Images, Signals and Neural Networks: Models of Neural Processing in Visual Perception (Progress in Neural Processing),By: Jeanny Herault, ISBN: 9814273686. WAPI (Tower ID): 113266891.

The retina filter includes the research contributions of phd/research collegues from which code has been redrawn by the author : _take a look at the retinacolor.hpp module to discover Brice Chaix de Lavarene color mosaicing/demosaicing and the reference paper: ====> B. Chaix de Lavarene, D. Alleysson, B. Durette, J. Herault (2007). "Efficient demosaicing through recursive filtering", IEEE International Conference on Image Processing ICIP 2007 _take a look at imagelogpolprojection.hpp to discover retina spatial log sampling which originates from Barthelemy Durette phd with Jeanny Herault. A Retina / V1 cortex projection is also proposed and originates from Jeanny's discussions. ====> more informations in the above cited Jeanny Heraults's book.

Constructor & Destructor Documentation

§ Retina() [1/2]

cv::Retina::Retina ( Size  inputSize)

Main constructor with most commun use setup : create an instance of color ready retina model

Parameters
inputSize: the input frame size

§ Retina() [2/2]

cv::Retina::Retina ( Size  inputSize,
const bool  colorMode,
RETINA_COLORSAMPLINGMETHOD  colorSamplingMethod = RETINA_COLOR_BAYER,
const bool  useRetinaLogSampling = false,
const double  reductionFactor = 1.0,
const double  samplingStrenght = 10.0 
)

Complete Retina filter constructor which allows all basic structural parameters definition

Parameters
inputSize: the input frame size
colorMode: the chosen processing mode : with or without color processing
colorSamplingMethodspecifies which kind of color sampling will be used
useRetinaLogSamplingactivate retina log sampling, if true, the 2 following parameters can be used
reductionFactoronly usefull if param useRetinaLogSampling=true, specifies the reduction factor of the output frame (as the center (fovea) is high resolution and corners can be underscaled, then a reduction of the output is allowed without precision leak
samplingStrenghtonly usefull if param useRetinaLogSampling=true, specifies the strenght of the log scale that is applied

§ ~Retina()

virtual cv::Retina::~Retina ( )
virtual

Member Function Documentation

§ _convertCvMat2ValarrayBuffer()

bool cv::Retina::_convertCvMat2ValarrayBuffer ( const cv::Mat  inputMatToConvert,
std::valarray< float > &  outputValarrayMatrix 
)
protected
Parameters
inputMatToConvert: the OpenCV cv::Mat that has to be converted to gray or RGB valarray buffer that will be processed by the retina model
outputValarrayMatrix: the output valarray
Returns
the input image color mode (color=true, gray levels=false)

§ _convertValarrayBuffer2cvMat()

void cv::Retina::_convertValarrayBuffer2cvMat ( const std::valarray< float > &  grayMatrixToConvert,
const unsigned int  nbRows,
const unsigned int  nbColumns,
const bool  colorMode,
Mat outBuffer 
)
protected

exports a valarray buffer outing from HVStools objects to a cv::Mat in CV_8UC1 (gray level picture) or CV_8UC3 (color) format

Parameters
grayMatrixToConvertthe valarray to export to OpenCV
nbRows: the number of rows of the valarray flatten matrix
nbColumns: the number of rows of the valarray flatten matrix
colorMode: a flag which mentions if matrix is color (true) or graylevel (false)
outBuffer: the output matrix which is reallocated to satisfy Retina output buffer dimensions

§ _init()

void cv::Retina::_init ( const Size  inputSize,
const bool  colorMode,
RETINA_COLORSAMPLINGMETHOD  colorSamplingMethod = RETINA_COLOR_BAYER,
const bool  useRetinaLogSampling = false,
const double  reductionFactor = 1.0,
const double  samplingStrenght = 10.0 
)
protected

private method called by constructors, gathers their parameters and use them in a unified way

§ activateContoursProcessing()

void cv::Retina::activateContoursProcessing ( const bool  activate)

Activate/desactivate the Parvocellular pathway processing (contours information extraction), by default, it is activated

Parameters
activatetrue if Parvocellular (contours information extraction) output should be activated, false if not

§ activateMovingContoursProcessing()

void cv::Retina::activateMovingContoursProcessing ( const bool  activate)

Activate/desactivate the Magnocellular pathway processing (motion information extraction), by default, it is activated

Parameters
activatetrue if Magnocellular output should be activated, false if not

§ clearBuffers()

void cv::Retina::clearBuffers ( )

clear all retina buffers (equivalent to opening the eyes after a long period of eye close ;o)

§ getMagno() [1/3]

void cv::Retina::getMagno ( Mat retinaOutput_magno)

accessor of the motion channel of the retina (models peripheral vision)

Parameters
retinaOutput_magno: the output buffer (reallocated if necessary), this output is rescaled for standard 8bits image processing use in OpenCV

§ getMagno() [2/3]

void cv::Retina::getMagno ( std::valarray< float > &  retinaOutput_magno)

accessor of the motion channel of the retina (models peripheral vision)

Parameters
retinaOutput_magno: the output buffer (reallocated if necessary), this output is the original retina filter model output, without any quantification or rescaling

§ getMagno() [3/3]

const std::valarray<float>& cv::Retina::getMagno ( ) const

§ getParameters()

Retina::RetinaParameters cv::Retina::getParameters ( )
Returns
the current parameters setup

§ getParvo() [1/3]

void cv::Retina::getParvo ( Mat retinaOutput_parvo)

accessor of the details channel of the retina (models foveal vision)

Parameters
retinaOutput_parvo: the output buffer (reallocated if necessary), this output is rescaled for standard 8bits image processing use in OpenCV

§ getParvo() [2/3]

void cv::Retina::getParvo ( std::valarray< float > &  retinaOutput_parvo)

accessor of the details channel of the retina (models foveal vision)

Parameters
retinaOutput_parvo: the output buffer (reallocated if necessary), this output is the original retina filter model output, without any quantification or rescaling

§ getParvo() [3/3]

const std::valarray<float>& cv::Retina::getParvo ( ) const

§ inputSize()

Size cv::Retina::inputSize ( )

retreive retina input buffer size

§ outputSize()

Size cv::Retina::outputSize ( )

retreive retina output buffer size

§ printSetup()

const std::string cv::Retina::printSetup ( )

parameters setup display method

Returns
a string which contains formatted parameters information

§ run()

void cv::Retina::run ( const Mat inputImage)

method which allows retina to be applied on an input image, after run, encapsulated retina module is ready to deliver its outputs using dedicated acccessors, see getParvo and getMagno methods

Parameters
inputImage: the input cv::Mat image to be processed, can be gray level or BGR coded in any format (from 8bit to 16bits)

§ setColorSaturation()

void cv::Retina::setColorSaturation ( const bool  saturateColors = true,
const float  colorSaturationValue = 4.0 
)

activate color saturation as the final step of the color demultiplexing process -> this saturation is a sigmoide function applied to each channel of the demultiplexed image.

Parameters
saturateColorsboolean that activates color saturation (if true) or desactivate (if false)
colorSaturationValuethe saturation factor

§ setup() [1/3]

void cv::Retina::setup ( std::string  retinaParameterFile = "",
const bool  applyDefaultSetupOnFailure = true 
)

try to open an XML retina parameters file to adjust current retina instance setup => if the xml file does not exist, then default setup is applied => warning, Exceptions are thrown if read XML file is not valid

Parameters
retinaParameterFile: the parameters filename
applyDefaultSetupOnFailure: set to true if an error must be thrown on error

§ setup() [2/3]

void cv::Retina::setup ( cv::FileStorage fs,
const bool  applyDefaultSetupOnFailure = true 
)

try to open an XML retina parameters file to adjust current retina instance setup => if the xml file does not exist, then default setup is applied => warning, Exceptions are thrown if read XML file is not valid

Parameters
fs: the open Filestorage which contains retina parameters
applyDefaultSetupOnFailure: set to true if an error must be thrown on error

§ setup() [3/3]

void cv::Retina::setup ( RetinaParameters  newParameters)

try to open an XML retina parameters file to adjust current retina instance setup => if the xml file does not exist, then default setup is applied => warning, Exceptions are thrown if read XML file is not valid

Parameters
newParameters: a parameters structures updated with the new target configuration

§ setupIPLMagnoChannel()

void cv::Retina::setupIPLMagnoChannel ( const bool  normaliseOutput = true,
const float  parasolCells_beta = 0,
const float  parasolCells_tau = 0,
const float  parasolCells_k = 7,
const float  amacrinCellsTemporalCutFrequency = 1.2f,
const float  V0CompressionParameter = 0.95f,
const float  localAdaptintegration_tau = 0,
const float  localAdaptintegration_k = 7 
)

set parameters values for the Inner Plexiform Layer (IPL) magnocellular channel this channel processes signals outpint from OPL processing stage in peripheral vision, it allows motion information enhancement. It is decorrelated from the details channel. See reference paper for more details.

Parameters
normaliseOutput: specifies if (true) output is rescaled between 0 and 255 of not (false)
parasolCells_betathe low pass filter gain used for local contrast adaptation at the IPL level of the retina (for ganglion cells local adaptation), typical value is 0
parasolCells_tauthe low pass filter time constant used for local contrast adaptation at the IPL level of the retina (for ganglion cells local adaptation), unit is frame, typical value is 0 (immediate response)
parasolCells_kthe low pass filter spatial constant used for local contrast adaptation at the IPL level of the retina (for ganglion cells local adaptation), unit is pixels, typical value is 5
amacrinCellsTemporalCutFrequencythe time constant of the first order high pass fiter of the magnocellular way (motion information channel), unit is frames, tipicall value is 5
V0CompressionParameterthe compression strengh of the ganglion cells local adaptation output, set a value between 160 and 250 for best results, a high value increases more the low value sensitivity... and the output saturates faster, recommended value: 200
localAdaptintegration_tauspecifies the temporal constant of the low pas filter involved in the computation of the local "motion mean" for the local adaptation computation
localAdaptintegration_kspecifies the spatial constant of the low pas filter involved in the computation of the local "motion mean" for the local adaptation computation

§ setupOPLandIPLParvoChannel()

void cv::Retina::setupOPLandIPLParvoChannel ( const bool  colorMode = true,
const bool  normaliseOutput = true,
const float  photoreceptorsLocalAdaptationSensitivity = 0.7f,
const float  photoreceptorsTemporalConstant = 0.5f,
const float  photoreceptorsSpatialConstant = 0.53f,
const float  horizontalCellsGain = 0,
const float  HcellsTemporalConstant = 1,
const float  HcellsSpatialConstant = 7,
const float  ganglionCellsSensitivity = 0.7f 
)

setup the OPL and IPL parvo channels (see biologocal model) OPL is referred as Outer Plexiform Layer of the retina, it allows the spatio-temporal filtering which withens the spectrum and reduces spatio-temporal noise while attenuating global luminance (low frequency energy) IPL parvo is the OPL next processing stage, it refers to Inner Plexiform layer of the retina, it allows high contours sensitivity in foveal vision. for more informations, please have a look at the paper 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: http://dx.doi.org/10.1016/j.cviu.2010.01.011

Parameters
colorMode: specifies if (true) color is processed of not (false) to then processing gray level image
normaliseOutput: specifies if (true) output is rescaled between 0 and 255 of not (false)
photoreceptorsLocalAdaptationSensitivitythe photoreceptors sensitivity renage is 0-1 (more log compression effect when value increases)
photoreceptorsTemporalConstantthe time constant of the first order low pass filter of the photoreceptors, use it to cut high temporal frequencies (noise or fast motion), unit is frames, typical value is 1 frame
photoreceptorsSpatialConstantthe spatial constant of the first order low pass filter of the photoreceptors, use it to cut high spatial frequencies (noise or thick contours), unit is pixels, typical value is 1 pixel
horizontalCellsGaingain of the horizontal cells network, if 0, then the mean value of the output is zero, if the parameter is near 1, then, the luminance is not filtered and is still reachable at the output, typicall value is 0
HcellsTemporalConstantthe time constant of the first order low pass filter of the horizontal cells, use it to cut low temporal frequencies (local luminance variations), unit is frames, typical value is 1 frame, as the photoreceptors
HcellsSpatialConstantthe spatial constant of the first order low pass filter of the horizontal cells, use it to cut low spatial frequencies (local luminance), unit is pixels, typical value is 5 pixel, this value is also used for local contrast computing when computing the local contrast adaptation at the ganglion cells level (Inner Plexiform Layer parvocellular channel model)
ganglionCellsSensitivitythe compression strengh of the ganglion cells local adaptation output, set a value between 160 and 250 for best results, a high value increases more the low value sensitivity... and the output saturates faster, recommended value: 230

§ write() [1/2]

virtual void cv::Retina::write ( std::string  fs) const
virtual

write xml/yml formated parameters information

Parameters
fs: the filename of the xml file that will be open and writen with formatted parameters information

§ write() [2/2]

virtual void cv::Retina::write ( FileStorage fs) const
virtual

write xml/yml formated parameters information

Parameters
fs: a cv::Filestorage object ready to be filled

Member Data Documentation

§ _inputBuffer

std::valarray<float> cv::Retina::_inputBuffer
protected

buffer used to convert input cv::Mat to internal retina buffers format (valarrays)

§ _retinaFilter

RetinaFilter* cv::Retina::_retinaFilter
protected

the pointer to the retina module, allocated with instance construction

§ _retinaParameters

RetinaParameters cv::Retina::_retinaParameters
protected

The documentation for this class was generated from the following file: