ximgproc.hpp 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * By downloading, copying, installing or using the software you agree to this license.
  3. * If you do not agree to this license, do not download, install,
  4. * copy or use the software.
  5. *
  6. *
  7. * License Agreement
  8. * For Open Source Computer Vision Library
  9. * (3 - clause BSD License)
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met :
  13. *
  14. * * Redistributions of source code must retain the above copyright notice,
  15. * this list of conditions and the following disclaimer.
  16. *
  17. * * Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and / or other materials provided with the distribution.
  20. *
  21. * * Neither the names of the copyright holders nor the names of the contributors
  22. * may be used to endorse or promote products derived from this software
  23. * without specific prior written permission.
  24. *
  25. * This software is provided by the copyright holders and contributors "as is" and
  26. * any express or implied warranties, including, but not limited to, the implied
  27. * warranties of merchantability and fitness for a particular purpose are disclaimed.
  28. * In no event shall copyright holders or contributors be liable for any direct,
  29. * indirect, incidental, special, exemplary, or consequential damages
  30. * (including, but not limited to, procurement of substitute goods or services;
  31. * loss of use, data, or profits; or business interruption) however caused
  32. * and on any theory of liability, whether in contract, strict liability,
  33. * or tort(including negligence or otherwise) arising in any way out of
  34. * the use of this software, even if advised of the possibility of such damage.
  35. */
  36. #ifndef __OPENCV_XIMGPROC_HPP__
  37. #define __OPENCV_XIMGPROC_HPP__
  38. #include "ximgproc/edge_filter.hpp"
  39. #include "ximgproc/disparity_filter.hpp"
  40. #include "ximgproc/sparse_match_interpolator.hpp"
  41. #include "ximgproc/structured_edge_detection.hpp"
  42. #include "ximgproc/seeds.hpp"
  43. #include "ximgproc/segmentation.hpp"
  44. #include "ximgproc/fast_hough_transform.hpp"
  45. #include "ximgproc/estimated_covariance.hpp"
  46. #include "ximgproc/weighted_median_filter.hpp"
  47. #include "ximgproc/slic.hpp"
  48. #include "ximgproc/lsc.hpp"
  49. #include "ximgproc/paillou_filter.hpp"
  50. #include "ximgproc/fast_line_detector.hpp"
  51. #include "ximgproc/deriche_filter.hpp"
  52. #include "ximgproc/peilin.hpp"
  53. /** @defgroup ximgproc Extended Image Processing
  54. @{
  55. @defgroup ximgproc_edge Structured forests for fast edge detection
  56. This module contains implementations of modern structured edge detection algorithms,
  57. i.e. algorithms which somehow takes into account pixel affinities in natural images.
  58. @defgroup ximgproc_filters Filters
  59. @defgroup ximgproc_superpixel Superpixels
  60. @defgroup ximgproc_segmentation Image segmentation
  61. @defgroup ximgproc_fast_line_detector Fast line detector
  62. @}
  63. */
  64. namespace cv
  65. {
  66. namespace ximgproc
  67. {
  68. enum ThinningTypes{
  69. THINNING_ZHANGSUEN = 0, // Thinning technique of Zhang-Suen
  70. THINNING_GUOHALL = 1 // Thinning technique of Guo-Hall
  71. };
  72. /**
  73. * @brief Specifies the binarization method to use in cv::ximgproc::niBlackThreshold
  74. */
  75. enum LocalBinarizationMethods{
  76. BINARIZATION_NIBLACK = 0, //!< Classic Niblack binarization. See @cite Niblack1985 .
  77. BINARIZATION_SAUVOLA = 1, //!< Sauvola's technique. See @cite Sauvola1997 .
  78. BINARIZATION_WOLF = 2, //!< Wolf's technique. See @cite Wolf2004 .
  79. BINARIZATION_NICK = 3 //!< NICK technique. See @cite Khurshid2009 .
  80. };
  81. //! @addtogroup ximgproc
  82. //! @{
  83. /** @brief Performs thresholding on input images using Niblack's technique or some of the
  84. popular variations it inspired.
  85. The function transforms a grayscale image to a binary image according to the formulae:
  86. - **THRESH_BINARY**
  87. \f[dst(x,y) = \fork{\texttt{maxValue}}{if \(src(x,y) > T(x,y)\)}{0}{otherwise}\f]
  88. - **THRESH_BINARY_INV**
  89. \f[dst(x,y) = \fork{0}{if \(src(x,y) > T(x,y)\)}{\texttt{maxValue}}{otherwise}\f]
  90. where \f$T(x,y)\f$ is a threshold calculated individually for each pixel.
  91. The threshold value \f$T(x, y)\f$ is determined based on the binarization method chosen. For
  92. classic Niblack, it is the mean minus \f$ k \f$ times standard deviation of
  93. \f$\texttt{blockSize} \times\texttt{blockSize}\f$ neighborhood of \f$(x, y)\f$.
  94. The function can't process the image in-place.
  95. @param _src Source 8-bit single-channel image.
  96. @param _dst Destination image of the same size and the same type as src.
  97. @param maxValue Non-zero value assigned to the pixels for which the condition is satisfied,
  98. used with the THRESH_BINARY and THRESH_BINARY_INV thresholding types.
  99. @param type Thresholding type, see cv::ThresholdTypes.
  100. @param blockSize Size of a pixel neighborhood that is used to calculate a threshold value
  101. for the pixel: 3, 5, 7, and so on.
  102. @param k The user-adjustable parameter used by Niblack and inspired techniques. For Niblack, this is
  103. normally a value between 0 and 1 that is multiplied with the standard deviation and subtracted from
  104. the mean.
  105. @param binarizationMethod Binarization method to use. By default, Niblack's technique is used.
  106. Other techniques can be specified, see cv::ximgproc::LocalBinarizationMethods.
  107. @sa threshold, adaptiveThreshold
  108. */
  109. CV_EXPORTS_W void niBlackThreshold( InputArray _src, OutputArray _dst,
  110. double maxValue, int type,
  111. int blockSize, double k, int binarizationMethod = BINARIZATION_NIBLACK );
  112. /** @brief Applies a binary blob thinning operation, to achieve a skeletization of the input image.
  113. The function transforms a binary blob image into a skeletized form using the technique of Zhang-Suen.
  114. @param src Source 8-bit single-channel image, containing binary blobs, with blobs having 255 pixel values.
  115. @param dst Destination image of the same size and the same type as src. The function can work in-place.
  116. @param thinningType Value that defines which thinning algorithm should be used. See cv::ximgproc::ThinningTypes
  117. */
  118. CV_EXPORTS_W void thinning( InputArray src, OutputArray dst, int thinningType = THINNING_ZHANGSUEN);
  119. /** @brief Performs anisotropic diffusian on an image.
  120. The function applies Perona-Malik anisotropic diffusion to an image. This is the solution to the partial differential equation:
  121. \f[{\frac {\partial I}{\partial t}}={\mathrm {div}}\left(c(x,y,t)\nabla I\right)=\nabla c\cdot \nabla I+c(x,y,t)\Delta I\f]
  122. Suggested functions for c(x,y,t) are:
  123. \f[c\left(\|\nabla I\|\right)=e^{{-\left(\|\nabla I\|/K\right)^{2}}}\f]
  124. or
  125. \f[ c\left(\|\nabla I\|\right)={\frac {1}{1+\left({\frac {\|\nabla I\|}{K}}\right)^{2}}} \f]
  126. @param src Grayscale Source image.
  127. @param dst Destination image of the same size and the same number of channels as src .
  128. @param alpha The amount of time to step forward by on each iteration (normally, it's between 0 and 1).
  129. @param K sensitivity to the edges
  130. @param niters The number of iterations
  131. */
  132. CV_EXPORTS_W void anisotropicDiffusion(InputArray src, OutputArray dst, float alpha, float K, int niters );
  133. //! @}
  134. }
  135. }
  136. #endif // __OPENCV_XIMGPROC_HPP__