- //图中五个圈起来的区域是有重叠的产品,用for循环做进一步处理
- read_image (Image, 'C:/Users/Desktop/针头.jpg')
- rgb1_to_gray (Image, GrayImage)
- threshold (GrayImage, Region, 0, 180)
- connection (Region, ConnectedRegions)
- opening_circle (ConnectedRegions, RegionOpening, 15)
- connection (RegionOpening, ConnectedRegions1)
- count_obj (ConnectedRegions1, Number)
- select_shape (ConnectedRegions1, SelectedRegions, 'area', 'and', 4500, 100000)
- count_obj (SelectedRegions, Number1)
- for Index := 1 to Number1 by 1
- select_obj (SelectedRegions, ObjectSelected, Index)
- area_center (ObjectSelected, Area, Row, Column)
- num := int(Area/4500)
- Number := Number + num
- endfor
复制代码
|