- 引言
- 一、结果
- 1.1 Halcon演示结果
- 1.2 MFC演示结果
- 二、Halcon代码
- 2.1 area_center (Operator)分析
使用MFC联合Halcon,将HDevelop中的演示结果用MFC中对话框的形式显示,使用area_center (Operator)计算区域的面积和区域的中心坐标。
一、结果 1.1 Halcon演示结果 1.2 MFC演示结果
二、Halcon代码
//Read an image with different file formats. read_image (Image, 'fabrik') dev_close_window () //Open a new graphics window. dev_open_window (0, 0, 512, 512, 'black', WindowID) set_display_font (WindowID, 14, 'sans', 'true', 'false') dev_set_colored (6) //Segment an image using regiongrowing. regiongrowing (Image, Regions, 1, 1, 3, 200) dev_set_draw ('margin') dev_display (Regions) // Area and center of regions area_center (Regions, Area, Row, Column) //Get the spatial size of a string get_string_extents (WindowID, 12345, Ascent, Descent, TxtWidth, TxtHeight) for I := 0 to |Area| - 1 by 1 disp_message (WindowID, Area[I], 'image', Row[I] - TxtHeight / 2, Column[I] - TxtWidth / 2, 'white', 'false') endfor2.1 area_center (Operator)分析
area_center — 区域的面积和中心。
area_center(Regions : : : Area, Row, Column) //参数 Regions (input_object) //要检查的区域 Area (output_control) //区域的面积 Row (output_control) //中心的线索引 Column (output_control) //中心的列索引
运算符 area_center 计算输入区域的面积和中心。 面积定义为一个区域的像素数。 中心分别计算为所有像素的行或列坐标的平均值。
如果传递了多个区域,则结果存储在元组中,元组中值的索引对应于输入区域的索引。 在空区域的情况下,如果没有设置其他行为(请参阅 set_system),则所有参数的值都为 0.0。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)