SuperpixelSEEDS.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. //
  2. // This file is auto-generated. Please don't modify it!
  3. //
  4. #pragma once
  5. #ifdef __cplusplus
  6. //#import "opencv.hpp"
  7. #import "opencv2/ximgproc.hpp"
  8. #import "opencv2/ximgproc/seeds.hpp"
  9. #else
  10. #define CV_EXPORTS
  11. #endif
  12. #import <Foundation/Foundation.h>
  13. #import "Algorithm.h"
  14. @class Mat;
  15. NS_ASSUME_NONNULL_BEGIN
  16. // C++: class SuperpixelSEEDS
  17. /**
  18. * Class implementing the SEEDS (Superpixels Extracted via Energy-Driven Sampling) superpixels
  19. * algorithm described in CITE: VBRV14 .
  20. *
  21. * The algorithm uses an efficient hill-climbing algorithm to optimize the superpixels' energy
  22. * function that is based on color histograms and a boundary term, which is optional. The energy
  23. * function encourages superpixels to be of the same color, and if the boundary term is activated, the
  24. * superpixels have smooth boundaries and are of similar shape. In practice it starts from a regular
  25. * grid of superpixels and moves the pixels or blocks of pixels at the boundaries to refine the
  26. * solution. The algorithm runs in real-time using a single CPU.
  27. *
  28. * Member of `Ximgproc`
  29. */
  30. CV_EXPORTS @interface SuperpixelSEEDS : Algorithm
  31. #ifdef __cplusplus
  32. @property(readonly)cv::Ptr<cv::ximgproc::SuperpixelSEEDS> nativePtrSuperpixelSEEDS;
  33. #endif
  34. #ifdef __cplusplus
  35. - (instancetype)initWithNativePtr:(cv::Ptr<cv::ximgproc::SuperpixelSEEDS>)nativePtr;
  36. + (instancetype)fromNative:(cv::Ptr<cv::ximgproc::SuperpixelSEEDS>)nativePtr;
  37. #endif
  38. #pragma mark - Methods
  39. //
  40. // int cv::ximgproc::SuperpixelSEEDS::getNumberOfSuperpixels()
  41. //
  42. /**
  43. * Calculates the superpixel segmentation on a given image stored in SuperpixelSEEDS object.
  44. *
  45. * The function computes the superpixels segmentation of an image with the parameters initialized
  46. * with the function createSuperpixelSEEDS().
  47. */
  48. - (int)getNumberOfSuperpixels NS_SWIFT_NAME(getNumberOfSuperpixels());
  49. //
  50. // void cv::ximgproc::SuperpixelSEEDS::iterate(Mat img, int num_iterations = 4)
  51. //
  52. /**
  53. * Calculates the superpixel segmentation on a given image with the initialized
  54. * parameters in the SuperpixelSEEDS object.
  55. *
  56. * This function can be called again for other images without the need of initializing the
  57. * algorithm with createSuperpixelSEEDS(). This save the computational cost of allocating memory
  58. * for all the structures of the algorithm.
  59. *
  60. * @param img Input image. Supported formats: CV_8U, CV_16U, CV_32F. Image size & number of
  61. * channels must match with the initialized image size & channels with the function
  62. * createSuperpixelSEEDS(). It should be in HSV or Lab color space. Lab is a bit better, but also
  63. * slower.
  64. *
  65. * @param num_iterations Number of pixel level iterations. Higher number improves the result.
  66. *
  67. * The function computes the superpixels segmentation of an image with the parameters initialized
  68. * with the function createSuperpixelSEEDS(). The algorithms starts from a grid of superpixels and
  69. * then refines the boundaries by proposing updates of blocks of pixels that lie at the boundaries
  70. * from large to smaller size, finalizing with proposing pixel updates. An illustrative example
  71. * can be seen below.
  72. *
  73. * ![image](pics/superpixels_blocks2.png)
  74. */
  75. - (void)iterate:(Mat*)img num_iterations:(int)num_iterations NS_SWIFT_NAME(iterate(img:num_iterations:));
  76. /**
  77. * Calculates the superpixel segmentation on a given image with the initialized
  78. * parameters in the SuperpixelSEEDS object.
  79. *
  80. * This function can be called again for other images without the need of initializing the
  81. * algorithm with createSuperpixelSEEDS(). This save the computational cost of allocating memory
  82. * for all the structures of the algorithm.
  83. *
  84. * @param img Input image. Supported formats: CV_8U, CV_16U, CV_32F. Image size & number of
  85. * channels must match with the initialized image size & channels with the function
  86. * createSuperpixelSEEDS(). It should be in HSV or Lab color space. Lab is a bit better, but also
  87. * slower.
  88. *
  89. *
  90. * The function computes the superpixels segmentation of an image with the parameters initialized
  91. * with the function createSuperpixelSEEDS(). The algorithms starts from a grid of superpixels and
  92. * then refines the boundaries by proposing updates of blocks of pixels that lie at the boundaries
  93. * from large to smaller size, finalizing with proposing pixel updates. An illustrative example
  94. * can be seen below.
  95. *
  96. * ![image](pics/superpixels_blocks2.png)
  97. */
  98. - (void)iterate:(Mat*)img NS_SWIFT_NAME(iterate(img:));
  99. //
  100. // void cv::ximgproc::SuperpixelSEEDS::getLabels(Mat& labels_out)
  101. //
  102. /**
  103. * Returns the segmentation labeling of the image.
  104. *
  105. * Each label represents a superpixel, and each pixel is assigned to one superpixel label.
  106. *
  107. * @param labels_out Return: A CV_32UC1 integer array containing the labels of the superpixel
  108. * segmentation. The labels are in the range [0, getNumberOfSuperpixels()].
  109. *
  110. * The function returns an image with ssthe labels of the superpixel segmentation. The labels are in
  111. * the range [0, getNumberOfSuperpixels()].
  112. */
  113. - (void)getLabels:(Mat*)labels_out NS_SWIFT_NAME(getLabels(labels_out:));
  114. //
  115. // void cv::ximgproc::SuperpixelSEEDS::getLabelContourMask(Mat& image, bool thick_line = false)
  116. //
  117. /**
  118. * Returns the mask of the superpixel segmentation stored in SuperpixelSEEDS object.
  119. *
  120. * @param image Return: CV_8UC1 image mask where -1 indicates that the pixel is a superpixel border,
  121. * and 0 otherwise.
  122. *
  123. * @param thick_line If false, the border is only one pixel wide, otherwise all pixels at the border
  124. * are masked.
  125. *
  126. * The function return the boundaries of the superpixel segmentation.
  127. *
  128. * NOTE:
  129. * - (Python) A demo on how to generate superpixels in images from the webcam can be found at
  130. * opencv_source_code/samples/python2/seeds.py
  131. * - (cpp) A demo on how to generate superpixels in images from the webcam can be found at
  132. * opencv_source_code/modules/ximgproc/samples/seeds.cpp. By adding a file image as a command
  133. * line argument, the static image will be used instead of the webcam.
  134. * - It will show a window with the video from the webcam with the superpixel boundaries marked
  135. * in red (see below). Use Space to switch between different output modes. At the top of the
  136. * window there are 4 sliders, from which the user can change on-the-fly the number of
  137. * superpixels, the number of block levels, the strength of the boundary prior term to modify
  138. * the shape, and the number of iterations at pixel level. This is useful to play with the
  139. * parameters and set them to the user convenience. In the console the frame-rate of the
  140. * algorithm is indicated.
  141. *
  142. * ![image](pics/superpixels_demo.png)
  143. */
  144. - (void)getLabelContourMask:(Mat*)image thick_line:(BOOL)thick_line NS_SWIFT_NAME(getLabelContourMask(image:thick_line:));
  145. /**
  146. * Returns the mask of the superpixel segmentation stored in SuperpixelSEEDS object.
  147. *
  148. * @param image Return: CV_8UC1 image mask where -1 indicates that the pixel is a superpixel border,
  149. * and 0 otherwise.
  150. *
  151. * are masked.
  152. *
  153. * The function return the boundaries of the superpixel segmentation.
  154. *
  155. * NOTE:
  156. * - (Python) A demo on how to generate superpixels in images from the webcam can be found at
  157. * opencv_source_code/samples/python2/seeds.py
  158. * - (cpp) A demo on how to generate superpixels in images from the webcam can be found at
  159. * opencv_source_code/modules/ximgproc/samples/seeds.cpp. By adding a file image as a command
  160. * line argument, the static image will be used instead of the webcam.
  161. * - It will show a window with the video from the webcam with the superpixel boundaries marked
  162. * in red (see below). Use Space to switch between different output modes. At the top of the
  163. * window there are 4 sliders, from which the user can change on-the-fly the number of
  164. * superpixels, the number of block levels, the strength of the boundary prior term to modify
  165. * the shape, and the number of iterations at pixel level. This is useful to play with the
  166. * parameters and set them to the user convenience. In the console the frame-rate of the
  167. * algorithm is indicated.
  168. *
  169. * ![image](pics/superpixels_demo.png)
  170. */
  171. - (void)getLabelContourMask:(Mat*)image NS_SWIFT_NAME(getLabelContourMask(image:));
  172. @end
  173. NS_ASSUME_NONNULL_END