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>)設置行為。如有必要,將引發異常。