Color filtering in HSL color space.

The filter operates in HSL color space and filters pixels, which color is inside/outside of the specified HSL range - it keeps pixels with colors inside/outside of the specified range and fills the rest with specified color.

The filter accepts 24 and 32 bpp color images for processing.

Sample usage:

// create filter HSLFiltering filter = new HSLFiltering( ); // set color ranges to keep filter.Hue = new IntRange( 335, 0 ); filter.Saturation = new Range( 0.6f, 1 ); filter.Luminance = new Range( 0.1f, 1 ); // apply the filter filter.ApplyInPlace( image );

Initial image:

Result image:

Sample usage with saturation update only:

// create filter HSLFiltering filter = new HSLFiltering( ); // configure the filter filter.Hue = new IntRange( 340, 20 ); filter.UpdateLuminance = false; filter.UpdateHue = false; // apply the filter filter.ApplyInPlace( image );

Result image:

Inheritance: BaseInPlacePartialFilter
Example #1
0
        private void SetFilter()
        {
            ImageType = ImageTypes.Rgb32bpp;
            Af.HSLFiltering newFilter = new Af.HSLFiltering();

            newFilter.FillColor = Accord.Imaging.HSL.FromRGB(new Accord.Imaging.RGB(color));

            newFilter.Hue        = new Accord.IntRange((int)Remap(hue.T0, 0, 359), (int)Remap(hue.T1, 0, 359));
            newFilter.Saturation = new Accord.Range((float)saturation.T0, (float)saturation.T1);
            newFilter.Luminance  = new Accord.Range((float)luminance.T0, (float)luminance.T1);

            newFilter.FillOutsideRange = outside;

            imageFilter = newFilter;
        }
Example #2
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="HslBlobTracker"/> class.
        /// </summary>
        /// 
        /// <param name="filter">The filter.</param>
        /// 
        public HslBlobTracker(HSLFiltering filter)
        {
            this.filter = filter;
            this.blobCounter = new BlobCounter();
            this.trackingObject = new TrackingObject();

            blobCounter.CoupledSizeFiltering = false;
            blobCounter.FilterBlobs = true;
        }