CannyEdgeDetector2d
Performs Canny's computational approach to edge detection on a two-dimensional grayscale image.
Access to parameter description
This algorithm extracts the local maxima of a smoothed gradient image by applying the following steps:
To complete the Canny edge detector method, a thresholding by hysteresis must be applied on this output image afterward.
A second output provides an estimation of the two threshold values necessary to perform this step.
Reference: J.F.Canny. "A computational approach to edge detection." IEEE Transactions on Pattern Analysis and Machine Intelligence, vol.8, No 6, pp. 679-698, Nov. 1986.
See also
Access to parameter description
This algorithm extracts the local maxima of a smoothed gradient image by applying the following steps:
- Gaussian filtering
- Gradient computation
- Non maximum suppression in the gradient direction
To complete the Canny edge detector method, a thresholding by hysteresis must be applied on this output image afterward.
A second output provides an estimation of the two threshold values necessary to perform this step.
Reference: J.F.Canny. "A computational approach to edge detection." IEEE Transactions on Pattern Analysis and Machine Intelligence, vol.8, No 6, pp. 679-698, Nov. 1986.
See also
Function Syntax
This function returns a CannyEdgeDetector2dOutput structure containing outputImage and outputMeasurement.
// Output structure of the cannyEdgeDetector2d function. struct CannyEdgeDetector2dOutput { /// The output grayscale image representing the detected edges. std::shared_ptr< iolink::ImageView > outputImage; /// The output measurement provides the estimated parameters of the threshold values used by the hysteresis. CannyEdgeDetectorMsr::Ptr outputMeasurement; }; // Function prototype
CannyEdgeDetector2dOutput cannyEdgeDetector2d( std::shared_ptr< iolink::ImageView > inputImage, iolink::Vector2d standardDeviation, std::shared_ptr< iolink::ImageView > outputImage = nullptr, CannyEdgeDetectorMsr::Ptr outputMeasurement = nullptr );
This function returns a tuple containing output_image and output_measurement.
// Function prototype. canny_edge_detector_2d(input_image: idt.ImageType, standard_deviation: Union[Iterable[int], Iterable[float]] = [1, 1], output_image: idt.ImageType = None, output_measurement: Union[Any, None] = None) -> Tuple[idt.ImageType, CannyEdgeDetectorMsr]
This function returns a CannyEdgeDetector2dOutput structure containing outputImage and outputMeasurement.
/// Output structure of the CannyEdgeDetector2d function. public struct CannyEdgeDetector2dOutput { /// The output grayscale image representing the detected edges. public IOLink.ImageView outputImage; /// /// The output measurement provides the estimated parameters of the threshold values used by the hysteresis. /// public CannyEdgeDetectorMsr outputMeasurement; }; // Function prototype. public static CannyEdgeDetector2dOutput CannyEdgeDetector2d( IOLink.ImageView inputImage, double[] standardDeviation = null, IOLink.ImageView outputImage = null, CannyEdgeDetectorMsr outputMeasurement = null );
Class Syntax
Parameters
Parameter Name | Description | Type | Supported Values | Default Value | |
---|---|---|---|---|---|
inputImage |
The input grayscale image. | Image | Binary, Label, Grayscale or Multispectral | nullptr | |
standardDeviation |
The gaussian filter standard deviation value. | Vector2d | >=0.1 | {1.f, 1.f} | |
outputImage |
The output grayscale image representing the detected edges.
Its dimensions are forced to the same values as the input. Its data type is forced to floating point. |
Image | nullptr | ||
outputMeasurement |
The output measurement provides the estimated parameters of the threshold values used by the hysteresis. | CannyEdgeDetectorMsr | nullptr |
Parameter Name | Description | Type | Supported Values | Default Value | |
---|---|---|---|---|---|
input_image |
The input grayscale image. | image | Binary, Label, Grayscale or Multispectral | None | |
standard_deviation |
The gaussian filter standard deviation value. | vector2d | >=0.1 | [1, 1] | |
output_image |
The output grayscale image representing the detected edges.
Its dimensions are forced to the same values as the input. Its data type is forced to floating point. |
image | None | ||
output_measurement |
The output measurement provides the estimated parameters of the threshold values used by the hysteresis. | CannyEdgeDetectorMsr | None |
Parameter Name | Description | Type | Supported Values | Default Value | |
---|---|---|---|---|---|
inputImage |
The input grayscale image. | Image | Binary, Label, Grayscale or Multispectral | null | |
standardDeviation |
The gaussian filter standard deviation value. | Vector2d | >=0.1 | {1f, 1f} | |
outputImage |
The output grayscale image representing the detected edges.
Its dimensions are forced to the same values as the input. Its data type is forced to floating point. |
Image | null | ||
outputMeasurement |
The output measurement provides the estimated parameters of the threshold values used by the hysteresis. | CannyEdgeDetectorMsr | null |
Object Examples
auto polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" ); CannyEdgeDetector2d cannyEdgeDetector2dAlgo; cannyEdgeDetector2dAlgo.setInputImage( polystyrene ); cannyEdgeDetector2dAlgo.setStandardDeviation( {1, 1} ); cannyEdgeDetector2dAlgo.execute(); std::cout << "outputImage:" << cannyEdgeDetector2dAlgo.outputImage()->toString(); std::cout << "thresholdHigh: " << cannyEdgeDetector2dAlgo.outputMeasurement()->thresholdHigh( 0 ) ;
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif")) canny_edge_detector_2d_algo = imagedev.CannyEdgeDetector2d() canny_edge_detector_2d_algo.input_image = polystyrene canny_edge_detector_2d_algo.standard_deviation = [1, 1] canny_edge_detector_2d_algo.execute() print("output_image:", str(canny_edge_detector_2d_algo.output_image)) print("thresholdHigh: ", str(canny_edge_detector_2d_algo.output_measurement.threshold_high(0)))
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" ); CannyEdgeDetector2d cannyEdgeDetector2dAlgo = new CannyEdgeDetector2d { inputImage = polystyrene, standardDeviation = new double[]{1, 1} }; cannyEdgeDetector2dAlgo.Execute(); Console.WriteLine( "outputImage:" + cannyEdgeDetector2dAlgo.outputImage.ToString() ); Console.WriteLine( "thresholdHigh: " + cannyEdgeDetector2dAlgo.outputMeasurement.thresholdHigh( 0 ) );
Function Examples
auto polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" ); auto result = cannyEdgeDetector2d( polystyrene, {1, 1} ); std::cout << "outputImage:" << result.outputImage->toString(); std::cout << "thresholdHigh: " << result.outputMeasurement->thresholdHigh( 0 ) ;
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif")) result_output_image, result_output_measurement = imagedev.canny_edge_detector_2d(polystyrene, [1, 1]) print("output_image:", str(result_output_image)) print("thresholdHigh: ", str(result_output_measurement.threshold_high(0)))
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" ); Processing.CannyEdgeDetector2dOutput result = Processing.CannyEdgeDetector2d( polystyrene, new double[]{1, 1} ); Console.WriteLine( "outputImage:" + result.outputImage.ToString() ); Console.WriteLine( "thresholdHigh: " + result.outputMeasurement.thresholdHigh( 0 ) );