cv::segmentation::IntelligentScissorsMB Class ReferenceImage Processing » Image Segmentation Примеры с cv2.imshow требуют сборки OpenCV с GUI. В ноутбуке с headless-версией используйте вывод изображений через Matplotlib.
cv::segmentation::IntelligentScissorsMB Class Reference
Intelligent Scissors image segmentation.
More...
#include <opencv2/imgproc/segmentation.hpp>
Collaboration diagram for cv::segmentation::IntelligentScissorsMB:
The documentation for this class was generated from the following file:
Specify input image and extract image features.
Specify custom features of input image.
Prepares a map of optimal paths for the given source point on the image.
Extracts optimal contour for the given target point on the image.
Switch edge feature extractor to use Canny edge detector.
Switch to "Laplacian Zero-Crossing" edge feature extractor and specify its parameters.
Specify gradient magnitude max value threshold.
Specify weights of feature functions.
Detailed Description Intelligent Scissors image segmentation.
This class is used to find the path (contour) between two points which can be used for image segmentation.
Usage example:
segmentation ::IntelligentScissorsMB tool ;
tool .setEdgeFeatureCannyParameters (16 , 100 )
.setGradientMagnitudeMaxLimit (200 );
tool .applyImage (image );
Point source_point (200 , 100 );
tool .buildMap (source_point );
Point target_point (400 , 300 );
std ::vector <Point > pts ;
tool .getContour (target_point , pts );Reference: "Intelligent Scissors for Image Composition" algorithm designed by Eric N. Mortensen and William A. Barrett, Brigham Young University [205]
Constructor & Destructor Documentation
IntelligentScissorsMB()
cv::segmentation::IntelligentScissorsMB::IntelligentScissorsMB ( )
Python: cv.segmentation.IntelligentScissorsMB( ) -> <segmentation_IntelligentScissorsMB object>
Member Function Documentation
applyImage()
Python: cv.segmentation.IntelligentScissorsMB.applyImage( image ) -> retval
Specify input image and extract image features.
Parameters
applyImageFeatures()
Python: cv.segmentation.IntelligentScissorsMB.applyImageFeatures( non_edge, gradient_direction, gradient_magnitude[, image] ) -> retval
Specify custom features of input image.
Customized advanced variant of applyImage() call.
Parameters
non_edge Specify cost of non-edge pixels. Type is CV_8UC1. Expected values are {0, 1}. gradient_direction Specify gradient direction feature. Type is CV_32FC2. Values are expected to be normalized: x^2 + y^2 == 1 gradient_magnitude Specify cost of gradient magnitude function: Type is CV_32FC1. Values should be in range [0, 1]. image . Must be specified if subset of features is specified (non-specified features are calculated internally)
buildMap()
void cv::segmentation::IntelligentScissorsMB::buildMap ( const Point & sourcePt )
Python: cv.segmentation.IntelligentScissorsMB.buildMap( sourcePt ) -> None
Prepares a map of optimal paths for the given source point on the image.
Parameters
sourcePt The source point used to find the paths
getContour()
void cv::segmentation::IntelligentScissorsMB::getContour ( const Point & targetPt , OutputArray contour , bool backward = false ) const
Python: cv.segmentation.IntelligentScissorsMB.getContour( targetPt[, contour[, backward]] ) -> contour
Extracts optimal contour for the given target point on the image.
Parameters
targetPt The target point [out] 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>) backward
setEdgeFeatureCannyParameters()
IntelligentScissorsMB & cv::segmentation::IntelligentScissorsMB::setEdgeFeatureCannyParameters ( double threshold1 , double threshold2 , int apertureSize = 3 , bool L2gradient = false )
Python: cv.segmentation.IntelligentScissorsMB.setEdgeFeatureCannyParameters( threshold1, threshold2[, apertureSize[, L2gradient]] ) -> retval
Switch edge feature extractor to use Canny edge detector.
"Laplacian Zero-Crossing" feature extractor is used by default (following to original article)
setEdgeFeatureZeroCrossingParameters()
IntelligentScissorsMB & cv::segmentation::IntelligentScissorsMB::setEdgeFeatureZeroCrossingParameters ( float gradient_magnitude_min_value = 0.0f )
Python: cv.segmentation.IntelligentScissorsMB.setEdgeFeatureZeroCrossingParameters( [, gradient_magnitude_min_value] ) -> retval
Switch to "Laplacian Zero-Crossing" edge feature extractor and specify its parameters.
This feature extractor is used by default according to article.
Implementation has additional filtering for regions with low-amplitude noise. This filtering is enabled through parameter of minimal gradient amplitude (use some small value 4, 8, 16).
Current implementation of this feature extractor is based on processing of grayscale images (color image is converted to grayscale image first).
Canny edge detector is a bit slower, but provides better results (especially on color images): use setEdgeFeatureCannyParameters() .
Parameters
gradient_magnitude_min_value Minimal gradient magnitude value for edge pixels (default: 0, check is disabled)
setGradientMagnitudeMaxLimit()
IntelligentScissorsMB & cv::segmentation::IntelligentScissorsMB::setGradientMagnitudeMaxLimit ( float gradient_magnitude_threshold_max = 0.0f )
Python: cv.segmentation.IntelligentScissorsMB.setGradientMagnitudeMaxLimit( [, gradient_magnitude_threshold_max] ) -> retval
Specify gradient magnitude max value threshold.
Zero limit value is used to disable gradient magnitude thresholding (default behavior, as described in original article). Otherwize pixels with gradient magnitude >= threshold have zero cost.
Thresholding should be used for images with irregular regions (to avoid stuck on parameters from high-contract areas, like embedded logos).
Parameters
gradient_magnitude_threshold_max Specify gradient magnitude max value threshold (default: 0, disabled)
setWeights()
IntelligentScissorsMB & cv::segmentation::IntelligentScissorsMB::setWeights ( float weight_non_edge , float weight_gradient_direction , float weight_gradient_magnitude )
Python: cv.segmentation.IntelligentScissorsMB.setWeights( weight_non_edge, weight_gradient_direction, weight_gradient_magnitude ) -> retval
Specify weights of feature functions.
Consider keeping weights normalized (sum of weights equals to 1.0) Discrete dynamic programming (DP) goal is minimization of costs between pixels.
Parameters
weight_non_edge Specify cost of non-edge pixels (default: 0.43f) weight_gradient_direction Specify cost of gradient direction function (default: 0.43f) weight_gradient_magnitude Specify cost of gradient magnitude function (default: 0.14f)
Optional parameter
Here is the call graph for this function:
Flag to indicate reverse order of retrieved pixels (use "true" value to fetch points from the target to the source point)