Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 567107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:02:52+00:00 2026-05-13T13:02:52+00:00

After detecting the lines in an image using Hough lines , how can I

  • 0

After detecting the lines in an image using Hough lines, how can I use it to calculate the change in angle (rotation) of the lines of a reference image?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T13:02:53+00:00Added an answer on May 13, 2026 at 1:02 pm

    Note to readers: This is a follow-up question, refer to these for background:

    • How to select maximum intensity in Hough transform in MATLAB?
    • Calculating displacement moved in MATLAB

    The process is similar to what I showed before. Below I am using the images from your previous question (since you provided only one, I created the other by rotating the first by 10 degrees).

    We start by detecting the lines for the two images. We do this with the help of the Hough transform functions. This what it looks like applied to both images:

    Images with detected lines and points order

    Next, we want to perform image registration using the line endpoints as control-points. First, we make sure the points correspond to each other in the two images. I do this by computing the convex hull using convhull which automatically sorts them in counterclockwise-order (or is it in the opposite direction!). The numbers shown above indicate the order.

    Finally, we use the function cp2tform to get the transformation matrix, which we use to align the images and extract the translation, rotation, and scaling.

    The following is the complete code:

    %% # Step 1: read and prepare images
    %# (since you provided only one, I created the other by rotating the first).
    I1 = imread('https://i.stack.imgur.com/Se6zX.jpg');
    I1 = rgb2gray( imcrop(I1, [85   35  445  345]) ); %# Get rid of white border
    I2 = imrotate(I1, -10, 'bilinear', 'crop'); %# Create 2nd by rotating 10 degrees
    
    %% # Step 2: detect the cross sign endpoints (sorted in same order)
    p1 = getCross(I1);
    p2 = getCross(I2);
    
    %% # Step 3: perform Image Registration
    %# Find transformation that maps I2 to I1 using the 4 control points for each
    t = cp2tform(p2,p1,'affine');
    
    %# Transform I2 to be aligned with I1
    II2 = imtransform(I2, t, 'XData',[1 size(I1,2)], 'YData',[1 size(I1,1)]);
    
    %# Plot
    figure('menu','none')
    subplot(131), imshow(I1), title('I1')
    subplot(132), imshow(I2), title('I2')
    subplot(133), imshow(II2), title('I2 (aligned)')
    
    %# Recover affine transformation params (translation, rotation, scale)
    ss = t.tdata.Tinv(2,1);
    sc = t.tdata.Tinv(1,1);
    tx = t.tdata.Tinv(3,1);
    ty = t.tdata.Tinv(3,2);
    scale = sqrt(ss*ss + sc*sc)
    rotation = atan2(ss,sc)*180/pi
    translation = [tx ty]
    

    And here’s the function that extract the lines endpoints:

    function points = getCross(I)
        %# Get edges (simply by thresholding)
        I = imfilter(I, fspecial('gaussian', [7 7], 1), 'symmetric');
        BW = imclearborder(~im2bw(I, 0.5));
    
        %# Hough transform
        [H,T,R] = hough(BW);
    
        %# Detect peaks
        P  = houghpeaks(H, 2);
    
        %# Detect lines
        lines = houghlines(BW, T, R, P);
    
        %# Sort 2D points in counterclockwise order
        points = [vertcat(lines.point1); vertcat(lines.point2)];
        idx = convhull(points(:,1), points(:,2));
        points = points(idx(1:end-1),:);
    end
    

    with the result:

    Resulting aligned image

    scale =
        1.0025
    rotation =
       -9.7041
    translation =
       32.5270  -38.5021
    

    The rotation is recovered as almost 10 degrees (with some inevitable error), and scaling is effectively 1 (meaning there was no zooming). Note that there was a translation component in the above example, because rotation was not performed around the center of the cross sign).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm using a php script for redirection after detecting the search word to my
I have the following image acquired after a Canny edge detection: After Hough transformation
I am trying to implement a Data Flow Anomaly Detection using ptrace. After a
After some experience with functional languages, I'm starting to use recursion more in Java
I am using a ListView to load and display thumbnails for image files. The
I create a table in j2me.Using javax.microedition.lcdui.CustomItem by drawing lines & placing a string.Then
After converting my site to use utf-8, I'm now faced with the prospect of
After I upload an image via Upload tab > Upload, I get this error
Does anyone know what the esiest way to update the entity model after adding/deleting
I am deleting segments after they gets indexed then how nutch will get that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.