resolved conflicts, updated retina class interface and optimized a heavy retinacolor...
authoralexandre benoit <benoit.alexandre.vision@gmail.com>
Mon, 29 Apr 2013 17:06:35 +0000 (19:06 +0200)
committeralexandre benoit <benoit.alexandre.vision@gmail.com>
Mon, 29 Apr 2013 17:06:35 +0000 (19:06 +0200)
1  2 
doc/tutorials/contrib/retina_model/retina_model.rst
modules/contrib/doc/retina/index.rst
modules/contrib/include/opencv2/contrib/retina.hpp
modules/contrib/src/retina.cpp
samples/cpp/OpenEXRimages_HighDynamicRange_Retina_toneMapping.cpp
samples/cpp/OpenEXRimages_HighDynamicRange_Retina_toneMapping_video.cpp
samples/cpp/retinaDemo.cpp
samples/cpp/tutorial_code/contrib/retina_tutorial.cpp

@@@ -228,19 -228,19 +228,18 @@@ Once all input parameters are processed
  Now, everything is ready to run the retina model. I propose here to allocate a retina instance and to manage the eventual log sampling option. The Retina constructor expects at least a cv::Size object that shows the input data size that will have to be managed. One can activate other options such as color and its related color multiplexing strategy (here Bayer multiplexing is chosen using enum cv::RETINA_COLOR_BAYER). If using log sampling, the image reduction factor (smaller output images) and log sampling strengh can be adjusted.
  
  .. code-block:: cpp
-       
 -        // pointer to a retina object
 +      // pointer to a retina object
          cv::Ptr<cv::Retina> myRetina;
  
          // if the last parameter is 'log', then activate log sampling (favour foveal vision and subsamples peripheral vision)
          if (useLogSampling)
          {
 -            myRetina = new cv::Retina(inputFrame.size(), true, cv::RETINA_COLOR_BAYER, true, 2.0, 10.0);
 +            myRetina = cv::createRetina(inputFrame.size(), true, cv::RETINA_COLOR_BAYER, true, 2.0, 10.0);
          }
          else// -> else allocate "classical" retina :
 -            myRetina = new cv::Retina(inputFrame.size());
 -
 +            myRetina = cv::createRetina(inputFrame.size());
  
-         
  Once done, the proposed code writes a default xml file that contains the default parameters of the retina. This is useful to make your own config using this template. Here generated template xml file is called *RetinaDefaultParameters.xml*.
  
  .. code-block:: cpp
@@@ -323,30 -323,30 +322,29 @@@ Once done open the configuration file *
  
  .. code-block:: cpp
  
 -        <?xml version="1.0"?>
 -        <opencv_storage>
 -        <OPLandIPLparvo>
 -          <colorMode>1</colorMode>
 -          <normaliseOutput>1</normaliseOutput>
 -          <photoreceptorsLocalAdaptationSensitivity>7.0e-01</photoreceptorsLocalAdaptationSensitivity>
 -          <photoreceptorsTemporalConstant>5.0e-01</photoreceptorsTemporalConstant>
 -          <photoreceptorsSpatialConstant>5.3e-01</photoreceptorsSpatialConstant>
 -          <horizontalCellsGain>0.</horizontalCellsGain>
 -          <hcellsTemporalConstant>1.</hcellsTemporalConstant>
 -          <hcellsSpatialConstant>7.</hcellsSpatialConstant>
 -          <ganglionCellsSensitivity>7.0e-01</ganglionCellsSensitivity></OPLandIPLparvo>
 -        <IPLmagno>
 -          <normaliseOutput>1</normaliseOutput>
 -          <parasolCells_beta>0.</parasolCells_beta>
 -          <parasolCells_tau>0.</parasolCells_tau>
 -          <parasolCells_k>7.</parasolCells_k>
 -          <amacrinCellsTemporalCutFrequency>1.2e+00</amacrinCellsTemporalCutFrequency>
 -          <V0CompressionParameter>9.5e-01</V0CompressionParameter>
 -          <localAdaptintegration_tau>0.</localAdaptintegration_tau>
 -          <localAdaptintegration_k>7.</localAdaptintegration_k></IPLmagno>
 -        </opencv_storage>
 -
 +      <?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 hints but actually, the best parameter setup depends more on what you want to do with the retina rather than the images input that you give to retina. Apart from the more specific case of High Dynamic Range images (HDR) that require more specific setup for specific luminance compression objective, the retina behaviors should be rather stable from content to content. Note that OpenCV is able to manage such HDR format thanks to the OpenEXR images compatibility.
  
  Then, if the application target requires details enhancement prior to specific image processing, you need to know if mean luminance information is required or not. If not, the the retina can cancel or significantly reduce its energy thus giving more visibility to higher spatial frequency details.
@@@ -381,7 -381,7 +379,7 @@@ This parameter set tunes the neural net
  
  * **horizontalCellsGain** here is a critical parameter ! If you are not interested by the mean luminance and focus on details enhancement, then, set to zero. But if you want to keep some environment luminance data, let some low spatial frequencies pass into the system and set a higher value (<1).
  
- * **hcellsTemporalConstant** similar to photo-receptors, this acts on the temporal constant of a low pass temporal filter that smooths input data. Here, a high value generates a high retina after effect while a lower value makes the retina more reactive. this value should be lower than **photoreceptorsTemporalConstant** to limit strong retina after effects.
 -* **hcellsTemporalConstant** similar to photo-receptors, this acts on the temporal constant of a low pass temporal filter that smooths input data. Here, a high value generates a high retina after effect while a lower value makes the retina more reactive.
++* **hcellsTemporalConstant** similar to photo-receptors, this acts on the temporal constant of a low pass temporal filter that smooths input data. Here, a high value generates a high retina after effect while a lower value makes the retina more reactive. This value should be lower than **photoreceptorsTemporalConstant** to limit strong retina after effects.
  
  * **hcellsSpatialConstant** is the spatial constant of the low pass filter of these cells filter. It specifies the lowest spatial frequency allowed in the following. Visually, a high value leads to very low spatial frequencies processing and leads to salient halo effects. Lower values reduce this effect but the limit is : do not go lower than the value of **photoreceptorsSpatialConstant**. Those 2 parameters actually specify the spatial band-pass of the retina.
  
@@@ -405,12 -405,10 +403,11 @@@ Once image information is cleaned, thi
  
  * **parasolCells_k** the spatial constant of the spatial filtering effect, set it at a high value to favor low spatial frequency signals that are lower subject to residual noise.
  
- * **amacrinCellsTemporalCutFrequency** specifies the temporal constant of the high pass filter. High values let slow transient events to be selected.  
 -* **amacrinCellsTemporalCutFrequency** specifies the temporal constant of the high pass filter. High values let slow transient events to be selected.
++* **amacrinCellsTemporalCutFrequency** specifies the temporal constant of the high pass filter. High values let slow transient events to be selected.   
  
  * **V0CompressionParameter** specifies the strength of the log compression. Similar behaviors to previous description but here it enforces sensitivity of transient events.
  
  * **localAdaptintegration_tau** generally set to 0, no real use here actually
  
  * **localAdaptintegration_k** specifies the size of the area on which local adaptation is performed. Low values lead to short range local adaptation (higher sensitivity to noise), high values secure log compression.
 +
@@@ -45,11 -45,11 +45,11 @@@ The retina can be settled up with vario
      void clearBuffers ();
  
      // retreive input and output buffers sizes
 -    Size inputSize ();
 -    Size outputSize ();
 +    Size getInputSize ();
 +    Size getOutputSize ();
  
      // setup methods with specific parameters specification of global xml config file loading/write
-     void setup (std::string retinaParameterFile="", const bool applyDefaultSetupOnFailure=true);
+     void setup (String retinaParameterFile="", const bool applyDefaultSetupOnFailure=true);
      void setup (FileStorage &fs, const bool applyDefaultSetupOnFailure=true);
      void setup (RetinaParameters newParameters);
      struct Retina::RetinaParameters getParameters ();
@@@ -85,10 -85,10 +85,8 @@@ enum RETINA_COLORSAMPLINGMETHO
      RETINA_COLOR_BAYER//!< standard bayer sampling
  };
  
--class RetinaFilter;
--
  /**
-- * @class Retina a wrapper class which allows the Gipsa/Listic Labs model to be used.
++ * @class Retina a wrapper 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:
   * => It applies a spectral whithening (mid-frequency details enhancement)
@@@ -163,17 -182,17 +161,16 @@@ public
       * @param retinaParameterFile : the parameters filename
           * @param applyDefaultSetupOnFailure : set to true if an error must be thrown on error
       */
-     virtual void setup(std::string retinaParameterFile="", const bool applyDefaultSetupOnFailure=true)=0;
 -    void setup(String retinaParameterFile="", const bool applyDefaultSetupOnFailure=true);
--
++    virtual void setup(String retinaParameterFile="", const bool applyDefaultSetupOnFailure=true)=0;
  
      /**
       * 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
       * @param fs : the open Filestorage which contains retina parameters
-          * @param applyDefaultSetupOnFailure : set to true if an error must be thrown on error
+      * @param applyDefaultSetupOnFailure : set to true if an error must be thrown on error
       */
 -    void setup(cv::FileStorage &fs, const bool applyDefaultSetupOnFailure=true);
 +    virtual void setup(cv::FileStorage &fs, const bool applyDefaultSetupOnFailure=true)=0;
  
      /**
       * try to open an XML retina parameters file to adjust current retina instance setup
       * parameters setup display method
       * @return a string which contains formatted parameters information
       */
-     virtual const std::string printSetup()=0;
 -    const String printSetup();
++    virtual const String printSetup()=0;
  
      /**
       * write xml/yml formated parameters information
       * @rparam fs : the filename of the xml file that will be open and writen with formatted parameters information
       */
-     virtual void write( std::string fs ) const=0;
 -    virtual void write( String fs ) const;
--
++    virtual void write( String fs ) const=0;
  
      /**
       * write xml/yml formated parameters information
  namespace cv
  {
  
 -Retina::Retina(const cv::Size inputSz)
 +class RetinaImpl : public Retina
 +{
 +public:
 +    /**
 +     * Main constructor with most commun use setup : create an instance of color ready retina model
 +     * @param inputSize : the input frame size
 +     */
 +    RetinaImpl(Size inputSize);
 +
 +    /**
 +     * Complete Retina filter constructor which allows all basic structural parameters definition
 +         * @param inputSize : the input frame size
 +     * @param colorMode : the chosen processing mode : with or without color processing
 +     * @param colorSamplingMethod: specifies which kind of color sampling will be used
 +     * @param useRetinaLogSampling: activate retina log sampling, if true, the 2 following parameters can be used
 +     * @param reductionFactor: only 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
 +     * @param samplingStrenght: only usefull if param useRetinaLogSampling=true, specifies the strenght of the log scale that is applied
 +     */
 +    RetinaImpl(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 ~RetinaImpl();
 +    /**
 +        * retreive retina input buffer size
 +        */
 +        Size getInputSize();
 +
 +    /**
 +        * retreive retina output buffer size
 +        */
 +        Size getOutputSize();
 +
 +    /**
 +     * 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
 +     * @param retinaParameterFile : the parameters filename
 +         * @param applyDefaultSetupOnFailure : set to true if an error must be thrown on error
 +     */
-     void setup(std::string retinaParameterFile="", const bool applyDefaultSetupOnFailure=true);
++    void setup(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
 +     * @param fs : the open Filestorage which contains retina parameters
 +         * @param applyDefaultSetupOnFailure : set to true if an error must be thrown on error
 +     */
 +        void 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
 +     * @param newParameters : a parameters structures updated with the new target configuration
 +         * @param applyDefaultSetupOnFailure : set to true if an error must be thrown on error
 +     */
 +    void setup(Retina::RetinaParameters newParameters);
 +
 +    /**
 +    * @return the current parameters setup
 +    */
 +    struct Retina::RetinaParameters getParameters();
 +
 +    /**
 +     * parameters setup display method
 +     * @return a string which contains formatted parameters information
 +     */
-     const std::string printSetup();
++    const String printSetup();
 +
 +    /**
 +     * write xml/yml formated parameters information
 +     * @rparam fs : the filename of the xml file that will be open and writen with formatted parameters information
 +     */
-     virtual void write( std::string fs ) const;
++    virtual void write( String fs ) const;
 +
 +
 +    /**
 +     * write xml/yml formated parameters information
 +     * @param fs : a cv::Filestorage object ready to be filled
 +         */
 +    virtual void write( FileStorage& fs ) const;
 +
 +    /**
 +     * 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
 +     * @param colorMode : specifies if (true) color is processed of not (false) to then processing gray level image
 +     * @param normaliseOutput : specifies if (true) output is rescaled between 0 and 255 of not (false)
 +     * @param photoreceptorsLocalAdaptationSensitivity: the photoreceptors sensitivity renage is 0-1 (more log compression effect when value increases)
 +     * @param photoreceptorsTemporalConstant: the 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
 +     * @param photoreceptorsSpatialConstant: the 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
 +     * @param horizontalCellsGain: gain 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
 +     * @param HcellsTemporalConstant: the 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
 +     * @param HcellsSpatialConstant: the 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)
 +     * @param ganglionCellsSensitivity: the 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
 +     */
 +    void setupOPLandIPLParvoChannel(const bool colorMode=true, const bool normaliseOutput = true, const float photoreceptorsLocalAdaptationSensitivity=0.7, const float photoreceptorsTemporalConstant=0.5, const float photoreceptorsSpatialConstant=0.53, const float horizontalCellsGain=0, const float HcellsTemporalConstant=1, const float HcellsSpatialConstant=7, const float ganglionCellsSensitivity=0.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.
 +     * @param normaliseOutput : specifies if (true) output is rescaled between 0 and 255 of not (false)
 +     * @param parasolCells_beta: the 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
 +     * @param parasolCells_tau: the 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)
 +     * @param parasolCells_k: the 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
 +     * @param amacrinCellsTemporalCutFrequency: the time constant of the first order high pass fiter of the magnocellular way (motion information channel), unit is frames, tipicall value is 5
 +     * @param V0CompressionParameter: the 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
 +     * @param localAdaptintegration_tau: specifies the temporal constant of the low pas filter involved in the computation of the local "motion mean" for the local adaptation computation
 +     * @param localAdaptintegration_k: specifies the spatial constant of the low pas filter involved in the computation of the local "motion mean" for the local adaptation computation
 +     */
 +    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.2, const float V0CompressionParameter=0.95, const float localAdaptintegration_tau=0, const float localAdaptintegration_k=7);
 +
 +    /**
 +     * 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
 +     * @param inputImage : the input cv::Mat image to be processed, can be gray level or BGR coded in any format (from 8bit to 16bits)
 +     */
 +    void run(const Mat &inputImage);
 +
 +    /**
 +     * accessor of the details channel of the retina (models foveal vision)
 +     * @param retinaOutput_parvo : the output buffer (reallocated if necessary), this output is rescaled for standard 8bits image processing use in OpenCV
 +     */
 +    void getParvo(Mat &retinaOutput_parvo);
 +
 +    /**
 +     * accessor of the details channel of the retina (models foveal vision)
 +     * @param retinaOutput_parvo : a cv::Mat header filled with the internal parvo buffer of the retina module. This output is the original retina filter model output, without any quantification or rescaling
 +     */
 +    void getParvoRAW(Mat &retinaOutput_parvo);
 +
 +    /**
 +     * accessor of the motion channel of the retina (models peripheral vision)
 +     * @param retinaOutput_magno : the output buffer (reallocated if necessary), this output is rescaled for standard 8bits image processing use in OpenCV
 +     */
 +    void getMagno(Mat &retinaOutput_magno);
 +
 +    /**
 +     * accessor of the motion channel of the retina (models peripheral vision)
 +     * @param retinaOutput_magno : a cv::Mat header filled with the internal retina magno buffer of the retina module. This output is the original retina filter model output, without any quantification or rescaling
 +     */
 +    void getMagnoRAW(Mat &retinaOutput_magno);
 +
 +    // original API level data accessors : get buffers addresses from a Mat header, similar to getParvoRAW and getMagnoRAW...
 +    const Mat getMagnoRAW() const;
 +    const Mat getParvoRAW() const;
 +
 +    /**
 +     * 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.
 +     * @param saturateColors: boolean that activates color saturation (if true) or desactivate (if false)
 +     * @param colorSaturationValue: the saturation factor
 +     */
 +    void setColorSaturation(const bool saturateColors=true, const float colorSaturationValue=4.0);
 +
 +    /**
 +     * clear all retina buffers (equivalent to opening the eyes after a long period of eye close ;o)
 +     */
 +    void clearBuffers();
 +
 +        /**
 +        * Activate/desactivate the Magnocellular pathway processing (motion information extraction), by default, it is activated
 +        * @param activate: true if Magnocellular output should be activated, false if not
 +        */
 +        void activateMovingContoursProcessing(const bool activate);
 +
 +        /**
 +        * Activate/desactivate the Parvocellular pathway processing (contours information extraction), by default, it is activated
 +        * @param activate: true if Parvocellular (contours information extraction) output should be activated, false if not
 +        */
 +        void activateContoursProcessing(const bool activate);
 +private:
 +
 +    // Parameteres setup members
 +    RetinaParameters _retinaParameters; // structure of parameters
 +
 +        // Retina model related modules
 +    std::valarray<float> _inputBuffer; //!< buffer used to convert input cv::Mat to internal retina buffers format (valarrays)
 +
 +    // pointer to retina model
 +    RetinaFilter* _retinaFilter; //!< the pointer to the retina module, allocated with instance construction
 +
 +    /**
 +     * exports a valarray buffer outing from HVStools objects to a cv::Mat in CV_8UC1 (gray level picture) or CV_8UC3 (color) format
 +     * @param grayMatrixToConvert the valarray to export to OpenCV
 +     * @param nbRows : the number of rows of the valarray flatten matrix
 +     * @param nbColumns : the number of rows of the valarray flatten matrix
 +     * @param colorMode : a flag which mentions if matrix is color (true) or graylevel (false)
 +     * @param outBuffer : the output matrix which is reallocated to satisfy Retina output buffer dimensions
 +     */
 +    void _convertValarrayBuffer2cvMat(const std::valarray<float> &grayMatrixToConvert, const unsigned int nbRows, const unsigned int nbColumns, const bool colorMode, Mat &outBuffer);
 +
 +    /**
 +     *
 +     * @param inputMatToConvert : the OpenCV cv::Mat that has to be converted to gray or RGB valarray buffer that will be processed by the retina model
 +     * @param outputValarrayMatrix : the output valarray
 +     * @return the input image color mode (color=true, gray levels=false)
 +     */
 +        bool _convertCvMat2ValarrayBuffer(const cv::Mat inputMatToConvert, std::valarray<float> &outputValarrayMatrix);
 +
 +    //! private method called by constructors, gathers their parameters and use them in a unified way
 +    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);
 +
 +
 +};
 +
 +// smart pointers allocation :
 +Ptr<Retina> createRetina(Size inputSize){ return new RetinaImpl(inputSize); }
 +Ptr<Retina> createRetina(Size inputSize, const bool colorMode, RETINA_COLORSAMPLINGMETHOD colorSamplingMethod, const bool useRetinaLogSampling, const double reductionFactor, const double samplingStrenght){return new RetinaImpl(inputSize, colorMode, colorSamplingMethod, useRetinaLogSampling, reductionFactor, samplingStrenght);}
 +
 +// RetinaImpl code
 +RetinaImpl::RetinaImpl(const cv::Size inputSz)
  {
      _retinaFilter = 0;
      _init(inputSz, true, RETINA_COLOR_BAYER, false);
@@@ -321,10 -110,10 +322,9 @@@ void RetinaImpl::setColorSaturation(con
      _retinaFilter->setColorSaturation(saturateColors, colorSaturationValue);
  }
  
 -struct Retina::RetinaParameters Retina::getParameters(){return _retinaParameters;}
 -
 +struct Retina::RetinaParameters RetinaImpl::getParameters(){return _retinaParameters;}
  
- void RetinaImpl::setup(std::string retinaParameterFile, const bool applyDefaultSetupOnFailure)
 -void Retina::setup(String retinaParameterFile, const bool applyDefaultSetupOnFailure)
++void RetinaImpl::setup(String retinaParameterFile, const bool applyDefaultSetupOnFailure)
  {
      try
      {
@@@ -386,7 -176,7 +387,7 @@@ void RetinaImpl::setup(cv::FileStorage 
  
      }catch(Exception &e)
      {
-         std::cout<<"RetinaImpl::setup: resetting retina with default parameters"<<std::endl;
 -        printf("Retina::setup: resetting retina with default parameters\n");
++        printf("RetinaImpl::setup: resetting retina with default parameters\n");
          if (applyDefaultSetupOnFailure)
          {
              setupOPLandIPLParvoChannel();
      }
  
      // report current configuration
-     std::cout<<printSetup()<<std::endl;
+     printf("%s\n", printSetup().c_str());
  }
  
 -void Retina::setup(cv::Retina::RetinaParameters newConfiguration)
 +void RetinaImpl::setup(cv::Retina::RetinaParameters newConfiguration)
  {
      // simply copy structures
      memcpy(&_retinaParameters, &newConfiguration, sizeof(cv::Retina::RetinaParameters));
      setupOPLandIPLParvoChannel(_retinaParameters.OPLandIplParvo.colorMode, _retinaParameters.OPLandIplParvo.normaliseOutput, _retinaParameters.OPLandIplParvo.photoreceptorsLocalAdaptationSensitivity, _retinaParameters.OPLandIplParvo.photoreceptorsTemporalConstant, _retinaParameters.OPLandIplParvo.photoreceptorsSpatialConstant, _retinaParameters.OPLandIplParvo.horizontalCellsGain, _retinaParameters.OPLandIplParvo.hcellsTemporalConstant, _retinaParameters.OPLandIplParvo.hcellsSpatialConstant, _retinaParameters.OPLandIplParvo.ganglionCellsSensitivity);
      setupIPLMagnoChannel(_retinaParameters.IplMagno.normaliseOutput, _retinaParameters.IplMagno.parasolCells_beta, _retinaParameters.IplMagno.parasolCells_tau, _retinaParameters.IplMagno.parasolCells_k, _retinaParameters.IplMagno.amacrinCellsTemporalCutFrequency,_retinaParameters.IplMagno.V0CompressionParameter, _retinaParameters.IplMagno.localAdaptintegration_tau, _retinaParameters.IplMagno.localAdaptintegration_k);
  
 -
  }
  
- const std::string RetinaImpl::printSetup()
 -const String Retina::printSetup()
++const String RetinaImpl::printSetup()
  {
      std::stringstream outmessage;
  
      // displaying IPL magno setup
      outmessage<<"Current Retina instance setup :"
              <<"\nIPLmagno"<<"{"
 -            << "\n==> normaliseOutput : " << _retinaParameters.IplMagno.normaliseOutput
 -            << "\n==> parasolCells_beta : " << _retinaParameters.IplMagno.parasolCells_beta
 -            << "\n==> parasolCells_tau : " << _retinaParameters.IplMagno.parasolCells_tau
 -            << "\n==> parasolCells_k : " << _retinaParameters.IplMagno.parasolCells_k
 -            << "\n==> amacrinCellsTemporalCutFrequency : " << _retinaParameters.IplMagno.amacrinCellsTemporalCutFrequency
 -            << "\n==> V0CompressionParameter : " << _retinaParameters.IplMagno.V0CompressionParameter
 -            << "\n==> localAdaptintegration_tau : " << _retinaParameters.IplMagno.localAdaptintegration_tau
 -            << "\n==> localAdaptintegration_k : " << _retinaParameters.IplMagno.localAdaptintegration_k
 +            << "\n\t normaliseOutput : " << _retinaParameters.IplMagno.normaliseOutput
 +            << "\n\t parasolCells_beta : " << _retinaParameters.IplMagno.parasolCells_beta
 +            << "\n\t parasolCells_tau : " << _retinaParameters.IplMagno.parasolCells_tau
 +            << "\n\t parasolCells_k : " << _retinaParameters.IplMagno.parasolCells_k
 +            << "\n\t amacrinCellsTemporalCutFrequency : " << _retinaParameters.IplMagno.amacrinCellsTemporalCutFrequency
 +            << "\n\t V0CompressionParameter : " << _retinaParameters.IplMagno.V0CompressionParameter
 +            << "\n\t localAdaptintegration_tau : " << _retinaParameters.IplMagno.localAdaptintegration_tau
 +            << "\n\t localAdaptintegration_k : " << _retinaParameters.IplMagno.localAdaptintegration_k
              <<"}";
-     return outmessage.str();
+     return outmessage.str().c_str();
  }
  
- void RetinaImpl::write( std::string fs ) const
 -void Retina::write( String fs ) const
++void RetinaImpl::write( String fs ) const
  {
      FileStorage parametersSaveFile(fs, cv::FileStorage::WRITE );
      write(parametersSaveFile);
@@@ -602,10 -366,10 +603,10 @@@ void RetinaImpl::_init(const cv::Size i
      _retinaFilter->clearAllBuffers();
  
      // report current configuration
-     std::cout<<printSetup()<<std::endl;
+     printf("%s\n", printSetup().c_str());
  }
  
 -void Retina::_convertValarrayBuffer2cvMat(const std::valarray<float> &grayMatrixToConvert, const unsigned int nbRows, const unsigned int nbColumns, const bool colorMode, cv::Mat &outBuffer)
 +void RetinaImpl::_convertValarrayBuffer2cvMat(const std::valarray<float> &grayMatrixToConvert, const unsigned int nbRows, const unsigned int nbColumns, const bool colorMode, cv::Mat &outBuffer)
  {
      // fill output buffer with the valarray buffer
      const float *valarrayPTR=get_data(grayMatrixToConvert);
Simple merge
@@@ -99,10 -100,10 +100,12 @@@ int main(int argc, char* argv[]) 
          // if the last parameter is 'log', then activate log sampling (favour foveal vision and subsamples peripheral vision)
          if (useLogSampling)
          {
-                         myRetina = cv::createRetina(inputFrame.size(), true, cv::RETINA_COLOR_BAYER, true, 2.0, 10.0);
 -                        myRetina = new cv::Retina(inputFrame.size(), true, cv::RETINA_COLOR_BAYER, true, 2.0, 10.0);
++            myRetina = cv::createRetina(inputFrame.size(), true, cv::RETINA_COLOR_BAYER, true, 2.0, 10.0);
          }
          else// -> else allocate "classical" retina :
 -            myRetina = new cv::Retina(inputFrame.size());
++        {
 +            myRetina = cv::createRetina(inputFrame.size());
++        }
  
          // save default retina parameters file in order to let you see this and maybe modify it and reload using method "setup"
          myRetina->write("RetinaDefaultParameters.xml");