Пример #1
0
 private static Image <TPixelType> Inversion <TPixelType>(this Image <TPixelType> image, PixelOperator <TPixelType> pixelOperator)
 {
     image.ForEach((x, y) =>
     {
         var pixel    = image.Get(x, y);
         var newPixel = pixelOperator(pixel);
         image.Set(x, y, newPixel);
     });
     return(image);
 }
Пример #2
0
 private static Image <TPixelType> GammaCorrection <TPixelType>(this Image <TPixelType> image, PixelOperator <TPixelType> pixelOperator, double gamma)
 {
     image.ForEach((x, y) =>
     {
         var pixel = image.Get(x, y);
         image.Set(x, y, pixelOperator(pixel));
     });
     return(image);
 }
        private static Image <TPixelType> HistogramStretch <TPixelType>(this Image <TPixelType> image, PixelOperator <TPixelType> pixelOperator, byte rMin, byte rMax, byte gMin, byte gMax, byte bMin, byte bMax)
        {
            MathUtils.Orientate(ref rMin, ref rMax);
            MathUtils.Orientate(ref gMin, ref gMax);
            MathUtils.Orientate(ref bMin, ref bMax);

            Validate(rMin, rMax, gMin, gMax, bMin, bMax);

            image.ForEach((x, y) =>
            {
                var pixel    = image.Get(x, y);
                var newPixel = pixelOperator(pixel);
                image.Set(x, y, newPixel);
            });
            return(image);
        }
 private static Image <TPixelType> NaiveQuantize <TPixelType>(this Image <TPixelType> image, PixelOperator <TPixelType> pixelOperator, int levels)
 {
     Validate(levels);
     image.ForEach((x, y) =>
     {
         var pixel    = image.Get(x, y);
         var newPixel = pixelOperator(pixel);
         image.Set(x, y, newPixel);
     });
     return(image);
 }
        private static Image <TPixelType> Noise <TPixelType>(this Image <TPixelType> image, PixelOperator <TPixelType> pixelOperator, double intensity)
        {
            var steps      = GetNoiseSteps(image, intensity);
            var dataLength = image.Size;

            for (double i = 0; i < dataLength; i += steps)
            {
                var index    = MathUtils.Clamp(MathUtils.RoundToInt(random.NextDouble(i, i + steps)), 0, dataLength - 1);
                var pixel    = image.Get(index);
                var newPixel = pixelOperator(pixel);
                image.Set(index, newPixel);
            }
            return(image);
        }
 private static Image <TPixelType> BlackAndWhite <TPixelType>(this Image <TPixelType> image, PixelOperator <TPixelType> pixelOperator)
 {
     image.ForEach((x, y) =>
     {
         var pixel         = image.Get(x, y);
         var blackAndWhite = pixelOperator(pixel);
         image.Set(x, y, blackAndWhite);
     });
     return(image);
 }