当前位置:网站首页>Defect detection - Halcon surface scratch detection
Defect detection - Halcon surface scratch detection
2022-07-05 21:35:00 【MrL_ JJ】
One . Project scenario :
Extract surface scratch defects 
Two . Solution :
1. First, do median filtering on the original image :
2. Local threshold processing 
3.blob Analyze and extract features 
3、 ... and .halcon Code
read_image (Image, 'scratchSrc')
mean_image (Image, ImageMean, 7, 7)
dyn_threshold (Image, ImageMean, DarkPixels, 5, 'dark')
connection (DarkPixels, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 10, 1000)
union1 (SelectedRegions, RegionUnion)
dilation_circle (RegionUnion, RegionDilation, 3.5)
skeleton (RegionDilation, Skeleton)
connection (Skeleton, Errors)
select_shape (Errors, Scratches, 'area', 'and', 50, 10000)
select_shape (Errors, Dots, 'area', 'and', 1, 50)
Four . Core algorithm analysis
dyn_threshold (OrigImage, ThresholdImage, RegionDynThresh, Offset, LightDark)
Algorithm function : Use local threshold to segment the image .
OrigImage: Original input image
ThresholdImage: Input image after smoothing
RegionDynThresh: Result output image
Offset: be relative to ThresholdImage The offset of each pixel value of the image
LightDark: Options , Extract light 、 Dark or similar areas ?
The default value is :“light” Options provided : ‘dark’, ‘equal’, ‘light’, ‘not_equal’
Analysis of the original figure shows , The scratch and background in the figure are very small , It is completely impossible to find a suitable global threshold to segment the scratch from the background . Therefore, the local threshold segmentation algorithm is the solution The key to .
The principle is as follows :
Select the area where the pixel meets the threshold condition from the input image , Make g{o} = g{OrigImage}, g{t} = g{ThresholdImage}. that LightDark= 'dark’ Is the condition of :
g{o} <= g{t} - Offset
OrigImag and ThresholdImage Each pixel is compared one by one , When ThresholdImage Pixel value of minus Offset The offset is greater than or equal to OrigImag Pixel value of , said OrigImag The pixel value of meets the conditional threshold , In pixel values 255 Save to RegionDynThresh in , If the rest are not satisfied, the pixel value 0 Save in RegionDynThresh in .
If LightDark= 'light’ Then the condition is :
g{o} >= g{t} - Offset
c++ Source code implementation effect

边栏推荐
- Zhang Lijun: penetrating uncertainty depends on four "invariants"
- Selenium gets the verification code image in DOM
- Five layer network protocol
- 有些事情让感情无处安放
- MySQL 千万数据量深分页优化, 拒绝线上故障!
- Objects in the list, sorted by a field
- Summary of data analysis steps
- Deployment of Jenkins under win7
- Advantages of robot framework
- regular expression
猜你喜欢

使用Aspect制作全局异常处理类

KingbaseES V8R3集群维护案例之---在线添加备库管理节点

Influence of oscilloscope probe on signal source impedance

Exercise 1 simple training of R language drawing

Golang(1)|从环境准备到快速上手

Why can't Chinese software companies produce products? Abandon the Internet after 00; Open source high-performance API gateway component of station B | weekly email exclusive to VIP members of Menon w

MQ----activeMq

Zhang Lijun: la pénétration de l’incertitude dépend de quatre « invariants»

2.2.5 basic sentences of R language drawing

递归查询多级菜单数据
随机推荐
Add ICO icon to clion MinGW compiled EXE file
秋招将临 如何准备算法面试、回答算法面试题
postgres 建立连接并删除记录
Arcgis\qgis no plug-in loading (no offset) mapbox HD image map
123456
Postgres establish connection and delete records
EBS Oracle 11g 克隆步骤(单节点)
【日常训练】729. 我的日程安排表 I
2.2.3 output of documents
Deployment of Jenkins under win7
Objects in the list, sorted by a field
Exercise 1 simple training of R language drawing
Cold violence -- another perspective of objective function setting
Modifiers of attributes of TS public, private, protect
KingbaseES V8R3集群维护案例之---在线添加备库管理节点
PostGIS installation geographic information extension
JMeter installation under win7
Pytoch practice -- MNIST dataset handwritten digit recognition
Cross end solution to improve development efficiency rapidly
Making global exception handling classes with aspect