当前位置:网站首页>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
边栏推荐
- kingbaseES V8R3数据安全案例之---审计记录清除案例
- Chapter 05_ Storage engine
- Exercise 1 simple training of R language drawing
- Xlrd common operations
- Two ways to realize video recording based on avfoundation
- postgres 建立连接并删除记录
- 让开发效率飞速提升的跨端方案
- Cold violence -- another perspective of objective function setting
- EasyExcel的读写操作
- int GetMonth( ) const throw( ); What does throw () mean?
猜你喜欢
"Grain mall" -- Summary and induction
Pytoch practice -- MNIST dataset handwritten digit recognition
MySQL deep paging optimization with tens of millions of data, and online failure is rejected!
Cold violence -- another perspective of objective function setting
Feng Tang's "spring breeze is not as good as you" digital collection, logged into xirang on July 8!
Uni app Bluetooth communication
Ethereum ETH的奖励机制
让开发效率飞速提升的跨端方案
PVC plastic sheets BS 476-6 determination of flame propagation properties
Teach yourself to train pytorch model to Caffe (III)
随机推荐
R语言【数据管理】
Add ICO icon to clion MinGW compiled EXE file
Selenium gets the verification code image in DOM
校招期间 准备面试算法岗位 该怎么做?
Some things make feelings nowhere to put
Simple interest mode - lazy type
【日常训练】729. 我的日程安排表 I
int GetMonth( ) const throw( ); What does throw () mean?
LeetCode_哈希表_困难_149. 直线上最多的点数
有些事情让感情无处安放
Golang(1)|从环境准备到快速上手
ESP32
2022-07-03-CKA-粉丝反馈最新情况
Access Zadig self-test environment outside the cluster based on ingress controller (best practice)
Selenium finds the contents of B or P Tags
Parker驱动器维修COMPAX控制器维修CPX0200H
Introduction of ArcGIS grid resampling method
KingbaseES V8R3集群维护案例之---在线添加备库管理节点
Get JS of the previous day (timestamp conversion)
Emotional analysis of wechat chat records on Valentine's day based on Text Mining