Class DilateFilter
A filter to apply dilation to an image.
Inheritance
Implements
Namespace: IronBarCode
Assembly: IronBarCode.dll
Syntax
public class DilateFilter : Object, IImageFilter
DilateFilter thickens the dark regions of a barcode image so thin or broken bars join into a solid, readable shape. Dilation is a morphological operation that grows the foreground pixels, which closes small gaps and reconnects a pattern that printing, faxing, or low-resolution scanning has eroded into fragments. Reach for it when a code reads as a scatter of disconnected marks rather than continuous bars; for the opposite problem, where bars have bled together, the erosion filter shrinks them back.
The filter implements IImageFilter and is added to the ImageFilterCollection on BarcodeReaderOptions.ImageFilters, where filters run in collection order before the read. A developer constructs it, adds it to the collection, and passes the options to BarcodeReader.Read. The parameterless constructor uses a KernelSize of 3, the length of one side of the square kernel that controls how aggressively the bars are grown. The DilateFilter(int kernelSize) overload or the KernelSize property raises that value for heavier dilation when the gaps are wide.
using IronBarCode;
var options = new BarcodeReaderOptions
{
ImageFilters = new ImageFilterCollection { new DilateFilter() }
};
var results = BarcodeReader.Read("faded.png", options);The image correction how-to walks through filter selection on a sample barcode, and the imperfect barcode example reads a degraded image through a filter pipeline.
Constructors
DilateFilter()
Initializes a new instance of the DilateFilter class.
Declaration
public DilateFilter()
DilateFilter(Int32)
Initializes a new instance of the DilateFilter class.
Declaration
public DilateFilter(int kernelSize)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | kernelSize | Size of the kernel used to apply dilation, expressed as the length of one side of a square kernel of ones. |
Fields
KernelSize
Size of the kernel used to apply dilation, expressed as the length of one side of a square kernel of ones. Default = 3.
Declaration
public int KernelSize
Field Value
| Type | Description |
|---|---|
| System.Int32 |
Remarks
The greater the size of the kernel, the more the low color intensity regions grow.