当前位置:网站首页>Halcon principle: correlation matching
Halcon principle: correlation matching
2022-06-23 11:59:00 【Mr anhydrous】
One 、 The basic principle
NCC It is an algorithm based on statistics to calculate the correlation between two groups of samples , Its value range is 【-1,1】 Between , And for images , Each pixel is viewed as RGB Vector , The whole image is a sample set . If it has a subset , Match with another sample data , Then it's NCC The value is 1; It means that the correlation is very high , If it is -1, The table is completely irrelevant ; Based on this principle, template matching and recognition are realized , The first step is to normalize the data , The mathematical formula :

among ,f Express p Point gray value ,
Represents the average value of pixels in the window ,
Represents the standard deviation .
If t Represents the template pixel value , be :

among n Is the total number of template pixels ,n-1 It's the degree of freedom .
Two 、 Implementation method
1) Get the average value of template pixels 、 Standard deviation 、 Pixel and mean fiff Data samples .
2) According to the template size , On the target image , From top to bottom 、 Pan the template from left to right , Calculate every pixel moved , Template and image area NCC value , And record it at the center point . After completion , Of each point NCC Compare with the threshold , Beyond the threshold is the matching result .
3) Mark the matching position with a rectangular box .
4) Use UI Output .
3、 ... and 、Halcon Of NCC matching
Halcon Of ncc Templates use , This is done by two functions :create_ncc_model and find_ncc_model Cooperate to complete . Below we have prepared a picture , To explain this matching
3.1 create_ncc_model and find_ncc_model function
The function prototype :
- create_ncc_model(Template : : NumLevels, AngleStart, AngleExtent, AngleStep, Metric : ModelID)
Template: Image of the template , It can be a rectangle , It can also be a circle .
NumLevels: Is the hierarchy of templates , If one layer , Just use “auto”
AngleStart, AngleExtent, AngleStep: These three represent the rotation of the angle template , Starting angle 、 Termination angle 、 Rotation step .
Metric: Matching criteria
ModelID: Template label
- find_ncc_model(Image : : ModelID, AngleStart, AngleExtent, MinScore, NumMatches, MaxOverlap, SubPixel, NumLevels : Row, Column, Angle, Score)
Image: The detected image
ModelID: Template number
AngleStart, AngleExtent: angle
MinScore: Match points
NumMatches: matching , Number of templates hit
MaxOverlap,
SubPixel:
NumLevels: Number of formwork layers
Row, Column, Angle, Score: Return value , Hit rows 、 Column 、 angle 、 The score is .
Four 、 Case study
1 Open a grayscale image file :
read_image (Image, 'F:/images/hugeImg/gtexst.jpg')
get_image_size (Image, Width, Height)
dev_close_window ()
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
dev_update_window ('off')

2 Generate template
gen_circle (Circle, 210,692, 41)
area_center (Circle, Area, RowRef, ColumnRef)
reduce_domain (Image, Circle, ImageReduced1)
disp_image(ImageReduced1,WindowHandle)
gen_circle (Circle, 701,854, 59)
area_center (Circle, Area, RowRef, ColumnRef)
reduce_domain (Image, Circle, ImageReduced2)
disp_image(ImageReduced2,WindowHandle)
Generate two circular templates
create_ncc_model (ImageReduced1 , 5, 0, 10, 'auto', 'use_polarity', ModelID1)
get_ncc_model_params( ModelID1 ,NumLevels, AngleStart, AngleExtent, AngleStep, Metric)
create_ncc_model (ImageReduced2 , 5, 0, 10, 'auto', 'use_polarity', ModelID2)
get_ncc_model_params( ModelID2 ,NumLevels, AngleStart, AngleExtent, AngleStep, Metric)
3 Template matching
find_ncc_model (Image, ModelID1, 0, 10, 0.5, 1, 0.5, 'true', 0, Row1, Column1, Angle, Score1)
find_ncc_model (Image, ModelID2, 0, 10, 0.5, 1, 0.5, 'true', 0, Row2, Column2, Angle, Score2)
4 Mark the matching area
dev_set_draw ('margin')
dev_set_colored (12)
dev_set_line_width (3)
dev_display (Image)
gen_rectangle1(Rectangle1, Row1-41, Column1-41, Row1+41, Column1+41)
gen_rectangle1(Rectangle2, Row2-59, Column2-59, Row2+59, Column2+59)
dev_set_window(WindowHandle)
dev_display(Rectangle1)
dev_display(Rectangle2)
5、 ... and 、 Enumeration of related functions
5.1 Possible antecedents :
draw_region
reduce_domain
threshold
5.2 Possible post items :
find_ncc_model
get_ncc_model_params
clear_ncc_model
write_ncc_model
set_ncc_model_origin
set_ncc_model_param
5.3 Possible alternatives :
create_shape_model
create_scaled_shape_model
create_aniso_shape_model
create_template_rot
边栏推荐
- LinkedList 5-141. 环形链表
- 基本数据类型和对应的包装类
- 2022施工员-装饰方向-岗位技能(施工员)操作证考试题库模拟考试平台操作
- MySQL在一个字段中匹配多个值
- 32路电话+2路千兆以太网32路PCM电话光端机支持FXO口FXS语音电话转光纤
- 【综合笔试题】30. 串联所有单词的子串
- How many days is the general term of financial products?
- Ppt makes 3D rotation animation from beginner to advanced
- Hot spot of equity transfer: 93.75% equity transfer of Chongqing Jianke Construction Engineering Quality Inspection Co., Ltd
- 广播级E1转AES-EBU音频编解码器 E1转立体声音频卡侬头(XLR)编解码器
猜你喜欢

爱可可AI前沿推介(6.23)

2022年全国最新消防设施操作员(初级消防设施操作员)模拟题及答案

go-zero微服务实战系列(六、缓存一致性保证)

Shell process control - 39. Special process control statements

链表5 - 234. 回文链表

Getting started with redis - Chapter 2 - data structures and objects - linked lists

64路电话+2路千兆以太网64路PCM电话光端机语音电话转光纤

Qt 知识:使用 QGraphicsPixmapItem类

navicat定时任务无效

Use xtradiagram Diagramcontrol for drawing and controlling process graphics
随机推荐
64路电话+2路千兆以太网64路PCM电话光端机语音电话转光纤
ROS知识:librviz库的调用实践
【进程和线程】
Analysis of six dimensional chart: analysis of enterprise growth of CSCEC
公开课丨玩的就是短视频!今晚教你精准变现!
Design of routing service for multi Activity Architecture Design
ROS知识:点云文件.pcd格式
【云原生&微服务八】Ribbon负载均衡策略之WeightedResponseTimeRule源码剖析(响应时间加权)
2022年全国最新消防设施操作员(初级消防设施操作员)模拟题及答案
【云驻共创】无码时代,软件开发如何走向每个人?
How does easygbs solve the abnormal use of intercom function?
Want to learn ETS development? Teach you to develop an iq-eq test application
Getting started with redis - Chapter 4 - data structures and objects - jump table
电脑坏了,换了台电脑,装node环境的时候出了问题,报错URL not defined
LinkedList 5-141. 环形链表
汉源高科USB2.0光端机USB2.0光纤延长器USB2.0光纤传输器USB2.0接口转光纤
Halcon知识:binocular_disparity 知识
蓝桥杯单片机(一)——关闭外设及熄灭LED
我在佛山,到哪里开户比较好?手机开户安全么?
Leetcode 1209. 删除字符串中的所有相邻重复项 II(牛逼,终于过了)