フィルターのクリア

measuring a triangle

2 ビュー (過去 30 日間)
Rob
Rob 2012 年 4 月 24 日
I have an image with a 2D triangle object. Any help as how to proceed to measure its dimensions in pixels?. thanks for help.

回答 (3 件)

Rick Rosson
Rick Rosson 2012 年 4 月 24 日
>> doc imtool

Geoff
Geoff 2012 年 4 月 24 日
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 2012 年 4 月 24 日
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?

カテゴリ

Help Center および File ExchangeImages についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by