当前位置:网站首页>[image detection] line recognition based on Hough transform (fitting angle bisector) with matlab code
[image detection] line recognition based on Hough transform (fitting angle bisector) with matlab code
2022-06-29 00:13:00 【Matlab scientific research studio】
1 brief introduction
Line detection is an important part of digital image processing , In road recognition , Building identification , Medical image analysis and other fields have very important applications . Through the edge detection of the obtained image , And then use Hough Transform edge detection for line detection . The method is simple , It is less affected by the gap and noise in the straight line . stay Matlab The method is simulated in the environment , The linear object in the image is detected , The results show that this method is fast and effective for detecting linear objects in images .
2 Part of the code
function chengxu()
% The first 1 Step
close all
I=imread('1.jpg'); % Read images
I=rgb2gray(I); % Color image is converted into gray image
% I=im2bw(I); % Two valued
I=edge(double(I)); % Detect the edge of the image
figure
imshow(I) % Display the results of edge detection
% The first 2 Step
[m,n]=size(I); % Calculate the size of the image
M=3; % Definition X Number of blocks divided by direction
N=3; % Definition Y Number of blocks divided by direction
mm=floor(m/M); % The length of the sub block row
nn=floor(n/N); % The length of the subblock column
count=1; % Counter
figure
for i=1:M
for j=1:N
A=I((i-1)*mm+1:i*mm,(j-1)*nn+1:j*nn); % Segment the original image , Get a sub block
subplot(M,N,count)
imshow(A) % Display a sub block
zuoshangjiao=[(i-1)*mm+1 (j-1)*nn+1]; % Coordinates of the upper left corner of the sub block
[x,y,k,b]=zikuai(A,zuoshangjiao); % Get the slope of the straight line fitting the white pixels in the sub block k And intercept b( call zikuai function )
X{count}=x; % Save all white pixels in the sub block x coordinate
Y{count}=y; % Save all white pixels in the sub block y coordinate
K(count)=k; % Save the slope of the fitted line in the sub block k
B(count)=b; % Save the intercept of the fitted line in the sub block b
count=count+1; % Counter plus 1, Calculate the next sub block
end
end
% The first 3 Step
KK=K(~isnan(K)); % Get rid of K Medium NaN( White pixels are less than 10 Sub block of )
BB=B(~isnan(B)); % Get rid of B Medium NaN( White pixels are less than 10 Sub block of )
mean_K=mean(KK); % Find the average of all slopes
mean_B=mean(BB); % Find the average of all intercepts
figure
subplot(2,1,1)
plot(KK,'-o')
title(' The straight line fitted by each sub block k value ')
subplot(2,1,2)
plot(BB,'-o')
title(' The straight line fitted by each sub block b value ')
% Draw the angle bisector
xx0=[1 m];
yy0=[1 n];
YY1=K01*xx0+B01; % The angular bisector 1
YY2=K02*xx0+B02; % The angular bisector 2
plot(xx0,YY1); % Draw the angle bisector 1
plot(xx0,YY2); % Draw the angle bisector 2
view([90 90])
end
3 Simulation results



4 reference
[1] Tangjialin , Wangzhenbo , Zhangxinxin . Line detection technology based on Hough transform [J]. Technology Information , 2011(14):2.
About bloggers : Good at intelligent optimization algorithms 、 Neural networks predict 、 signal processing 、 Cellular automata 、 The image processing 、 Path planning 、 UAV and other fields Matlab Simulation , relevant matlab Code problems can be exchanged by private letter .
边栏推荐
- Sword finger offer 12 Path in matrix
- 在线买股票开户安全嘛?
- [software analysis] iterative explanation of software analysis, design and modeling
- Typescript -- Section 3: Interface
- 12. object detection mask RCNN
- Encapsulation of JDBC connection and disconnection database
- Along with the notes: methods simulating array like classes
- FATAL ERROR: Could not find ./bin/my_print_defaults的解决办法
- Technology sharing | software development process that you must understand if you want to get started with testing
- How many locks are added to an update statement? Take you to understand the underlying principles
猜你喜欢

Quartz explanation and use

12.物体检测Mask-Rcnn

WPF implementation calls local camera~

12. object detection mask RCNN

随笔记:模拟类数组(array-like)的方法

Typescript -- Section 5: classes

12. Détection d'objets Mask rcnn

MySQL 8.0 above reporting 2058 solution

Technology sharing | software development process that you must understand if you want to get started with testing

Single machine multi instance MySQL master-slave replication
随机推荐
转载:VTK笔记-裁剪分割-三维曲线或几何切割体数据(黑山老妖)
单机多实例MYSQL主从复制
Stm32f407----- capacitive touch button
ES6模块
Technology sharing | software development process that you must understand if you want to get started with testing
毕业三年的25岁码农总结
Quartz explanation and use
Trois questions PWN
Typescript -- Section 2: variable declaration
Yyds dry goods count 【 vs code work record III 】 set vs code format
FATAL ERROR: Could not find ./bin/my_print_defaults的解决办法
LeetCode每日一题:实现strStr()
LinkedIn datahub - experience sharing
"Five considerations" for safe use of the Internet
【LeetCode】21. 合并两个有序链表 - Go 语言题解
在线买股票开户安全嘛?
TypeScript -- 第六节 泛型
Stm32f407----- register address name mapping analysis
websocket-js连接如何携带token验证
6.28 learning content