Show / Hide Table of Contents

Class IntelligentScissorsMB

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: Intelligent Scissors for Image Composition http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.138.3811&rep=rep1&type=pdf algorithm designed by Eric N. Mortensen and William A. Barrett, Brigham Young University @cite Mortensen95intelligentscissors

Inheritance
System.Object
DisposableObject
DisposableCvObject
IntelligentScissorsMB
Implements
ICvPtrHolder
Inherited Members
DisposableCvObject.ptr
DisposableCvObject.CvPtr
DisposableObject.DataHandle
DisposableObject.IsDisposed
DisposableObject.IsEnabledDispose
DisposableObject.AllocatedMemory
DisposableObject.AllocatedMemorySize
DisposableObject.Dispose()
DisposableObject.Dispose(Boolean)
DisposableObject.DisposeManaged()
DisposableObject.AllocGCHandle(Object)
DisposableObject.AllocMemory(Int32)
DisposableObject.NotifyMemoryPressure(Int64)
DisposableObject.ThrowIfDisposed()
Namespace: OpenCvSharp.Segmentation
Assembly: OpenCvSharp.dll
Syntax
public class IntelligentScissorsMB : DisposableCvObject, ICvPtrHolder

Constructors

| Improve this Doc View Source

IntelligentScissorsMB()

Constructor

Declaration
public IntelligentScissorsMB()

Methods

| Improve this Doc View Source

ApplyImage(InputArray)

Specify input image and extract image features

Declaration
public IntelligentScissorsMB ApplyImage(InputArray image)
Parameters
Type Name Description
InputArray image

input image. Type is #CV_8UC1 / #CV_8UC3

Returns
Type Description
IntelligentScissorsMB
| Improve this Doc View Source

ApplyImageFeatures(InputArray, InputArray, InputArray, InputArray)

Specify custom features of imput image Customized advanced variant of applyImage() call.

Declaration
public IntelligentScissorsMB ApplyImageFeatures(InputArray nonEdge, InputArray gradientDirection, InputArray gradientMagnitude, InputArray image = null)
Parameters
Type Name Description
InputArray nonEdge

Specify cost of non-edge pixels. Type is CV_8UC1. Expected values are {0, 1}.

InputArray gradientDirection

Specify gradient direction feature. Type is CV_32FC2. Values are expected to be normalized: x^2 + y^2 == 1

InputArray gradientMagnitude

Specify cost of gradient magnitude function: Type is CV_32FC1. Values should be in range [0, 1].

InputArray image

Optional parameter. Must be specified if subset of features is specified (non-specified features are calculated internally)

Returns
Type Description
IntelligentScissorsMB
| Improve this Doc View Source

BuildMap(Point)

Prepares a map of optimal paths for the given source point on the image Note: applyImage() / applyImageFeatures() must be called before this call

Declaration
public void BuildMap(Point sourcePt)
Parameters
Type Name Description
OpenCvSharp.Point sourcePt

The source point used to find the paths

| Improve this Doc View Source

DisposeUnmanaged()

Releases unmanaged resources

Declaration
protected override void DisposeUnmanaged()
Overrides
DisposableCvObject.DisposeUnmanaged()
| Improve this Doc View Source

GetContour(Point, OutputArray, Boolean)

Extracts optimal contour for the given target point on the image Note: buildMap() must be called before this call

Declaration
public void GetContour(Point targetPt, OutputArray contour, bool backward = false)
Parameters
Type Name Description
OpenCvSharp.Point targetPt

The target point

OutputArray contour

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>)

System.Boolean backward

Flag to indicate reverse order of retrived pixels (use "true" value to fetch points from the target to the source point)

| Improve this Doc View Source

SetEdgeFeatureCannyParameters(Double, Double, Int32, Boolean)

Switch edge feature extractor to use Canny edge detector Note: "Laplacian Zero-Crossing" feature extractor is used by default (following to original article)

Declaration
public IntelligentScissorsMB SetEdgeFeatureCannyParameters(double threshold1, double threshold2, int apertureSize = 3, bool l2gradient = false)
Parameters
Type Name Description
System.Double threshold1
System.Double threshold2
System.Int32 apertureSize
System.Boolean l2gradient
Returns
Type Description
IntelligentScissorsMB
| Improve this Doc View Source

SetEdgeFeatureZeroCrossingParameters(Single)

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().

Declaration
public IntelligentScissorsMB SetEdgeFeatureZeroCrossingParameters(float gradientMagnitudeMinValue = 0F)
Parameters
Type Name Description
System.Single gradientMagnitudeMinValue

Minimal gradient magnitude value for edge pixels (default: 0, check is disabled)

Returns
Type Description
IntelligentScissorsMB
| Improve this Doc View Source

SetGradientMagnitudeMaxLimit(Single)

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.

@note Thresholding should be used for images with irregular regions (to avoid stuck on parameters from high-contract areas, like embedded logos).

Declaration
public IntelligentScissorsMB SetGradientMagnitudeMaxLimit(float gradientMagnitudeThresholdMax = 0F)
Parameters
Type Name Description
System.Single gradientMagnitudeThresholdMax

Specify gradient magnitude max value threshold (default: 0, disabled)

Returns
Type Description
IntelligentScissorsMB
| Improve this Doc View Source

SetWeights(Single, Single, Single)

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.

Declaration
public IntelligentScissorsMB SetWeights(float weightNonEdge, float weightGradientDirection, float weightGradientMagnitude)
Parameters
Type Name Description
System.Single weightNonEdge

Specify cost of non-edge pixels (default: 0.43f)

System.Single weightGradientDirection

Specify cost of gradient direction function (default: 0.43f)

System.Single weightGradientMagnitude

Specify cost of gradient magnitude function (default: 0.14f)

Returns
Type Description
IntelligentScissorsMB

Implements

ICvPtrHolder
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX