Measuring angle in an image

18 views (last 30 days)
Darren G
Darren G on 27 Jun 2013
Dear Image Analyst,
I need to draw a line between two points in an image during execution of the program and measure the angle w.r.t. horizontal. This need to be done interactively for a large set of images. Need idea on how to start with?
Thanks. Darren

Answers (4)

Matt J
Matt J on 27 Jun 2013
Edited: Matt J on 27 Jun 2013

Matt J
Matt J on 28 Jun 2013
Edited: Matt J on 28 Jun 2013
Those pair of patches are not point like and finding/clicking the centre of the patch is not very accurate. hence the measured angle as well.
You can use regionprops to pre-compute the centroids of all the patches. Then, as long as you are clicking reasonably close to the center of the patch, you can use the ginput coordinates to find the closest centroid.

Image Analyst
Image Analyst on 27 Jun 2013
Do you need to know how to process a sequence of files, like the FAQ shows: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
Or do you need to know how to calculate the angle given 3 points?
Or do you need to know how to ask the user to draw the angle (like with imline function in the Image Processing Toolbox)?

Darren G
Darren G on 28 Jun 2013
Hi,
Thanks for all your answers. In fact, I have a series of images with intensity patches. These images are slightly differ one from another. These images are symmetric about the centre of the image. What I need to do is to find the maximum intensity patch pair in the image (The line connecting that pair pass through the centre of the image because of the symmetry). Then I need to find the angle of that line w.r.t. horizontal.
I have now used the ginput() for finding the (x1,y1) and (x2,y2) co-ordinates of those point patches and then used tand((y2-y1)/(x2-x1)) to find the angle. This can be done for all series of images.
Here is the problem currently I am encountering. Those pair of patches are not point like and finding/clicking the centre of the patch is not very accurate. hence the measured angle as well. What I really need now is a way to find the centre of gravity of those patch region for both patches and then to find the angle of the line connecting those centre of gravity points with the horizontal. Is there any way of how to do it? I tried the imrect and imellipse to select those patched regions but do not know how to find the centre of gravity points of that patch region and then relating that points co-ordinates to the original image co-ordinates to find the angle.
Any help on this is much appreciated.
Thanks. Darren

Community Treasure Hunt

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

Start Hunting!