HOWTO: Improve Ocr Color Images Read Quality


All of Atalasoft’s OcrEngine based classes perform optimum reads on a 1 bit per pixel images (black and white). However the input image does not have to be in Pixel1bppIndexed pixel format. Inside the ImageSendOff event the initial image will get the results of any modifications done to the image. Here using the DynamicThresholdCommand should provide the best reads.

C#

void engine_ImageSendOff(object sender, Atalasoft.Ocr.OcrImagePreprocessingEventArgs e)
{
DynamicThresholdCommand DTC = new DynamicThresholdCommand();
if (DTC.IsPixelFormatSupported(e.ImageIn.PixelFormat))
    e.ImageOut = DTC.Apply(e.ImageIn).Image; 
else
    e.ImageOut = e.ImageIn;
}

VB.NET

Private Sub engine_ImageSendOff(ByVal sender As Object, ByVal e As Atalasoft.Ocr.OcrImagePreprocessingEventArgs) 
    Dim DTC As New DynamicThresholdCommand() 
    If DTC.IsPixelFormatSupported(e.ImageIn.PixelFormat) Then 
        e.ImageOut = DTC.Apply(e.ImageIn).Image 
    Else 
        e.ImageOut = e.ImageIn 
    End If 
End Sub

Original Article:
Q10255 - HOWTO: Improve Ocr Color Images Read Quality