鬼马汤圆 2020-07-06 17:35 采纳率: 0%
浏览 148

霍夫变换轮廓线与图像轮廓不符

使用霍夫变换画出的轮廓比原始图形大很多,请问这是什么原因?
霍夫变换寻找的直线

img_actural = imread("C:\Users\cip\Desktop\fivesquare.jpg");
img = rgb2gray(img_actural);
img_edge = edge(img, "canny");
figure(1), imshow(img_edge), title("canny");

%apply Hough transform to find candidate line
[accum theta rho] = hough(img_edge);
figure(2), imshow(accum, [], "XData", theta, "YData", rho), title("hough accumlator");
xlabel('\theta'), ylabel('\rho');
axis on, axis normal, hold on, hold off;

%find peaks in the Hough accmulator matrix
peaks = houghpeaks(accum, 100, "Threshold", ceil(0.56 * max(accum(:))), "NHoodSize", [5 5]);
hold on, plot(theta(peaks( :, 2)), rho(peaks(:,1)), "rs"), hold off;

%find lines segments in the image
line_seg = houghlines(img, theta, rho, peaks, "Fillgap", 50, "Minlength", 100);
figure(3), imshow(img_actural), title("line segments");
hold on;
for k = 1 : length(line_seg)
    end_points = [line_seg(k).point1; line_seg(k).point2];
    % Plot beginnings and ends of lines
    plot(end_points(1,1), end_points(1,2),'x','LineWidth',2,'Color','yellow');
    plot(end_points(2,1),end_points(2,2),'x','LineWidth',2,'Color','red');
    plot(end_points(:, 1), end_points(:, 2), "LineWidth", 2, "Color", "green");
end
hold off;

  • 写回答

1条回答 默认 最新

  • zqbnqsdsmd 2020-08-02 15:33
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 SPSS分类模型实训题步骤
  • ¥15 求解决扩散模型代码问题
  • ¥15 工创大赛太阳能电动车项目零基础要学什么
  • ¥20 limma多组间分析最终p值只有一个
  • ¥15 nopCommerce开发问题
  • ¥15 torch.multiprocessing.spawn.ProcessExitedException: process 1 terminated with signal SIGKILL
  • ¥15 QuartusⅡ15.0编译项目后,output_files中的.jdi、.sld、.sof不更新怎么解决
  • ¥15 pycharm输出和导师的一样,但是标红
  • ¥15 想问问富文本拿到的html怎么转成docx的
  • ¥15 我看了您的文章,遇到了个问题。