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.
- Find boundary. Move from center to outside and find first white pixel. Repeat for as many direction as you want.
- 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.
- Identify triangle. If boundary is builded from 3 good lines then it is a triangle.
It's only idea, I'll hope that help.
精彩评论