Need character whitelist function for better result

Sometime I want to OCR a captcha image that only has a number so I need a character whitelist function for better detection. Image may contain noise so it is sometimes detected as dots

For captcha detection, did you try the new ocr engine5? I find it works best.