ximgproc.hpp 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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/edgeboxes.hpp"
  43. #include "ximgproc/edge_drawing.hpp"
  44. #include "ximgproc/seeds.hpp"
  45. #include "ximgproc/segmentation.hpp"
  46. #include "ximgproc/fast_hough_transform.hpp"
  47. #include "ximgproc/estimated_covariance.hpp"
  48. #include "ximgproc/weighted_median_filter.hpp"
  49. #include "ximgproc/slic.hpp"
  50. #include "ximgproc/lsc.hpp"
  51. #include "ximgproc/paillou_filter.hpp"
  52. #include "ximgproc/fast_line_detector.hpp"
  53. #include "ximgproc/deriche_filter.hpp"
  54. #include "ximgproc/peilin.hpp"
  55. #include "ximgproc/fourier_descriptors.hpp"
  56. #include "ximgproc/ridgefilter.hpp"
  57. #include "ximgproc/brightedges.hpp"
  58. /** @defgroup ximgproc Extended Image Processing
  59. @{
  60. @defgroup ximgproc_edge Structured forests for fast edge detection
  61. This module contains implementations of modern structured edge detection algorithms,
  62. i.e. algorithms which somehow takes into account pixel affinities in natural images.
  63. @defgroup ximgproc_edgeboxes EdgeBoxes
  64. @defgroup ximgproc_filters Filters
  65. @defgroup ximgproc_superpixel Superpixels
  66. @defgroup ximgproc_segmentation Image segmentation
  67. @defgroup ximgproc_fast_line_detector Fast line detector
  68. @defgroup ximgproc_edge_drawing EdgeDrawing
  69. EDGE DRAWING LIBRARY FOR GEOMETRIC FEATURE EXTRACTION AND VALIDATION
  70. Edge Drawing (ED) algorithm is an proactive approach on edge detection problem. In contrast to many other existing edge detection algorithms which follow a subtractive
  71. approach (i.e. after applying gradient filters onto an image eliminating pixels w.r.t. several rules, e.g. non-maximal suppression and hysteresis in Canny), ED algorithm
  72. works via an additive strategy, i.e. it picks edge pixels one by one, hence the name Edge Drawing. Then we process those random shaped edge segments to extract higher level
  73. edge features, i.e. lines, circles, ellipses, etc. The popular method of extraction edge pixels from the thresholded gradient magnitudes is non-maximal supression that tests
  74. every pixel whether it has the maximum gradient response along its gradient direction and eliminates if it does not. However, this method does not check status of the
  75. neighboring pixels, and therefore might result low quality (in terms of edge continuity, smoothness, thinness, localization) edge segments. Instead of non-maximal supression,
  76. ED points a set of edge pixels and join them by maximizing the total gradient response of edge segments. Therefore it can extract high quality edge segments without need for
  77. an additional hysteresis step.
  78. @defgroup ximgproc_fourier Fourier descriptors
  79. @}
  80. */
  81. namespace cv
  82. {
  83. namespace ximgproc
  84. {
  85. enum ThinningTypes{
  86. THINNING_ZHANGSUEN = 0, // Thinning technique of Zhang-Suen
  87. THINNING_GUOHALL = 1 // Thinning technique of Guo-Hall
  88. };
  89. /**
  90. * @brief Specifies the binarization method to use in cv::ximgproc::niBlackThreshold
  91. */
  92. enum LocalBinarizationMethods{
  93. BINARIZATION_NIBLACK = 0, //!< Classic Niblack binarization. See @cite Niblack1985 .
  94. BINARIZATION_SAUVOLA = 1, //!< Sauvola's technique. See @cite Sauvola1997 .
  95. BINARIZATION_WOLF = 2, //!< Wolf's technique. See @cite Wolf2004 .
  96. BINARIZATION_NICK = 3 //!< NICK technique. See @cite Khurshid2009 .
  97. };
  98. //! @addtogroup ximgproc
  99. //! @{
  100. /** @brief Performs thresholding on input images using Niblack's technique or some of the
  101. popular variations it inspired.
  102. The function transforms a grayscale image to a binary image according to the formulae:
  103. - **THRESH_BINARY**
  104. \f[dst(x,y) = \fork{\texttt{maxValue}}{if \(src(x,y) > T(x,y)\)}{0}{otherwise}\f]
  105. - **THRESH_BINARY_INV**
  106. \f[dst(x,y) = \fork{0}{if \(src(x,y) > T(x,y)\)}{\texttt{maxValue}}{otherwise}\f]
  107. where \f$T(x,y)\f$ is a threshold calculated individually for each pixel.
  108. The threshold value \f$T(x, y)\f$ is determined based on the binarization method chosen. For
  109. classic Niblack, it is the mean minus \f$ k \f$ times standard deviation of
  110. \f$\texttt{blockSize} \times\texttt{blockSize}\f$ neighborhood of \f$(x, y)\f$.
  111. The function can't process the image in-place.
  112. @param _src Source 8-bit single-channel image.
  113. @param _dst Destination image of the same size and the same type as src.
  114. @param maxValue Non-zero value assigned to the pixels for which the condition is satisfied,
  115. used with the THRESH_BINARY and THRESH_BINARY_INV thresholding types.
  116. @param type Thresholding type, see cv::ThresholdTypes.
  117. @param blockSize Size of a pixel neighborhood that is used to calculate a threshold value
  118. for the pixel: 3, 5, 7, and so on.
  119. @param k The user-adjustable parameter used by Niblack and inspired techniques. For Niblack, this is
  120. normally a value between 0 and 1 that is multiplied with the standard deviation and subtracted from
  121. the mean.
  122. @param binarizationMethod Binarization method to use. By default, Niblack's technique is used.
  123. Other techniques can be specified, see cv::ximgproc::LocalBinarizationMethods.
  124. @sa threshold, adaptiveThreshold
  125. */
  126. CV_EXPORTS_W void niBlackThreshold( InputArray _src, OutputArray _dst,
  127. double maxValue, int type,
  128. int blockSize, double k, int binarizationMethod = BINARIZATION_NIBLACK );
  129. /** @brief Applies a binary blob thinning operation, to achieve a skeletization of the input image.
  130. The function transforms a binary blob image into a skeletized form using the technique of Zhang-Suen.
  131. @param src Source 8-bit single-channel image, containing binary blobs, with blobs having 255 pixel values.
  132. @param dst Destination image of the same size and the same type as src. The function can work in-place.
  133. @param thinningType Value that defines which thinning algorithm should be used. See cv::ximgproc::ThinningTypes
  134. */
  135. CV_EXPORTS_W void thinning( InputArray src, OutputArray dst, int thinningType = THINNING_ZHANGSUEN);
  136. /** @brief Performs anisotropic diffusion on an image.
  137. The function applies Perona-Malik anisotropic diffusion to an image. This is the solution to the partial differential equation:
  138. \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]
  139. Suggested functions for c(x,y,t) are:
  140. \f[c\left(\|\nabla I\|\right)=e^{{-\left(\|\nabla I\|/K\right)^{2}}}\f]
  141. or
  142. \f[ c\left(\|\nabla I\|\right)={\frac {1}{1+\left({\frac {\|\nabla I\|}{K}}\right)^{2}}} \f]
  143. @param src Source image with 3 channels.
  144. @param dst Destination image of the same size and the same number of channels as src .
  145. @param alpha The amount of time to step forward by on each iteration (normally, it's between 0 and 1).
  146. @param K sensitivity to the edges
  147. @param niters The number of iterations
  148. */
  149. CV_EXPORTS_W void anisotropicDiffusion(InputArray src, OutputArray dst, float alpha, float K, int niters );
  150. //! @}
  151. }
  152. }
  153. #endif // __OPENCV_XIMGPROC_HPP__