Auto align an image using Hough Transform

1 回表示 (過去 30 日間)
Jason
Jason 2016 年 1 月 15 日
編集済み: Pavel Dey 2016 年 1 月 21 日
I have an image that is slightly misaligned. I thought the Hough transform would be relevant to aligning it.
But the answer is coming out to be 32 degrees which is wrong. Heres my code:
BW2 = edge(ROI,'canny');
figure(),imshow(BW2);
% Perform the Hough transform
[H, theta, rho] = hough(BW2);
% Find the peak pt in the Hough transform
peak = houghpeaks(H);
% Find the angle of the bars
barAngle = theta(peak(2));
title (num2str(barAngle))
Thanks for any help Jason

回答 (1 件)

Pavel Dey
Pavel Dey 2016 年 1 月 21 日
編集済み: Pavel Dey 2016 年 1 月 21 日
I would like to know how are you verifying the result? Have you written another code to get the output? In that case I would suggest you to do the same check with one of the example image given in the documentation page.
See if the results are matching for the given example. If the difference is still there then check the following things,
1) How large is the difference? 2) Make sure that your reference for measuring the angle is same as the MATLAB. See the algorithm part of the doc link for Hough Transform
Hope that helps.
  1 件のコメント
Jason
Jason 2016 年 1 月 21 日
Thanks for replying...I had given up as no responses!!
Its clear to see that the red line is not at 32 degrees with respect to the horizontal.

サインインしてコメントする。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by