An algorithm for detection of tuberculosis bacilli in Ziehl-Neelsen sputum smear images