Detect edges (amplitude) using the Sobel operator.
sobel_amp 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
'thin_sum_abs' (thin(|a|) + thin(|b|)) / 2
'thin_max_abs' max(thin(|a|),thin(|b|))
'x' b
'y' a
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' and '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 (Size =
5,7,9 and 11) the input image is first smoothed using a Gaussian
filter of size Size-2. Therefore,
sobel_amp(I:E:FilterType,S)
for Size > 3 is equivalent to
gauss_image(I:G:S-2) >
sobel_amp(G:E:FilterType,3).
|
Image (input_object) |
(multichannel-)image(-array) -> object : byte / int2 / uint2 |
| Input image. | |
|
EdgeAmplitude (output_object) |
(multichannel-)image(-array) -> object : int1 / int2 / uint2 |
| Edge amplitude (gradient magnitude) image. | |
|
FilterType (input_control) |
string -> string |
| Filter type. | |
| Default value: 'sum_abs' | |
| List of values: 'sum_abs', 'thin_sum_abs', 'thin_max_abs', 'sum_sqrt', 'x', 'y' | |
|
Size (input_control) |
integer -> integer |
| Size of filter mask. | |
| Default value: 3 | |
| List of values: 3, 5, 7, 9, 11, 13 | |
read_image(Image,'fabrik') sobel_amp(Image,Amp,'sum_abs',3) threshold(Amp,Edg,128,255).
sobel_amp 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>). If necessary, an exception handling is raised.
sobel_amp is reentrant and automatically parallelized (on tuple level, channel level, domain level).
gauss_image, mean_image, anisotrope_diff, sigma_image
threshold, nonmax_suppression_amp, gray_skeleton
frei_amp, roberts, kirsch_amp, prewitt_amp, robinson_amp
laplace, highpass_image, bandpass_image
Image filters