当前位置:网站首页>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
边栏推荐
- 人人可参与开源活动正式上线,诚邀您来体验!
- 微软Azure和易观分析联合发布《企业级云原生平台驱动数字化转型》报告
- Partial correlation calculation of R language and partial correlations calculation using pcor function of GGM package
- Qtimgui compilation
- 这届年轻人,为“丑东西”有多上头?
- Ultimate doll 2.0 | cloud native delivery package
- 阿里云技术专家秦隆:可靠性保障必备——云上如何进行混沌工程?
- You can change this value on the server by setting the 'Max_ allowed_ Packet 'variable error
- 通讯录(二)
- 华为年内二度招聘“天才少年”;540万Twitter账号信息泄露,卖价3万美元;谷歌解雇了相信AI有意识的工程师|极客头条
猜你喜欢

Yyds dry inventory interview must brush top101: reverse linked list

人人可参与开源活动正式上线,诚邀您来体验!

阿里云技术专家秦隆:可靠性保障必备——云上如何进行混沌工程?

浏览器内核有几种,浏览器版本过低怎么升级

Visual model network connection

Dachang cloud business adjustment, a new round of war turn

大厂云业务调整,新一轮战争转向

3DE reply

JVM基础和问题分析入门笔记

Circulaindicator component, which makes the indicator style more diversified
随机推荐
浅析IM即时通讯开发出现上网卡顿?网络掉线?
文件常用操作
7/24 training log
"Wdsr-3" Penglai pharmaceutical Bureau solution
PHP 中的跨站请求伪造
接口自动化测试平台FasterRunner系列(四)- 持续集成、解决多域名
F5: Six capabilities required for enterprise digital transformation
软件测试进阶篇—测试分类
VC/PE正跑向青岛
Interface automation test platform fasterrunner series (IV) - continuous integration and solution of multi domain names
Osmosis extends its cross chain footprint to poca through integration with axelar and moonbeam
With a market value of 30billion yuan, the largest IPO in Europe in the past decade was re launched on the New York Stock Exchange
Vc/pe is running towards Qingdao
#夏日挑战赛#【FFH】这个盛夏,来一场“清凉”的代码雨!
With a financing of 200million yuan, the former online bookstore is now closed nationwide, with only 3 stores left in 60 stores
【翻译】Logstash、Fluentd、Fluent Bit,还是Vector?如何选择合适的开源日志收集器...
【开源工程】STM32C8T6+ADC信号采集+OLED波形显示
Paper revision reply 1
What is the difference between GB and gib disk space units?
《21天精通TypeScript-4》-类型推断与语义检查