例程功能
找钻孔直径。
代码如下
dev_update_off () * **** * step: acquire image * **** read_image (Image, 'rim') get_image_size (Image, Width, Height) dev_open_window_fit_image (Image, 0, 0, Width, Height, WindowID) set_display_font (WindowID, 14, 'mono', 'true', 'false') * **** * step: determine region of interest (ROI) * **** threshold (Image, Dark, 0, 128) connection (Dark, DarkRegions) select_shape (DarkRegions, Circles, ['circularity', 'area'], 'and', [0.85, 50], [1.0, 99999]) boundary (Circles, RegionBorder, 'inner') dilation_circle (RegionBorder, RegionDilation, 6.5) union1 (RegionDilation, ROIEdges) dev_display (Image) dev_set_color ('yellow') dev_set_draw ('margin') dev_display (ROIEdges) disp_continue_message (WindowID, 'black', 'true') stop () * **** * step: extract edges * **** reduce_domain (Image, ROIEdges, ImageROI) edges_sub_pix (ImageROI, Edges, 'lanser2', 0.3, 10, 30) sort_contours_xld (Edges, SortedContours, 'upper_left', 'true', 'row') dev_display (Image) colored_display (SortedContours, ['cyan', 'white']) disp_continue_message (WindowID, 'black', 'true') stop () * **** * step: process contours * **** fit_ellipse_contour_xld (Edges, 'ftukey', -1, 2, 0, 200, 3, 2, Row, Column, Phi, Ra, Rb, StartPhi, EndPhi, PointOrder) NumHoles := |Ra| gen_ellipse_contour_xld (ContEllipse, Row, Column, Phi, Ra, Rb, gen_tuple_const(NumHoles,0), gen_tuple_const(NumHoles,rad(360)), gen_tuple_const(NumHoles,'positive'), 1) dev_display (Image) sort_contours_xld (ContEllipse, SortedContEllipse, 'upper_left', 'true', 'row') colored_display (SortedContEllipse, ['cyan', 'white']) dev_set_color ('yellow') for i := 0 to NumHoles - 1 by 1 sinPhi := sin(Phi[i]) cosPhi := cos(Phi[i]) disp_arrow (WindowID, Row[i], Column[i], Row[i] - sinPhi * Ra[i], Column[i] + cosPhi * Ra[i], 1) disp_arrow (WindowID, Row[i], Column[i], Row[i] - cosPhi * Rb[i], Column[i] - sinPhi * Rb[i], 1) disp_arrow (WindowID, Row[i], Column[i], Row[i] + sinPhi * Ra[i], Column[i] - cosPhi * Ra[i], 1) disp_arrow (WindowID, Row[i], Column[i], Row[i] + cosPhi * Rb[i], Column[i] + sinPhi * Rb[i], 1) set_tposition (WindowID, Row[i] - Rb[i] - 50, Column[i] - 85) write_string (WindowID, 'D1=' + 2 * Ra[i]) set_tposition (WindowID, Row[i] - Rb[i] - 30, Column[i] - 85) write_string (WindowID, 'D2=' + 2 * Rb[i]) endfor
要求
- 轮廓提取是一个耗时的步骤,因此有必要在轮廓提取前提取ROI;
threshold (Image, Dark, 0, 128) connection (Dark, DarkRegions) select_shape (DarkRegions, Circles, ['circularity', 'area'], 'and', [0.85, 50], [1.0, 99999]) boundary (Circles, RegionBorder, 'inner') dilation_circle (RegionBorder, RegionDilation, 6.5) union1 (RegionDilation, ROIEdges)
- 用椭圆合轮廓fit_ellipse_contour_xld,拟合返回的参数可以用来生成gen_ellipse_contour_xld并显示椭圆(用圆拟合也行fit_circle_contour_xld ~> gen_circle_contour_xld);
fit_ellipse_contour_xld (Edges, 'ftukey', -1, 2, 0, 200, 3, 2, Row, Column, Phi, Ra, Rb, StartPhi, EndPhi, PointOrder) NumHoles := |Ra| gen_ellipse_contour_xld (ContEllipse, Row, Column, Phi, Ra, Rb, gen_tuple_const(NumHoles,0), gen_tuple_const(NumHoles,rad(360)), gen_tuple_const(NumHoles,'positive'), 1)
猜你喜欢
- 24天前(夏日旅行海报)夏日旅行|精简行囊 向快乐进发
- 24天前(河南省文旅大会精神)2025河南省文化旅游发展大会新闻发布会在郑州召开
- 24天前(天气预报 华为)2025HDC华为天气上新系统级天气智能体,引领更智能的气象服务
- 24天前(希尔顿集团2021年筹建的酒店)希尔顿集团两大重点项目亮相第四届上海旅游投资促进大会
- 24天前(大黄山景区高质量发展联盟成立多少年)大黄山景区高质量发展联盟成立
- 24天前(殷建祥简历)全国十大牛商解码:殷建祥如何用178天技术突围打造星空梦星空房
- 24天前(“三天跨两城”催生租车新需求,神州租车清明跨城订单同比增长416%)“三天跨两城”催生租车新需求,神州租车清明跨城订单同比增长416%
- 24天前(泛舟诗海觅春迹什么意思)泛舟觅桃源,又一头部机构下场文旅赛道
- 24天前(筑格集团有限公司)洲际酒店集团旗下筑格酒店品牌正式亮相大中华区
- 24天前(第三届“堡里有年味·回村过大年”民俗花灯会活动)第三届“堡里有年味·回村过大年”民俗花灯会活动
网友评论
- 搜索
- 最新文章
- (2020广州车展哈弗)你的猛龙 独一无二 哈弗猛龙广州车展闪耀登场
- (哈弗新能源suv2019款)智能科技颠覆出行体验 哈弗重塑新能源越野SUV价值认知
- (2021款全新哈弗h5自动四驱报价)新哈弗H5再赴保障之旅,无惧冰雪护航哈弗全民电四驱挑战赛
- (海南航空现况怎样)用一场直播找到市场扩张新渠道,海南航空做对了什么?
- (visa jcb 日本)优惠面面俱到 JCB信用卡邀您畅玩日本冰雪季
- (第三届“堡里有年味·回村过大年”民俗花灯会活动)第三届“堡里有年味·回村过大年”民俗花灯会活动
- (展示非遗魅力 长安启源助力铜梁龙舞出征)展示非遗魅力 长安启源助力铜梁龙舞出征
- (阿斯塔纳航空公司)阿斯塔纳航空机队飞机数量增至50架
- (北京香港航班动态查询)香港快运航空北京大兴新航线今日首航
- (我在港航“呵护”飞机 每一次安全着陆就是最好的荣誉)我在港航“呵护”飞机 每一次安全着陆就是最好的荣誉
- 热门文章