Question

Could you suggest an approach for color-based segmentation for square or triangular shapes? I'm working on an iOS app for recognizing road signs and have implemented it for round signs but that approach doesn't seem to work with other forms. For the circles we do the following:

  1. Detect the colors we need, e.g. red and white, through HSV/B.

  2. Detect circle through the method called Fast Circle Detection Using Gradient Pair Vectors based on analysis of gradient direction vectors (description and code: http://rnd.azoft.com/applied-use-of-m2m-tchnology-in-ios-apps/)

Triangles and squares demand differed approach and we've stuck a bit.

Was it helpful?

Solution

Assuming you're looking for red lines...

  • Threshold just the red component of the image
  • Compute hough lines and look for line segments of an estimated length (if you know the length of the sides of the triangle/square you're looking for).
  • Once you have this list, find combinations of lines that form triangles and squares.
  • Verify each candidate triangle/square by checking that their areas are within expected ranges.

If you follow this method, it is likely that you will find multiple shapes within close proximity of each other i.e. the same triangle/square in the real world will be found multiple times by the algorithm depending on the thickness of the lines. In this case, cluster them by distance and only retain one shape per cluster.

Another option is

  • Threshold the red component of the image.
  • Find contours.
  • Check for closed contours.
  • For every close contour, check if the shape resembles an equilateral triangle or a square by plotting histograms of slopes of individual points on the contour. The histogram for a square will have two highly populated bins, while that of a triangle will have three highly populated bins.

OTHER TIPS

I have studied on a school project for road sign detection and for our segmentation part, we really benefited from this paper.

http://vc.cs.nthu.edu.tw/home/paper/codfiles/cmwang/201201100409/110104%20Goal%20evaluation%20of%20segmentation%20algorithms%20for%20traffic%20sign%20recognition.pdf

It compares performance of many color based segmentation techniques and some non-color based approaches. Tests compared with different signs.

Unlike some survey paper in this area it explains threshold values for different methods.

Good luck.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top