我想找形的边长在给定的图像。

25日视图(30天)
我有一个小幅的形象和想强调的边缘三角形和还发现每个三角形的每条边的长度。显示高亮显示的三角形,三角形的每条边的长度。
三角形的边缘不直,但很少有不均匀(曲线)线。我想强调的边缘成一条直线。也有不同的形状除了三角形,我必须首先检测一个三角形(也许关于夹角两行),然后找到三角形的每条边的长度。

答案(1)

图像分析
图像分析 约1小时前
帮助houghlines
HOUGHLINES基于霍夫变换提取线段。行= HOUGHLINES (BW,θ,ρ,山峰)提取图像中的线段BW霍夫变换与特定的垃圾箱。θ和ρ是返回的向量函数的脚腕。矩阵的山峰,HOUGHPEAKS返回的函数,包含的行和列坐标霍夫变换垃圾箱用于寻找线段。HOUGHLINES返回线结构数组的长度等于合并线段发现的数量。结构数组的每个元素有这些字段:point1线段的端点;双元素向量卷帘窗线段的端点;双元素向量θ角(度)的霍夫变换本ρRho-axis Hough变换本端点的位置向量包含(X, Y)坐标。行= HOUGHLINES (VAL1,…, PARAM1 PARAM2, VAL2)设置各种参数。参数名称可以缩写,并不重要。 Each string parameter is followed by a value as indicated below: 'FillGap' Positive real scalar. When HOUGHLINES finds two line segments associated with the same Hough transform bin that are separated by less than 'FillGap' distance, HOUGHLINES merges them into a single line segment. Default: 20 'MinLength' Positive real scalar. Merged line segments shorter than 'MinLength' are discarded. Default: 40 Class Support ------------- BW can be logical or numeric and it must be real, 2-D, and nonsparse. References ---------- Rafael C. Gonzalez, Richard E. Woods, Steven L. Eddins, "Digital Image Processing Using MATLAB", Prentice Hall, 2003 Example ------- % Search for line segments corresponding to five peaks in the Hough % transform of the rotated circuit.tif image. Additionally, highlight % the longest segment. I = imread('circuit.tif'); rotI = imrotate(I,33,'crop'); BW = edge(rotI,'canny'); [H,T,R] = hough(BW); imshow(H,[],'XData',T,'YData',R,'InitialMagnification','fit'); xlabel('\theta'), ylabel('\rho'); axis on, axis normal, hold on; P = houghpeaks(H,5,'threshold',ceil(0.3*max(H(:)))); x = T(P(:,2)); y = R(P(:,1)); plot(x,y,'s','color','white'); % Find lines and plot them lines = houghlines(BW,T,R,P,'FillGap',5,'MinLength',7); figure, imshow(rotI), hold on max_len = 0; for k = 1:length(lines) 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'); % determine the endpoints of the longest line segment len = norm(lines(k).point1 - lines(k).point2); if ( len > max_len) max_len = len; xy_long = xy; end end % highlight the longest line segment plot(xy_long(:,1),xy_long(:,2),'LineWidth',2,'Color','cyan'); See also HOUGH, HOUGHPEAKS. Documentation for houghlines doc houghlines
5个评论
Surabhi一个年代
Surabhi一个年代 2分钟前
例子很好但是我不能够根据我的需求。所以我问你解释编码部分

登录置评。

下载188bet金宝搏


释放

R2018a

社区寻宝

找到宝藏在MATLAB中央,发现社区如何帮助你!

开始狩猎!