Class BrightnessFilter
A filter to adjust image brightness.
Inheritance
Implements
Namespace: IronBarCode
Assembly: IronBarCode.dll
Syntax
public class BrightnessFilter : Object, IImageFilter
When a barcode image is too dark to read, a photo shot in poor light or a scan that came out underexposed, BrightnessFilter lifts the overall luminance so the bars separate cleanly from the background. It scales the brightness of every pixel by a single amount, which is the simplest correction in the set and often the only one a dim but otherwise clean image needs before decoding.
The filter implements IImageFilter and is added to the ImageFilterCollection on BarcodeReaderOptions.ImageFilters, applied in collection order ahead of the read. A developer constructs it, drops it into the collection, and passes the options to BarcodeReader.Read. The single Amount property sets the scaling: the default value of 1 leaves the image unchanged, 0 produces a fully black image, and values above 1 brighten it. The single-argument constructor sets Amount at creation. Brightness pairs naturally with a contrast pass when an image is both dark and flat.
using IronBarCode;
var options = new BarcodeReaderOptions
{
ImageFilters = new ImageFilterCollection { new BrightnessFilter(1.5f) }
};
var results = BarcodeReader.Read("underexposed.png", options);The image correction how-to shows the brightness pass on a sample barcode, and the imperfect barcode example reads a low-quality image after correction.
Constructors
BrightnessFilter()
Initializes a new instance of the BrightnessFilter class.
Declaration
public BrightnessFilter()
BrightnessFilter(Single)
Initializes a new instance of the BrightnessFilter class with the specified amount.
Declaration
public BrightnessFilter(float amount)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | amount | The proportion of the conversion. Value must be between [-1, 1]. Positive values increase brightness, negative values decrease brightness. A value of 0 leaves the image unchanged. |
Properties
Amount
The proportion of the conversion. Value must be between [-1, 1]. Default = 0.
Positive values increase brightness, negative values decrease brightness. A value of 0 leaves the image unchanged.
Declaration
public float Amount { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Single |