Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's a simple and efficient method for extracting line segments from a simple 2D image?

Specifically, I'm trying to extract all of the relevant line segments from screenshots of the game 'asteroids'. I've looked through the various methods for edge detection, but none seem to fit my problem for two reasons:

  1. They detect smooth contours, whereas I just need the detection of straight line segments, and only those within a certain range of length. Now, these constraints should make my task considerably easier than the general case, but I don't want to just use a full blown edge detector and then clear the result of curved lines, as that would be prohibitively costly. Speed is of the utmost importance for my purposes.

  2. They output a modified image where the edges are highlights, whereas I want a set of pixel coordinates depicting the endpoints of the detected line segments. Alternatively, a list of all of the pixels included in each segment would work as well.

I have an inkling that one possible solution would involve a hough transform, but I don't know how to use this to get the actual locations of the line segments (i.e. endpoints in pixel space). Though even if I did, I have no idea if that would be the simplest or most efficient way of doing things, hence the general wording of the question title.

Lastly, here's a sample image:

enter image description here

Notice that all of the major lines are similar in length and density, and that the overall image contrast is very high. I'm hoping the solution to my problem will exploit these features, because again, efficiency is paramount.

One caveat: while most of the line segments in this context are part of a polygon, I don't want a solution that relies on this fact.

like image 334
zergylord Avatar asked Aug 10 '11 08:08

zergylord


People also ask

What are the methods adopted for image segmentation?

Following are the primary types of image segmentation techniques: Thresholding Segmentation. Edge-Based Segmentation. Region-Based Segmentation.

Which technique is applied for edge segmentation?

The Sobel technique of edge detection for image segmentation finds edges using Sobel approximation derivative [6]. It performs a 2-D spatial gradient measurement on an image and so emphasizes regions of high spatial gradient that corresponds to edges.

What is image segmentation What are the types of segmentation?

Image segmentation is a method in which a digital image is broken down into various subgroups called Image segments which helps in reducing the complexity of the image to make further processing or analysis of the image simpler. Segmentation in easy words is assigning labels to pixels.

What is segmentation in digital image processing?

Image segmentation is a method of dividing a digital image into subgroups called image segments, reducing the complexity of the image and enabling further processing or analysis of each image segment.


1 Answers

Have a look at the Line Segment Detector algorithm.

Here's what they do :

enter image description hereenter image description here

You can find an impressive video at the bottom of the page.

There's a C implementation (that works with C++ compilers) that works out of the box. There are just one or two files, and no additional dependencies

But, be warned, the algorithm is under the GNU Allegro GPL license.

like image 185
B. Decoster Avatar answered Oct 06 '22 04:10

B. Decoster