Horus Doc || Global Function Guide || General documentation   | Function documentation  

HxCannyThreshold

Synopsis

HxImageRep HxCannyThreshold (HxImageRep img, double sigma, double level)

Input

HxImageRep img
The 2D scalar image you want to determine the edges of.

double sigma
The standard deviation of the Gaussian kernel that is used to calculate the canny edge map.

double level
The threshold level for the grayvalue of the edges.

Return value

HxImageRep
The resulting 2D integer image.

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

Valid input images
This function is only properly defined for 2D images with scalar pixels.

Valid values for sigma and level
This function is only properly defined for sigma greater than 0. `Level' can have any double value.

Border handling
This function uses MIRRORED border handling, see the section on Border handling.

Possible overflow
For very large values of the level parameter, this function can result in an overflow.

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;
}

exampleImage1.gif

Input image for the HxCannyThreshold example.

HxCannyThresholdResult1.gif

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,


Generated on Mon Jan 27 15:44:58 2003 for GlobalFunctionGuide by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001