white_balance.hpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*M///////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
  4. //
  5. // By downloading, copying, installing or using the software you agree to this license.
  6. // If you do not agree to this license, do not download, install,
  7. // copy or use the software.
  8. //
  9. //
  10. // License Agreement
  11. // For Open Source Computer Vision Library
  12. //
  13. // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
  14. // Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved.
  15. // Third party copyrights are property of their respective owners.
  16. //
  17. // Redistribution and use in source and binary forms, with or without modification,
  18. // are permitted provided that the following conditions are met:
  19. //
  20. // * Redistribution's of source code must retain the above copyright notice,
  21. // this list of conditions and the following disclaimer.
  22. //
  23. // * Redistribution's in binary form must reproduce the above copyright notice,
  24. // this list of conditions and the following disclaimer in the documentation
  25. // and/or other materials provided with the distribution.
  26. //
  27. // * The name of the copyright holders may not be used to endorse or promote products
  28. // derived from this software without specific prior written permission.
  29. //
  30. // This software is provided by the copyright holders and contributors "as is" and
  31. // any express or implied warranties, including, but not limited to, the implied
  32. // warranties of merchantability and fitness for a particular purpose are disclaimed.
  33. // In no event shall the Intel Corporation or contributors be liable for any direct,
  34. // indirect, incidental, special, exemplary, or consequential damages
  35. // (including, but not limited to, procurement of substitute goods or services;
  36. // loss of use, data, or profits; or business interruption) however caused
  37. // and on any theory of liability, whether in contract, strict liability,
  38. // or tort (including negligence or otherwise) arising in any way out of
  39. // the use of this software, even if advised of the possibility of such damage.
  40. //
  41. //M*/
  42. #ifndef __OPENCV_SIMPLE_COLOR_BALANCE_HPP__
  43. #define __OPENCV_SIMPLE_COLOR_BALANCE_HPP__
  44. /** @file
  45. @date Jun 26, 2014
  46. @author Yury Gitman
  47. */
  48. #include <opencv2/core.hpp>
  49. namespace cv
  50. {
  51. namespace xphoto
  52. {
  53. //! @addtogroup xphoto
  54. //! @{
  55. //! various white balance algorithms
  56. enum WhitebalanceTypes
  57. {
  58. /** perform smart histogram adjustments (ignoring 4% pixels with minimal and maximal
  59. values) for each channel */
  60. WHITE_BALANCE_SIMPLE = 0,
  61. WHITE_BALANCE_GRAYWORLD = 1
  62. };
  63. /** @brief The function implements different algorithm of automatic white balance,
  64. i.e. it tries to map image's white color to perceptual white (this can be violated due to
  65. specific illumination or camera settings).
  66. @param src
  67. @param dst
  68. @param algorithmType see xphoto::WhitebalanceTypes
  69. @param inputMin minimum value in the input image
  70. @param inputMax maximum value in the input image
  71. @param outputMin minimum value in the output image
  72. @param outputMax maximum value in the output image
  73. @sa cvtColor, equalizeHist
  74. */
  75. CV_EXPORTS_W void balanceWhite(const Mat &src, Mat &dst, const int algorithmType,
  76. const float inputMin = 0.0f, const float inputMax = 255.0f,
  77. const float outputMin = 0.0f, const float outputMax = 255.0f);
  78. /** @brief Implements a simple grayworld white balance algorithm.
  79. The function autowbGrayworld scales the values of pixels based on a
  80. gray-world assumption which states that the average of all channels
  81. should result in a gray image.
  82. This function adds a modification which thresholds pixels based on their
  83. saturation value and only uses pixels below the provided threshold in
  84. finding average pixel values.
  85. Saturation is calculated using the following for a 3-channel RGB image per
  86. pixel I and is in the range [0, 1]:
  87. \f[ \texttt{Saturation} [I] = \frac{\textrm{max}(R,G,B) - \textrm{min}(R,G,B)
  88. }{\textrm{max}(R,G,B)} \f]
  89. A threshold of 1 means that all pixels are used to white-balance, while a
  90. threshold of 0 means no pixels are used. Lower thresholds are useful in
  91. white-balancing saturated images.
  92. Currently only works on images of type @ref CV_8UC3.
  93. @param src Input array.
  94. @param dst Output array of the same size and type as src.
  95. @param thresh Maximum saturation for a pixel to be included in the
  96. gray-world assumption.
  97. @sa balanceWhite
  98. */
  99. CV_EXPORTS_W void autowbGrayworld(InputArray src, OutputArray dst,
  100. float thresh = 0.5f);
  101. //! @}
  102. }
  103. }
  104. #endif // __OPENCV_SIMPLE_COLOR_BALANCE_HPP__