当前位置:网站首页>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
边栏推荐
猜你喜欢
Influence of oscilloscope probe on signal source impedance
Realize the function of verifying whether the user has completed login when browsing the page
递归查询多级菜单数据
Simple interest mode - evil Chinese style
使用Aspect制作全局异常处理类
R language [data management]
Deployment of Jenkins under win7
怎么利用Tensorflow2进行猫狗分类识别
MMAP
EBS Oracle 11g 克隆步骤(单节点)
随机推荐
Selenium finds the contents of B or P Tags
Traps in the explode function in PHP
Parker driver maintenance COMPAX controller maintenance cpx0200h
Selenium's method of getting attribute values in DOM
Which securities company is better and which platform is safer for stock account opening
vant 源码解析 event.ts 事件处理 全局函数 addEventListener详解
Oracle检查点队列–实例崩溃恢复原理剖析
int GetMonth( ) const throw( );后面的throw( )什么意思?
oracle 控制文件的多路复用
Evolution of zhenai microservice underlying framework from open source component encapsulation to self-development
2.2.5 basic sentences of R language drawing
Establishment of terminal security capability verification environment and penetration test records
Exercise 1 simple training of R language drawing
2.2 basic grammar of R language
Deep merge object deep copy of vant source code parsing
How to prepare for the algorithm interview and answer the algorithm interview questions
張麗俊:穿透不確定性要靠四個“不變”
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
Introduction to TS, constructor and its this, inheritance, abstract class and interface
Access Zadig self-test environment outside the cluster based on ingress controller (best practice)