当前位置:网站首页>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
边栏推荐
- Excellent test / development programmers should make breakthroughs and never forget their original intentions, so that they can always
- Disk performance and capacity
- 终极套娃 2.0 | 云原生交付的封装
- Paper revision reply 1
- jmeter性能测试实战视频(常用性能测试工具有哪些)
- 如何创建一个有效的帮助文档?
- 关爱一线防疫工作者,浩城嘉业携手高米店街道办事处共筑公益长城
- 这届年轻人,为“丑东西”有多上头?
- Qtimgui 编译
- Ultimate doll 2.0 | cloud native delivery package
猜你喜欢

软件测试进阶篇—测试分类

2022年IAA行业品类发展洞察系列报告·第二期

从目标检测到图像分割简要发展史

Vc/pe is running towards Qingdao

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

What is hpapaas platform?

浅析IM即时通讯开发出现上网卡顿?网络掉线?

How high are the young people in this class for "ugly things"?

TypeError: Unrecognized value type: <class ‘str‘> ParserError: Unknown string format

给生活加点惊喜,做创意生活的原型设计师丨编程挑战赛 x 选手分享
随机推荐
Address book (I)
Baklib:制作优秀的产品说明手册
CircleIndicator组件,使指示器风格更加多样化
Common file operations
Ceres curve fitting
APP测试点(思维导图)
【帮助中心】为您的客户提供自助服务的核心选项
东北人,最懂性感
拍卖行作VC,第一次出手就投了个Web3
7/24 training log
[translation] LFX 2022 spring tutor qualification opening - apply for CNCF project before February 13!
Typescript反射对象Reflect使用
动态内存管理
这届年轻人,为“丑东西”有多上头?
[translation] logstash, fluent, fluent bit, or vector? How to choose the right open source log collector
Address book (II)
Pixel2Mesh从单个RGB图像生成三维网格ECCV2018
市值300亿,欧洲十年来最大IPO再冲纽交所
n-queens problem
【小程序开发】页面导航详解