classPiiEdgeDetector
#include <PiiEdgeDetector.h>
Detect edges on images.
Inherits PiiDefaultOperation
Description
The operation works by estimating the strength of local gradient with user-selectable masks. The output is thresholded to produce a binary image.
Inputs
Outputs
Properties
|
Edge detection method. |
|
|
double
|
Used in hysteresis thresholding with the Canny edge detector. |
|
double
|
The value with which the gradient magnitude is thresholded. |
Public types
|
enum
|
{ SobelDetector, RobertsDetector, PrewittDetector, CannyDetector }
Supported edge detectors. |
Constructors and destructor
|
( )
|
Public member functions
|
virtual void
|
(
Checks the operation for execution. |
|
( )
|
|
|
double
|
( )
|
|
void
|
|
|
void
|
(
|
|
void
|
(
|
|
double
|
( )
|
Protected member functions
|
virtual void
|
( )
Executes one round of processing. |
Property details
-
Detector detector
[read, write]Edge detection method.
Except for the Canny detector, the only difference between the detection methods is in the gradient estimation filters. The default is
CannyDetector. -
double lowThreshold
[read, write]Used in hysteresis thresholding with the Canny edge detector.
If set to zero, the low threshold will be 0.4 * threshold. The default is zero.
-
double threshold
[read, write]The value with which the gradient magnitude is thresholded.
Set to zero to make the operation find a suitable threshold automatically. A "suitable" value is found by adding two times the standard deviation of the gradient magnitude to the mean gradient magnitude. Default is zero.
Enumeration details
-
enum Detector
Supported edge detectors.
-
SobelDetector- Sobel masks are used to calculate gradient. -
RobertsDetector- Roberts' masks are used to calculate gradient. -
PrewittDetector- Prewitt's masks are used to calculate gradient. -
CannyDetector- The three-step procedure is used to detect edges: 1) Sobel masks are used to measure the gradient 2) the image is processed to contain only local maxima (PiiImage::suppressNonMaxima()) 3) hysteresis thresholding is performed (PiiImage::hysteresisThreshold()). This technique requires two thresholds (lowThreshold and threshold).
The original edge detection technique by Canny actually uses derivatives of 2D Gaussians to calculate the gradient. This implementation uses Sobel masks to estimate gradient. This choice was made to keep the design modular. Typically, one should prepend this operation by a PiiImageFilterOperation and set its filter to "Gaussian" to prevent spurious edges. In fact, this technique does not do much harm to the other edge detectors either.
-
Function details
-
PiiEdgeDetector
() -
virtual void check
(- bool reset
[virtual]Checks the operation for execution.
This function creates a suitable flow controller by calling createFlowController(). It then sets the flow controller to the active processor and sets the processor as the input controller for all inputs.
If you change socket groupings in your overridden implementation, please call PiiDefaultOperation::check() after that. Otherwise, your new groupings will not be in effect.
Reimplemented from PiiDefaultOperation.
-
Detector detector
() -
double lowThreshold
() -
void setDetector
-
void setLowThreshold
(- double lowThreshold
-
void setThreshold
(- double threshold
-
double threshold
() -
virtual void process
()[protected, virtual]Executes one round of processing.
This function is invoked by the processor if the necessary preconditions for a new processing round are met. This function does all the necessary calculations to create output objects and sends them to output sockets.
Calls to process(), syncEvent(), and setProperty() are synchronized and cannot occur simultaneously. PiiDefaultOperation ensures this by locking processLock() for reading before calling process().
Note: With time-consuming operations, one should occasionally check that the operation hasn't been interrupted, i.e. that state() returns
Running.Exceptions
- PiiExecutionException
-
whenever an unrecoverable error occurs during a processing round, the operation is interrupted, or finishes execution due to end of input data.
Reimplemented from PiiDefaultOperation.
Add a note
Not a single note added yet. Be the first, add yours.