#include "HxImageRep.h"
Go to the source code of this file.
Functions | |
HxImageRep L_HXIMAGEREP | HxCannyThreshold (HxImageRep img, double sigma, double level) |
Computes the Canny edge map of a scalar image, performs non-maxima suppression, and tresholds the norm of the resulting vector field at the given level. More... |
|
Computes the Canny edge map of a scalar image, performs non-maxima suppression, and tresholds the norm of the resulting vector field at the given level.
00017 { 00018 HxString fname("HxCannyThreshold"); 00019 00020 if (img.isNull()) 00021 { 00022 HxGlobalError::instance()->reportError(fname, img.name(), "null image", HxGlobalError::HX_GE_INVALID); 00023 return HxImageRep(); 00024 } 00025 00026 if (sigma <= 0.0) 00027 { 00028 HxGlobalError::instance()->reportError(fname, img.name(), "invalid value of sigma", HxGlobalError::HX_GE_INVALID); 00029 return HxImageRep(); 00030 } 00031 00032 if (img.signature().imageDimensionality() != 2) 00033 { 00034 HxGlobalError::instance()->reportError(fname, "only defined for 2D images", HxGlobalError::HX_GE_INVALID); 00035 return HxImageRep(); 00036 } 00037 if (img.signature().pixelDimensionality() != 1) 00038 { 00039 HxGlobalError::instance()->reportError(fname, "only defined for scalar pixel types", HxGlobalError::HX_GE_INVALID); 00040 return HxImageRep(); 00041 } 00042 00043 HxImageRep edges = HxCannyEdgeMap(img, sigma); 00044 HxImageRep nonmax = HxNonMaxSuppressionGradDir(edges); 00045 return HxThreshold(HxNorm2Sqr(nonmax), HxValue(level * level)); 00046 } |