Esempio n. 1
0
        protected override Color CalculateNewPixelColor(FastBitmap bmp, int x, int y)
        {
            if (kernel == null)
            {
                return(bmp.GetPixel(x, y));
            }
            x -= kernel.GetLength(0) / 2;
            y -= kernel.GetLength(1) / 2;
            float resR = 0, resG = 0, resB = 0;

            for (int dx = 0; dx < kernel.GetLength(0); ++dx)
            {
                for (int dy = 0; dy < kernel.GetLength(1); ++dy)
                {
                    int   newX  = Clamp(x + dx, 0, bmp.width - 1);
                    int   newY  = Clamp(y + dy, 0, bmp.height - 1);
                    Color color = bmp.GetPixel(newX, newY);
                    resR += color.R * kernel[dx, dy];
                    resG += color.G * kernel[dx, dy];
                    resB += color.B * kernel[dx, dy];
                }
            }
            Color result = Color.FromArgb(255, Clamp((int)resR, 0, 255),
                                          Clamp((int)resG, 0, 255), Clamp((int)resB, 0, 255));

            return(result);
        }
Esempio n. 2
0
        protected override Color CalculateNewPixelColor(FastBitmap bmp, int x, int y)
        {
            int newX = x + (int)((gen.NextDouble() - 0.5) * 40);
            int newY = y + (int)((gen.NextDouble() - 0.5) * 40);

            return(bmp.GetPixel(Clamp(newX, 0, bmp.width - 1), Clamp(newY, 0, bmp.height - 1)));
        }
Esempio n. 3
0
 protected override void DoPreprocessing(FastBitmap bmp)
 {
     for (int y = 0; y < bmp.height; ++y)
     {
         for (int x = 0; x < bmp.width; ++x)
         {
             Color color = bmp.GetPixel(x, y);
             if (rMult < color.R)
             {
                 rMult = color.R;
             }
             if (gMult < color.G)
             {
                 gMult = color.G;
             }
             if (bMult < color.B)
             {
                 bMult = color.B;
             }
         }
     }
     rMult = 255 / rMult;
     gMult = 255 / gMult;
     bMult = 255 / bMult;
 }
Esempio n. 4
0
 protected override void DoPreprocessing(FastBitmap bmp)
 {
     for (int y = 0; y < bmp.height; ++y)
     {
         for (int x = 0; x < bmp.width; ++x)
         {
             Color color = bmp.GetPixel(x, y);
             if (color.R < rMin)
             {
                 rMin = color.R;
             }
             if (color.R > rMax)
             {
                 rMax = color.R;
             }
             if (color.G < gMin)
             {
                 gMin = color.G;
             }
             if (color.G > gMax)
             {
                 gMax = color.G;
             }
             if (color.B < bMin)
             {
                 bMin = color.B;
             }
             if (color.B > bMax)
             {
                 bMax = color.B;
             }
         }
     }
 }
Esempio n. 5
0
        protected override Color CalculateNewPixelColor(FastBitmap bmp, int x, int y)
        {
            Color source = bmp.GetPixel(x, y);

            return(Color.FromArgb((source.R - rMin) * 255 / (rMax - rMin),
                                  (source.G - gMin) * 255 / (gMax - gMin),
                                  (source.B - bMin) * 255 / (bMax - bMin)));
        }
Esempio n. 6
0
        protected override Color CalculateNewPixelColor(FastBitmap bmp, int x, int y)
        {
            int newX = (int)((x - xBase) * Math.Cos(angle) - (y - yBase) * Math.Sin(angle)) + xBase;
            int newY = (int)((x - xBase) * Math.Sin(angle) + (y - yBase) * Math.Cos(angle)) + yBase;

            if (Clamp(newX, 0, bmp.width - 1) != newX || Clamp(newY, 0, bmp.height - 1) != newY)
            {
                return(Color.Black);
            }
            return(bmp.GetPixel(newX, newY));
        }
Esempio n. 7
0
 protected override void DoPreprocessing(FastBitmap bmp)
 {
     binaryImage = new bool[bmp.width, bmp.height];
     for (int x = 0; x < bmp.width; ++x)
     {
         for (int y = 0; y < bmp.height; ++y)
         {
             Color col = bmp.GetPixel(x, y);
             binaryImage[x, y] = col.R <= 127 && col.G <= 127 && col.B > 127;
         }
     }
 }
Esempio n. 8
0
        protected override Color CalculateNewPixelColor(FastBitmap bmp, int x, int y)
        {
            for (int dx = -radius; dx <= radius; ++dx)
            {
                for (int dy = -radius; dy <= radius; ++dy)
                {
                    colArr[(dx + radius) * size + dy + radius] = bmp.GetPixel(Clamp(x + dx, 0, bmp.width - 1), Clamp(y + dy, 0, bmp.height - 1)).R;
                }
            }
            byte medianCol = FindMedian();

            return(Color.FromArgb(medianCol, medianCol, medianCol));
        }
Esempio n. 9
0
        protected override void DoPreprocessing(FastBitmap bmp)
        {
            for (int y = 0; y < bmp.height; ++y)
            {
                for (int x = 0; x < bmp.width; ++x)
                {
                    Color color = bmp.GetPixel(x, y);
                    rMult += color.R;
                    gMult += color.G;
                    bMult += color.B;
                }
            }
            int pixelCount = bmp.height * bmp.width;

            rMult /= pixelCount;
            gMult /= pixelCount;
            bMult /= pixelCount;
            float avg = (rMult + gMult + bMult) / 3;

            rMult = avg / rMult;
            gMult = avg / gMult;
            bMult = avg / bMult;

            /// Normalizing multipliers
            float max = rMult;

            if (gMult > max)
            {
                max = gMult;
            }
            if (bMult > max)
            {
                max = bMult;
            }
            rMult /= max;
            gMult /= max;
            bMult /= max;
        }
Esempio n. 10
0
        protected override Color CalculateNewPixelColor(FastBitmap bmp, int x, int y)
        {
            Color source = bmp.GetPixel(x, y);

            return(Color.FromArgb((int)(source.R * rMult), (int)(source.G * gMult), (int)(source.B * bMult)));
        }
Esempio n. 11
0
        protected override Color CalculateNewPixelColor(FastBitmap bmp, int x, int y)
        {
            Color source = bmp.GetPixel(x, y);

            return(Color.FromArgb(255 - source.R, 255 - source.G, 255 - source.B));
        }