This Technical tip explains how to perform faster and better barcode image recognition using Aspose.BarCode for .NET. Aspose.BarCode for .NET provides better and faster barcode recognition using the following image processing algorithms:
• Median smoothing image processing (RecognitionHints.ImageBinarizationHints.MedianSmoothing)
• HLS image processing (RecognitionHints.ImageBinarizationHints.HLS)
• Grayscale image processing (RecognitionHints.ImageBinarizationHints.Grayscale)
Median smoothing: MedianSmoothing technique gives a perfect result. In more complicated images, less data will be lost by taking the median. MedianSmoothing removes the noise from the image while preserving the image edges.
HLS: HLS is also a Color space similar to RGB. But instead of red, green and blue components, HLS contain Hue, Luminance & Saturation components. It's a color space in which the Hue, saturation and luminance of a color can be separated and modified.
GrayScale: It converts image to grayscale. This processing technique can be useful while detecting bar codes from scanned or slightly damaged images. The probability of bar code detection will increase by this setting.
The following code snippet shows how to use median smoothing, HLS and gray-scale image processing techniques while recognizing the barcode.
string image = @"code39Extended.jpg";
// create an instance of BarCodeReader and set image and symbology type to recognize
BarCodeReader reader = new BarCodeReader(image, BarCodeReadType.Code39Standard);
// set grayscale image processing
reader.ImageBinarizationHints = RecognitionHints.ImageBinarization.Grayscale;
// try to recognize all possible barcodes in the image
// display the codetext
Console.WriteLine("Codetext: " + reader.GetCodeText());
// close the reader
Dim image As String = "code39Extended.jpg"
' create an instance of BarCodeReader and set image and symbology type to recognize
Dim reader As BarCodeReader = New BarCodeReader(image, BarCodeReadType.Code39Standard)
' setgrayscale image processing
reader.ImageBinarizationHints = RecognitionHints.ImageBinarization.Grayscale
' try to recognize all possible barcodes in the image
Do While reader.Read()
' display the codetext
Console.WriteLine("Codetext: " &reader.GetCodeText())
' close the reader