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.