1 2 1
0 0 0
-1 -2 -1
b =
1 0 -1
2 0 -2
1 0 -1
EdgeAmplitude output -- 边缘强度图像
FilterType
'sum_sqrt' sqrt(a^2 + b^2) / 4
'sum_abs' (|a| + |b|) / 4
'thin_sum_abs' (thin(|a|) + thin(|b|)) / 4
'thin_max_abs' max(thin(|a|),thin(|b|)) / 4
'x' b / 4
'y' a / 4
read_image(Image,'fuse')
get_image_size(Image,Width,Height)
dev_open_window(0,0,Width,Height,'black',WindowHandle)
sobel_amp(Image,EdgeAmplitude,'thin_sum_abs',3)
threshold(EdgeAmplitude,Region,30,255)
skeleton(Region,Skeleton)
is the best of the old-fashioned filters. It combines speed with a reasonable quality. The corresponding
operators are called sobel_amp and sobel_dir.
In contrast, edges_image provides the state of the art of edge filters. This operator is actually more
than just a filter. It includes a thinning of the edges using a non-maximum suppression and a hysteresis
threshold for the selection of significant edge points. It also returns the edge direction and the edge
amplitude very accurately, which is not the case with the Sobel filter. This operator is recommended if
higher quality is more important than a longer execution time. If the images are not noisy or blurred,
you can even combine accuracy and speed by using the mode ’sobel_fast’ inside edges_image. The
corresponding operator to find edges in multi-channel images, e.g., a color image, is edges_color.
amplitude ,如果图像不是很多噪声且要追求追求高质量推荐使用此运算符。
The easiest way to extract the edges from the edge amplitude image is to apply threshold to select
pixels with a high edge amplitude. The result of this step is a region that contains all edge points. With
skeleton, these edges can be thinned to a width of one pixel. As an advanced version for threshold,
hysteresis_threshold can be used to eliminate insignificant edges. A further advanced option is to
call the operator nonmax_suppression_dir before skeleton, which in difficult cases may result in
more accurate edges. Note that in order to use this operator you must have computed the edge direction
image.
In contrast, the advanced filter edges_image already includes the non-maximum suppression and the
hysteresis threshold. Therefore, in this case a simple threshold suffices to extract edges that are one
pixel wide.
If only the edge points as a region are needed, the operator inspect_shape_model can be used. Here,
all steps including edge filtering, non-maximum suppression, and hysteresis thresholding are performed
in one step with high efficiency.
in one step with high efficiency.
This operator must be called for each connected component (result of connection) and returns all the
control points of the line segments. As an alternative, a Hough transform can be used to obtain the
line segments. Here, the operators hough_lines_dir and hough_lines are available. You can also
convert the edge region into XLD contours by using, e.g., the operator gen_contours_skeleton_xld.
page 81, e.g., for contour segmentation, feature extraction, or approximation.
You can extract the regions enclosed by the edges easily using background_seg. If regions merge
because of gaps in the edges, the operators close_edges or close_edges_length can be used in
advance to close the gaps before regions are extracted. As an alternative, morphological operators like
opening_circle can be applied to the output regions of background_seg. In general, all operators
described for the method Process Regions on page 33 can be applied here as well.
read_image(Image,'mreut')
get_image_size(Image,Width,Height)
dev_close_window()
dev_open_window(0,0,Width,Height,'black',WindowHandle)
edges_image (Image, ImaAmp, ImaDir, 'canny', 1, 'nms', 20, 40)
threshold (ImaDir, Regions,1, 255)
connection(Regions,ConnectionRegions)
count_obj(ConnectionRegions,Number)
gen_empty_obj(XLDContours)
dev_clear_window()
for i :=1 to Number by 1
select_obj(ConnectionRegions,SingleEdgeObject,i)
split_skeleton_lines(SingleEdgeObject,2,BeginRow,BeginCol,EndRow,EndCol)
for k :=0 to |BeginRow|-1 by 1
gen_contour_polygon_xld(Contour,[BeginRow[k],EndRow[k]],[BeginCol[k],\
EndCol[k]])
concat_obj(XLDContours,Contour,XLDContours)
endfor
endfor
dev_display(XLDContours)
dev_update_window('off')
dev_update_pc('off')
dev_update_var('off')
read_image(Image,'olympic_stadium')
get_image_size(Image,Width,Height)
dev_close_window()
dev_open_window(0,0,Width,Height,'black',WindowHandle)
edges_color (Image, ImaAmp, ImaDir, 'canny', 1, 'nms', 20, 40)
threshold(ImaAmp,RegionColor,1,255)
skeleton(RegionColor,EdgesColor)
dev_display(Image)
dev_display(EdgesColor)
stop()