Detect edges (amplitude and direction) using the Sobel operator.
::sobel_dir 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 und b denote the results of
convolving an image with A und B for one particular pixel.)
'sum_sqrt' sqrt(a^2 + b^2)
'sum_abs' (|a| + |b|) / 2
For a Sobel operator with size 3x3, the
corresponding filters A and B are applied directly, while for
larger filter sizes (Size = 5,7,9 and 11) the input image
is first smoothed using a Gaussian filter of size Size-2.
Therefore,
sobel_dir(I:Amp,Dir:FilterType,S)
for Size > 3 is equivalent to
gauss_image(I:G:S-2) >
sobel_dir(G:Amp,Dir:FilterType,3).
The edge directions are returned in EdgeDirection, and
are stored in 2-degree steps, i.e., an edge direction of x
degrees with respect to the horizontal axis is stored as x / 2
in the edge direction image. Furthermore, the direction
of the change of intensity is taken into account. Let
[Ex,Ey] denote the image gradient. Then the
following edge directions are returned as r/2:
intensity increase Ex / Ey edge direction r from bottom to top 0 / + 0 from lower right to upper left + / - ]0,90[ from right to left + / 0 90 from upper right to lower left + / + ]90,180[ from top to bottom 0 / + 180 from upper left to lower right - / + ]180,270[ from left to right + / 0 270 from lower left to upper right - / - ]270,360[.Points with edge amplitude 0 are assigned the edge direction 255 (undefined direction).
|
Image (input_object) |
(multichannel-)image(-array) -> Hobject: HImage(Array) ( byte / int2 ) |
| Input image. | |
|
EdgeAmplitude (output_object) |
(multichannel-)image(-array) -> Hobject * : HImage(Array) ( byte / int2 ) |
| Edge amplitude (gradient magnitude) image. | |
|
EdgeDirection (output_object) |
multichannel-image(-array) -> Hobject * : HImage(Array) ( direction ) |
| Edge direction image. | |
|
FilterType (input_control) |
string -> HTuple.char * |
| Filter type. | |
| Default value: 'sum_abs' | |
| List of values: 'sum_abs', 'sum_sqrt' | |
|
Size (input_control) |
integer -> HTuple.long |
| Size of filter mask. | |
| Default value: 3 | |
| List of values: 3, 5, 7, 9, 11, 13 | |
read_image(&Image,"fabrik"); sobel_dir(Image,&Amp,&Dir,"sum_abs",3); threshold(Amp,&Edg,128.0,255.0);
::sobel_dir returns 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>). If necessary, an exception handling is raised.
::gauss_image, ::mean_image, ::anisotrope_diff, ::sigma_image
::nonmax_suppression_dir, ::hysteresis_threshold, ::threshold
::edges_image, ::frei_dir, ::kirsch_dir, ::prewitt_dir, ::robinson_dir
::roberts, ::laplace, ::highpass_image, ::bandpass_image
Image filters