Search Results for

    Show / Hide Table of Contents

    Class MedianBlurFilter

    A filter to apply Median blur to an image.

    Inheritance
    System.Object
    MedianBlurFilter
    Implements
    IImageFilter
    Namespace: IronBarCode
    Assembly: IronBarCode.dll
    Syntax
    public class MedianBlurFilter : Object, IImageFilter

    Salt-and-pepper specks scattered across a scan are cleared by MedianBlurFilter, which replaces each pixel with the median value of its neighborhood. Unlike an averaging blur, a median pass removes isolated bright and dark dots without smearing the sharp transitions between bars, so the edges that a decoder depends on stay crisp. It is the filter to reach for when a thresholded or low-quality scan is peppered with stray pixels rather than uniformly grainy; for a gentler, edge-softening smooth of general noise, a Gaussian blur is the alternative.

    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 5, the size of the neighborhood sampled for each median. KernelSize must be an odd value greater than 0; the MedianBlurFilter(int kernelSize) overload or the KernelSize property raises it for stronger speck removal on heavier noise.

    using IronBarCode;
    
    var options = new BarcodeReaderOptions
    {
        ImageFilters = new ImageFilterCollection { new MedianBlurFilter() }
    };
    var results = BarcodeReader.Read("speckled.png", options);

    The image correction how-to covers the correction filters on a sample barcode, and the imperfect barcode example reads a degraded image through a filter pipeline.

    Constructors

    MedianBlurFilter()

    Initializes a new instance of the MedianBlurFilter class.

    Declaration
    public MedianBlurFilter()

    MedianBlurFilter(Int32)

    Initializes a new instance of the MedianBlurFilter class.

    Declaration
    public MedianBlurFilter(int kernelSize)
    Parameters
    Type Name Description
    System.Int32 kernelSize

    Size of the kernel to apply Median blur.

    Properties

    KernelSize

    Size of the kernel to apply Median blur. Must be an odd value greater than 0. Default = 5.

    Declaration
    public int KernelSize { get; set; }
    Property Value
    Type Description
    System.Int32

    Implements

    IImageFilter
    ☀
    ☾
    Downloads
    • Download with Nuget
    • Start for Free
    In This Article
    Back to top
    Install with Nuget