hyperknot
hyperknot

Reputation: 13966

Identify directions of similar triangles in MATLAB

I have a BW bitmap of similar triangles. I am trying to identify the direction each triangle is facing. By "facing" I mean describing the direction in a way what is constant across all triangles, by for example the direction of the longest side's median.

So far I could identify the triangles individually, but I don't know what would be the best way to find out the direction of each triangle.

As a first idea I thought about using Hough transform to fit lines for the sides of each individual triangle. Once I have the 3 sides, I can calculate their intersections and then I have the coordinates of the 3 vertices. From the 3 vertices it’s easy to find out the longest side's median.

My problem with this approach is that I never used Hough transforms and I don't know how hard it is to write a function which finds the sides and returns them in a way what I can use for calculating intersections. Can you link me to some article or explain briefly how to use Hough transform to find sides in a representation what I can use for calculating intersections?

My other idea is to use rotation invariant moments, directly on the bitmap images, without recognising their sides by Hough transform.

My problem with this solution is that I don't know what is the "meaning" of a direction when I describe it using moments. If I use invariant moments, how can I define a reference direction?

A sample image with the identified objects: sample

A single object sample1

Upvotes: 1

Views: 1015

Answers (1)

Jacob
Jacob

Reputation: 34601

Use houghlines to find the longest in each triangle i.e. the BW input should only contain the edges of one triangle (e.g. use BW = edge(I,'canny')). This will give you the equation of the longest side to your triangle.

If your triangles are isoceles, then the normal to the longest side passing through its midpoint is the median, and you're done.

If not, I guess you'll have to find the 3 edges, etc.

Update:

Looking at your blobs, I'd recommend experimenting with R = regionprops(BW,'Orientation');

Upvotes: 1

Related Questions