Azzera filtri
Azzera filtri

measuring a triangle

2 visualizzazioni (ultimi 30 giorni)
Rob
Rob il 24 Apr 2012
I have an image with a 2D triangle object. Any help as how to proceed to measure its dimensions in pixels?. thanks for help.

Risposte (3)

Rick Rosson
Rick Rosson il 24 Apr 2012
>> doc imtool

Geoff
Geoff il 24 Apr 2012
You want the side lengths? Is it easy to determine whether a pixel is in the triangle or not? ie is it isolated?
You could try this pretty unimaginative algorithm. Dunno if it's the done thing, as I just invented it on the spot.
1. Find the two pixels with the largest and smallest y-values. These are guaranteed to be corners because of the properties of triangles.
2. Find the two pixels with the largest and smallest x-values. If one of these co-ordinates is significantly different from the other two from step 1, then you have found your third corner.
3. Otherwise you are going to have to search for the third corner. I propose that you calculate the total length of a line passing from corner 1, through each pixel, and to corner 2. Your third corner ought to be the one where this distance is largest.
In fact you might want to do step 3 always and not bother with step 2, but it's more efficient to only do the search on smaller triangles. That is, triangles that lie inside the rectangle formed by your two known corners from step 1.
If you have the corners, then presumably you have all the information you require.
Hope that helps.

Image Analyst
Image Analyst il 24 Apr 2012
Basically threshold, bwlabel(), then regionprops(). If you want a well commented image segmentation tutorial, see my File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
If you want to find the lengths of the sides, find the points (vertices) with the corner() function, then use Pythagorean theorem. Uploading your image may help us give better answers. Is this a homework problem?

Categorie

Scopri di più su Images in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by