intensity_transform.hpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // This file is part of OpenCV project.
  2. // It is subject to the license terms in the LICENSE file found in the top-level directory
  3. // of this distribution and at http://opencv.org/license.html.
  4. #ifndef OPENCV_INTENSITY_TRANSFORM_H
  5. #define OPENCV_INTENSITY_TRANSFORM_H
  6. #include "opencv2/core.hpp"
  7. /**
  8. * @defgroup intensity_transform The module brings implementations of intensity transformation algorithms to adjust image contrast.
  9. *
  10. * Namespace for all functions is `cv::intensity_transform`.
  11. *
  12. * ### Supported Algorithms
  13. * - Autoscaling
  14. * - Log Transformations
  15. * - Power-Law (Gamma) Transformations
  16. * - Contrast Stretching
  17. * - BIMEF, A Bio-Inspired Multi-Exposure Fusion Framework for Low-light Image Enhancement @cite ying2017bio @cite ying2017new
  18. *
  19. * References from following book and websites:
  20. * - Digital Image Processing 4th Edition Chapter 3 [Rafael C. Gonzalez, Richard E. Woods] @cite Gonzalez2018
  21. * - http://www.cs.uregina.ca/Links/class-info/425/Lab3/ @cite lcs435lab
  22. * - https://theailearner.com/2019/01/30/contrast-stretching/ @cite theailearner
  23. */
  24. namespace cv {
  25. namespace intensity_transform {
  26. //! @addtogroup intensity_transform
  27. //! @{
  28. /**
  29. * @brief Given an input bgr or grayscale image and constant c, apply log transformation to the image
  30. * on domain [0, 255] and return the resulting image.
  31. *
  32. * @param input input bgr or grayscale image.
  33. * @param output resulting image of log transformations.
  34. */
  35. CV_EXPORTS_W void logTransform(const Mat input, Mat& output);
  36. /**
  37. * @brief Given an input bgr or grayscale image and constant gamma, apply power-law transformation,
  38. * a.k.a. gamma correction to the image on domain [0, 255] and return the resulting image.
  39. *
  40. * @param input input bgr or grayscale image.
  41. * @param output resulting image of gamma corrections.
  42. * @param gamma constant in c*r^gamma where r is pixel value.
  43. */
  44. CV_EXPORTS_W void gammaCorrection(const Mat input, Mat& output, const float gamma);
  45. /**
  46. * @brief Given an input bgr or grayscale image, apply autoscaling on domain [0, 255] to increase
  47. * the contrast of the input image and return the resulting image.
  48. *
  49. * @param input input bgr or grayscale image.
  50. * @param output resulting image of autoscaling.
  51. */
  52. CV_EXPORTS_W void autoscaling(const Mat input, Mat& output);
  53. /**
  54. * @brief Given an input bgr or grayscale image, apply linear contrast stretching on domain [0, 255]
  55. * and return the resulting image.
  56. *
  57. * @param input input bgr or grayscale image.
  58. * @param output resulting image of contrast stretching.
  59. * @param r1 x coordinate of first point (r1, s1) in the transformation function.
  60. * @param s1 y coordinate of first point (r1, s1) in the transformation function.
  61. * @param r2 x coordinate of second point (r2, s2) in the transformation function.
  62. * @param s2 y coordinate of second point (r2, s2) in the transformation function.
  63. */
  64. CV_EXPORTS_W void contrastStretching(const Mat input, Mat& output, const int r1, const int s1, const int r2, const int s2);
  65. /**
  66. * @brief Given an input color image, enhance low-light images using the BIMEF method (@cite ying2017bio @cite ying2017new).
  67. *
  68. * @param input input color image.
  69. * @param output resulting image.
  70. * @param mu enhancement ratio.
  71. * @param a a-parameter in the Camera Response Function (CRF).
  72. * @param b b-parameter in the Camera Response Function (CRF).
  73. *
  74. * @warning This is a C++ implementation of the [original MATLAB algorithm](https://github.com/baidut/BIMEF).
  75. * Compared to the original code, this implementation is a little bit slower and does not provide the same results.
  76. * In particular, quality of the image enhancement is degraded for the bright areas in certain conditions.
  77. */
  78. CV_EXPORTS_W void BIMEF(InputArray input, OutputArray output, float mu=0.5f, float a=-0.3293f, float b=1.1258f);
  79. /**
  80. * @brief Given an input color image, enhance low-light images using the BIMEF method (@cite ying2017bio @cite ying2017new).
  81. *
  82. * This is an overloaded function with the exposure ratio given as parameter.
  83. *
  84. * @param input input color image.
  85. * @param output resulting image.
  86. * @param k exposure ratio.
  87. * @param mu enhancement ratio.
  88. * @param a a-parameter in the Camera Response Function (CRF).
  89. * @param b b-parameter in the Camera Response Function (CRF).
  90. *
  91. * @warning This is a C++ implementation of the [original MATLAB algorithm](https://github.com/baidut/BIMEF).
  92. * Compared to the original code, this implementation is a little bit slower and does not provide the same results.
  93. * In particular, quality of the image enhancement is degraded for the bright areas in certain conditions.
  94. */
  95. CV_EXPORTS_AS(BIMEF2) void BIMEF(InputArray input, OutputArray output, float k, float mu, float a, float b);
  96. //! @}
  97. }} // cv::intensity_transform::
  98. #endif