Class GaussianBlurFilter
A filter to apply Gaussian blur to an image.
Inheritance
Implements
Namespace: IronBarCode
Assembly: IronBarCode.dll
Syntax
public class GaussianBlurFilter : Object, IImageFilter
Speckle and high-frequency noise that confuse a decoder are smoothed away by GaussianBlurFilter, which averages each pixel with its neighbors using a Gaussian function. A moderate blur removes the grain in a noisy scan or photo so the bar pattern reads as a continuous shape rather than a field of dots. It is the standard noise-reduction pass when edge preservation is not the priority; for noise removal that keeps the edges crisp, the bilateral filter is the alternative.
The filter implements IImageFilter and goes into the ImageFilterCollection on BarcodeReaderOptions.ImageFilters, applied in collection order before the read. A developer constructs it, adds it to the collection, and passes the options to BarcodeReader.Read. The defaults produce a moderate blur from a 3x3 kernel with a Sigma of 3.0; the overloads expose KernelWidth and KernelHeight to size the averaging neighborhood and Sigma to control the blur intensity. Raise Sigma for a stronger blur when the noise is heavy.
using IronBarCode;
var options = new BarcodeReaderOptions
{
ImageFilters = new ImageFilterCollection { new GaussianBlurFilter() }
};
var results = BarcodeReader.Read("noisy.png", options);The image correction how-to shows the Gaussian pass on a sample barcode, and the imperfect barcode example reads a degraded image through a filter pipeline.
Constructors
GaussianBlurFilter()
Initializes a new instance of the GaussianBlurFilter class.
Declaration
public GaussianBlurFilter()
GaussianBlurFilter(Int32, Int32, Single)
Initializes a new instance of the GaussianBlurFilter class.
Declaration
public GaussianBlurFilter(int kernelWidth, int kernelHeight, float sigma)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | kernelWidth | Width of the kernel to apply Gaussian blur. |
| System.Int32 | kernelHeight | Height of the kernel to apply Gaussian blur. |
| System.Single | sigma | The 'Sigma' value representing the weight of the blur. |
GaussianBlurFilter(Single)
Initializes a new instance of the GaussianBlurFilter class.
Declaration
public GaussianBlurFilter(float sigma)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | sigma | The 'Sigma' value representing the weight of the blur. |
Properties
KernelHeight
Height of the kernel to apply Gaussian blur. Must be an odd value greater than 0. Default = 3.
Declaration
public int KernelHeight { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
KernelWidth
Width of the kernel to apply Gaussian blur. Must be an odd value greater than 0. Default = 3.
Declaration
public int KernelWidth { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Sigma
The 'Sigma' value representing the weight of the blur. Default = 3.0f.
Declaration
public float Sigma { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Single |