sobel_dir sobel_dir SobelDir SobelDir sobel_dir (Operator)
Name
sobel_dir sobel_dir SobelDir SobelDir sobel_dir
— Detect edges (amplitude and direction) using the Sobel operator.
Signature
void SobelDir (const HObject& Image , HObject* EdgeAmplitude , HObject* EdgeDirection , const HTuple& FilterType , const HTuple& Size )
HImage HImage ::SobelDir (HImage* EdgeDirection , const HString& FilterType , const HTuple& Size ) const
HImage HImage ::SobelDir (HImage* EdgeDirection , const HString& FilterType , Hlong Size ) const
HImage HImage ::SobelDir (HImage* EdgeDirection , const char* FilterType , Hlong Size ) const
HImage HImage ::SobelDir (HImage* EdgeDirection , const wchar_t* FilterType , Hlong Size ) const
(
Windows only)
def sobel_dir (image : HObject, filter_type : str, size : MaybeSequence[int]) -> Tuple[HObject, HObject]
Description
sobel_dir sobel_dir SobelDir SobelDir SobelDir 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 and b denote the results of
convolving an image with A and B for one particular pixel.)
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_image gauss_image GaussImage GaussImage GaussImage gauss_image
) or a binomial filter (see
binomial_filter binomial_filter BinomialFilter BinomialFilter BinomialFilter binomial_filter
) of size
Size Size Size Size size size
-2. The Gaussian
filter is selected for the above values of
FilterType FilterType FilterType FilterType filterType filter_type
.
Here,
Size Size Size Size size size
= 5, 7, 9, 11, or 13 must be used. The binomial
filter is selected by appending
'_binomial' "_binomial" "_binomial" "_binomial" "_binomial" "_binomial" to the above
values of
FilterType FilterType FilterType FilterType filterType filter_type
. Here,
Size Size Size Size size size
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
Size Size Size Size size size
. Here, the first value of
Size Size Size Size size size
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_dir(I,Amp,Dir,FilterType,S) sobel_dir(I,Amp,Dir,FilterType,S) SobelDir(I,Amp,Dir,FilterType,S) SobelDir(I,Amp,Dir,FilterType,S) SobelDir(I,Amp,Dir,FilterType,S) sobel_dir(I,Amp,Dir,FilterType,S)
for
Size Size Size Size size size
>
3 is conceptually equivalent to
scale_image(I,F,2,0) scale_image(I,F,2,0) ScaleImage(I,F,2,0) ScaleImage(I,F,2,0) ScaleImage(I,F,2,0) scale_image(I,F,2,0)
gauss_image(F,G,S-2) gauss_image(F,G,S-2) GaussImage(F,G,S-2) GaussImage(F,G,S-2) GaussImage(F,G,S-2) gauss_image(F,G,S-2)
sobel_dir(G,Amp,Dir,FilterType,3) sobel_dir(G,Amp,Dir,FilterType,3) SobelDir(G,Amp,Dir,FilterType,3) SobelDir(G,Amp,Dir,FilterType,3) SobelDir(G,Amp,Dir,FilterType,3) sobel_dir(G,Amp,Dir,FilterType,3)
or to
scale_image(I,F,2,0) scale_image(I,F,2,0) ScaleImage(I,F,2,0) ScaleImage(I,F,2,0) ScaleImage(I,F,2,0) scale_image(I,F,2,0)
binomial_filter(F,G,S[0]-2,S[1]-2) binomial_filter(F,G,S[0]-2,S[1]-2) BinomialFilter(F,G,S[0]-2,S[1]-2) BinomialFilter(F,G,S[0]-2,S[1]-2) BinomialFilter(F,G,S[0]-2,S[1]-2) binomial_filter(F,G,S[0]-2,S[1]-2)
sobel_dir(G,Amp,Dir,FilterType,3) sobel_dir(G,Amp,Dir,FilterType,3) SobelDir(G,Amp,Dir,FilterType,3) SobelDir(G,Amp,Dir,FilterType,3) SobelDir(G,Amp,Dir,FilterType,3) sobel_dir(G,Amp,Dir,FilterType,3)
.
The edge directions are returned in
EdgeDirection EdgeDirection EdgeDirection EdgeDirection edgeDirection edge_direction
, and
are stored in 2-degree steps, i.e., an edge direction of x
degrees in mathematically positive sense and 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
denote the image gradient. Then the
following edge directions
are returned as
:
intensity increase
edge direction
[deg]
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).
sobel_amp sobel_amp SobelAmp SobelAmp SobelAmp sobel_amp
can be executed on OpenCL devices. Note that when using
gaussian filtering for Size Size Size Size size size
> 3, the results can vary from the
CPU implementation.
Attention
Note that filter operators may return unexpected results if
an image with a reduced domain is used as input. Please refer to the
chapter Filters .
Execution Information
Supports OpenCL compute devices.
Multithreading type: reentrant (runs in parallel with non-exclusive operators).
Multithreading scope: global (may be called from any thread).
Automatically parallelized on tuple level.
Automatically parallelized on channel level.
Automatically parallelized on domain level.
Parameters
Image Image Image Image image image
(input_object) (multichannel-)image(-array) →
object HImage HObject HImage Hobject (byte / int2 / uint2 / real)
Input image.
EdgeAmplitude EdgeAmplitude EdgeAmplitude EdgeAmplitude edgeAmplitude edge_amplitude
(output_object) (multichannel-)image(-array) →
object HImage HObject HImage Hobject * (byte / int2 / uint2 / real)
Edge amplitude (gradient magnitude) image.
EdgeDirection EdgeDirection EdgeDirection EdgeDirection edgeDirection edge_direction
(output_object) (multichannel-)image(-array) →
object HImage HObject HImage Hobject * (direction)
Edge direction image.
FilterType FilterType FilterType FilterType filterType filter_type
(input_control) string →
HTuple str HTuple Htuple (string) (string ) (HString ) (char* )
Filter type.
Default:
'sum_abs'
"sum_abs"
"sum_abs"
"sum_abs"
"sum_abs"
"sum_abs"
List of values:
'sum_abs' "sum_abs" "sum_abs" "sum_abs" "sum_abs" "sum_abs" , 'sum_abs_binomial' "sum_abs_binomial" "sum_abs_binomial" "sum_abs_binomial" "sum_abs_binomial" "sum_abs_binomial" , 'sum_sqrt' "sum_sqrt" "sum_sqrt" "sum_sqrt" "sum_sqrt" "sum_sqrt" , 'sum_sqrt_binomial' "sum_sqrt_binomial" "sum_sqrt_binomial" "sum_sqrt_binomial" "sum_sqrt_binomial" "sum_sqrt_binomial"
List of values (for compute devices):
'sum_abs' "sum_abs" "sum_abs" "sum_abs" "sum_abs" "sum_abs" , 'sum_sqrt' "sum_sqrt" "sum_sqrt" "sum_sqrt" "sum_sqrt" "sum_sqrt" , 'sum_abs_binomial' "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" "sum_sqrt_binomial"
Size Size Size Size size size
(input_control) integer(-array) →
HTuple MaybeSequence[int] HTuple Htuple (integer) (int / long) (Hlong ) (Hlong )
Size of filter mask.
Default:
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_dir(Image,Amp,Dir,'sum_abs',3)
threshold(Amp,Edg,128,255)
Example (C)
read_image(&Image,"fabrik");
sobel_dir(Image,&Amp,&Dir,"sum_abs",3);
threshold(Amp,&Edg,128.0,255.0);
Example (HDevelop)
read_image(Image,'fabrik')
sobel_dir(Image,Amp,Dir,'sum_abs',3)
threshold(Amp,Edg,128,255)
Example (HDevelop)
read_image(Image,'fabrik')
sobel_dir(Image,Amp,Dir,'sum_abs',3)
threshold(Amp,Edg,128,255)
Example (HDevelop)
read_image(Image,'fabrik')
sobel_dir(Image,Amp,Dir,'sum_abs',3)
threshold(Amp,Edg,128,255)
Result
sobel_dir sobel_dir SobelDir SobelDir SobelDir sobel_dir
returns 2 (
H_MSG_TRUE )
if all parameters are
correct. If the input is empty the behavior can be set via
set_system('no_object_result',<Result>) set_system("no_object_result",<Result>) SetSystem("no_object_result",<Result>) SetSystem("no_object_result",<Result>) SetSystem("no_object_result",<Result>) set_system("no_object_result",<Result>)
. If
necessary, an exception is raised.
Possible Predecessors
binomial_filter binomial_filter BinomialFilter BinomialFilter BinomialFilter binomial_filter
,
gauss_filter gauss_filter GaussFilter GaussFilter GaussFilter gauss_filter
,
mean_image mean_image MeanImage MeanImage MeanImage mean_image
,
anisotropic_diffusion anisotropic_diffusion AnisotropicDiffusion AnisotropicDiffusion AnisotropicDiffusion anisotropic_diffusion
,
sigma_image sigma_image SigmaImage SigmaImage SigmaImage sigma_image
Possible Successors
nonmax_suppression_dir nonmax_suppression_dir NonmaxSuppressionDir NonmaxSuppressionDir NonmaxSuppressionDir nonmax_suppression_dir
,
hysteresis_threshold hysteresis_threshold HysteresisThreshold HysteresisThreshold HysteresisThreshold hysteresis_threshold
,
threshold threshold Threshold Threshold Threshold threshold
Alternatives
edges_image edges_image EdgesImage EdgesImage EdgesImage edges_image
,
frei_dir frei_dir FreiDir FreiDir FreiDir frei_dir
,
kirsch_dir kirsch_dir KirschDir KirschDir KirschDir kirsch_dir
,
prewitt_dir prewitt_dir PrewittDir PrewittDir PrewittDir prewitt_dir
,
robinson_dir robinson_dir RobinsonDir RobinsonDir RobinsonDir robinson_dir
See also
roberts roberts Roberts Roberts Roberts roberts
,
laplace laplace Laplace Laplace Laplace laplace
,
highpass_image highpass_image HighpassImage HighpassImage HighpassImage highpass_image
,
bandpass_image bandpass_image BandpassImage BandpassImage BandpassImage bandpass_image
Module
Foundation