HALCON Reference Manual 10.0.2
Table of Contents / Filters / Edges ClassesClassesClasses | | | Operators

sobel_ampsobel_ampsobel_ampSobelAmpSobelAmp (Operator)

Name

sobel_ampsobel_ampsobel_ampSobelAmpSobelAmp — Detect edges (amplitude) using the Sobel operator.

Signature

sobel_amp(Image : EdgeAmplitude : FilterType, Size : )

Herror sobel_amp(const Hobject Image, Hobject* EdgeAmplitude, const char* FilterType, const Hlong Size)

Herror T_sobel_amp(const Hobject Image, Hobject* EdgeAmplitude, const Htuple FilterType, const Htuple Size)

Herror sobel_amp(Hobject Image, Hobject* EdgeAmplitude, const HTuple& FilterType, const HTuple& Size)

HImage HImage::SobelAmp(const HTuple& FilterType, const HTuple& Size) const

HImageArray HImageArray::SobelAmp(const HTuple& FilterType, const HTuple& Size) const

void HOperatorSetX.SobelAmp(
[in] IHUntypedObjectX* Image, [out] IHUntypedObjectX*EdgeAmplitude, [in] VARIANT FilterType, [in] VARIANT Size)

IHImageX* HImageX.SobelAmp(
[in] BSTR FilterType, [in] VARIANT Size)

static void HOperatorSet.SobelAmp(HObject image, out HObject edgeAmplitude, HTuple filterType, HTuple size)

HImage HImage.SobelAmp(string filterType, HTuple size)

HImage HImage.SobelAmp(string filterType, int size)

Description

sobel_ampsobel_ampsobel_ampSobelAmpSobelAmp calculates first derivative of an image and is used as an edge detector. The filter is based on the following filter masks:

  A =
           1       2       1
           0       0       0
          -1      -2      -1

  B =
           1       0      -1
           2       0      -2
           1       0      -1

These masks are used differently, according to the selected filter type. (In the following, a and b denote the results of convolving an image with A and B for one particular pixel.)

     'sum_sqrt'              sqrt(a^2 + b^2) / 4
     'sum_abs'               (|a| + |b|) / 4
     'thin_sum_abs'          (thin(|a|) + thin(|b|)) / 4
     'thin_max_abs'          max(thin(|a|),thin(|b|)) / 4
     'x'                     b / 4
     'y'                     a / 4

Here, thin(x) is equal to x for a vertical maximum (mask A) and a horizontal maximum (mask B), respectively, and 0 otherwise. Thus, for 'thin_sum_abs' and 'thin_max_abs' the gradient image is thinned. For the filter types 'x'"x""x""x""x" and 'y'"y""y""y""y" if the input image is of type byte the output image is of type int1, of type int2 otherwise. For a Sobel operator with size 3x3, the corresponding filters A and B are applied directly, while for larger filter sizes the input image is first smoothed using a Gaussian filter (see gauss_imagegauss_imagegauss_imageGaussImageGaussImage) or a binomial filter (see binomial_filterbinomial_filterbinomial_filterBinomialFilterBinomialFilter) of size SizeSizeSizeSizesize-2. The Gaussian filter is selected for the above values of FilterTypeFilterTypeFilterTypeFilterTypefilterType. Here, SizeSizeSizeSizesize = 5, 7, 9, 11, or 13 must be used. The binomial filter is selected by appending '_binomial'"_binomial""_binomial""_binomial""_binomial" to the above values of FilterTypeFilterTypeFilterTypeFilterTypefilterType. Here, SizeSizeSizeSizesize can be selected between 5 and 39. Furthermore, it is possible to select different amounts of smoothing the column and row direction by passing two values in SizeSizeSizeSizesize. Here, the first value of SizeSizeSizeSizesize corresponds to the mask width (smoothing in the column direction), while the second value corresponds to the mask height (smoothing in the row direction) of the binomial filter. The binomial filter can only be used for images of type byte, uint2 and real. Since smoothing reduces the edge amplitudes, in this case the edge amplitudes are multiplied by a factor of 2 to prevent information loss. Therefore,

     sobel_amp(I,E,FilterType,S)

for Size > 3 is conceptually equivalent to

     scale_image(I,F,2,0)
     gauss_image(F,G,S-2)
     sobel_amp(G,E,FilterType,3)

or to

     scale_image(I,F,2,0)
     binomial_filter(F,G,S[0]-2,S[1]-2)
     sobel_amp(G,E,FilterType,3).

For sobel_ampsobel_ampsobel_ampSobelAmpSobelAmp special optimizations are implemented FilterTypeFilterTypeFilterTypeFilterTypefilterType = 'sum_abs'"sum_abs""sum_abs""sum_abs""sum_abs" that use SIMD technology. The actual application of these special optimizations is controlled by the system parameter 'mmx_enable'"mmx_enable""mmx_enable""mmx_enable""mmx_enable" (see set_systemset_systemset_systemSetSystemSetSystem). If 'mmx_enable'"mmx_enable""mmx_enable""mmx_enable""mmx_enable" is set to 'true'"true""true""true""true" (and the SIMD instruction set is available), the internal calculations are performed using SIMD technology. Note that SIMD technology performs best on large, compact input regions. Depending on the input region and the capabilities of the hardware the execution of sobel_ampsobel_ampsobel_ampSobelAmpSobelAmp might even take significantly more time with SIMD technology than without.

sobel_ampsobel_ampsobel_ampSobelAmpSobelAmp can be executed on OpenCL devices for the filter types 'sum_abs'"sum_abs""sum_abs""sum_abs""sum_abs", 'sum_sqrt'"sum_sqrt""sum_sqrt""sum_sqrt""sum_sqrt", 'x'"x""x""x""x" and 'y'"y""y""y""y" (as well as their binomial variants). Note that when using gaussian filtering for SizeSizeSizeSizesize > 3, the results can vary from the CPU implementation.

Parallelization

Parameters

ImageImageImageImageimage (input_object)  (multichannel-)image(-array) objectHImageHImageHImageXHobject (byte / int2 / uint2 / real)

Input image.

EdgeAmplitudeEdgeAmplitudeEdgeAmplitudeEdgeAmplitudeedgeAmplitude (output_object)  (multichannel-)image(-array) objectHImageHImageHImageXHobject * (int1 / int2 / uint2 / real)

Edge amplitude (gradient magnitude) image.

FilterTypeFilterTypeFilterTypeFilterTypefilterType (input_control)  string HTupleHTupleVARIANTHtuple (string) (string) (char*) (BSTR) (char*)

Filter type.

Default value: 'sum_abs' "sum_abs" "sum_abs" "sum_abs" "sum_abs"

List of values: 'sum_abs'"sum_abs""sum_abs""sum_abs""sum_abs", 'thin_sum_abs'"thin_sum_abs""thin_sum_abs""thin_sum_abs""thin_sum_abs", 'thin_max_abs'"thin_max_abs""thin_max_abs""thin_max_abs""thin_max_abs", 'sum_sqrt'"sum_sqrt""sum_sqrt""sum_sqrt""sum_sqrt", 'x'"x""x""x""x", 'y'"y""y""y""y", 'sum_abs_binomial'"sum_abs_binomial""sum_abs_binomial""sum_abs_binomial""sum_abs_binomial", 'thin_sum_abs_binomial'"thin_sum_abs_binomial""thin_sum_abs_binomial""thin_sum_abs_binomial""thin_sum_abs_binomial", 'thin_max_abs_binomial'"thin_max_abs_binomial""thin_max_abs_binomial""thin_max_abs_binomial""thin_max_abs_binomial", 'sum_sqrt_binomial'"sum_sqrt_binomial""sum_sqrt_binomial""sum_sqrt_binomial""sum_sqrt_binomial", 'x_binomial'"x_binomial""x_binomial""x_binomial""x_binomial", 'y_binomial'"y_binomial""y_binomial""y_binomial""y_binomial"

List of values (for compute devices): 'sum_abs'"sum_abs""sum_abs""sum_abs""sum_abs", 'sum_sqrt'"sum_sqrt""sum_sqrt""sum_sqrt""sum_sqrt", 'x'"x""x""x""x", 'y'"y""y""y""y", 'sum_abs_binomial'"sum_abs_binomial""sum_abs_binomial""sum_abs_binomial""sum_abs_binomial", 'sum_sqrt_binomial'"sum_sqrt_binomial""sum_sqrt_binomial""sum_sqrt_binomial""sum_sqrt_binomial", 'x_binomial'"x_binomial""x_binomial""x_binomial""x_binomial", 'y_binomial'"y_binomial""y_binomial""y_binomial""y_binomial"

SizeSizeSizeSizesize (input_control)  integer(-array) HTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong)

Size of filter mask.

Default value: 3

List of values: 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39

Example (HDevelop)

read_image(Image,'fabrik')
sobel_amp(Image,Amp,'sum_abs',3)
threshold(Amp,Edg,128,255)

Example (C)

read_image(&Image,"fabrik");
sobel_amp(Image,&Amp,"sum_abs",3);
threshold(Amp,&Edg,128.0,255.0);

Example (HDevelop)

read_image(Image,'fabrik')
sobel_amp(Image,Amp,'sum_abs',3)
threshold(Amp,Edg,128,255)

Example (HDevelop)

read_image(Image,'fabrik')
sobel_amp(Image,Amp,'sum_abs',3)
threshold(Amp,Edg,128,255)

Example (HDevelop)

read_image(Image,'fabrik')
sobel_amp(Image,Amp,'sum_abs',3)
threshold(Amp,Edg,128,255)

Result

sobel_ampsobel_ampsobel_ampSobelAmpSobelAmp returns 2 (H_MSG_TRUE) if all parameters are correct. If the input is empty the behaviour can be set via set_system('no_object_result',<Result>)set_system("no_object_result",<Result>)set_system("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>). If necessary, an exception is raised.

Possible Predecessors

binomial_filterbinomial_filterbinomial_filterBinomialFilterBinomialFilter, gauss_imagegauss_imagegauss_imageGaussImageGaussImage, mean_imagemean_imagemean_imageMeanImageMeanImage, anisotropic_diffusionanisotropic_diffusionanisotropic_diffusionAnisotropicDiffusionAnisotropicDiffusion, sigma_imagesigma_imagesigma_imageSigmaImageSigmaImage

Possible Successors

thresholdthresholdthresholdThresholdThreshold, nonmax_suppression_ampnonmax_suppression_ampnonmax_suppression_ampNonmaxSuppressionAmpNonmaxSuppressionAmp, gray_skeletongray_skeletongray_skeletonGraySkeletonGraySkeleton

Alternatives

frei_ampfrei_ampfrei_ampFreiAmpFreiAmp, robertsrobertsrobertsRobertsRoberts, kirsch_ampkirsch_ampkirsch_ampKirschAmpKirschAmp, prewitt_ampprewitt_ampprewitt_ampPrewittAmpPrewittAmp, robinson_amprobinson_amprobinson_ampRobinsonAmpRobinsonAmp

See also

laplacelaplacelaplaceLaplaceLaplace, highpass_imagehighpass_imagehighpass_imageHighpassImageHighpassImage, bandpass_imagebandpass_imagebandpass_imageBandpassImageBandpassImage

Module

Foundation


Table of Contents / Filters / Edges ClassesClassesClasses | | | Operators
HALCON Reference Manual 10.0.2 Copyright © 1996-2011 MVTec Software GmbH