/// <inheritdoc />
        public Bitmap Filter(Bitmap bitmap, BitMatrix kernel)
        {
            if (bitmap is null)
            {
                throw new ArgumentNullException(nameof(bitmap));
            }
            if (kernel is null)
            {
                throw new ArgumentNullException(nameof(kernel));
            }
            if (bitmap.PixelFormat != PixelFormat.Format32bppArgb)
            {
                throw new NotSupportedException(Errors.NotSupported);
            }

            var subtraction = new SubtractionOperator();
            var dilation    = new DilationOperator();
            var erosion     = new ErosionOperator();

            using (var rvalue = new Bitmap(bitmap))
            {
                return(subtraction
                       .Filter(dilation.Filter(bitmap, kernel),
                               erosion.Filter(rvalue, kernel)
                               ));
            }
        }
Beispiel #2
0
        /// <inheritdoc />
        public Bitmap Filter(Bitmap bitmap, BitMatrix kernel)
        {
            if (bitmap is null)
            {
                throw new ArgumentNullException(nameof(bitmap));
            }
            if (kernel is null)
            {
                throw new ArgumentNullException(nameof(kernel));
            }
            if (bitmap.PixelFormat != PixelFormat.Format32bppArgb)
            {
                throw new NotSupportedException(Errors.NotSupported);
            }

            var dilation = new DilationOperator();
            var erosion  = new ErosionOperator();

            return(dilation.Filter(erosion.Filter(bitmap, kernel), kernel));
        }