示例#1
0
        //@Override
        public CustomImage process(CustomImage imageIn)
        {
            int width = imageIn.getWidth();
            int height = imageIn.getHeight();
            CustomImage clone = imageIn.clone();
            int r = 0, g = 0, b = 0;
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    int k = NoiseFilter.getRandomInt(1, 123456);

                    int dx = x + k % 19;
                    int dy = y + k % 19;
                    if (dx >= width)
                    {
                        dx = width - 1;
                    }
                    if (dy >= height)
                    {
                        dy = height - 1;
                    }
                    r = clone.getRComponent(dx, dy);
                    g = clone.getGComponent(dx, dy);
                    b = clone.getBComponent(dx, dy);
                    imageIn.setPixelColor(x, y, r, g, b);
                }
            }
            return imageIn;
        }
示例#2
0
 //@Override
 public CustomImage process(CustomImage imageIn)
 {
     Palette palette = this.Map.CreatePalette(0x100);
     byte[] red = palette.Red;
     byte[] green = palette.Green;
     byte[] blue = palette.Blue;
     CustomImage bitmap = imageIn.clone();
     bitmap.clearImage((255 << 24) + (255 << 16) + (255 << 8) + 255);
     int bfactor = (int) (this.BrightnessFactor * 255f);
     float cfactor = 1f + this.ContrastFactor;
     cfactor *= cfactor;
     int limit = ((int) (cfactor * 32768f)) + 1;
     for (int i = 0; i < imageIn.colorArray.Length; i++)
     {
     int r = (imageIn.colorArray[i]& 0x00FF0000) >> 16;
     int g = (imageIn.colorArray[i]& 0x0000FF00) >> 8;
     int b = imageIn.colorArray[i]& 0x000000FF;
     int index = (((r * 0x1b36) + (g * 0x5b8c)) + (b * 0x93e)) >> 15;
     if (bfactor != 0)
     {
         index += bfactor;
         index = (index > 0xff) ? 0xff : ((index < 0) ? 0 : index);
     }
     if (limit != 0x8001)
     {
         index -= 0x80;
         index = (index * limit) >> 15;
         index += 0x80;
         index = (index > 0xff) ? 0xff : ((index < 0) ? 0 : index);
     }
     bitmap.colorArray[i] = (0xff << 24) + (red[index] << 16) + (green[index] << 8) + blue[index];
     }
     return bitmap;
 }
示例#3
0
        private CustomImage ProcessColor(int k00, int k01, int k02, int k20, int k21, int k22, CustomImage imageIn, int thresholdSq)
        {
            int width = imageIn.getWidth();
            int height = imageIn.getHeight();
            int r, g, b;
            CustomImage clone = imageIn.clone();
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    int color1 = GetPixelColor(clone, x - 1, y - 1, width, height);
                    int color2 = GetPixelColor(clone, x, y - 1, width, height);
                    int color3 = GetPixelColor(clone, x + 1, y - 1, width, height);
                    int color4 = GetPixelColor(clone, x - 1, y, width, height);
                    int color5 = GetPixelColor(clone, x + 1, y, width, height);
                    int color6 = GetPixelColor(clone, x - 1, y + 1, width, height);
                    int color7 = GetPixelColor(clone, x, y + 1, width, height);
                    int color8 = GetPixelColor(clone, x + 1, y + 1, width, height);

                    int color1RGB = (0x00FF0000 & color1) >> 16;
                    int color3RGB = (0x00FF0000 & color3) >> 16;
                    int color6RGB = (0x00FF0000 & color6) >> 16;
                    int color8RGB = (0x00FF0000 & color8) >> 16;
                    int colorSum1 = (color1RGB * k00 + color3RGB * k02 + ((0x00FF0000 & color2) >> 16) * k01 + color6RGB * k20 + ((0x00FF0000 & color7) >> 16) * k21 + color8RGB * k22) >> 8;
                    int colorSum2 = (color1RGB * k00 + color3RGB * k20 + ((0x00FF0000 & color4) >> 16) * k01 + color6RGB * k02 + ((0x00FF0000 & color5) >> 16) * k21 + color8RGB * k22) >> 8;
                    r = (((colorSum1 * colorSum1) + (colorSum2 * colorSum2)) > thresholdSq) ? 0 : 0xff;
                    if (this.DoInversion)
                    {
                        r = 255 - r;
                    }

                    color1RGB = (0x0000FF00 & color1) >> 8;
                    color3RGB = (0x0000FF00 & color3) >> 8;
                    color6RGB = (0x0000FF00 & color6) >> 8;
                    color8RGB = (0x0000FF00 & color8) >> 8;
                    colorSum1 = (color1RGB * k00 + color3RGB * k02 + ((0x0000FF00 & color2) >> 8) * k01 + color6RGB * k20 + ((0x0000FF00 & color7) >> 8) * k21 + color8RGB * k22) >> 8;
                    colorSum2 = (color1RGB * k00 + color3RGB * k20 + ((0x0000FF00 & color4) >> 8) * k01 + color6RGB * k02 + ((0x0000FF00 & color5) >> 8) * k21 + color8RGB * k22) >> 8;
                    g = (((colorSum1 * colorSum1) + (colorSum2 * colorSum2)) > thresholdSq) ? 0 : 0xff;
                    if (this.DoInversion)
                    {
                        g = 255 - g;
                    }

                    color1RGB = 0x000000FF & color1;
                    color3RGB = 0x000000FF & color3;
                    color6RGB = 0x000000FF & color6;
                    color8RGB = 0x000000FF & color8;
                    colorSum1 = (color1RGB * k00 + color3RGB * k02 + (0x000000FF & color2) * k01 + color6RGB * k20 + (0x000000FF & color7) * k21 + color8RGB * k22) >> 8;
                    colorSum2 = (color1RGB * k00 + color3RGB * k20 + (0x000000FF & color4) * k01 + color6RGB * k02 + (0x000000FF & color5) * k21 + color8RGB * k22) >> 8;
                    b = (((colorSum1 * colorSum1) + (colorSum2 * colorSum2)) > thresholdSq) ? 0 : 0xff;
                    if (DoInversion)
                    {
                        b = 255 - b;
                    }
                    imageIn.setPixelColor(x, y, r, g, b);
                }
            }
            return imageIn;
        }
示例#4
0
 //@Override
 public CustomImage process(CustomImage imageIn)
 {
     ParamEdgeDetectFilter pde = new ParamEdgeDetectFilter();
     pde.K00 = 1;
     pde.K01 = 2;
     pde.K02 = 1;
     pde.Threshold = 0.25f;
     pde.DoGrayConversion = false;
     ImageBlender ib = new ImageBlender();
     ib.Mode = (int)BlendMode.Multiply;
     return ib.Blend(imageIn.clone(), pde.process(imageIn));
 }
示例#5
0
        //@Override
        public CustomImage process(CustomImage imageIn)
        {
            int k00 = (int)(K00 * 255f);
            int k01 = (int)(K01 * 255f);
            int k02 = (int)(K02 * 255f);
            int thresholdSqFactor = (int)(Threshold * 255f * 2f);
            int thresholdSq = thresholdSqFactor * thresholdSqFactor;

            if (!DoGrayConversion)
            {
                return ProcessColor(k00, k01, k02, -k00, -k01, -k02, imageIn.clone(), thresholdSq);
            }
            return ProcessGray(k00, k01, k02, -k00, -k01, -k02, imageIn, thresholdSq);
        }
示例#6
0
        //@Override
        public CustomImage process(CustomImage imageIn)
        {
            GradientMapFilter gmf = new GradientMapFilter(Gradient.BlackSepia());
            gmf.ContrastFactor = 0.15f;

            ImageBlender ib = new ImageBlender();
            ib.Mixture = 0.7f;
            ib.Mode = BlendMode.Overlay;
            imageIn = ib.Blend(imageIn.clone(), gmf.process(imageIn));

            VignetteFilter vigette = new VignetteFilter();
            vigette.Size = 0.7f;
            return vigette.process(imageIn);
        }
示例#7
0
 //@Override
 public CustomImage process(CustomImage imageIn)
 {
     int width = imageIn.getWidth();
     int height = imageIn.getHeight();
     CustomImage clone = imageIn.clone();
     int r = 0, g = 0, b = 0, avg = 0;
     for (int x = 0; x < width; x++)
     {
         for (int y = 0; y < height; y++)
         {
             r = clone.getRComponent(x, y);
             g = clone.getGComponent(x, y);
             b = clone.getBComponent(x, y);
             avg = (r + g + b) / 3;
             avg = avg >= ThreshHold ? 255 : 0;
             imageIn.setPixelColor(x, y, avg, avg, avg);
         }
     }
     return imageIn;
 }
示例#8
0
 //@Override
 public CustomImage process(CustomImage imageIn)
 {
     int width = imageIn.getWidth();
     int height = imageIn.getHeight();
     CustomImage clone = imageIn.clone();
     int r = 0, g = 0, b = 0, xx = 0, yy = 0;
     for (int x = 0; x < width; x++)
     {
         for (int y = 0; y < height; y++)
         {
             int pos = NoiseFilter.getRandomInt(1, 10000) % Model;
             xx = (x + pos) < width ? (x + pos) : (x - pos) >= 0 ? (x - pos) : x;
             yy = (y + pos) < height ? (y + pos) : (y - pos) >= 0 ? (y - pos) : y;
             r = clone.getRComponent(xx, yy);
             g = clone.getGComponent(xx, yy);
             b = clone.getBComponent(xx, yy);
             imageIn.setPixelColor(x, y, r, g, b);
         }
     }
     return imageIn;
 }
示例#9
0
        //@Override
        public CustomImage process(CustomImage imageIn)
        {
            int r, g, b;

            int height = imageIn.getHeight();
            int width = imageIn.getWidth();
            int start;
            int limit;
            CustomImage clone = imageIn.clone();

            if (this.IsHorizontal)
            {
                int y_offset = (int)(this.Offset * height);
                if (this.Offset > 0.5f)
                {
                    start = y_offset - (height - y_offset);
                    limit = y_offset;
                }
                else
                {
                    start = y_offset;
                    limit = y_offset + y_offset;
                }
                if (start < 0)
                {
                    start = 0;
                }
                for (int y = start; (y < limit) && (y < height); y++)
                {
                    int y_pos = (-y + (2 * y_offset)) - 1;
                    y_pos = (y_pos < 0) ? 0 : (y_pos >= height ? height - 1 : y_pos);
                    for (int x = 0; x < width; x++)
                    {
                        r = clone.getRComponent(x, y);
                        g = clone.getGComponent(x, y);
                        b = clone.getBComponent(x, y);
                        imageIn.setPixelColor(x, y_pos, r, g, b);
                    }
                }
            }
            else
            {
                int x_offset = (int)(this.Offset * width);
                if (this.Offset > 0.5f)
                {
                    start = x_offset - (width - x_offset);
                    limit = x_offset;
                }
                else
                {
                    start = x_offset;
                    limit = x_offset + x_offset;
                }
                if (start < 0)
                {
                    start = 0;
                }
                for (int x = start; (x < limit) && (x < width); x++)
                {
                    int x_pos = (-x + (2 * x_offset)) - 1;
                    x_pos = x_pos < 0 ? 0 : (x_pos >= width ? width - 1 : x_pos);
                    for (int y = 0; y < height; y++)
                    {
                        r = clone.getRComponent(x, y);
                        g = clone.getGComponent(x, y);
                        b = clone.getBComponent(x, y);
                        imageIn.setPixelColor(x_pos, y, r, g, b);
                    }
                }
            }
            return imageIn;
        }
示例#10
0
 private CustomImage ProcessGray(int k00, int k01, int k02, int k20, int k21, int k22, CustomImage imageIn, int thresholdSq)
 {
     int width = imageIn.getWidth();
     int height = imageIn.getHeight();
     CustomImage clone = imageIn.clone();
     for (int x = 0; x < width; x++)
     {
         for (int y = 0; y < height; y++)
         {
             int color1 = GetPixelBrightness(clone, x - 1, y - 1, width, height);
             int color2 = GetPixelBrightness(clone, x, y - 1, width, height);
             int color3 = GetPixelBrightness(clone, x + 1, y - 1, width, height);
             int color4 = GetPixelBrightness(clone, x - 1, y, width, height);
             int color5 = GetPixelBrightness(clone, x + 1, y, width, height);
             int color6 = GetPixelBrightness(clone, x - 1, y + 1, width, height);
             int color7 = GetPixelBrightness(clone, x, y + 1, width, height);
             int color8 = GetPixelBrightness(clone, x + 1, y + 1, width, height);
             int colorSum1 = (color1 * k00 + color2 * k01 + color3 * k02 + color6 * k20 + color7 * k21 + color8 * k22) >> 8;
             int colorSum2 = (color1 * k00 + color3 * k20 + color4 * k01 + color5 * k21 + color6 * k02 + color8 * k22) >> 8;
             int rgb = (((colorSum1 * colorSum1) + (colorSum2 * colorSum2)) > thresholdSq) ? 0 : 0xff;
             if (DoInversion)
             {
                 rgb = 0xff - rgb;
             }
             imageIn.setPixelColor(x, y, rgb, rgb, rgb);
         }
     }
     return imageIn;
 }