ImageDev

CannyEdgeDetector3d

Performs Canny's computational approach to edge detection on a three-dimensional grayscale image.

Access to parameter description

This algorithm extracts the local maxima of a smoothed gradient image by applying the following steps: The output image is a grayscale image representing the detected contours with one pixel thickness.

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 CannyEdgeDetector3dOutput structure containing outputImage and outputMeasurement.
// Output structure of the cannyEdgeDetector3d function.
struct CannyEdgeDetector3dOutput
{
    /// 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
CannyEdgeDetector3dOutput cannyEdgeDetector3d( std::shared_ptr< iolink::ImageView > inputImage, iolink::Vector3d 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_3d(input_image: idt.ImageType,
                       standard_deviation: Union[Iterable[int], Iterable[float]] = [1, 1, 1],
                       output_image: idt.ImageType = None,
                       output_measurement: Union[Any, None] = None) -> Tuple[idt.ImageType, CannyEdgeDetectorMsr]
This function returns a CannyEdgeDetector3dOutput structure containing outputImage and outputMeasurement.
/// Output structure of the CannyEdgeDetector3d function.
public struct CannyEdgeDetector3dOutput
{
    /// 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 CannyEdgeDetector3dOutput
CannyEdgeDetector3d( IOLink.ImageView inputImage,
                     double[] standardDeviation = null,
                     IOLink.ImageView outputImage = null,
                     CannyEdgeDetectorMsr outputMeasurement = null );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
inputImage
The input grayscale image. Image Binary, Label, Grayscale or Multispectral nullptr
input
standardDeviation
The gaussian filter standard deviation value. Vector3d >=0.1 {1.f, 1.f, 1.f}
output
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
output
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
input_image
The input grayscale image. image Binary, Label, Grayscale or Multispectral None
input
standard_deviation
The gaussian filter standard deviation value. vector3d >=0.1 [1, 1, 1]
output
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
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
input
inputImage
The input grayscale image. Image Binary, Label, Grayscale or Multispectral null
input
standardDeviation
The gaussian filter standard deviation value. Vector3d >=0.1 {1f, 1f, 1f}
output
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
output
outputMeasurement
The output measurement provides the estimated parameters of the threshold values used by the hysteresis. CannyEdgeDetectorMsr null

Object Examples

auto foam = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam.vip" );

CannyEdgeDetector3d cannyEdgeDetector3dAlgo;
cannyEdgeDetector3dAlgo.setInputImage( foam );
cannyEdgeDetector3dAlgo.setStandardDeviation( {1, 1, 1} );
cannyEdgeDetector3dAlgo.execute();

std::cout << "outputImage:" << cannyEdgeDetector3dAlgo.outputImage()->toString();
std::cout << "thresholdHigh: " << cannyEdgeDetector3dAlgo.outputMeasurement()->thresholdHigh( 0 ) ;
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip"))

canny_edge_detector_3d_algo = imagedev.CannyEdgeDetector3d()
canny_edge_detector_3d_algo.input_image = foam
canny_edge_detector_3d_algo.standard_deviation = [1, 1, 1]
canny_edge_detector_3d_algo.execute()

print("output_image:", str(canny_edge_detector_3d_algo.output_image))
print("thresholdHigh: ", str(canny_edge_detector_3d_algo.output_measurement.threshold_high(0)))
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" );

CannyEdgeDetector3d cannyEdgeDetector3dAlgo = new CannyEdgeDetector3d
{
    inputImage = foam,
    standardDeviation = new double[]{1, 1, 1}
};
cannyEdgeDetector3dAlgo.Execute();

Console.WriteLine( "outputImage:" + cannyEdgeDetector3dAlgo.outputImage.ToString() );
Console.WriteLine( "thresholdHigh: " + cannyEdgeDetector3dAlgo.outputMeasurement.thresholdHigh( 0 ) );

Function Examples

auto foam = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam.vip" );

auto result = cannyEdgeDetector3d( foam, {1, 1, 1} );

std::cout << "outputImage:" << result.outputImage->toString();
std::cout << "thresholdHigh: " << result.outputMeasurement->thresholdHigh( 0 ) ;
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip"))

result_output_image, result_output_measurement = imagedev.canny_edge_detector_3d(foam, [1, 1, 1])

print("output_image:", str(result_output_image))
print("thresholdHigh: ", str(result_output_measurement.threshold_high(0)))
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" );

Processing.CannyEdgeDetector3dOutput result = Processing.CannyEdgeDetector3d( foam, new double[]{1, 1, 1} );

Console.WriteLine( "outputImage:" + result.outputImage.ToString() );
Console.WriteLine(  "thresholdHigh: " + result.outputMeasurement.thresholdHigh( 0 )  );