用matlab对图像处理时,运用了霍夫变换 peaks =houghpeaks(H,N,'threshold',0.2*max(H(:)))

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用matlab对图像处理时,运用了霍夫变换 peaks =houghpeaks(H,N,'threshold',0.2*max(H(:)))相关的知识,希望对你有一定的参考价值。

[H, theta, rho] = hough(f, 'ThetaResolution', 0.25);
N=4;
peaks =houghpeaks(H,N,'threshold',0.2*max(H(:)))
运行之后可以看见下面的情况,不懂peaks的意思,下面是数值都是什么意思?有谁知道的,麻烦说明一下,谢谢

houghpeaks返回的是霍夫空间中峰值点对应坐标,第一列是rho,代表直线与原点(图像左上角)的距离,第二列是theta,代表直线与原点间的垂直线和x轴线的夹角,因为你在霍夫变换时角度的步进间隔为0.25,所以(-90)- 89度被分为180/0.25=720份,1代表-90度,720代表89度,例如第一个,(323/720)*180-90= (-9.25)度,差不多这样子 参考技术A houghpeaks是霍夫变换的峰值检测,返回peaks是峰值的坐标 参考技术B houghpeaks 函数不知道 是不可能知道peaks的具体含义的,只能说能通过这个peaks定位圆是可以确定的, 坐标的话感觉不太像 因为第一列的4692 。。。。5100 都太大了,感觉一般不是特别的应用 输入图片达不到这个大小。 感觉应该 第一列是圆心对应到hough矩阵一维化后的位置 第二列应该是圆的半径 纯属猜测。

matlab 霍夫变换(hough) 检测直线

  霍夫变换是一种特征检测(feature extraction),被广泛应用在图像分析(image analysis)、电脑视觉 (computer vision)以及数位影像处理 (digital image processing)。 霍夫变换是用来辨别找出物件中的特征,例如:线条。他的算法流程大致如下,给定一个物件、要辨别的形状的种类,算法会在参数空间(parameter space)中执行投票来决定物体的形状, 而这是由累加空间(accumulator space)里的局部最大值(local maximum)来决定。  

  Hough变换的基本原理在于,利用点与线的对偶性,将图像空间的线条变为参数空间的聚集点,从而检测给定图像是否存在给定性质的曲线。

clc;clear ; close 
set(0,‘defaultfigurecolor‘,[1,1,1]) 
load DATA2.mat
data = D1;
BW = data;

figure(1)
imshow(BW)
title(‘原图像‘);
figure(2) subplot 211; %%进行霍夫变换 [H, theta , rho] = hough (BW); %%绘制霍夫空间 imshow(imadjust(mat2gray(H)),[],‘XData‘,theta,‘YData‘,rho,... ‘InitialMagnification‘,‘fit‘); xlabel(‘ heta (degrees)‘), ylabel(‘ ho‘); axis on, axis normal, hold on; colormap(hot); title(‘霍夫空间‘) %%峰值 P = houghpeaks(H,5,‘threshold‘,0.5*max(H(:))); x = theta(P(:,2)); y = rho(P(:,1)); plot(x,y,‘s‘,‘color‘,‘black‘); %lines = houghlines(BW,theta,rho,P,‘FillGap‘,10,‘MinLength‘,10); lines = houghlines(BW,theta,rho,P,‘FillGap‘,10,‘MinLength‘,10); subplot 212 imshow(BW) ,hold on max_len = 0; count = 1; points = zeros(2,2); for k = 1:length(lines) points(count,1) = lines(k).point1(1); points(count,2) = lines(k).point1(2); count =count +1; points(count,1) = lines(k).point2(1); points(count,2) = lines(k).point2(2); count =count +1; xy = [lines(k).point1; lines(k).point2]; plot(xy(:,1),xy(:,2),‘LineWidth‘,2,‘Color‘,‘green‘); % Plot beginnings and ends of lines plot(xy(1,1),xy(1,2),‘x‘,‘LineWidth‘,2,‘Color‘,‘yellow‘); plot(xy(2,1),xy(2,2),‘x‘,‘LineWidth‘,2,‘Color‘,‘red‘); end title(‘直线检测‘);

  效果如下:

技术分享图片

 


技术分享图片

 



以上是关于用matlab对图像处理时,运用了霍夫变换 peaks =houghpeaks(H,N,'threshold',0.2*max(H(:)))的主要内容,如果未能解决你的问题,请参考以下文章

MATLAB中用霍夫变换检测出了直线之后怎么求斜率

图像压缩基于matlab余弦变换及霍夫曼编码jpeg压缩和解压含Matlab源码 2086期

图像压缩基于matlab余弦变换及霍夫曼编码jpeg压缩和解压含Matlab源码 2086期

Python OpenCV 霍夫(Hough Transform)直线变换检测原理,图像处理第 33 篇博客

matlab 霍夫变换(hough) 检测直线

使用 Matlab 进行霍夫变换