Hair removal algorithm development

I will assume that you understand what a grayscale image is and operations upon it are. If not, edit your question to clarify.

The Matlab Image Processing Toolbox includes the imclose function. Morphological closing is explained on Wikipedia. The Internet is awash with information about mathematical morphology for image processing.

EDIT after comment

This page gives a general introduction for mathematical morphology for image processing. One view of what you are trying to do is remove noise from your image, where that noise is expressed as long(-ish) thin(-ish) dark elements against a light background -- if, that is, the hairs are dark and the skin is light. This isn't an application I've looked at so I can't provide any more help. Have fun.