关于一张图像的Hough完整处理过程

首先载入图片

A=imread(‘DSC9342.bmp’);

由于图片可能不是二值图片,需要进行转换

X=rgb2gray(A);

之后对图片进行边缘检测

BW=edge(X,‘sobel’,0.1);
imshow(A),figure;imshow(BW),figure;

关于一张图像的Hough完整处理过程
对检测结果进行Hough变换

[H,T,R]=hough(BW,‘ThetaResolution’,1,‘RhoResolution’,10);
imshow(H,[],‘Xdata’,T,‘Ydata’,R,‘Initialmagnification’,‘fit’);
xlabel(’\theta’),ylabel(‘r’);
axis on,axis normal,hold on;

关于一张图像的Hough完整处理过程
对Hough变换中的密集交点进行检测

P=houghpeaks(H,20,‘threshold’,ceil(0.15*max(H(????)),‘NHoodSize’,[101,101]);
x=T(P(:,2));y=R(P(:,1));
plot(x,y,‘s’,‘color’,‘white’);
lines=houghlines(BW,T,R,P,‘FillGap’,20,‘MinLength’,20);
figure,imshow(X),hold on
max_len=0;
for k=1:length(lines)
xy=[lines(k).point1;lines(k).point2];
plot(xy(:,1),xy(:,2),‘LineWidth’,4,‘Color’,‘black’);
end

得到最后的结果为:
关于一张图像的Hough完整处理过程

可见其中主要的线条已经被检测出来了,之后需要的就是读取线条的数据,得到倾斜角度,最后将图片旋转就完成了。

相关文章:

  • 2021-09-26
  • 2021-05-09
  • 2021-05-16
  • 2022-12-23
  • 2022-01-25
  • 2021-12-14
  • 2021-06-05
  • 2021-06-30
猜你喜欢
  • 2021-05-01
  • 2021-11-10
  • 2021-07-14
  • 2021-06-19
  • 2021-06-10
  • 2021-07-28
  • 2021-08-03
相关资源
相似解决方案