Synopsis
HxImageRep HxCannyThreshold (HxImageRep img, double sigma, double level)
Input
HxImageRep img
double sigma
double level
Return value
HxImageRep
Description
The function HxCannyThresholds computes the magnitude of the gradient of img in the X- and Y-direction. Then the Euclidean norm of these gradient vectors is determined, after which it is thresholded with the double `level'.
The magnitudes of the gradient in the X- and Y-direction are calculated by convolving img with the derivative of a 1D-Gaussian in both directions. The used Gaussians have a standard deviation of sigma.
Remarks
Examples
Finding edges with HxCannyThreshold
#include "HxImageRepGlobalFuncs.h" #include "HxImageRep.h" HxImageRep HxCannyThresholdExample1(HxImageRep img) { img = HxImageAsDouble(img); img = HxCannyThreshold(img, 3.0, 5.0); img = HxContrastStretch(img, 255); img = HxImageAsByte(img); return img; } int main(int argc, char* argv[]) { HxImageRep im1 = HxMakeFromFile(argv[1]); im1 = HxCannyThresholdExample1(im1); HxWriteFile(im1, argv[2]); return 0; }
Input image for the HxCannyThreshold example.
Output image of the HxCannyThreshold example.
In this example we use HxCannyThreshold to determine the edges in a 2D scalar image. For sigma we take 3.0, for the level we take 5.0. The resulting image is stretched for proper visualisation (HxContrastStretch).
See also
HxCannyEdgeMap, HxCannyThresholdAlt,
Keywords
Edge detection, Filter, Canny,