IntelligentScissorsMB.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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/imgproc.hpp"
  8. #import "opencv2/imgproc/segmentation.hpp"
  9. #else
  10. #define CV_EXPORTS
  11. #endif
  12. #import <Foundation/Foundation.h>
  13. @class Mat;
  14. @class Point2i;
  15. NS_ASSUME_NONNULL_BEGIN
  16. // C++: class IntelligentScissorsMB
  17. /**
  18. * Intelligent Scissors image segmentation
  19. *
  20. * This class is used to find the path (contour) between two points
  21. * which can be used for image segmentation.
  22. *
  23. * Usage example:
  24. * SNIPPET: snippets/imgproc_segmentation.cpp usage_example_intelligent_scissors
  25. *
  26. * Reference: <a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.138.3811&rep=rep1&type=pdf">"Intelligent Scissors for Image Composition"</a>
  27. * algorithm designed by Eric N. Mortensen and William A. Barrett, Brigham Young University
  28. * CITE: Mortensen95intelligentscissors
  29. *
  30. * Member of `Imgproc`
  31. */
  32. CV_EXPORTS @interface IntelligentScissorsMB : NSObject
  33. #ifdef __cplusplus
  34. @property(readonly)cv::Ptr<cv::segmentation::IntelligentScissorsMB> nativePtr;
  35. #endif
  36. #ifdef __cplusplus
  37. - (instancetype)initWithNativePtr:(cv::Ptr<cv::segmentation::IntelligentScissorsMB>)nativePtr;
  38. + (instancetype)fromNative:(cv::Ptr<cv::segmentation::IntelligentScissorsMB>)nativePtr;
  39. #endif
  40. #pragma mark - Methods
  41. //
  42. // cv::segmentation::IntelligentScissorsMB::IntelligentScissorsMB()
  43. //
  44. - (instancetype)init;
  45. //
  46. // IntelligentScissorsMB cv::segmentation::IntelligentScissorsMB::setWeights(float weight_non_edge, float weight_gradient_direction, float weight_gradient_magnitude)
  47. //
  48. /**
  49. * Specify weights of feature functions
  50. *
  51. * Consider keeping weights normalized (sum of weights equals to 1.0)
  52. * Discrete dynamic programming (DP) goal is minimization of costs between pixels.
  53. *
  54. * @param weight_non_edge Specify cost of non-edge pixels (default: 0.43f)
  55. * @param weight_gradient_direction Specify cost of gradient direction function (default: 0.43f)
  56. * @param weight_gradient_magnitude Specify cost of gradient magnitude function (default: 0.14f)
  57. */
  58. - (IntelligentScissorsMB*)setWeights:(float)weight_non_edge weight_gradient_direction:(float)weight_gradient_direction weight_gradient_magnitude:(float)weight_gradient_magnitude NS_SWIFT_NAME(setWeights(weight_non_edge:weight_gradient_direction:weight_gradient_magnitude:));
  59. //
  60. // IntelligentScissorsMB cv::segmentation::IntelligentScissorsMB::setGradientMagnitudeMaxLimit(float gradient_magnitude_threshold_max = 0.0f)
  61. //
  62. /**
  63. * Specify gradient magnitude max value threshold
  64. *
  65. * Zero limit value is used to disable gradient magnitude thresholding (default behavior, as described in original article).
  66. * Otherwize pixels with `gradient magnitude >= threshold` have zero cost.
  67. *
  68. * NOTE: Thresholding should be used for images with irregular regions (to avoid stuck on parameters from high-contract areas, like embedded logos).
  69. *
  70. * @param gradient_magnitude_threshold_max Specify gradient magnitude max value threshold (default: 0, disabled)
  71. */
  72. - (IntelligentScissorsMB*)setGradientMagnitudeMaxLimit:(float)gradient_magnitude_threshold_max NS_SWIFT_NAME(setGradientMagnitudeMaxLimit(gradient_magnitude_threshold_max:));
  73. /**
  74. * Specify gradient magnitude max value threshold
  75. *
  76. * Zero limit value is used to disable gradient magnitude thresholding (default behavior, as described in original article).
  77. * Otherwize pixels with `gradient magnitude >= threshold` have zero cost.
  78. *
  79. * NOTE: Thresholding should be used for images with irregular regions (to avoid stuck on parameters from high-contract areas, like embedded logos).
  80. *
  81. */
  82. - (IntelligentScissorsMB*)setGradientMagnitudeMaxLimit NS_SWIFT_NAME(setGradientMagnitudeMaxLimit());
  83. //
  84. // IntelligentScissorsMB cv::segmentation::IntelligentScissorsMB::setEdgeFeatureZeroCrossingParameters(float gradient_magnitude_min_value = 0.0f)
  85. //
  86. /**
  87. * Switch to "Laplacian Zero-Crossing" edge feature extractor and specify its parameters
  88. *
  89. * This feature extractor is used by default according to article.
  90. *
  91. * Implementation has additional filtering for regions with low-amplitude noise.
  92. * This filtering is enabled through parameter of minimal gradient amplitude (use some small value 4, 8, 16).
  93. *
  94. * NOTE: Current implementation of this feature extractor is based on processing of grayscale images (color image is converted to grayscale image first).
  95. *
  96. * NOTE: Canny edge detector is a bit slower, but provides better results (especially on color images): use setEdgeFeatureCannyParameters().
  97. *
  98. * @param gradient_magnitude_min_value Minimal gradient magnitude value for edge pixels (default: 0, check is disabled)
  99. */
  100. - (IntelligentScissorsMB*)setEdgeFeatureZeroCrossingParameters:(float)gradient_magnitude_min_value NS_SWIFT_NAME(setEdgeFeatureZeroCrossingParameters(gradient_magnitude_min_value:));
  101. /**
  102. * Switch to "Laplacian Zero-Crossing" edge feature extractor and specify its parameters
  103. *
  104. * This feature extractor is used by default according to article.
  105. *
  106. * Implementation has additional filtering for regions with low-amplitude noise.
  107. * This filtering is enabled through parameter of minimal gradient amplitude (use some small value 4, 8, 16).
  108. *
  109. * NOTE: Current implementation of this feature extractor is based on processing of grayscale images (color image is converted to grayscale image first).
  110. *
  111. * NOTE: Canny edge detector is a bit slower, but provides better results (especially on color images): use setEdgeFeatureCannyParameters().
  112. *
  113. */
  114. - (IntelligentScissorsMB*)setEdgeFeatureZeroCrossingParameters NS_SWIFT_NAME(setEdgeFeatureZeroCrossingParameters());
  115. //
  116. // IntelligentScissorsMB cv::segmentation::IntelligentScissorsMB::setEdgeFeatureCannyParameters(double threshold1, double threshold2, int apertureSize = 3, bool L2gradient = false)
  117. //
  118. /**
  119. * Switch edge feature extractor to use Canny edge detector
  120. *
  121. * NOTE: "Laplacian Zero-Crossing" feature extractor is used by default (following to original article)
  122. *
  123. * @see `Canny`
  124. */
  125. - (IntelligentScissorsMB*)setEdgeFeatureCannyParameters:(double)threshold1 threshold2:(double)threshold2 apertureSize:(int)apertureSize L2gradient:(BOOL)L2gradient NS_SWIFT_NAME(setEdgeFeatureCannyParameters(threshold1:threshold2:apertureSize:L2gradient:));
  126. /**
  127. * Switch edge feature extractor to use Canny edge detector
  128. *
  129. * NOTE: "Laplacian Zero-Crossing" feature extractor is used by default (following to original article)
  130. *
  131. * @see `Canny`
  132. */
  133. - (IntelligentScissorsMB*)setEdgeFeatureCannyParameters:(double)threshold1 threshold2:(double)threshold2 apertureSize:(int)apertureSize NS_SWIFT_NAME(setEdgeFeatureCannyParameters(threshold1:threshold2:apertureSize:));
  134. /**
  135. * Switch edge feature extractor to use Canny edge detector
  136. *
  137. * NOTE: "Laplacian Zero-Crossing" feature extractor is used by default (following to original article)
  138. *
  139. * @see `Canny`
  140. */
  141. - (IntelligentScissorsMB*)setEdgeFeatureCannyParameters:(double)threshold1 threshold2:(double)threshold2 NS_SWIFT_NAME(setEdgeFeatureCannyParameters(threshold1:threshold2:));
  142. //
  143. // IntelligentScissorsMB cv::segmentation::IntelligentScissorsMB::applyImage(Mat image)
  144. //
  145. /**
  146. * Specify input image and extract image features
  147. *
  148. * @param image input image. Type is #CV_8UC1 / #CV_8UC3
  149. */
  150. - (IntelligentScissorsMB*)applyImage:(Mat*)image NS_SWIFT_NAME(applyImage(image:));
  151. //
  152. // IntelligentScissorsMB cv::segmentation::IntelligentScissorsMB::applyImageFeatures(Mat non_edge, Mat gradient_direction, Mat gradient_magnitude, Mat image = Mat())
  153. //
  154. /**
  155. * Specify custom features of input image
  156. *
  157. * Customized advanced variant of applyImage() call.
  158. *
  159. * @param non_edge Specify cost of non-edge pixels. Type is CV_8UC1. Expected values are `{0, 1}`.
  160. * @param gradient_direction Specify gradient direction feature. Type is CV_32FC2. Values are expected to be normalized: `x^2 + y^2 == 1`
  161. * @param gradient_magnitude Specify cost of gradient magnitude function: Type is CV_32FC1. Values should be in range `[0, 1]`.
  162. * @param image **Optional parameter**. Must be specified if subset of features is specified (non-specified features are calculated internally)
  163. */
  164. - (IntelligentScissorsMB*)applyImageFeatures:(Mat*)non_edge gradient_direction:(Mat*)gradient_direction gradient_magnitude:(Mat*)gradient_magnitude image:(Mat*)image NS_SWIFT_NAME(applyImageFeatures(non_edge:gradient_direction:gradient_magnitude:image:));
  165. /**
  166. * Specify custom features of input image
  167. *
  168. * Customized advanced variant of applyImage() call.
  169. *
  170. * @param non_edge Specify cost of non-edge pixels. Type is CV_8UC1. Expected values are `{0, 1}`.
  171. * @param gradient_direction Specify gradient direction feature. Type is CV_32FC2. Values are expected to be normalized: `x^2 + y^2 == 1`
  172. * @param gradient_magnitude Specify cost of gradient magnitude function: Type is CV_32FC1. Values should be in range `[0, 1]`.
  173. */
  174. - (IntelligentScissorsMB*)applyImageFeatures:(Mat*)non_edge gradient_direction:(Mat*)gradient_direction gradient_magnitude:(Mat*)gradient_magnitude NS_SWIFT_NAME(applyImageFeatures(non_edge:gradient_direction:gradient_magnitude:));
  175. //
  176. // void cv::segmentation::IntelligentScissorsMB::buildMap(Point sourcePt)
  177. //
  178. /**
  179. * Prepares a map of optimal paths for the given source point on the image
  180. *
  181. * NOTE: applyImage() / applyImageFeatures() must be called before this call
  182. *
  183. * @param sourcePt The source point used to find the paths
  184. */
  185. - (void)buildMap:(Point2i*)sourcePt NS_SWIFT_NAME(buildMap(sourcePt:));
  186. //
  187. // void cv::segmentation::IntelligentScissorsMB::getContour(Point targetPt, Mat& contour, bool backward = false)
  188. //
  189. /**
  190. * Extracts optimal contour for the given target point on the image
  191. *
  192. * NOTE: buildMap() must be called before this call
  193. *
  194. * @param targetPt The target point
  195. * @param contour The list of pixels which contains optimal path between the source and the target points of the image. Type is CV_32SC2 (compatible with `std::vector<Point>`)
  196. * @param backward Flag to indicate reverse order of retrived pixels (use "true" value to fetch points from the target to the source point)
  197. */
  198. - (void)getContour:(Point2i*)targetPt contour:(Mat*)contour backward:(BOOL)backward NS_SWIFT_NAME(getContour(targetPt:contour:backward:));
  199. /**
  200. * Extracts optimal contour for the given target point on the image
  201. *
  202. * NOTE: buildMap() must be called before this call
  203. *
  204. * @param targetPt The target point
  205. * @param contour The list of pixels which contains optimal path between the source and the target points of the image. Type is CV_32SC2 (compatible with `std::vector<Point>`)
  206. */
  207. - (void)getContour:(Point2i*)targetPt contour:(Mat*)contour NS_SWIFT_NAME(getContour(targetPt:contour:));
  208. @end
  209. NS_ASSUME_NONNULL_END