retina.hpp 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. /*#******************************************************************************
  2. ** IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
  3. **
  4. ** By downloading, copying, installing or using the software you agree to this license.
  5. ** If you do not agree to this license, do not download, install,
  6. ** copy or use the software.
  7. **
  8. **
  9. ** bioinspired : interfaces allowing OpenCV users to integrate Human Vision System models. Presented models originate from Jeanny Herault's original research and have been reused and adapted by the author&collaborators for computed vision applications since his thesis with Alice Caplier at Gipsa-Lab.
  10. ** Use: extract still images & image sequences features, from contours details to motion spatio-temporal features, etc. for high level visual scene analysis. Also contribute to image enhancement/compression such as tone mapping.
  11. **
  12. ** Maintainers : Listic lab (code author current affiliation & applications) and Gipsa Lab (original research origins & applications)
  13. **
  14. ** Creation - enhancement process 2007-2015
  15. ** Author: Alexandre Benoit (benoit.alexandre.vision@gmail.com), LISTIC lab, Annecy le vieux, France
  16. **
  17. ** Theses algorithm have been developped by Alexandre BENOIT since his thesis with Alice Caplier at Gipsa-Lab (www.gipsa-lab.inpg.fr) and the research he pursues at LISTIC Lab (www.listic.univ-savoie.fr).
  18. ** Refer to the following research paper for more information:
  19. ** 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
  20. ** This work have been carried out thanks to Jeanny Herault who's research and great discussions are the basis of all this work, please take a look at his book:
  21. ** 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.
  22. **
  23. ** The retina filter includes the research contributions of phd/research collegues from which code has been redrawn by the author :
  24. ** _take a look at the retinacolor.hpp module to discover Brice Chaix de Lavarene color mosaicing/demosaicing and the reference paper:
  25. ** ====> B. Chaix de Lavarene, D. Alleysson, B. Durette, J. Herault (2007). "Efficient demosaicing through recursive filtering", IEEE International Conference on Image Processing ICIP 2007
  26. ** _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.
  27. ** ====> more informations in the above cited Jeanny Heraults's book.
  28. **
  29. ** License Agreement
  30. ** For Open Source Computer Vision Library
  31. **
  32. ** Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
  33. ** Copyright (C) 2008-2011, Willow Garage Inc., all rights reserved.
  34. **
  35. ** For Human Visual System tools (bioinspired)
  36. ** Copyright (C) 2007-2015, LISTIC Lab, Annecy le Vieux and GIPSA Lab, Grenoble, France, all rights reserved.
  37. **
  38. ** Third party copyrights are property of their respective owners.
  39. **
  40. ** Redistribution and use in source and binary forms, with or without modification,
  41. ** are permitted provided that the following conditions are met:
  42. **
  43. ** * Redistributions of source code must retain the above copyright notice,
  44. ** this list of conditions and the following disclaimer.
  45. **
  46. ** * Redistributions in binary form must reproduce the above copyright notice,
  47. ** this list of conditions and the following disclaimer in the documentation
  48. ** and/or other materials provided with the distribution.
  49. **
  50. ** * The name of the copyright holders may not be used to endorse or promote products
  51. ** derived from this software without specific prior written permission.
  52. **
  53. ** This software is provided by the copyright holders and contributors "as is" and
  54. ** any express or implied warranties, including, but not limited to, the implied
  55. ** warranties of merchantability and fitness for a particular purpose are disclaimed.
  56. ** In no event shall the Intel Corporation or contributors be liable for any direct,
  57. ** indirect, incidental, special, exemplary, or consequential damages
  58. ** (including, but not limited to, procurement of substitute goods or services;
  59. ** loss of use, data, or profits; or business interruption) however caused
  60. ** and on any theory of liability, whether in contract, strict liability,
  61. ** or tort (including negligence or otherwise) arising in any way out of
  62. ** the use of this software, even if advised of the possibility of such damage.
  63. *******************************************************************************/
  64. #ifndef __OPENCV_BIOINSPIRED_RETINA_HPP__
  65. #define __OPENCV_BIOINSPIRED_RETINA_HPP__
  66. /**
  67. @file
  68. @date Jul 19, 2011
  69. @author Alexandre Benoit
  70. */
  71. #include "opencv2/core.hpp" // for all OpenCV core functionalities access, including cv::Exception support
  72. namespace cv{
  73. namespace bioinspired{
  74. //! @addtogroup bioinspired
  75. //! @{
  76. enum {
  77. RETINA_COLOR_RANDOM, //!< each pixel position is either R, G or B in a random choice
  78. RETINA_COLOR_DIAGONAL,//!< color sampling is RGBRGBRGB..., line 2 BRGBRGBRG..., line 3, GBRGBRGBR...
  79. RETINA_COLOR_BAYER//!< standard bayer sampling
  80. };
  81. /** @brief retina model parameters structure
  82. For better clarity, check explenations on the comments of methods : setupOPLandIPLParvoChannel and setupIPLMagnoChannel
  83. Here is the default configuration file of the retina module. It gives results such as the first
  84. retina output shown on the top of this page.
  85. @code{xml}
  86. <?xml version="1.0"?>
  87. <opencv_storage>
  88. <OPLandIPLparvo>
  89. <colorMode>1</colorMode>
  90. <normaliseOutput>1</normaliseOutput>
  91. <photoreceptorsLocalAdaptationSensitivity>7.5e-01</photoreceptorsLocalAdaptationSensitivity>
  92. <photoreceptorsTemporalConstant>9.0e-01</photoreceptorsTemporalConstant>
  93. <photoreceptorsSpatialConstant>5.3e-01</photoreceptorsSpatialConstant>
  94. <horizontalCellsGain>0.01</horizontalCellsGain>
  95. <hcellsTemporalConstant>0.5</hcellsTemporalConstant>
  96. <hcellsSpatialConstant>7.</hcellsSpatialConstant>
  97. <ganglionCellsSensitivity>7.5e-01</ganglionCellsSensitivity></OPLandIPLparvo>
  98. <IPLmagno>
  99. <normaliseOutput>1</normaliseOutput>
  100. <parasolCells_beta>0.</parasolCells_beta>
  101. <parasolCells_tau>0.</parasolCells_tau>
  102. <parasolCells_k>7.</parasolCells_k>
  103. <amacrinCellsTemporalCutFrequency>2.0e+00</amacrinCellsTemporalCutFrequency>
  104. <V0CompressionParameter>9.5e-01</V0CompressionParameter>
  105. <localAdaptintegration_tau>0.</localAdaptintegration_tau>
  106. <localAdaptintegration_k>7.</localAdaptintegration_k></IPLmagno>
  107. </opencv_storage>
  108. @endcode
  109. Here is the 'realistic" setup used to obtain the second retina output shown on the top of this page.
  110. @code{xml}
  111. <?xml version="1.0"?>
  112. <opencv_storage>
  113. <OPLandIPLparvo>
  114. <colorMode>1</colorMode>
  115. <normaliseOutput>1</normaliseOutput>
  116. <photoreceptorsLocalAdaptationSensitivity>8.9e-01</photoreceptorsLocalAdaptationSensitivity>
  117. <photoreceptorsTemporalConstant>9.0e-01</photoreceptorsTemporalConstant>
  118. <photoreceptorsSpatialConstant>5.3e-01</photoreceptorsSpatialConstant>
  119. <horizontalCellsGain>0.3</horizontalCellsGain>
  120. <hcellsTemporalConstant>0.5</hcellsTemporalConstant>
  121. <hcellsSpatialConstant>7.</hcellsSpatialConstant>
  122. <ganglionCellsSensitivity>8.9e-01</ganglionCellsSensitivity></OPLandIPLparvo>
  123. <IPLmagno>
  124. <normaliseOutput>1</normaliseOutput>
  125. <parasolCells_beta>0.</parasolCells_beta>
  126. <parasolCells_tau>0.</parasolCells_tau>
  127. <parasolCells_k>7.</parasolCells_k>
  128. <amacrinCellsTemporalCutFrequency>2.0e+00</amacrinCellsTemporalCutFrequency>
  129. <V0CompressionParameter>9.5e-01</V0CompressionParameter>
  130. <localAdaptintegration_tau>0.</localAdaptintegration_tau>
  131. <localAdaptintegration_k>7.</localAdaptintegration_k></IPLmagno>
  132. </opencv_storage>
  133. @endcode
  134. */
  135. struct RetinaParameters{
  136. //! Outer Plexiform Layer (OPL) and Inner Plexiform Layer Parvocellular (IplParvo) parameters
  137. struct OPLandIplParvoParameters{
  138. OPLandIplParvoParameters():colorMode(true),
  139. normaliseOutput(true),
  140. photoreceptorsLocalAdaptationSensitivity(0.75f),
  141. photoreceptorsTemporalConstant(0.9f),
  142. photoreceptorsSpatialConstant(0.53f),
  143. horizontalCellsGain(0.01f),
  144. hcellsTemporalConstant(0.5f),
  145. hcellsSpatialConstant(7.f),
  146. ganglionCellsSensitivity(0.75f) { } // default setup
  147. bool colorMode, normaliseOutput;
  148. float photoreceptorsLocalAdaptationSensitivity, photoreceptorsTemporalConstant, photoreceptorsSpatialConstant, horizontalCellsGain, hcellsTemporalConstant, hcellsSpatialConstant, ganglionCellsSensitivity;
  149. };
  150. //! Inner Plexiform Layer Magnocellular channel (IplMagno)
  151. struct IplMagnoParameters{
  152. IplMagnoParameters():
  153. normaliseOutput(true),
  154. parasolCells_beta(0.f),
  155. parasolCells_tau(0.f),
  156. parasolCells_k(7.f),
  157. amacrinCellsTemporalCutFrequency(2.0f),
  158. V0CompressionParameter(0.95f),
  159. localAdaptintegration_tau(0.f),
  160. localAdaptintegration_k(7.f) { } // default setup
  161. bool normaliseOutput;
  162. float parasolCells_beta, parasolCells_tau, parasolCells_k, amacrinCellsTemporalCutFrequency, V0CompressionParameter, localAdaptintegration_tau, localAdaptintegration_k;
  163. };
  164. OPLandIplParvoParameters OPLandIplParvo;
  165. IplMagnoParameters IplMagno;
  166. };
  167. /** @brief class which allows the Gipsa/Listic Labs model to be used with OpenCV.
  168. This retina model allows spatio-temporal image processing (applied on still images, video sequences).
  169. As a summary, these are the retina model properties:
  170. - It applies a spectral whithening (mid-frequency details enhancement)
  171. - high frequency spatio-temporal noise reduction
  172. - low frequency luminance to be reduced (luminance range compression)
  173. - local logarithmic luminance compression allows details to be enhanced in low light conditions
  174. USE : this model can be used basically for spatio-temporal video effects but also for :
  175. _using the getParvo method output matrix : texture analysiswith enhanced signal to noise ratio and enhanced details robust against input images luminance ranges
  176. _using the getMagno method output matrix : motion analysis also with the previously cited properties
  177. for more information, reer to the following papers :
  178. 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
  179. 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.
  180. The retina filter includes the research contributions of phd/research collegues from which code has been redrawn by the author :
  181. take a look at the retinacolor.hpp module to discover Brice Chaix de Lavarene color mosaicing/demosaicing and the reference paper:
  182. B. Chaix de Lavarene, D. Alleysson, B. Durette, J. Herault (2007). "Efficient demosaicing through recursive filtering", IEEE International Conference on Image Processing ICIP 2007
  183. 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.
  184. more informations in the above cited Jeanny Heraults's book.
  185. */
  186. class CV_EXPORTS_W Retina : public Algorithm {
  187. public:
  188. /** @brief Retreive retina input buffer size
  189. @return the retina input buffer size
  190. */
  191. CV_WRAP virtual Size getInputSize()=0;
  192. /** @brief Retreive retina output buffer size that can be different from the input if a spatial log
  193. transformation is applied
  194. @return the retina output buffer size
  195. */
  196. CV_WRAP virtual Size getOutputSize()=0;
  197. /** @brief Try to open an XML retina parameters file to adjust current retina instance setup
  198. - if the xml file does not exist, then default setup is applied
  199. - warning, Exceptions are thrown if read XML file is not valid
  200. @param retinaParameterFile the parameters filename
  201. @param applyDefaultSetupOnFailure set to true if an error must be thrown on error
  202. You can retrieve the current parameters structure using the method Retina::getParameters and update
  203. it before running method Retina::setup.
  204. */
  205. CV_WRAP virtual void setup(String retinaParameterFile="", const bool applyDefaultSetupOnFailure=true)=0;
  206. /** @overload
  207. @param fs the open Filestorage which contains retina parameters
  208. @param applyDefaultSetupOnFailure set to true if an error must be thrown on error
  209. */
  210. virtual void setup(cv::FileStorage &fs, const bool applyDefaultSetupOnFailure=true)=0;
  211. /** @overload
  212. @param newParameters a parameters structures updated with the new target configuration.
  213. */
  214. virtual void setup(RetinaParameters newParameters)=0;
  215. /**
  216. @return the current parameters setup
  217. */
  218. virtual RetinaParameters getParameters()=0;
  219. /** @brief Outputs a string showing the used parameters setup
  220. @return a string which contains formated parameters information
  221. */
  222. CV_WRAP virtual String printSetup()=0;
  223. /** @brief Write xml/yml formated parameters information
  224. @param fs the filename of the xml file that will be open and writen with formatted parameters
  225. information
  226. */
  227. CV_WRAP virtual void write( String fs ) const=0;
  228. /** @overload */
  229. virtual void write( FileStorage& fs ) const CV_OVERRIDE = 0;
  230. /** @brief Setup the OPL and IPL parvo channels (see biologocal model)
  231. OPL is referred as Outer Plexiform Layer of the retina, it allows the spatio-temporal filtering
  232. which withens the spectrum and reduces spatio-temporal noise while attenuating global luminance
  233. (low frequency energy) IPL parvo is the OPL next processing stage, it refers to a part of the
  234. Inner Plexiform layer of the retina, it allows high contours sensitivity in foveal vision. See
  235. reference papers for more informations.
  236. 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
  237. @param colorMode specifies if (true) color is processed of not (false) to then processing gray
  238. level image
  239. @param normaliseOutput specifies if (true) output is rescaled between 0 and 255 of not (false)
  240. @param photoreceptorsLocalAdaptationSensitivity the photoreceptors sensitivity renage is 0-1
  241. (more log compression effect when value increases)
  242. @param photoreceptorsTemporalConstant the time constant of the first order low pass filter of
  243. the photoreceptors, use it to cut high temporal frequencies (noise or fast motion), unit is
  244. frames, typical value is 1 frame
  245. @param photoreceptorsSpatialConstant the spatial constant of the first order low pass filter of
  246. the photoreceptors, use it to cut high spatial frequencies (noise or thick contours), unit is
  247. pixels, typical value is 1 pixel
  248. @param horizontalCellsGain gain of the horizontal cells network, if 0, then the mean value of
  249. the output is zero, if the parameter is near 1, then, the luminance is not filtered and is
  250. still reachable at the output, typicall value is 0
  251. @param HcellsTemporalConstant the time constant of the first order low pass filter of the
  252. horizontal cells, use it to cut low temporal frequencies (local luminance variations), unit is
  253. frames, typical value is 1 frame, as the photoreceptors
  254. @param HcellsSpatialConstant the spatial constant of the first order low pass filter of the
  255. horizontal cells, use it to cut low spatial frequencies (local luminance), unit is pixels,
  256. typical value is 5 pixel, this value is also used for local contrast computing when computing
  257. the local contrast adaptation at the ganglion cells level (Inner Plexiform Layer parvocellular
  258. channel model)
  259. @param ganglionCellsSensitivity the compression strengh of the ganglion cells local adaptation
  260. output, set a value between 0.6 and 1 for best results, a high value increases more the low
  261. value sensitivity... and the output saturates faster, recommended value: 0.7
  262. */
  263. CV_WRAP virtual 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.f, const float HcellsTemporalConstant=1.f, const float HcellsSpatialConstant=7.f, const float ganglionCellsSensitivity=0.7f)=0;
  264. /** @brief Set parameters values for the Inner Plexiform Layer (IPL) magnocellular channel
  265. this channel processes signals output from OPL processing stage in peripheral vision, it allows
  266. motion information enhancement. It is decorrelated from the details channel. See reference
  267. papers for more details.
  268. @param normaliseOutput specifies if (true) output is rescaled between 0 and 255 of not (false)
  269. @param parasolCells_beta the low pass filter gain used for local contrast adaptation at the
  270. IPL level of the retina (for ganglion cells local adaptation), typical value is 0
  271. @param parasolCells_tau the low pass filter time constant used for local contrast adaptation
  272. at the IPL level of the retina (for ganglion cells local adaptation), unit is frame, typical
  273. value is 0 (immediate response)
  274. @param parasolCells_k the low pass filter spatial constant used for local contrast adaptation
  275. at the IPL level of the retina (for ganglion cells local adaptation), unit is pixels, typical
  276. value is 5
  277. @param amacrinCellsTemporalCutFrequency the time constant of the first order high pass fiter of
  278. the magnocellular way (motion information channel), unit is frames, typical value is 1.2
  279. @param V0CompressionParameter the compression strengh of the ganglion cells local adaptation
  280. output, set a value between 0.6 and 1 for best results, a high value increases more the low
  281. value sensitivity... and the output saturates faster, recommended value: 0.95
  282. @param localAdaptintegration_tau specifies the temporal constant of the low pas filter
  283. involved in the computation of the local "motion mean" for the local adaptation computation
  284. @param localAdaptintegration_k specifies the spatial constant of the low pas filter involved
  285. in the computation of the local "motion mean" for the local adaptation computation
  286. */
  287. CV_WRAP virtual void setupIPLMagnoChannel(const bool normaliseOutput = true, const float parasolCells_beta=0.f, const float parasolCells_tau=0.f, const float parasolCells_k=7.f, const float amacrinCellsTemporalCutFrequency=1.2f, const float V0CompressionParameter=0.95f, const float localAdaptintegration_tau=0.f, const float localAdaptintegration_k=7.f)=0;
  288. /** @brief Method which allows retina to be applied on an input image,
  289. after run, encapsulated retina module is ready to deliver its outputs using dedicated
  290. acccessors, see getParvo and getMagno methods
  291. @param inputImage the input Mat image to be processed, can be gray level or BGR coded in any
  292. format (from 8bit to 16bits)
  293. */
  294. CV_WRAP virtual void run(InputArray inputImage)=0;
  295. /** @brief Method which processes an image in the aim to correct its luminance correct
  296. backlight problems, enhance details in shadows.
  297. This method is designed to perform High Dynamic Range image tone mapping (compress \>8bit/pixel
  298. images to 8bit/pixel). This is a simplified version of the Retina Parvocellular model
  299. (simplified version of the run/getParvo methods call) since it does not include the
  300. spatio-temporal filter modelling the Outer Plexiform Layer of the retina that performs spectral
  301. whitening and many other stuff. However, it works great for tone mapping and in a faster way.
  302. Check the demos and experiments section to see examples and the way to perform tone mapping
  303. using the original retina model and the method.
  304. @param inputImage the input image to process (should be coded in float format : CV_32F,
  305. CV_32FC1, CV_32F_C3, CV_32F_C4, the 4th channel won't be considered).
  306. @param outputToneMappedImage the output 8bit/channel tone mapped image (CV_8U or CV_8UC3 format).
  307. */
  308. CV_WRAP virtual void applyFastToneMapping(InputArray inputImage, OutputArray outputToneMappedImage)=0;
  309. /** @brief Accessor of the details channel of the retina (models foveal vision).
  310. Warning, getParvoRAW methods return buffers that are not rescaled within range [0;255] while
  311. the non RAW method allows a normalized matrix to be retrieved.
  312. @param retinaOutput_parvo the output buffer (reallocated if necessary), format can be :
  313. - a Mat, this output is rescaled for standard 8bits image processing use in OpenCV
  314. - RAW methods actually return a 1D matrix (encoding is R1, R2, ... Rn, G1, G2, ..., Gn, B1,
  315. B2, ...Bn), this output is the original retina filter model output, without any
  316. quantification or rescaling.
  317. @see getParvoRAW
  318. */
  319. CV_WRAP virtual void getParvo(OutputArray retinaOutput_parvo)=0;
  320. /** @brief Accessor of the details channel of the retina (models foveal vision).
  321. @see getParvo
  322. */
  323. CV_WRAP virtual void getParvoRAW(OutputArray retinaOutput_parvo)=0;
  324. /** @brief Accessor of the motion channel of the retina (models peripheral vision).
  325. Warning, getMagnoRAW methods return buffers that are not rescaled within range [0;255] while
  326. the non RAW method allows a normalized matrix to be retrieved.
  327. @param retinaOutput_magno the output buffer (reallocated if necessary), format can be :
  328. - a Mat, this output is rescaled for standard 8bits image processing use in OpenCV
  329. - RAW methods actually return a 1D matrix (encoding is M1, M2,... Mn), this output is the
  330. original retina filter model output, without any quantification or rescaling.
  331. @see getMagnoRAW
  332. */
  333. CV_WRAP virtual void getMagno(OutputArray retinaOutput_magno)=0;
  334. /** @brief Accessor of the motion channel of the retina (models peripheral vision).
  335. @see getMagno
  336. */
  337. CV_WRAP virtual void getMagnoRAW(OutputArray retinaOutput_magno)=0;
  338. /** @overload */
  339. CV_WRAP virtual Mat getMagnoRAW() const=0;
  340. /** @overload */
  341. CV_WRAP virtual Mat getParvoRAW() const=0;
  342. /** @brief Activate color saturation as the final step of the color demultiplexing process -\> this
  343. saturation is a sigmoide function applied to each channel of the demultiplexed image.
  344. @param saturateColors boolean that activates color saturation (if true) or desactivate (if false)
  345. @param colorSaturationValue the saturation factor : a simple factor applied on the chrominance
  346. buffers
  347. */
  348. CV_WRAP virtual void setColorSaturation(const bool saturateColors=true, const float colorSaturationValue=4.0f)=0;
  349. /** @brief Clears all retina buffers
  350. (equivalent to opening the eyes after a long period of eye close ;o) whatchout the temporal
  351. transition occuring just after this method call.
  352. */
  353. CV_WRAP virtual void clearBuffers()=0;
  354. /** @brief Activate/desactivate the Magnocellular pathway processing (motion information extraction), by
  355. default, it is activated
  356. @param activate true if Magnocellular output should be activated, false if not... if activated,
  357. the Magnocellular output can be retrieved using the **getMagno** methods
  358. */
  359. CV_WRAP virtual void activateMovingContoursProcessing(const bool activate)=0;
  360. /** @brief Activate/desactivate the Parvocellular pathway processing (contours information extraction), by
  361. default, it is activated
  362. @param activate true if Parvocellular (contours information extraction) output should be
  363. activated, false if not... if activated, the Parvocellular output can be retrieved using the
  364. Retina::getParvo methods
  365. */
  366. CV_WRAP virtual void activateContoursProcessing(const bool activate)=0;
  367. /** @overload */
  368. CV_WRAP static Ptr<Retina> create(Size inputSize);
  369. /** @brief Constructors from standardized interfaces : retreive a smart pointer to a Retina instance
  370. @param inputSize the input frame size
  371. @param colorMode the chosen processing mode : with or without color processing
  372. @param colorSamplingMethod specifies which kind of color sampling will be used :
  373. - cv::bioinspired::RETINA_COLOR_RANDOM: each pixel position is either R, G or B in a random choice
  374. - cv::bioinspired::RETINA_COLOR_DIAGONAL: color sampling is RGBRGBRGB..., line 2 BRGBRGBRG..., line 3, GBRGBRGBR...
  375. - cv::bioinspired::RETINA_COLOR_BAYER: standard bayer sampling
  376. @param useRetinaLogSampling activate retina log sampling, if true, the 2 following parameters can
  377. be used
  378. @param reductionFactor only usefull if param useRetinaLogSampling=true, specifies the reduction
  379. factor of the output frame (as the center (fovea) is high resolution and corners can be
  380. underscaled, then a reduction of the output is allowed without precision leak
  381. @param samplingStrength only usefull if param useRetinaLogSampling=true, specifies the strength of
  382. the log scale that is applied
  383. */
  384. CV_WRAP static Ptr<Retina> create(Size inputSize, const bool colorMode,
  385. int colorSamplingMethod=RETINA_COLOR_BAYER,
  386. const bool useRetinaLogSampling=false,
  387. const float reductionFactor=1.0f, const float samplingStrength=10.0f);
  388. };
  389. //! @}
  390. }
  391. }
  392. #endif /* __OPENCV_BIOINSPIRED_RETINA_HPP__ */