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

  • Home
  • SEARCH
  • 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 511625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:14:09+00:00 2026-05-13T07:14:09+00:00

After doing the Hough transform in MATLAB , how do I pick the lines

  • 0

After doing the Hough transform in MATLAB, how do I pick the lines so that I can compare between two or more images?

I followed the example given by Amro and actually what I wanted to detect is the two lines in the first picture. However, what I got is the one in the second picture. How can I do this?

Alt text

Alt text

  • 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-13T07:14:09+00:00Added an answer on May 13, 2026 at 7:14 am

    I think you meant the goal to be to detect lines in an image, not comparing two images (?).

    Anyway, to find the maximum intensities in the Hough transform matrix generated by the hough function, we use the houghpeaks function, and pass it the desired number of peaks to detect.


    EDIT1:

    I figured I would add an example to show the procedure:

    %# Load image, process it, find edges
    I  = rgb2gray( imread('pillsetc.png') );
    I = imcrop(I, [30 30 450 350]);
    J = imfilter(I, fspecial('gaussian', [17 17], 5), 'symmetric');
    BW = edge(J, 'canny');
    
    %# Perform Hough transform and show matrix
    [H,T,R] = hough(BW);
    imshow(imadjust(mat2gray(H)), [], 'XData',T, 'YData',R, ...
           'InitialMagnification','fit')
    xlabel('\theta (degrees)'), ylabel('\rho')
    axis on, axis normal, hold on
    colormap(hot), colorbar
    
    %# Detect peaks
    P  = houghpeaks(H, 4);
    plot(T(P(:,2)), R(P(:,1)), 'gs', 'LineWidth',2);
    
    %# Detect lines and overlay on top of image
    lines = houghlines(BW, T, R, P);
    figure, imshow(I), hold on
    for k = 1:length(lines)
        xy = [lines(k).point1; lines(k).point2];
        plot(xy(:,1), xy(:,2), 'g.-', 'LineWidth',2);
    end
    hold off
    

    Accumulator matrix
    Image with overlayed lines


    EDIT2:

    Following your recent update, I managed to detect the lines by only making a few changes to the same above code:

    • I cropped the region to: [200 70 160 140]
    • I used an 11×11 Gaussian filter with sigma=3

    Note: You will have to add the offset to get the position of the lines in the original image uncropped. Also, if you want more accurate results, you might want to detect four lines and get the lines in the middle as shown below:

    Four enclosing lines

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

Sidebar

Ask A Question

Stats

  • Questions 245k
  • Answers 245k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer From your question i'm assuming you don't have full control… May 13, 2026 at 8:11 am
  • Editorial Team
    Editorial Team added an answer Other's have already provided you with correct answers, but here's… May 13, 2026 at 8:11 am
  • Editorial Team
    Editorial Team added an answer If I understand you correctly, this will get you close.… May 13, 2026 at 8:11 am

Related Questions

I'm doing the following: var data = $(form).serializeArray(); // Now I want to add
An error has occurred while establishing a connection to the server. When connecting to
I have a PHP app running happily on the following system: web app: PHP
I am using framework 2.0, and I don't understand how the datagrid and the
I would like to override response_change in a ModelAdmin in order to update a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.