Halcyon sobel_amp 使用Sobel运算符检测边缘


sobel_amp 使用Sobel运算符检测边缘(幅度)。

sobel_amp(Image : EdgeAmplitude : FilterType, Size : )

sobel_amp计算图像的一阶导数,并用作边缘检测器。过滤器基于以下过滤器掩码

 

 

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.) 

根据选择的滤镜类型,这些遮罩的使用方式有所不同。 (以下,a和b表示针对一个特定像素将图像与A和B卷积的结果。)

 

 

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 the input image is first smoothed using a Gaussian filter (see gauss_image) or a binomial filter (see binomial_filter) of size Size-2. The Gaussian filter is selected for the above values of FilterType. Here, Size = 5, 7, 9, 11, or 13 must be used. The binomial filter is selected by appending '_binomial' to the above values of FilterType. Here, 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. Here, the first value of 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, 

在这里,thin(x)分别等于垂直最大值(掩码A)和水平最大值(掩码B)的x,否则等于0。因此,对于“ thin_sum_abs”和“ thin_max_abs”,梯度图像变薄。对于过滤器类型“ x”和“ y”,如果输入图像为字节类型,则输出图像为int1类型,否则为int2类型。对于大小为3x3的Sobel运算符,将直接应用相应的过滤器A和B,而对于较大的过滤器,则首先使用大小为2的高斯过滤器(请参阅gauss_image)或二项式过滤器(请参见binomial_filter)对输入图像进行平滑处理。 。为FilterType的上述值选择了高斯滤波器。在这里,必须使用Size = 5、7、9、11或13。通过将“ _binomial”附加到上述FilterType的值来选择二项式过滤器。在此,可以在5到39之间选择大小。此外,可以通过传递两个值来选择不同的平滑列和行方向的量。在此,Size的第一个值对应于二项式滤波器的掩模宽度(沿列方向平滑),而第二个值对应于二项式滤波器的掩模高度(沿行方向平滑)。二项式过滤器只能用于字节,uint2和实数类型的图像。由于平滑会减小边缘幅度,因此在这种情况下,边缘幅度会乘以2倍,以防止信息丢失。因此,

sobel_amp(I,E,FilterType,S)

for Size > 3 is conceptually equivalent to

对于Size> 3在概念上等效于

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_amp special optimizations are implemented FilterType = 'sum_abs' that use SIMD technology. The actual application of these special optimizations is controlled by the system parameter 'mmx_enable' (see set_system). If 'mmx_enable' is set to '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_amp might even take significantly more time with SIMD technology than without.

对于sobel_amp,使用SIMD技术实现了FilterType ='sum_abs'的特殊优化。这些特殊优化的实际应用由系统参数“ mmx_enable”(请参见set_system)控制。如果将“ mmx_enable”设置为“ true”(并且SIMD指令集可用),则使用SIMD技术执行内部计算。请注意,SIMD技术在大型紧凑的输入区域上表现最佳。根据输入区域和硬件功能的不同,使用SIMD技术执行sobel_amp所花费的时间甚至可能要比不使用SIMD技术花费的时间多得多。

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

sobel_amp可以在OpenCL设备上针对过滤器类型“ sum_abs”,“ sum_sqrt”,“ x”和“ y”(及其二项式变量)执行。请注意,当对大小> 3使用高斯滤波时,结果可能因CPU实现而异。

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.

请注意,如果使用缩小域的图像作为输入,则过滤器运算符可能会返回意外结果。请参阅过滤器一章。

Parameters(参数)

Image (input_object) 
    Input image.(预处理图片)
EdgeAmplitude (output_object) 
    Edge amplitude (gradient magnitude) image.(边缘幅度(梯度幅度)图像)
FilterType (input_control)  string 
    Filter type. (滤波类型)
    Default value: 'sum_abs'  (默认值:'sum_abs')
    List of values: 'sum_abs', 'sum_abs_binomial', 'sum_sqrt', 'sum_sqrt_binomial', 'thin_max_abs', 'thin_max_abs_binomial', 'thin_sum_abs', 'thin_sum_abs_binomial', 'x', 'x_binomial', 'y', 'y_binomial'
    List of values (for compute devices): 'sum_abs', 'sum_sqrt', 'x', 'y', 'sum_abs_binomial', 'sum_sqrt_binomial', 'x_binomial', 'y_binomial'
Size (input_control) integer(-array) → (integer)
    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)


Result (输出结果)

sobel_amp 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>). If necessary, an exception is raised.

如果所有参数正确,则sobel_amp返回2(H_MSG_TRUE)。如果输入为空,则可以通过set_system('no_object_result',<Result>)设置行为。如有必要,将引发异常。

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM