5, derivate_gauss.hdev
a)高斯导数滤波用作 平滑滤波器(使用分水岭watershed得到contours)(用于很多小块的图像)
read_image...
derivate_gauss(Meningg5,Smoothed, 2, 'none')
用一个图片Image和一个高斯函数的导数求卷积,从而计算出不同的特征值。sigma控制高斯函数,当sigma为一个值时候,行和列的方向上sigma相同,当sigma为两个值时候,第一个控制列的程度,第二个控制行的程度。‘none’这里指Smoothing only,其余参数请自行查看帮助文档。
convert_image_type(Smoothed, SmoothedByte,'byte')
watersheds(SmoothedByte, Basins, Watersheds)
找出图片的分水岭和凹陷块区域,用于图片分割
b) 高斯导数滤波用作边缘检测
read_image....
derivate_gauss(Image,GradientAmp1, 1.5,'gradient')
threshold....
c) 高斯导数滤波用作角检测?
derivate(Image, Det, 1.5, 'det')
threshold(Det, Corners, 20, 1000000)
d ) 高斯导数滤波用作边缘检测( 二阶导数)
derivate_gauss(Image, EdgesAreZero, 3, '2nd_ddg')
zero_crossing(EdgesAreZero, Edges)
(zero_crossing returns the zero crossings of the input image as a region. A pixel is accepted as a zero crossing if its gray value (in
Image) is zero, or if at least one of its neighbors of the 4-neighborhood has a different sign.
This operator is intended to be used after edge operators returning the second derivative of the image (e.g., laplace_of_gauss), which were possibly followed by a smoothing operator. In this case, the zero crossings are (candidates for) edges.)
6, 各种滤波
diff_of_gauss + zero_crossing
laplace_of_gauss + zero_crossing
derivate_gauss + zero_crossing
7,显示一个保存边界的XLD对象
read_image
edges_sub_pix(Image,Edges, 'mderiche2', 0.7, 10,20)
使用Deriche, Lanser, Shen, or Canny滤波器来精确检测边缘
edges_image(Image, ImaAmp, ImaDir,'mderiche2', 0.7,'nms',10, 20)
使用Deriche, Lanser, Shen, or Canny滤波器来检测边缘,并得到边缘的幅值和方向
count_seconds(a1) 记录当前时间
disp_xld(Edges, WindowID)
count_seconds(a2)
Time:=a2-a1
记录执行下面一步所用的时间
8, edge_segments.hdev 边缘分割
read_image...
get_image_size(Image, Width, Height)
dev_open_window_fit_image
显示
edges_image(Image, ImaAmp, ImaDir,'lanser2', 0.5,'nms',20, 40)
lanser精度很高, 用来计算边界
threshold
connection
用来提取出边界
边界的显示:
count_obj(ConnectedRegions, Number)
gen_empty_obj(XLDContours) 用来存储边界
for i:=1 to Number by 1
select_obj(ConnectedRegions, 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