一 如何跟进特征过滤区域和XLD
dev_open_window(0,0,512,512,'black',WindowHandle)
read_image(Image,'fabrik')
threshold(Image,Region,128,255)
connection(Region,ConnectedRegions)
*根据面积范围[8000,9000]
dev_display(Image)
select_shape(ConnectedRegions,SelectedRegions,'area','and',8000,9000)
dev_display(Image)
dev_display(SelectedRegions)
*算子select_shape_std将给定区域的形状与默认形状进行比较。如果该区域具有相似的形状,则输出相似的形状
select_shape_std(ConnectedRegions,SelectedContours1,'rectangle1',90)
dev_display(Image)
dev_display(SelectedContours1)
*算子select_shape_proto过滤出彼此具有一定关系区域
select_shape_proto(ConnectedRegions,SelectedRegions,SelectedRegions2,'distance_center',0,200)
dev_display(Image)
dev_display(SelectedRegions2)
二 程序运行时间
count_seconds(T1)
read_image(Image,'fabrik')
get_image_size(Image,Width,Height)
dev_open_window(0,0,Width,Height,'black',WindowHandle)
count_seconds(T2)
RunTime:=(T2-T1)*1000
dev_display(Image)
disp_message (WindowHandle, '程序运行的时间: '+RunTime+' ms', 'window', 10, 10, 'black', 'true')
三 绘制ROI
dev_open_window(0,0,512,512,'black',WindowHandle)
dev_set_draw('margin')
*画圆
draw_circle(WindowHandle,Row,Column,Radius)
gen_circle(Circle, Row, Column, Radius)
*画椭圆
draw_ellipse(WindowHandle,Row1, Column1, Phi, Radius1, Radius2)
gen_ellipse(Ellipse, Row1, Column1, Phi, Radius1, Radius2)
*画不规则区域
draw_polygon(PolygonRegion, WindowHandle)
draw_line(WindowHandle,Row11, Column11, Row2, Column2)
disp_line(WindowHandle, Row11, Column11, Row2, Column2)
*画标准矩形
draw_rectangle1(WindowHandle,Row12, Column12, Row21, Column21)
gen_rectangle1(Rectangle, Row12, Column12, Row21, Column21)
*画仿射矩形
draw_rectangle2(WindowHandle,Row3, Column3, Phi1, Length1, Length2)
gen_rectangle2(Rectangle1, Row3, Column3, Phi1, Length1, Length2)
*画闭合区域
draw_region(Region, WindowHandle)
四 如何将Bayer图像转换为彩色图像
定义:bayer格式图片是伊士曼·柯达公司科学家Bryce Bayer发明的,Bryce Bayer所发明的拜耳阵列被广泛运用数字图像。
Bayer图像排列形式:
Bayer图像如何转换为RGB:
*读取图像
read_image(Image,'patras')
*获取图像大小
get_image_size(Image,Width,Height)
*打开窗口
dev_open_window(0,0,Width, Height, 'black', WindowHandle)
*显示窗口
dev_display(Image)
*模拟Bayer图像
simulate_bayer_image (Image, ImageCFA)
*产生一个空的对象
gen_empty_obj(RGBImage)
*Bayer图像转换为RGB图像
cfa_to_rgb(ImageCFA,RGBImage,'bayer_gb','bilinear')
*显示RGBt图像
dev_display(RGBImage)
五 如何将图像转化为矩阵形式
* 读取一张图像
read_image(Image,'fabrik')
*获取图像大小
get_image_size(Image,Width, Height)
*获取区域里各点的坐标
get_region_points(Image,Rows,Columns)
*获取图像中每一点的像素值和坐标位置
get_grayval(Image,Rows, Columns, Grayval)
*创建一个空的矩阵
create_matrix(Height,Width,0,GrayMatrix)
*为矩阵填充图像数据
set_value_matrix(GrayMatrix, Rows,Columns,Grayval)