Visual Servoing Platform
version 3.6.1 under development (2024-12-17)
|
#include <visp3/core/vpCannyEdgeDetection.h>
Public Member Functions | |
Detection methods | |
vpImage< unsigned char > | detect (const vpImage< vpRGBa > &I_color) |
vpImage< unsigned char > | detect (const vpImage< unsigned char > &I) |
Setters | |
void | setFilteringAndGradientType (const vpImageFilter::vpCannyFilteringAndGradientType &type) |
void | setGradients (const vpImage< float > &dIx, const vpImage< float > &dIy) |
void | setCannyThresholds (const float &lowerThresh, const float &upperThresh) |
void | setCannyThresholdsRatio (const float &lowerThreshRatio, const float &upperThreshRatio) |
void | setGaussianFilterParameters (const int &kernelSize, const float &stdev) |
void | setGradientFilterAperture (const unsigned int &apertureSize) |
void | setMask (const vpImage< bool > *p_mask) |
void | setMinimumStackSize (const unsigned int &requiredStackSize) |
void | setStoreEdgePoints (const bool &storeEdgePoints) |
Getters | |
std::vector< vpImagePoint > | getEdgePointsList () const |
unsigned int | getMinimumStackSize () const |
Constructors and initialization | |
vpCannyEdgeDetection () | |
vpCannyEdgeDetection (const int &gaussianKernelSize, const float &gaussianStdev, const unsigned int &sobelAperture, const float &lowerThreshold=-1.f, const float &upperThreshold=-1.f, const float &lowerThresholdRatio=0.6f, const float &upperThresholdRatio=0.8f, const vpImageFilter::vpCannyFilteringAndGradientType &filteringType=vpImageFilter::CANNY_GBLUR_SOBEL_FILTERING, const bool &storeEdgePoints=false) | |
vpCannyEdgeDetection (const std::string &jsonPath) | |
void | initFromJSON (const std::string &jsonPath) |
void | from_json (const nlohmann::json &j, vpCannyEdgeDetection &detector) |
void | to_json (nlohmann::json &j, const vpCannyEdgeDetection &detector) |
Class that implements the Canny's edge detector. It is possible to use a boolean mask to ignore some pixels of the input gray-scale image.
Definition at line 63 of file vpCannyEdgeDetection.h.
vpCannyEdgeDetection::vpCannyEdgeDetection | ( | ) |
Default constructor of the vpCannyEdgeDetection class. The thresholds used during the hysteresis thresholding step are set to be automatically computed.
Definition at line 95 of file vpCannyEdgeDetection.cpp.
vpCannyEdgeDetection::vpCannyEdgeDetection | ( | const int & | gaussianKernelSize, |
const float & | gaussianStdev, | ||
const unsigned int & | sobelAperture, | ||
const float & | lowerThreshold = -1.f , |
||
const float & | upperThreshold = -1.f , |
||
const float & | lowerThresholdRatio = 0.6f , |
||
const float & | upperThresholdRatio = 0.8f , |
||
const vpImageFilter::vpCannyFilteringAndGradientType & | filteringType = vpImageFilter::CANNY_GBLUR_SOBEL_FILTERING , |
||
const bool & | storeEdgePoints = false |
||
) |
Construct a new vpCannyEdgeDetection object that uses Gaussian blur + Sobel operators to compute the edge map.
[in] | gaussianKernelSize | : The size of the Gaussian filter kernel. Must be odd. |
[in] | gaussianStdev | : The standard deviation of the Gaussian filter. |
[in] | sobelAperture | : The size of the Sobel filters kernel. Must be odd. |
[in] | lowerThreshold | : The lower threshold of the hysteresis thresholding step. If negative, will be computed from the upper threshold. |
[in] | upperThreshold | : The upper threshold of the hysteresis thresholding step. If negative, will be computed from the histogram of the absolute gradient. |
[in] | lowerThresholdRatio | : If the thresholds must be computed,the lower threshold will be equal to the upper threshold times lowerThresholdRatio . |
[in] | upperThresholdRatio | : If the thresholds must be computed,the upper threshold will be equal to the value such as the number of pixels of the image times upperThresholdRatio have an absolute gradient lower than the upper threshold. |
[in] | filteringType | : The filtering and gradient operators to apply to the image before the edge detection operation. |
[in] | storeEdgePoints | : If true, the list of edge-points will be available using vpCannyEdgeDetection::getEdgePointsList(). |
Definition at line 114 of file vpCannyEdgeDetection.cpp.
vpCannyEdgeDetection::vpCannyEdgeDetection | ( | const std::string & | jsonPath | ) |
Construct a new vpCannyEdgeDetection object.
[in] | jsonPath | : The path towards the JSON file to use to initialize the vpCannyEdgeDetection object. |
Definition at line 144 of file vpCannyEdgeDetection.cpp.
Detect the edges in a gray-scale image.
[in] | I | : A gray-scale image, in ViSP format. |
Definition at line 255 of file vpCannyEdgeDetection.cpp.
References vpImageFilter::computeCannyThreshold(), vpException::fatalError, vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), and vpImage< Type >::resize().
Detect the edges in an image. Convert the color image into a gray-scale image.
[in] | I_color | : An RGB image, in ViSP format. |
Definition at line 247 of file vpCannyEdgeDetection.cpp.
References vpImageConvert::convert().
Referenced by vpImageFilter::canny(), and vpCircleHoughTransform::edgeDetection().
|
inline |
Get the list of edge-points that have been detected.
Definition at line 329 of file vpCannyEdgeDetection.h.
References vpException::fatalError.
|
inline |
Get the minimum stack size used by the algorithm.
Definition at line 351 of file vpCannyEdgeDetection.h.
void vpCannyEdgeDetection::initFromJSON | ( | const std::string & | jsonPath | ) |
Initialize all the algorithm parameters using the JSON file whose path is jsonPath. Throw a vpException error if the file does not exist.
[in] | jsonPath | : The path towards the JSON configuration file. |
Definition at line 153 of file vpCannyEdgeDetection.cpp.
References from_json, and vpException::ioError.
|
inline |
Set the lower and upper Canny Thresholds used to qualify the edge point candidates. Edge point candidates whose gradient is between these two values is kept only if it linked somehow to a strong edge point.
[in] | lowerThresh | : The lower threshold: each point whose gradient is below this threshold is discarded. When lower threshold value is negative, Canny recommendation is applied to have the lower threshold 3 times lower than the upper threshold. |
[in] | upperThresh | : The upper threshold: each point whose gradient is greater than this threshold is said to be a strong edge point and is kept. |
Definition at line 213 of file vpCannyEdgeDetection.h.
Referenced by vpCircleHoughTransform::edgeDetection().
|
inline |
Set the lower and upper Canny Thresholds ratio that are used to compute them automatically. To ask to compute automatically the thresholds, you must set the lower and upper thresholds with negative values using the appropriate setter.
[in] | lowerThreshRatio | : The lower threshold ratio: if the thresholds are computed automatically, the lower threshold will be equal to the upper threshold multiplied by lowerThreshRatio. |
[in] | upperThreshRatio | : The upper threshold ratio: if the thresholds are computed automatically, the upper threshold will be set such as upperThreshRatio times the number of pixels of the image have their absolute gradient lower then the upper threshold. |
Definition at line 231 of file vpCannyEdgeDetection.h.
Referenced by vpCircleHoughTransform::edgeDetection().
|
inline |
Set the Filtering And Gradient operators to apply to the image before the edge detection operation.
[in] | type | The operators to apply. |
Definition at line 183 of file vpCannyEdgeDetection.h.
Referenced by vpCircleHoughTransform::edgeDetection().
|
inline |
Set the Gaussian Filters kernel size and standard deviation and initialize the aforementioned filters.
[in] | kernelSize | : The size of the Gaussian filters kernel. |
[in] | stdev | : The standard deviation of the Gaussian filters used to blur and compute the gradient of the image. |
Definition at line 245 of file vpCannyEdgeDetection.h.
Referenced by vpCircleHoughTransform::initGaussianFilters().
|
inline |
Set the parameters of the gradient filter (Sobel or Scharr) kernel size filters.
[in] | apertureSize | The size of the gradient filters kernel. Must be an odd value. |
Definition at line 257 of file vpCannyEdgeDetection.h.
Referenced by vpCircleHoughTransform::initGradientFilters().
|
inline |
Set the Gradients of the image that will be processed.
[in] | dIx | : Gradient along the horizontal axis of the image. |
[in] | dIy | : Gradient along the vertical axis of the image. |
Definition at line 195 of file vpCannyEdgeDetection.h.
Referenced by vpImageFilter::canny(), and vpCircleHoughTransform::edgeDetection().
|
inline |
Set a mask to ignore pixels for which the mask is false.
p_mask | If different of nullptr , a mask of booleans where true indicates that a pixel must be considered and false that the pixel should be ignored. |
Definition at line 273 of file vpCannyEdgeDetection.h.
Referenced by vpImageFilter::canny(), and vpCircleHoughTransform::edgeDetection().
|
inline |
Set the minimum stack size, expressed in bytes, due to the recursive algorithm. If not called, the stack size is left at its default value when running the Canny edge detection algorithm.
[in] | requiredStackSize | The required stack size, in bytes. |
Definition at line 299 of file vpCannyEdgeDetection.h.
|
inline |
If set to true, the list of the detected edge-points will be available calling the method vpCannyEdgeDetection::getEdgePointsList().
[in] | storeEdgePoints | The new desired status. |
Definition at line 316 of file vpCannyEdgeDetection.h.
|
friend |
Read the detector configuration from JSON. All values are optional and if an argument is not present, the default value defined in the constructor is kept.
[in] | j | : The JSON object, resulting from the parsing of a JSON file. |
[out] | detector | : The detector that will be initialized from the JSON data. |
Definition at line 63 of file vpCannyEdgeDetection.cpp.
Referenced by initFromJSON().
|
friend |
Parse a vpCannyEdgeDetection object into JSON format.
[out] | j | : A JSON parser object. |
[in] | detector | : The vpCannyEdgeDetection object that must be parsed into JSON format. |
Definition at line 77 of file vpCannyEdgeDetection.cpp.