Class IntelligentScissorsMB


  • public class IntelligentScissorsMB
    extends java.lang.Object
    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: SNIPPET: snippets/imgproc_segmentation.cpp usage_example_intelligent_scissors 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> algorithm designed by Eric N. Mortensen and William A. Barrett, Brigham Young University CITE: Mortensen95intelligentscissors
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected long nativeObj  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static IntelligentScissorsMB __fromPtr__​(long addr)  
      IntelligentScissorsMB applyImage​(Mat image)
      Specify input image and extract image features
      IntelligentScissorsMB applyImageFeatures​(Mat non_edge, Mat gradient_direction, Mat gradient_magnitude)
      Specify custom features of imput image Customized advanced variant of applyImage() call.
      IntelligentScissorsMB applyImageFeatures​(Mat non_edge, Mat gradient_direction, Mat gradient_magnitude, Mat image)
      Specify custom features of imput image Customized advanced variant of applyImage() call.
      void buildMap​(Point sourcePt)
      Prepares a map of optimal paths for the given source point on the image Note: applyImage() / applyImageFeatures() must be called before this call
      protected void finalize()  
      void getContour​(Point targetPt, Mat contour)
      Extracts optimal contour for the given target point on the image Note: buildMap() must be called before this call
      void getContour​(Point targetPt, Mat contour, boolean backward)
      Extracts optimal contour for the given target point on the image Note: buildMap() must be called before this call
      long getNativeObjAddr()  
      IntelligentScissorsMB setEdgeFeatureCannyParameters​(double threshold1, double threshold2)
      Switch edge feature extractor to use Canny edge detector Note: "Laplacian Zero-Crossing" feature extractor is used by default (following to original article) SEE: Canny
      IntelligentScissorsMB setEdgeFeatureCannyParameters​(double threshold1, double threshold2, int apertureSize)
      Switch edge feature extractor to use Canny edge detector Note: "Laplacian Zero-Crossing" feature extractor is used by default (following to original article) SEE: Canny
      IntelligentScissorsMB setEdgeFeatureCannyParameters​(double threshold1, double threshold2, int apertureSize, boolean L2gradient)
      Switch edge feature extractor to use Canny edge detector Note: "Laplacian Zero-Crossing" feature extractor is used by default (following to original article) SEE: Canny
      IntelligentScissorsMB setEdgeFeatureZeroCrossingParameters()
      Switch to "Laplacian Zero-Crossing" edge feature extractor and specify its parameters This feature extractor is used by default according to article.
      IntelligentScissorsMB setEdgeFeatureZeroCrossingParameters​(float gradient_magnitude_min_value)
      Switch to "Laplacian Zero-Crossing" edge feature extractor and specify its parameters This feature extractor is used by default according to article.
      IntelligentScissorsMB setGradientMagnitudeMaxLimit()
      Specify gradient magnitude max value threshold Zero limit value is used to disable gradient magnitude thresholding (default behavior, as described in original article).
      IntelligentScissorsMB setGradientMagnitudeMaxLimit​(float gradient_magnitude_threshold_max)
      Specify gradient magnitude max value threshold Zero limit value is used to disable gradient magnitude thresholding (default behavior, as described in original article).
      IntelligentScissorsMB setWeights​(float weight_non_edge, float weight_gradient_direction, float weight_gradient_magnitude)
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • nativeObj

        protected final long nativeObj
    • Constructor Detail

      • IntelligentScissorsMB

        protected IntelligentScissorsMB​(long addr)
      • IntelligentScissorsMB

        public IntelligentScissorsMB()
    • Method Detail

      • getNativeObjAddr

        public long getNativeObjAddr()
      • setWeights

        public IntelligentScissorsMB setWeights​(float weight_non_edge,
                                                float weight_gradient_direction,
                                                float weight_gradient_magnitude)
        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)
        Returns:
        automatically generated
      • setGradientMagnitudeMaxLimit

        public IntelligentScissorsMB setGradientMagnitudeMaxLimit​(float gradient_magnitude_threshold_max)
        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 &gt;= threshold have zero cost. Note: 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)
        Returns:
        automatically generated
      • setGradientMagnitudeMaxLimit

        public IntelligentScissorsMB setGradientMagnitudeMaxLimit()
        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 &gt;= threshold have zero cost. Note: Thresholding should be used for images with irregular regions (to avoid stuck on parameters from high-contract areas, like embedded logos).
        Returns:
        automatically generated
      • setEdgeFeatureZeroCrossingParameters

        public IntelligentScissorsMB setEdgeFeatureZeroCrossingParameters​(float gradient_magnitude_min_value)
        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). Note: Current implementation of this feature extractor is based on processing of grayscale images (color image is converted to grayscale image first). Note: 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)
        Returns:
        automatically generated
      • setEdgeFeatureZeroCrossingParameters

        public IntelligentScissorsMB setEdgeFeatureZeroCrossingParameters()
        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). Note: Current implementation of this feature extractor is based on processing of grayscale images (color image is converted to grayscale image first). Note: Canny edge detector is a bit slower, but provides better results (especially on color images): use setEdgeFeatureCannyParameters().
        Returns:
        automatically generated
      • setEdgeFeatureCannyParameters

        public IntelligentScissorsMB setEdgeFeatureCannyParameters​(double threshold1,
                                                                   double threshold2,
                                                                   int apertureSize,
                                                                   boolean L2gradient)
        Switch edge feature extractor to use Canny edge detector Note: "Laplacian Zero-Crossing" feature extractor is used by default (following to original article) SEE: Canny
        Parameters:
        threshold1 - automatically generated
        threshold2 - automatically generated
        apertureSize - automatically generated
        L2gradient - automatically generated
        Returns:
        automatically generated
      • setEdgeFeatureCannyParameters

        public IntelligentScissorsMB setEdgeFeatureCannyParameters​(double threshold1,
                                                                   double threshold2,
                                                                   int apertureSize)
        Switch edge feature extractor to use Canny edge detector Note: "Laplacian Zero-Crossing" feature extractor is used by default (following to original article) SEE: Canny
        Parameters:
        threshold1 - automatically generated
        threshold2 - automatically generated
        apertureSize - automatically generated
        Returns:
        automatically generated
      • setEdgeFeatureCannyParameters

        public IntelligentScissorsMB setEdgeFeatureCannyParameters​(double threshold1,
                                                                   double threshold2)
        Switch edge feature extractor to use Canny edge detector Note: "Laplacian Zero-Crossing" feature extractor is used by default (following to original article) SEE: Canny
        Parameters:
        threshold1 - automatically generated
        threshold2 - automatically generated
        Returns:
        automatically generated
      • applyImage

        public IntelligentScissorsMB applyImage​(Mat image)
        Specify input image and extract image features
        Parameters:
        image - input image. Type is #CV_8UC1 / #CV_8UC3
        Returns:
        automatically generated
      • applyImageFeatures

        public IntelligentScissorsMB applyImageFeatures​(Mat non_edge,
                                                        Mat gradient_direction,
                                                        Mat gradient_magnitude,
                                                        Mat image)
        Specify custom features of imput 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 - Optional parameter. Must be specified if subset of features is specified (non-specified features are calculated internally)
        Returns:
        automatically generated
      • applyImageFeatures

        public IntelligentScissorsMB applyImageFeatures​(Mat non_edge,
                                                        Mat gradient_direction,
                                                        Mat gradient_magnitude)
        Specify custom features of imput 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].
        Returns:
        automatically generated
      • buildMap

        public void buildMap​(Point sourcePt)
        Prepares a map of optimal paths for the given source point on the image Note: applyImage() / applyImageFeatures() must be called before this call
        Parameters:
        sourcePt - The source point used to find the paths
      • getContour

        public void getContour​(Point targetPt,
                               Mat contour,
                               boolean backward)
        Extracts optimal contour for the given target point on the image Note: buildMap() must be called before this call
        Parameters:
        targetPt - The target point
        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&lt;Point&gt;)
        backward - Flag to indicate reverse order of retrived pixels (use "true" value to fetch points from the target to the source point)
      • getContour

        public void getContour​(Point targetPt,
                               Mat contour)
        Extracts optimal contour for the given target point on the image Note: buildMap() must be called before this call
        Parameters:
        targetPt - The target point
        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&lt;Point&gt;)
      • finalize

        protected void finalize()
                         throws java.lang.Throwable
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable