简介:
用于表面缺陷的检测,判定产品的良率、是否合格等。
介绍:
Image (input_object) | Image for which the minimum gray values are to be calculated. | 灰度图像 |
ImageOpening(output_object) | Image containing the minimum gray values. | 输出的灰色图像 |
MaskHeight (input_control) | Height of the filter mask. Default value: 11 Suggested values: 3, 5, 7, 9, 11, 13, 15 Typical range of values: 1.0 ≤ MaskHeight ≤ 511.0 | 运算的高参数 |
MaskWidth (input_control) | Width of the filter mask. Default value: 11 Suggested values: 3, 5, 7, 9, 11, 13, 15 Typical range of values: 1.0 ≤ MaskWidth ≤ 511.0 | 运算的宽参数 |
MaskShape (input_control) | Shape of the mask. Default value: 'octagon' List of values: 'octagon', 'rectangle', 'rhombus' | 形状 |
OrigImage (input_object) | Input image. | 图像 | ||||||||
ThresholdImage (input_object) | Image containing the local thresholds. | 要对比的图想 | ||||||||
RegionDynThresh (output_object) | Segmented regions. | 输出的对比后区域 | ||||||||
Offset (input_control) | Offset applied to ThresholdImage. Default value: 5.0 Suggested values: 1.0, 3.0, 5.0, 7.0, 10.0, 20.0, 30.0 Typical range of values: -255.0 ≤ Offset ≤ 255.0 (lin) Minimum increment: 0.01 Recommended increment: 5 Restriction: (-255 < Offset) && (Offset < 255) | 偏离量 | ||||||||
LightDark (input_control) | Extract light, dark or similar areas?
| 暗亮选择 |
使用:
- 彩色图像要转成灰色图像。
- 提取包含目标的图片或选择此目标的图片。
- 开和闭运算(参数需要根据实际更改),然后对比。
- 根据实际判断某个特征,例如面积,判定缺陷。
read_image (Image, 'E:/照片/缺陷')
*RGB图像转换
decompose3 (Image, Image1, Image2, Image3)
trans_from_rgb (Image1, Image2, Image3, ImageResult1, ImageResult2, ImageResult3, 'hsv')
dev_set_draw ('margin')
dev_set_color ('red')
*对比检测缺陷
openvalue := 1
closevalue := 100
gray_opening_shape (ImageResult3, ImageOpening, openvalue, openvalue, 'rectangle')
gray_closing_shape (ImageResult3, ImageClosing, closevalue, closevalue, 'rectangle')
dyn_threshold (ImageOpening, ImageClosing, RegionDynThresh, 50, 'dark')
connection (RegionDynThresh, ConnectedRegions)
count_obj (ConnectedRegions, Number)
*通过面积判定缺陷
for Index := 1 to Number by 1
select_obj (ConnectedRegions, ObjectSelected, Index)
area_center (ObjectSelected, Area1, Row1, Column1)
if (Area1 > 1000)
set_tposition (3600, Row1, Column1)
write_string (3600, Area1)
endif
endfor
dev_display (ImageResult3)
dev_display (RegionDynThresh)
![](https://i-blog.csdnimg.cn/blog_migrate/6cac0f8aefb9b92b3b7e373d75fabe6d.png)
![](https://i-blog.csdnimg.cn/blog_migrate/cdb1357bdf15b58d1be0a1c9fbf75f5e.png)