public class CannyOperation extends java.lang.Object implements DatasetOperation
Modifier and Type | Class and Description |
---|---|
static class |
CannyOperation.AutoThreshold
Whether and how to attempt automatic calculation of the lower and upper thresholds.
|
Modifier and Type | Field and Description |
---|---|
(package private) int[] |
cardinals
Cardinal points - horizontal, vertical, and diagonal.
|
Constructor and Description |
---|
CannyOperation()
Constructs a new Canny Edge detector, denoising input with a Gaussian Blur of radius 5 and calculating
gradients with a standard Sobel edge detector.
|
CannyOperation(BlurOperation blurOperation,
SobelOperation convolutionOperation)
Constructs a new Canny Edge detector with the specified denoise operation and gradient operation
|
CannyOperation(BlurOperation blurOperation,
SobelOperation convolutionOperation,
CannyOperation.AutoThreshold autoThreshold)
Constructs a new Canny Edge detector with the specified denoise operation and gradient operation
|
CannyOperation(int blurRadius)
Constructs a new Canny Edge detector, denoising input with a Gaussian Blur of the specified radius and
calculating gradients with a standard Sobel edge detector.
|
Modifier and Type | Method and Description |
---|---|
CannyOperation.AutoThreshold |
getAutoThreshold()
Returns the current settings for auto thresholding
|
BlurOperation |
getBlurOperation()
Returns the smoothing operation used to denoise input data.
|
SobelOperation |
getGradientOperation()
Returns the operation used to calculate horizontal and vertical gradients.
|
double |
getLowerThreshold()
Gets the "weak" or lower threshold for edge detection - elements with values less than this value are not
considered edges and are rejected.
|
java.util.Map<java.lang.String,java.lang.Object> |
getObjectMap()
Creates a map of the important fields for the instance, suitable for serialization.
|
long |
getSerializationVersion()
Returns the current version of the serialization format.
|
double |
getSigmaThreshold()
Returns the current threshold parameter for auto-thresholding based on the mean or median.
|
double |
getUpperThreshold()
Gets the "strong" or upper threshold for edge detection - elements with values greater than or equal to
this value are considered edges.
|
int |
getVersion()
Returns the current class version.
|
double |
gradMax(Dataset input,
int i,
int j,
double angle)
Calculates the local maximum along the gradient.
|
Dataset |
hysteresis(Dataset input)
Calculates the "hysteresis thresholding" of the input.
|
void |
initCurrentVersion(java.util.Map<java.lang.String,java.lang.Object> objectMap)
Initializes an instance with a current-version object graph.
|
double |
roundToCardinal(double radians)
Rounds the specified angle in radians to the closest cardinal direction
|
Dataset |
run(Dataset input)
Runs the operation on an input.
|
void |
setAutoThreshold(CannyOperation.AutoThreshold autoThreshold)
Sets the auto thresholding
|
void |
setBlurOperation(BlurOperation blurOperation)
Sets the operation used to denoise data prior to edge detection.
|
void |
setGradientOperation(SobelOperation gradientOperation)
Sets the operation used to calculate horizontal and vertical gradients
|
void |
setLowerThreshold(double lowerThreshold)
Sets the "weak" or lower threshold for edge detection - elements with values greater than or equal to
this value are considered edges.
|
void |
setSigmaThreshold(double sigmaThreshold)
Sets the threshold parameter for auto-thresholding based on the mean or median
|
void |
setUpperThreshold(double upperThreshold)
Sets the "strong" or upper threshold for edge detection - elements with values greater than or equal to
this value are considered edges.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
init, initPreviousVersion, initUnknownVersion, load, read, save, write
int[] cardinals
public CannyOperation(BlurOperation blurOperation, SobelOperation convolutionOperation, CannyOperation.AutoThreshold autoThreshold)
blurOperation
- BlurOperation used to smooth and denoise input dataconvolutionOperation
- ConvolutionOperation used to calculate horizontal and vertical gradientsautoThreshold
- whether/how to automatically determine thresholdspublic CannyOperation(BlurOperation blurOperation, SobelOperation convolutionOperation)
blurOperation
- BlurOperation used to smooth and denoise input dataconvolutionOperation
- ConvolutionOperation used to calculate horizontal and vertical gradientspublic CannyOperation()
public CannyOperation(int blurRadius)
blurRadius
- radius of smoothing operationpublic Dataset run(Dataset input)
DatasetOperation
run
in interface DatasetOperation
input
- Dataset on which to operatepublic Dataset hysteresis(Dataset input)
input
- Dataset to thresholdpublic double roundToCardinal(double radians)
radians
- angle in radianspublic double gradMax(Dataset input, int i, int j, double angle)
input
- input dataseti
- center element's horizontal index within inputj
- center element's vertical index within inputangle
- angle of gradient at point i, jpublic BlurOperation getBlurOperation()
public void setBlurOperation(BlurOperation blurOperation)
blurOperation
- smoothing operationpublic SobelOperation getGradientOperation()
public void setGradientOperation(SobelOperation gradientOperation)
gradientOperation
- gradient operation to usepublic double getUpperThreshold()
public void setUpperThreshold(double upperThreshold)
upperThreshold
- strong threshold valuepublic double getLowerThreshold()
public void setLowerThreshold(double lowerThreshold)
lowerThreshold
- weak threshold valuepublic CannyOperation.AutoThreshold getAutoThreshold()
public void setAutoThreshold(CannyOperation.AutoThreshold autoThreshold)
autoThreshold
- new thresholding settingpublic double getSigmaThreshold()
public void setSigmaThreshold(double sigmaThreshold)
sigmaThreshold
- parameter between 0 and 1public long getSerializationVersion()
ObjectMap
getSerializationVersion
in interface ObjectMap
public int getVersion()
ObjectMap
getVersion
in interface ObjectMap
public java.util.Map<java.lang.String,java.lang.Object> getObjectMap()
ObjectMap
getObjectMap
in interface ObjectMap
public void initCurrentVersion(java.util.Map<java.lang.String,java.lang.Object> objectMap)
ObjectMap
initCurrentVersion
in interface ObjectMap
objectMap
- object graph for initialization