detect or find right angle in an image

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
daffy

detect or find right angle in an image

Post by daffy »

Hi

Is there a way to find 90 degree (or intersecting lines) within an image?

i have an image with two lines (intersecting and making a right angle), i would like to crop all image that falls under right angle area.

thanks
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: detect or find right angle in an image

Post by anthony »

That can be tricky. Especially if the right angle can be rotated and at different scales (how long are the two lines). The first step would be appropriate cleanup of the image to remove extraneous detail that would only confuse what you are looking for.

The Hough Algorithm will find lines, though not intersections of those lines.

A Scale/Rotate/Translation invariant image search method, used against a edge detected image may also be a possibility. That is create a edge detection image, then transform it into a polar-log image before looking for the 'signature' pattern of the desired right angle.

The Raster to Vector translator, "AutoTrace" also has options in it about angle join limits for determining if a line should be a sharp angle or a smooth curve. That may also yield something useful, as it must then also know if two lines (edges) actually do form a right angle, and how much of a right angle. However this only works well on images with large areas of solid color, which may be difficult to generate.

However I am sure quite a number of other methods exist in an area I am not really familiar with... Image Registration. That is the location of specific types of points in an image, that can then be used to match up to similar points in a second image. One of the registration techniques is line intersections and corners. So I am sure it has something like what you are looking for. Do a google on that and see what you can find.

Oh an please let us know what you did find that is useful. It would be something like this would be useful in many other programs, and scripts. It may even be able to build into IM core library!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
daffy

Re: detect or find right angle in an image

Post by daffy »

thanks for the input!
I will give that some try and let you know.

another simple question i have is,

while looking for lines, could i specify length of the line (during edge detection) ?
i would like to detect edge only if its length is X and ignore all other edges.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: detect or find right angle in an image

Post by fmw42 »

IM has nothing that I know about that will measure and filter edges by length (as they need to be connected into lines first). IM edge detection only looks for discontinuities in grayscale (color) in a local or pixel neighborhood. You probably need to write something yourself. See all the details of such processing by Googling for Canny Edge Detector.

It would be nice if someone would contribute code to IM for either or both a Hough Line Transformation and a Canny Edge Detector.
Post Reply