Home > Code > C# > .NET Code for Better & Faster Image Processing in Barcode Recognition

.NET Code for Better & Faster Image Processing in Barcode Recognition

by sher azam   on Aug 27, 2013   Category: C#   |  Views: 1040    |  Points: 25   |  Gold 


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:

[C#]

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
while (reader.Read())
{
// display the codetext
Console.WriteLine("Codetext: " + reader.GetCodeText());
}
// close the reader
reader.Close();

[VB.NET]

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)
' set grayscale 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())
Loop
' close the reader
reader.Close()

Overview: Aspose.BarCode for .NET

Aspose.BarCode is a .NET component for generation and recognition of Linear and 2D barcodes on all kinds of .NET applications. It supports WPF with 29+ Barcode symbologies like OneCode, QR, Aztec, MSI, EAN128, EAN14, SSCC18, Code128, Code39, Postnet, MarcoPDF417, Datamatrix, UPCA etc. Other features include barcode insertion in PDF, Word and Excel documents. Also take image output in BMP, GIF, JPEG, PNG and WMF formats. You can also control image styles such as background color, bar color etc.

More about Aspose.BarCode for .NET

- Homepage of Aspose.BarCode for .NET: http://www.aspose.com/.net/barcode-component.aspx

- Download of Aspose.BarCode for .NET: http://www.aspose.com/community/files/51/.net-components/aspose.barcode-for-.net/default.aspx

- More Technical Tips for Barcode Recognition: http://www.aspose.com/docs/display/barcodenet/Working+with+Barcode+Recognition



Post Code  |  Code Snippet Home

User Responses


No response found, be the first to review this code snippet.

Submit feedback about this code snippet

Please sign in to post feedback

Latest Posts