- 博主写作不容易,孩子需要您鼓励
- 万水千山总是情 , 先点个赞行不行
|
处理要求
查找好的圆环,检测圆环不良
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/3d802b07da39c777ca4daecb807c7109.png#pic_center)
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/17c8aed69f27dcc9944c4e58ac563924.png#pic_center)
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/3c30ba7c9b626a9497005b7d5c54f42a.png#pic_center)
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/62a4f273bae2a036f29e9a5a9eaecba0.png#pic_center)
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/2d64778b97575dfc7353fcb691549326.png#pic_center)
程序源码
read_image (Image, 'F:/HALCON/圆环完整性检测/6.bmp')
rgb1_to_gray (Image, GrayImage)
var_threshold (GrayImage, RinRegion, 3, 3, 0.3, 5, 'light')
connection (RinRegion, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, ['area','width','height'], 'and', [100,25,25], [350,35,35])
dilation_circle (SelectedRegions, RegionDilation, 1.5)
fill_up (RegionDilation, RegionFillUp)
select_shape (RegionFillUp, SelectedRegions1, 'area', 'and', 600, 850)
intersection (SelectedRegions1, RegionDilation, RegionIntersection)
count_obj (RegionIntersection, Number)
gen_empty_obj (goodRegion)
circularityIn:=[]
circularityOut:=[]
for index:=1 to Number by 1
select_obj (RegionIntersection, ObjectSelected, index)
fill_up (ObjectSelected, OuterRegion)
circularity (OuterRegion, OutCircularity)
circularityOut:=[circularityOut,OutCircularity]
difference (OuterRegion, ObjectSelected, InnerRegion)
circularity (InnerRegion, InnerCircularity)
circularityIn:=[circularityIn,InnerCircularity]
if(OutCircularity>0.87 and InnerCircularity>0.87)
concat_obj (ObjectSelected, goodRegion, goodRegion)
endif
endfor
dev_display(GrayImage)
dev_display(goodRegion)
处理结果
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/f71ae8e8c85c33048131530db4eda249.png#pic_center)
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/f43c0de53921a35d6488338ea36eb138.png#pic_center)
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/e789ec02d4c1273bc3213e70d427dc39.png#pic_center)
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/570dbac18aa9092d17f3e75dc4a17e6b.png#pic_center)
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/0aab083543f7f37962514aced90e9b08.png#pic_center)
------------------------------------------------------------------------------------------
分割线
------------------------------------------------------------------------------------------
- 博主简介:
- 工业自动化上位机软件工程师、机器视觉算法工程师、运动控制算法工程师。目前从业于智能制造自动化行业。 博主邮箱:2296776525@qq.com
|