Beispiel #1
0
        public void ImageShouldApplyPixelateFilterInBox <TPixel>(TestImageProvider <TPixel> provider, int value)
            where TPixel : struct, IPixel <TPixel>
        {
            using (Image <TPixel> source = provider.GetImage())
                using (var image = new Image <TPixel>(source))
                {
                    var bounds = new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2);

                    image.Pixelate(value, bounds)
                    .DebugSave(provider, value, Extensions.Bmp);

                    for (int y = 0; y < image.Height; y++)
                    {
                        for (int x = 0; x < image.Width; x++)
                        {
                            int    tx          = x;
                            int    ty          = y;
                            TPixel sourceColor = source[tx, ty];
                            if (bounds.Contains(tx, ty))
                            {
                                int sourceX = tx - ((tx - bounds.Left) % value) + (value / 2);
                                int sourceY = ty - ((ty - bounds.Top) % value) + (value / 2);

                                sourceColor = image[sourceX, sourceY];
                            }
                            Assert.Equal(sourceColor, image[tx, ty]);
                        }
                    }

                    ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds);
                }
        }
Beispiel #2
0
        public void ImageShouldApplyGrayscaleFilterInBox <TPixel>(TestImageProvider <TPixel> provider, GrayscaleMode value)
            where TPixel : struct, IPixel <TPixel>
        {
            using (Image <TPixel> source = provider.GetImage())
                using (var image = new Image <TPixel>(source))
                {
                    var bounds = new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2);
                    image.Grayscale(value, bounds)
                    .DebugSave(provider, value.ToString());

                    ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds);
                }
        }
Beispiel #3
0
        public void ImageShouldApplyVignetteFilterInBox <TPixel>(TestImageProvider <TPixel> provider)
            where TPixel : struct, IPixel <TPixel>
        {
            using (Image <TPixel> source = provider.GetImage())
                using (var image = new Image <TPixel>(source))
                {
                    var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2);

                    image.Vignette(bounds)
                    .DebugSave(provider, null, Extensions.Bmp);

                    ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds);
                }
        }
Beispiel #4
0
        public void ImageShouldApplyDiffusionFilterInBox <TPixel>(TestImageProvider <TPixel> provider, string name, IErrorDiffuser diffuser)
            where TPixel : struct, IPixel <TPixel>
        {
            using (Image <TPixel> source = provider.GetImage())
                using (var image = new Image <TPixel>(source))
                {
                    var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2);

                    image.Dither(diffuser, .5F, bounds)
                    .DebugSave(provider, name, Extensions.Bmp);

                    ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds);
                }
        }
        public void ImageShouldApplyColorBlindnessFilterInBox <TPixel>(TestImageProvider <TPixel> provider, ColorBlindness colorBlindness)
            where TPixel : struct, IPixel <TPixel>
        {
            using (Image <TPixel> source = provider.GetImage())
                using (var image = new Image <TPixel>(source))
                {
                    var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2);

                    image.ColorBlindness(colorBlindness, bounds)
                    .DebugSave(provider, colorBlindness.ToString(), Extensions.Bmp);

                    ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds);
                }
        }
        public void ImageShouldApplyBinaryThresholdInBox <TPixel>(TestImageProvider <TPixel> provider, float value)
            where TPixel : struct, IPixel <TPixel>
        {
            using (Image <TPixel> source = provider.GetImage())
                using (var image = new Image <TPixel>(source))
                {
                    var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2);

                    image.BinaryThreshold(value, bounds)
                    .DebugSave(provider, value, Extensions.Bmp);

                    ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds);
                }
        }