Recognition Color Schemes Modes

Overview

Aspose.BarCode for .NET allows reading barcodes with non-typical color schemes, like barcodes with inverted colors (luminance) and color barcodes on color images. To do this, two properties InverseImage and ComplexBackground are added to QualitySettings. Additional recognition modes for non-typical color schemes can reduce recognition performance and increase recognition time.

Inverse Image Mode

Aspose.BarCode for .NET enables reading barcode images with inverted colors. To do this, it is required to use a special property called InverseImage, as listed in the table below.

Inverse Image Mode Description
Auto At this time the same as Disabled. Disables additional recognition for barcodes with inverted colors (luminance). In the future, barcode types like QR can use this mode
Disabled Disables additional recognition for barcodes with inverted colors (luminance)
Enabled Enables additional recognition for barcodes with inverted colors (luminance)

The following table shows difference in recognition quality, depends on option value.

Inverse Image Disabled Inverse Image Enabled
Recognized barcodes: 1 Recognized barcodes: 2
Console.WriteLine("ReadInverseImage:");
//recognize image with Inverse image mode Disabled
Console.WriteLine("InverseImageMode: Disabled");
using (BarCodeReader read = new BarCodeReader($"{path}aztec_regular_inverse.png", DecodeType.Aztec))
{
    read.QualitySettings.InverseImage = InverseImageMode.Disabled;
    Console.WriteLine($"Barcodes read: {read.ReadBarCodes().Length}");
    foreach (BarCodeResult result in read.FoundBarCodes)
        Console.WriteLine($"{result.CodeTypeName}:{result.CodeText}");
}

//recognize image with Inverse image mode Enabled
Console.WriteLine("InverseImageMode: Enabled");
using (BarCodeReader read = new BarCodeReader($"{path}aztec_regular_inverse.png", DecodeType.Aztec))
{
    read.QualitySettings.InverseImage = InverseImageMode.Enabled;
    Console.WriteLine($"Barcodes read: {read.ReadBarCodes().Length}");
    foreach (BarCodeResult result in read.FoundBarCodes)
        Console.WriteLine($"{result.CodeTypeName}:{result.CodeText}");
}
View the results of code execution
ReadInverseImage:
InverseImageMode: Disabled
Barcodes read: 1
Aztec:Aspose Regular
InverseImageMode: Enabled
Barcodes read: 2
Aztec:Aspose Regular
Aztec:Aspose Inverse

Complex Background Mode

Aspose.BarCode for .NET enables reading colored barcodes on a colored background. With property ComplexBackground the barcode recognition engine attempts to distinguish the colored background from barcode labels through color quantization and then subtract it. Mode list is shown in the table below.

Complex Background Mode Description
Auto At this time the same as Disabled. Disables additional recognition of color barcodes on color images
Disabled Disables additional recognition of color barcodes on color images
Enabled Enables additional recognition of color barcodes on color images

The following table shows difference in recognition quality, depends on option value.

Complex Background Disabled Complex Background Enabled
Recognized barcodes: 0 Recognized barcodes: 1
Console.WriteLine("ReadComplexBackground:");
//recognize image with Complex background mode Disabled
Console.WriteLine("ComplexBackgroundMode: Disabled");
using (BarCodeReader read = new BarCodeReader($"{path}qr_color.png", DecodeType.QR))
{
    read.QualitySettings.ComplexBackground = ComplexBackgroundMode.Disabled;
    Console.WriteLine($"Barcodes read: {read.ReadBarCodes().Length}");
    foreach (BarCodeResult result in read.FoundBarCodes)
        Console.WriteLine($"{result.CodeTypeName}:{result.CodeText}");
}

//recognize image with Complex background mode Enabled
Console.WriteLine("ComplexBackgroundMode: Enabled");
using (BarCodeReader read = new BarCodeReader($"{path}qr_color.png", DecodeType.QR))
{
    read.QualitySettings.ComplexBackground = ComplexBackgroundMode.Enabled;
    Console.WriteLine($"Barcodes read: {read.ReadBarCodes().Length}");
    foreach (BarCodeResult result in read.FoundBarCodes)
        Console.WriteLine($"{result.CodeTypeName}:{result.CodeText}");
}
View the results of code execution
ReadComplexBackground:
ComplexBackgroundMode: Disabled
Barcodes read: 0
ComplexBackgroundMode: Enabled
Barcodes read: 1
QR:Aspose常に先を行く