Im searching for a method or an algorithm that can help me
in finding number of holes in an image

this image is basically for a letter like "D" "B"
--->number of holes can distinguish between those letters..

this will help me alot in my project if it works
any suggestion .. i would appreciate it
thanks ..

Thanks Ramy,,
I looked to the link ,, it is really useful
but im implementing these steps but with different algorithms
for classification..

so that again im asking the same question
but in another way...

how can we detect the existence of closed curve in an image
any help would be appreciated

Sorry Dima I didn't make it before but I'm trying to help I search and I found this book Mathematical Tools in Computer Graphics with C# Implementations By Alexandre Hardy, Willi-Hans Steeb and I think it has the answer can you please take a look on http://books.google.com.eg/books?id=IGtIWmM2GWIC&pg=PA164&lpg=PA164&dq=detect+closed+curve+in+an+image+C%23&source=bl&ots=eBFYLo3g6L&sig=curnJy8dZ-t9GJ-3plt7PrLhoT0&hl=en&ei=NtGvSuuMOdzLjAes_tnABA&sa=X&oi=book_result&ct=result&resnum=7#v=onepage&q=&f=false