开发者

detect triangle in bitmap

开发者 https://www.devze.com 2023-03-18 02:35 出处:网络
Working on an android app, I have a bitmap obtained by applying edge detection on some image. Black background bitmap with white lines as edges.

Working on an android app, I have a bitmap obtained by applying edge detection on some image. Black background bitmap with white lines as edges.

I开发者_运维技巧 need to identify the first closed boundary moving outward from the centre and check if it is a triangle.

How do I do that? Even a methodology if not code sample would be of much help.


This is modified Hough transform, a little optimized for this problem.
Assuming that you applied edge detection and edge is white pixel.

  1. Find boundary. Move from center to outside and find first white pixel. Repeat for as many direction as you want.
  2. Find lines. Route line through pixels that are neighbours (take two pixels or find equation to route line through more than two pixels) and check how many white pixels are under the line. The more pixel under line, the better line it is. Take into account intersection with another lines and count white pixels till the intersection.
  3. Identify triangle. If boundary is builded from 3 good lines then it is a triangle.

It's only idea, I'll hope that help.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号