当前位置:网站首页>Hough transform understanding [easy to understand]
Hough transform understanding [easy to understand]
2022-07-25 18:48:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
hough Transformation concept In the computer , It is often necessary to extract some specific shapes from the picture , It is very difficult to search directly with pixels , At this time, we need to map the image from the pixel to the parameter space according to a certain algorithm .hough Change provides a transformation method from image pixel information to parameter space . For things like straight lines , round , Regular curves like ellipses hough Is a commonly used algorithm .hough The biggest advantage of the change is the tolerance of the interval in the feature edge description and the transformation is not affected by the image noise .
hough Transformation principle hough Transformation is a kind of mapping the points on the image to the accumulated parameter space , Realize the recognition of known analytic curve .
Parameter space Because of the slope of the line k There is an infinite case , here hough Transformation transforms the original image space into the parameter space represented by the polar coordinate system . Straight line y = k ∗ x + b y=k*x+b y=k∗x+b Convert to polar space ρ = x c o s θ + y s i n θ \rho=xcos\theta+ysin\theta ρ=xcosθ+ysinθ, ρ \rho ρ Represents the distance from the straight line to the origin , θ \theta θ Defines the slope of the line ( This is just about limitation , It's not the slope of a straight line ). Any straight line can pass ( ρ , θ ) (\rho,\theta) (ρ,θ) To express . Parameter space H ( ρ , θ ) H(\rho,\theta) H(ρ,θ) Represents a set of finite points . Parameter space H ( ρ , θ ) H(\rho,\theta) H(ρ,θ) Each point represents a straight line . As shown in the figure :
Cumulative voting of parameter space It's going on hough Before the change , First, we need to extract the edge image of the image , Based on the edge image hough Transformation . There are many straight lines passing through each point of the edge image , Here's the picture :
The representation of a straight line passing through a certain point in the parameter space is like a sine curve . In the edge image , Only the pixels representing the edge can form a straight line . Now go back to parameter space , In parameter space H ( ρ , θ ) H(\rho,\theta) H(ρ,θ) in , It will pass through every effective pixel in the edge image ( Edge pixels ) All line information of is added to H ( ρ , θ ) H(\rho,\theta) H(ρ,θ) On . such as , Pixel point ( x , y ) (x,y) (x,y) Represents a pixel that forms an edge , Traverse θ \theta θ, According to the formula ρ = x c o s θ + y s i n θ \rho=xcos\theta+ysin\theta ρ=xcosθ+ysinθ We can calculate all the passing points ( x , y ) (x,y) (x,y) Line information . For example, below :
Here are three points in a straight line , Lines of different colors represent straight lines passing through the impasse , The table below the figure shows the parameters of the line . Express the line parameter on the curve of parameter space , As shown in the figure :
Each curve is composed of all the parameters of the straight line passing through a point . We find three curves in (60,81) It crosses nearby , This shows that θ = 60 , ρ = 81 \theta=60,\rho=81 θ=60,ρ=81 There are three points on this line . This shows how we can start from the parameter space H ( ρ , θ ) H(\rho,\theta) H(ρ,θ) Look for line information on . take H H H As an accumulator , An accumulator that represents line information . Set a certain threshold , The line represented by the parameter point that exceeds the threshold indicates the existence of this line in the image . hough Transformation examples
RGB= imread('lines.png');
imshow(RGB),title('original image');
I = rgb2gray(RGB);
BW = edge(I, 'canny'); % use canny Algorithm to extract edge image
figure,imshow(BW),title('edge image');
[H, T, R]=hough(BW); % Calculated H For the parameter matrix ,T To limit the angle of the line ,R Is the value of the line to the origin
figure, imshow(imadjust(mat2gray(H)), 'XData', T, ... % draw hough Transformed graph
'YData', R, 'InitialMagnification', 'fit'),title('hough image');
xlabel('\theta'), ylabel('\rho');
axis on; axis normal; hold on;
colormap(hot);
peaks = houghpeaks(H,4); % The algorithm is used to extract a specified number of peak points , That is to find a straight line
figure, imshow(BW);
hold on;
lines = houghlines(BW, T, R, peaks, 'FillGap',30, 'MinLength',30);
max_len = 0;
for k=1:length(lines)
xy = [lines(k).point1; lines(k).point2];
plot(xy(:,1),xy(:,2),'LineWidth',3,'Color','b');
plot(xy(1,1),xy(1,2),'x','LineWidth',3,'Color','yellow');
plot(xy(2,1),xy(2,2),'x','LineWidth',3,'Color','red');
len = norm(lines(k).point1 - lines(k).point2);
if ( len > max_len)
max_len = len;
xy_long = xy;
end
endreference :《 digital image processing matlab edition 》- Zuofei 《 Digital image processing third edition 》 http://blog.csdn.net/poem_qianmo/article/details/26977557 https://en.wikipedia.org/wiki/Hough_transform http://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/127589.html Link to the original text :https://javaforall.cn
边栏推荐
- SQL realizes 10 common functions of Excel, with original interview questions attached
- Circulaindicator component, which makes the indicator style more diversified
- 韩国AI团队抄袭震动学界!1个导师带51个学生,还是抄袭惯犯
- F5:企业数字化转型所需六大能力
- Interface automation test platform fasterrunner series (II) - function module
- 阿里云技术专家郝晨栋:云上可观测能力——问题的发现与定位实践
- R language uses GT package and gtextras package to display tabular data beautifully: GT_ bar_ Plot function and GT_ plt_ bar_ PCT function visual percentage bar graph, percentage bar graph of original
- 3de 回复
- rust多线程安全计数
- 虚拟机vmware安装步骤(如何在虚拟机安装软件)
猜你喜欢

Dachang cloud business adjustment, a new round of war turn

华为年内二度招聘“天才少年”;540万Twitter账号信息泄露,卖价3万美元;谷歌解雇了相信AI有意识的工程师|极客头条

Baklib:制作优秀的产品说明手册

优秀的测试/开发程序员突破,不忘初心,方得始终......

#yyds干货盘点# 面试必刷TOP101:反转链表

【开源工程】STM32C8T6+ADC信号采集+OLED波形显示

What is the difference between GB and gib disk space units?

Communication between processes (pipeline communication)

Dynamic memory management

TypeError: Unrecognized value type: <class ‘str‘> ParserError: Unknown string format
随机推荐
ES6 implements the observer mode through proxy and reflection
8 年产品经验,我总结了这些持续高效研发实践经验 · 研发篇
论文修改回复1
如何创建一个有效的帮助文档?
3de 回复
阿里云技术专家邓青琳:云上跨可用区容灾和异地多活最佳实践
Excellent test / development programmers should make breakthroughs and never forget their original intentions, so that they can always
Experiment 2 goods purchase and sale management system
srec_ Use of common cat parameters
R language uses GT package and gtextras package to display tabular data beautifully: GT_ bar_ Plot function and GT_ plt_ bar_ PCT function visual percentage bar graph, percentage bar graph of original
Qtimgui compilation
ES6通过代理器(Proxy)与反射(Reflect)实现观察者模式
接口自动化测试平台FasterRunner系列(二)- 功能模块
Youwei low code: use resolutions
Register carefully! The number of applicants for these double non-governmental institutions exceeded 10000!
#夏日挑战赛#【FFH】这个盛夏,来一场“清凉”的代码雨!
Software testing (mind mapping)
Common file operations
【翻译】Logstash、Fluentd、Fluent Bit,还是Vector?如何选择合适的开源日志收集器...
怎样设计产品帮助中心?以下几点不可忽视