views:

539

answers:

2

Hi, I am successfully able to detect hair strands in an image as lines. I see that the output image detects each hair as line.I use cvHoughLines2() with method parameter as CV_HOUGH_PROBABILISTIC. Now I want to count these lines.The output image shows 1 or 2 line over each hair.I see that each line is composed of small line segments. And So it is difficult to directly get their total number. Any suggestions on this?

Thanks, Pradeep

A: 

You may actually be better off using the Canny edge detector. From your description, it seems to have a few key advantages over the Hough transform:

  • responds to contours of arbitrary shape, not just straight lines;
  • performs noise reduction and non-maximum suppression to minimize the response; and
  • does a second detection with looser threshold to "trace" or "solidify" edges.

Given the right parameters, it may be able to uniquely detect each hair with a single, continuous line.

This is implemented in OpenCV in the cvCanny() function. Play around with the value of the threshold1 and threshold2 parameters (3rd and 4th arguments) to experiment with detection and tracing.

As for actually counting the lines, I'm not sure how best to approach this (Canny output is a somewhat different form from Hough transform output), but you might find it easier to work with unique, solid edges than with fragmented sets of line parameters.

ezod
A: 

Thanks ezod,

I am using cvCanny() to detect edges and then applying cvHoughLines2() on that.I get the output image more or less according to my expectations. i.e Visually I can see the image has each line/hair marked distinctly.(Though it misses some)

But my problem is counting the lines. As you suggested I will try to play with cvCanny method to see if get something from it.

Thanks, Pradeep

Pradeep