retinafasttonemapping.hpp 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. **
  11. ** Maintainers : Listic lab (code author current affiliation & applications) and Gipsa Lab (original research origins & applications)
  12. **
  13. ** Creation - enhancement process 2007-2013
  14. ** Author: Alexandre Benoit (benoit.alexandre.vision@gmail.com), LISTIC lab, Annecy le vieux, France
  15. **
  16. ** 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).
  17. ** Refer to the following research paper for more information:
  18. ** 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
  19. ** 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:
  20. ** 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.
  21. **
  22. **
  23. **
  24. **
  25. **
  26. ** This class is based on image processing tools of the author and already used within the Retina class (this is the same code as method retina::applyFastToneMapping, but in an independent class, it is ligth from a memory requirement point of view). It implements an adaptation of the efficient tone mapping algorithm propose by David Alleyson, Sabine Susstruck and Laurence Meylan's work, please cite:
  27. ** -> 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
  28. **
  29. **
  30. ** License Agreement
  31. ** For Open Source Computer Vision Library
  32. **
  33. ** Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
  34. ** Copyright (C) 2008-2011, Willow Garage Inc., all rights reserved.
  35. **
  36. ** For Human Visual System tools (bioinspired)
  37. ** Copyright (C) 2007-2011, LISTIC Lab, Annecy le Vieux and GIPSA Lab, Grenoble, France, all rights reserved.
  38. **
  39. ** Third party copyrights are property of their respective owners.
  40. **
  41. ** Redistribution and use in source and binary forms, with or without modification,
  42. ** are permitted provided that the following conditions are met:
  43. **
  44. ** * Redistributions of source code must retain the above copyright notice,
  45. ** this list of conditions and the following disclaimer.
  46. **
  47. ** * Redistributions in binary form must reproduce the above copyright notice,
  48. ** this list of conditions and the following disclaimer in the documentation
  49. ** and/or other materials provided with the distribution.
  50. **
  51. ** * The name of the copyright holders may not be used to endorse or promote products
  52. ** derived from this software without specific prior written permission.
  53. **
  54. ** This software is provided by the copyright holders and contributors "as is" and
  55. ** any express or implied warranties, including, but not limited to, the implied
  56. ** warranties of merchantability and fitness for a particular purpose are disclaimed.
  57. ** In no event shall the Intel Corporation or contributors be liable for any direct,
  58. ** indirect, incidental, special, exemplary, or consequential damages
  59. ** (including, but not limited to, procurement of substitute goods or services;
  60. ** loss of use, data, or profits; or business interruption) however caused
  61. ** and on any theory of liability, whether in contract, strict liability,
  62. ** or tort (including negligence or otherwise) arising in any way out of
  63. ** the use of this software, even if advised of the possibility of such damage.
  64. *******************************************************************************/
  65. #ifndef __OPENCV_BIOINSPIRED_RETINAFASTTONEMAPPING_HPP__
  66. #define __OPENCV_BIOINSPIRED_RETINAFASTTONEMAPPING_HPP__
  67. /**
  68. @file
  69. @date May 26, 2013
  70. @author Alexandre Benoit
  71. */
  72. #include "opencv2/core.hpp" // for all OpenCV core functionalities access, including cv::Exception support
  73. namespace cv{
  74. namespace bioinspired{
  75. //! @addtogroup bioinspired
  76. //! @{
  77. /** @brief a wrapper class which allows the tone mapping algorithm of Meylan&al(2007) to be used with OpenCV.
  78. This algorithm is already implemented in thre Retina class (retina::applyFastToneMapping) but used it does not require all the retina model to be allocated. This allows a light memory use for low memory devices (smartphones, etc.
  79. As a summary, these are the model properties:
  80. - 2 stages of local luminance adaptation with a different local neighborhood for each.
  81. - first stage models the retina photorecetors local luminance adaptation
  82. - second stage models th ganglion cells local information adaptation
  83. - compared to the initial publication, this class uses spatio-temporal low pass filters instead of spatial only filters.
  84. this can help noise robustness and temporal stability for video sequence use cases.
  85. for more information, read to the following papers :
  86. 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-2816Benoit 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
  87. regarding spatio-temporal filter and the bigger retina model :
  88. 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.
  89. */
  90. class CV_EXPORTS_W RetinaFastToneMapping : public Algorithm
  91. {
  92. public:
  93. /** @brief applies a luminance correction (initially High Dynamic Range (HDR) tone mapping)
  94. using only the 2 local adaptation stages of the retina parvocellular channel : photoreceptors
  95. level and ganlion cells level. Spatio temporal filtering is applied but limited to temporal
  96. smoothing and eventually high frequencies attenuation. This is a lighter method than the one
  97. available using the regular retina::run method. It is then faster but it does not include
  98. complete temporal filtering nor retina spectral whitening. Then, it can have a more limited
  99. effect on images with a very high dynamic range. This is an adptation of the original still
  100. image HDR tone mapping algorithm of David Alleyson, Sabine Susstruck and Laurence Meylan's
  101. work, please cite: -> Meylan L., Alleysson D., and Susstrunk S., A Model of Retinal Local
  102. Adaptation for the Tone Mapping of Color Filter Array Images, Journal of Optical Society of
  103. America, A, Vol. 24, N 9, September, 1st, 2007, pp. 2807-2816
  104. @param inputImage the input image to process RGB or gray levels
  105. @param outputToneMappedImage the output tone mapped image
  106. */
  107. CV_WRAP virtual void applyFastToneMapping(InputArray inputImage, OutputArray outputToneMappedImage)=0;
  108. /** @brief updates tone mapping behaviors by adjusing the local luminance computation area
  109. @param photoreceptorsNeighborhoodRadius the first stage local adaptation area
  110. @param ganglioncellsNeighborhoodRadius the second stage local adaptation area
  111. @param meanLuminanceModulatorK the factor applied to modulate the meanLuminance information
  112. (default is 1, see reference paper)
  113. */
  114. CV_WRAP virtual void setup(const float photoreceptorsNeighborhoodRadius=3.f, const float ganglioncellsNeighborhoodRadius=1.f, const float meanLuminanceModulatorK=1.f)=0;
  115. CV_WRAP static Ptr<RetinaFastToneMapping> create(Size inputSize);
  116. };
  117. //! @}
  118. }
  119. }
  120. #endif /* __OPENCV_BIOINSPIRED_RETINAFASTTONEMAPPING_HPP__ */