//@Override
 public override Image process(Image imageIn)
 {
     int width = imageIn.getWidth();
     int halfw = width / 2;
     int height = imageIn.getHeight();
     int halfh = height / 2;
     int R = Math.Min(halfw, halfh);
     //中心点,发亮此值会让强光中心发生偏移
     Point point = new Point(halfw, halfh);
     int r = 0, g = 0, b = 0;
     for (int x = 0; x < width; x++)
     {
         for (int y = 0; y < height; y++)
         {
             float length = (float)Math.Sqrt(Math.Pow((x - point.X), 2) + Math.Pow((y - point.Y), 2));
             r = imageIn.getRComponent(x, y);
             g = imageIn.getGComponent(x, y);
             b = imageIn.getBComponent(x, y);
             //位于光晕中
             if (length < R)
             {
                 float pixel = Light * (1.0f - length / R);
                 r = r + (int)pixel;
                 r = Math.Max(0, Math.Min(r, 255));
                 g = g + (int)pixel;
                 g = Math.Max(0, Math.Min(g, 255));
                 b = b + (int)pixel;
                 b = Math.Max(0, Math.Min(b, 255));
             }
             imageIn.setPixelColor(x, y, r, g, b);
         }
     }
     return imageIn;
 }
        //@Override
        public Image process(Image imageIn)
        {
            double width = imageIn.getWidth();
            double height = imageIn.getHeight();
            Image clone = imageIn.clone();
            int r, g, b;
            for (int x = 0; x < (width - 1); x++)
            {
                for (int y = 0; y < (height - 1); y++)
                {
                    r = imageIn.getRComponent(x, y);
                    g = imageIn.getGComponent(x, y);
                    b = imageIn.getBComponent(x, y);

                    _scale = Math.Sqrt(width * width + height * height) / 2;
                    _offset = (int)(_scale / 2);
                    double cx = (x - width / 2.0) / _scale;
                    double cy = (y - height / 2.0) / _scale;
                    double angle = Math.Floor(Math.Atan2(cy, cx) / 2.0 / _amount) * 2.0 * _amount + _amount;
                    double radius = Math.Sqrt(cx * cx + cy * cy);
                    int xx = (int)(x - _offset * Math.Cos(angle));
                    int yy = (int)(y - _offset * Math.Sin(angle));
                    xx = Function.FClamp(xx, 0, (int)(width - 1));
                    yy = Function.FClamp(yy, 0, (int)(height - 1));

                    r = Function.FClamp0255(r + radius * (clone.getRComponent(xx, yy) - r));
                    g = Function.FClamp0255(g + radius * (clone.getGComponent(xx, yy) - g));
                    b = Function.FClamp0255(b + radius * (clone.getBComponent(xx, yy) - b));
                    imageIn.setPixelColor(x, y, r, g, b);
                }
            }
            return imageIn;
        }
        //@Override
        public Image process(Image imageIn)
        {
            clone = imageIn.clone();
              int width = imageIn.getWidth();
              int height = imageIn.getHeight();
              for(int x = 0 ; x < width; x++){
                  for(int y = 0 ; y < height ; y++){
                        double   un_x = 0, un_y = 0 ;
                        double[] result = calc_undistorted_coord (x, y, un_x, un_y) ;
                        un_x = result[0];un_y = result[1];
                        int crNull = 0xFFFFFF;//WHITE
                        int cr  = crNull ;
                        if ( (un_x > -1) && (un_x < width) && (un_y > -1) && (un_y < height) )
                        {
                            // only this range is valid
                            int nSrcX = ((un_x < 0) ? -1 : (int)un_x);
                            int nSrcY = ((un_y < 0) ? -1 : (int)un_y);
                            int nSrcX_1 = nSrcX + 1;
                            int nSrcY_1 = nSrcY + 1;

                            int[] color = new int[4];
                            color[0] = IsInside(width, height, nSrcX, nSrcY) ? clone.getPixelColor(nSrcX,nSrcY) : crNull;
                            color[1] = IsInside(width, height, nSrcX_1, nSrcY) ? clone.getPixelColor(nSrcX_1,nSrcY) : crNull;
                            color[2] = IsInside(width, height, nSrcX, nSrcY_1) ? clone.getPixelColor(nSrcX,nSrcY_1) : crNull;
                            color[3] = IsInside(width, height, nSrcX_1, nSrcY_1) ? clone.getPixelColor(nSrcX_1,nSrcY_1) : crNull;
                            cr = GetBilinear(un_x-nSrcX, un_y-nSrcY, color);
                        }
                        imageIn.setPixelColor(x, y, cr);
                  }
              }
            return imageIn;
        }
 //@Override
 public Image process(Image imageIn)
 {
     int r, g, b;
     int num = (int)(this.Intensity * 32768f);
     for (int x = 0; x < imageIn.getWidth(); x++)
     {
         for (int y = 0; y < imageIn.getHeight(); y++)
         {
             r = imageIn.getRComponent(x, y);
             g = imageIn.getGComponent(x, y);
             b = imageIn.getBComponent(x, y);
             if (num != 0)
             {
                 int rr = getRandomInt(-255, 0xff) * num;
                 int gg = getRandomInt(-255, 0xff) * num;
                 int bb = getRandomInt(-255, 0xff) * num;
                 int rrr = r + (rr >> 15);
                 int ggg = g + (gg >> 15);
                 int bbb = b + (bb >> 15);
                 r = (rrr > 0xff) ? ((byte)0xff) : ((rrr < 0) ? ((byte)0) : ((byte)rrr));
                 g = (ggg > 0xff) ? ((byte)0xff) : ((ggg < 0) ? ((byte)0) : ((byte)ggg));
                 b = (bbb > 0xff) ? ((byte)0xff) : ((bbb < 0) ? ((byte)0) : ((byte)bbb));
             }
             imageIn.setPixelColor(x, y, r, g, b);
         }
     }
     return imageIn;
 }
        //@Override
        public Image process(Image imageIn)
        {
            clone = imageIn.clone();
            int width  = imageIn.getWidth();
            int height = imageIn.getHeight();

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    double   un_x = 0, un_y = 0;
                    double[] result = calc_undistorted_coord(x, y, un_x, un_y);
                    un_x = result[0]; un_y = result[1];
                    int crNull = 0xFFFFFF;                        //WHITE
                    int cr     = crNull;
                    if ((un_x > -1) && (un_x < width) && (un_y > -1) && (un_y < height))
                    {
                        // only this range is valid
                        int nSrcX   = ((un_x < 0) ? -1 : (int)un_x);
                        int nSrcY   = ((un_y < 0) ? -1 : (int)un_y);
                        int nSrcX_1 = nSrcX + 1;
                        int nSrcY_1 = nSrcY + 1;

                        int[] color = new int[4];
                        color[0] = IsInside(width, height, nSrcX, nSrcY) ? clone.getPixelColor(nSrcX, nSrcY) : crNull;
                        color[1] = IsInside(width, height, nSrcX_1, nSrcY) ? clone.getPixelColor(nSrcX_1, nSrcY) : crNull;
                        color[2] = IsInside(width, height, nSrcX, nSrcY_1) ? clone.getPixelColor(nSrcX, nSrcY_1) : crNull;
                        color[3] = IsInside(width, height, nSrcX_1, nSrcY_1) ? clone.getPixelColor(nSrcX_1, nSrcY_1) : crNull;
                        cr       = GetBilinear(un_x - nSrcX, un_y - nSrcY, color);
                    }
                    imageIn.setPixelColor(x, y, cr);
                }
            }
            return(imageIn);
        }
        //@Override
        public Image process(Image imageIn)
        {
            int r, g, b;
            int num = (int)(this.Intensity * 32768f);

            for (int x = 0; x < imageIn.getWidth(); x++)
            {
                for (int y = 0; y < imageIn.getHeight(); y++)
                {
                    r = imageIn.getRComponent(x, y);
                    g = imageIn.getGComponent(x, y);
                    b = imageIn.getBComponent(x, y);
                    if (num != 0)
                    {
                        int rr  = getRandomInt(-255, 0xff) * num;
                        int gg  = getRandomInt(-255, 0xff) * num;
                        int bb  = getRandomInt(-255, 0xff) * num;
                        int rrr = r + (rr >> 15);
                        int ggg = g + (gg >> 15);
                        int bbb = b + (bb >> 15);
                        r = (rrr > 0xff) ? ((byte)0xff) : ((rrr < 0) ? ((byte)0) : ((byte)rrr));
                        g = (ggg > 0xff) ? ((byte)0xff) : ((ggg < 0) ? ((byte)0) : ((byte)ggg));
                        b = (bbb > 0xff) ? ((byte)0xff) : ((bbb < 0) ? ((byte)0) : ((byte)bbb));
                    }
                    imageIn.setPixelColor(x, y, r, g, b);
                }
            }
            return(imageIn);
        }
Example #7
0
        //@Override
        public override Image process(Image imageIn)
        {
            int width  = imageIn.getWidth();
            int halfw  = width / 2;
            int height = imageIn.getHeight();
            int halfh  = height / 2;
            int R      = Math.Min(halfw, halfh);
            //中心点,发亮此值会让强光中心发生偏移
            Point point = new Point(halfw, halfh);
            int   r = 0, g = 0, b = 0;

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    float length = (float)Math.Sqrt(Math.Pow((x - point.X), 2) + Math.Pow((y - point.Y), 2));
                    r = imageIn.getRComponent(x, y);
                    g = imageIn.getGComponent(x, y);
                    b = imageIn.getBComponent(x, y);
                    //位于光晕中
                    if (length < R)
                    {
                        float pixel = Light * (1.0f - length / R);
                        r = r + (int)pixel;
                        r = Math.Max(0, Math.Min(r, 255));
                        g = g + (int)pixel;
                        g = Math.Max(0, Math.Min(g, 255));
                        b = b + (int)pixel;
                        b = Math.Max(0, Math.Min(b, 255));
                    }
                    imageIn.setPixelColor(x, y, r, g, b);
                }
            }
            return(imageIn);
        }
        public Image process(Image imageIn)
        {
            int tr = (255 << 24) + (Colors.Red.R << 16) + (Colors.Red.G << 8) + Colors.Red.B;
            int tg = (255 << 24) + (Colors.Green.R << 16) + (Colors.Green.G << 8) + Colors.Green.B;
            int tb = (255 << 24) + (Colors.Blue.R << 16) + (Colors.Blue.G << 8) + Colors.Blue.B;
            int r, g, b;

            for (int x = 0; x < imageIn.getWidth(); x++)
            {
                for (int y = 0; y < imageIn.getHeight(); y++)
                {
                    r = (255 - imageIn.getRComponent(x, y));
                    g = (255 - imageIn.getGComponent(x, y));
                    b = (255 - imageIn.getBComponent(x, y));

                    // Convert to gray with constant factors 0.2126, 0.7152, 0.0722
                    int gray = (r * 6966 + g * 23436 + b * 2366) >> 15;

                    // Apply Tint color
                    r = (byte)((gray * tr) >> 8);
                    g = (byte)((gray * tg) >> 8);
                    b = (byte)((gray * tb) >> 8);

                    imageIn.setPixelColor(x, y, r, g, b);
                }
            }
            return(imageIn);
        }
Example #9
0
        //@Override
        public Image process(Image imageIn)
        {
            int    width  = imageIn.getWidth();
            int    height = imageIn.getHeight();
            double d      = this.OriginAngleDegree * 0.0174532925;
            float  cos    = (float)Math.Cos(d);
            float  sin    = (float)Math.Sin(d);
            float  radio  = (cos * width) + (sin * height);
            float  dcos   = cos * radio;
            float  dsin   = sin * radio;
            int    dist   = (int)Math.Sqrt((double)((dcos * dcos) + (dsin * dsin)));

            dist = Math.Max(Math.Max(dist, width), height);

            if ((this.palette == null) || (dist != this.palette.Length))
            {
                this.palette = this.Gradientf.CreatePalette(dist);
            }
            byte[] red   = this.palette.Red;
            byte[] green = this.palette.Green;
            byte[] blue  = this.palette.Blue;
            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    radio = (cos * j) + (sin * i);
                    dcos  = cos * radio;
                    dsin  = sin * radio;
                    dist  = (int)Math.Sqrt((double)((dcos * dcos) + (dsin * dsin)));
                    imageIn.setPixelColor(j, i, red[dist], green[dist], blue[dist]);
                }
            }
            return(imageIn);
        }
        //@Override
        public Image process(Image imageIn)
        {
            double width = imageIn.getWidth();
            double height = imageIn.getHeight();
            Image  clone = imageIn.clone();
            int    r, g, b;

            for (int x = 0; x < (width - 1); x++)
            {
                for (int y = 0; y < (height - 1); y++)
                {
                    r = imageIn.getRComponent(x, y);
                    g = imageIn.getGComponent(x, y);
                    b = imageIn.getBComponent(x, y);

                    _scale  = Math.Sqrt(width * width + height * height) / 2;
                    _offset = (int)(_scale / 2);
                    double cx     = (x - width / 2.0) / _scale;
                    double cy     = (y - height / 2.0) / _scale;
                    double angle  = Math.Floor(Math.Atan2(cy, cx) / 2.0 / _amount) * 2.0 * _amount + _amount;
                    double radius = Math.Sqrt(cx * cx + cy * cy);
                    int    xx     = (int)(x - _offset * Math.Cos(angle));
                    int    yy     = (int)(y - _offset * Math.Sin(angle));
                    xx = Function.FClamp(xx, 0, (int)(width - 1));
                    yy = Function.FClamp(yy, 0, (int)(height - 1));

                    r = Function.FClamp0255(r + radius * (clone.getRComponent(xx, yy) - r));
                    g = Function.FClamp0255(g + radius * (clone.getGComponent(xx, yy) - g));
                    b = Function.FClamp0255(b + radius * (clone.getBComponent(xx, yy) - b));
                    imageIn.setPixelColor(x, y, r, g, b);
                }
            }
            return(imageIn);
        }
        public Image process(Image imageIn)
        {
            int tr = (255 << 24) + (Colors.Red.R << 16) + (Colors.Red.G << 8) + Colors.Red.B;
            int tg = (255 << 24) + (Colors.Green.R << 16) + (Colors.Green.G << 8) + Colors.Green.B;
            int tb = (255 << 24) + (Colors.Blue.R << 16) + (Colors.Blue.G << 8) + Colors.Blue.B;
            int r, g, b;
            for (int x = 0; x < imageIn.getWidth(); x++)
            {
                for (int y = 0; y < imageIn.getHeight(); y++)
                {
                    r = (255 - imageIn.getRComponent(x, y));
                    g = (255 - imageIn.getGComponent(x, y));
                    b = (255 - imageIn.getBComponent(x, y));

                    // Convert to gray with constant factors 0.2126, 0.7152, 0.0722
                    int gray = (r * 6966 + g * 23436 + b * 2366) >> 15;

                    // Apply Tint color
                    r = (byte)((gray * tr) >> 8);
                    g = (byte)((gray * tg) >> 8);
                    b = (byte)((gray * tb) >> 8);

                    imageIn.setPixelColor(x, y, r, g, b);
                }
            }
            return imageIn;
        }
Example #12
0
        public override Image process(Image imageIn)
        {
            int ratio = imageIn.getWidth() > imageIn.getHeight() ? imageIn.getHeight() * 32768 / imageIn.getWidth() : imageIn.getWidth() * 32768 / imageIn.getHeight();

            // Calculate center, min and max
            int cx   = imageIn.getWidth() >> 1;
            int cy   = imageIn.getHeight() >> 1;
            int max  = cx * cx + cy * cy;
            int min  = (int)(max * (1 - Size));
            int diff = max - min;

            int width  = imageIn.getWidth();
            int height = imageIn.getHeight();

            float[] imageArray = ConvertImageWithPadding(imageIn, width, height);
            imageArray = ApplyBlur(imageArray, width, height);
            int newwidth = width + Padding * 2;

            for (int i = 0; i < height; i++)
            {
                int num = ((i + 3) * newwidth) + 3;
                for (int j = 0; j < width; j++)
                {
                    // Calculate distance to center and adapt aspect ratio
                    int dx = cx - j;
                    int dy = cy - i;
                    if (imageIn.getWidth() > imageIn.getHeight())
                    {
                        dy = (dy * ratio) >> 14;
                    }
                    else
                    {
                        dx = (dx * ratio) >> 14;
                    }
                    int distSq = dx * dx + dy * dy;

                    if (distSq > min)
                    {
                        int pos = (num + j) * 3;
                        imageIn.setPixelColor(j, i, (byte)(imageArray[pos] * 255f), (byte)(imageArray[pos + 1] * 255f), (byte)(imageArray[pos + 2] * 255f));
                    }
                }
            }
            return(imageIn);
        }
        //@Override
        public Image process(Image imageIn)
        {
            // Image size
            int width  = imageIn.getWidth();
            int height = imageIn.getHeight();

            bool[][] mask       = null;
            int[]    grayMatrix = new int[256];

            // Init gray matrix
            for (int i = 0; i <= 255; i++)
            {
                grayMatrix[i] = (255 << 24) + (i << 16) + (i << 8) + i;
            }

            int [,] luminance = new int[width, height];
            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    if (mask != null && !mask[x][y])
                    {
                        continue;
                    }
                    luminance[x, y] = (int)Luminance(imageIn.getRComponent(x, y), imageIn.getGComponent(x, y), imageIn.getBComponent(x, y));
                }
            }


            int grayX, grayY;
            int magnitude;

            for (int y = 1; y < height - 1; y++)
            {
                for (int x = 1; x < width - 1; x++)
                {
                    if (mask != null && !mask[x][y])
                    {
                        continue;
                    }

                    grayX = -luminance[x - 1, y - 1] + luminance[x - 1, y - 1 + 2] - 2 * luminance[x - 1 + 1, y - 1] + 2 * luminance[x - 1 + 1, y - 1 + 2] - luminance[x - 1 + 2, y - 1] + luminance[x - 1 + 2, y - 1 + 2];
                    grayY = luminance[x - 1, y - 1] + 2 * luminance[x - 1, y - 1 + 1] + luminance[x - 1, y - 1 + 2] - luminance[x - 1 + 2, y - 1] - 2 * luminance[x - 1 + 2, y - 1 + 1] - luminance[x - 1 + 2, y - 1 + 2];

                    // Magnitudes sum
                    magnitude = 255 - truncate(Math.Abs(grayX) + Math.Abs(grayY));
                    int grayscaleColor = grayMatrix[magnitude];

                    // Apply the color into a new image
                    imageIn.setPixelColor(x, y, grayscaleColor);
                }
            }

            return(imageIn);
        }
Example #14
0
        public override Image process(Image imageIn)
        {
            int matt   = imageIn.getWidth();
            int width  = matt;
            int height = imageIn.getHeight();

            if ((_point.X + _point.Y) <= 0)
            {
                _point.X = width / 2;
                _point.Y = height / 2;
            }
            _scolor = matt * 0.0375;
            _sglow  = matt * 0.078125;
            _sinner = matt * 0.1796875;
            _souter = matt * 0.3359375;
            _shalo  = matt * 0.084375;

            _color.r = 239.0 / 255.0; _color.g = 239.0 / 255.0; _color.b = 239.0 / 255.0;
            _glow.r  = 245.0 / 255.0; _glow.g = 245.0 / 255.0; _glow.b = 245.0 / 255.0;
            _inner.r = 255.0 / 255.0; _inner.g = 38.0 / 255.0; _inner.b = 43.0 / 255.0;
            _outer.r = 69.0 / 255.0; _outer.g = 59.0 / 255.0; _outer.b = 64.0 / 255.0;
            _halo.r  = 80.0 / 255.0; _halo.g = 15.0 / 255.0; _halo.b = 4.0 / 255.0;

            initref((int)_point.X, (int)_point.Y, width, imageIn.getHeight(), matt);
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    double hyp   = FHypot(x - _point.X, y - _point.Y);
                    int    color = imageIn.getPixelColor(x, y);
                    color = mcolor(color, hyp); /* make color */
                    color = mglow(color, hyp);  /* make _glow  */
                    color = minner(color, hyp); /* make _inner */
                    color = mouter(color, hyp); /* make _outer */
                    color = mhalo(color, hyp);  /* make _halo  */

                    for (int i = 0; i < _numref; i++)
                    {
                        switch (_reflect[i].type)
                        {
                        case 1: { color = mrt1(color, _reflect[i], x, y); break; }

                        case 2: { color = mrt2(color, _reflect[i], x, y); break; }

                        case 3: { color = mrt3(color, _reflect[i], x, y); break; }

                        case 4: { color = mrt4(color, _reflect[i], x, y); break; }
                        }
                    }
                    imageIn.setPixelColor(x, y, color);
                }
            }
            return(imageIn);
        }
        public override Image process(Image imageIn)
        {
            int matt = imageIn.getWidth();
            int width = matt;
            int height = imageIn.getHeight();
            if ((_point.X + _point.Y) <= 0)
            {
                _point.X = width / 2;
                _point.Y = height / 2;
            }
            _scolor = matt * 0.0375;
            _sglow = matt * 0.078125;
            _sinner = matt * 0.1796875;
            _souter = matt * 0.3359375;
            _shalo = matt * 0.084375;

            _color.r = 239.0 / 255.0; _color.g = 239.0 / 255.0; _color.b = 239.0 / 255.0;
            _glow.r = 245.0 / 255.0; _glow.g = 245.0 / 255.0; _glow.b = 245.0 / 255.0;
            _inner.r = 255.0 / 255.0; _inner.g = 38.0 / 255.0; _inner.b = 43.0 / 255.0;
            _outer.r = 69.0 / 255.0; _outer.g = 59.0 / 255.0; _outer.b = 64.0 / 255.0;
            _halo.r = 80.0 / 255.0; _halo.g = 15.0 / 255.0; _halo.b = 4.0 / 255.0;

            initref((int)_point.X, (int)_point.Y, width, imageIn.getHeight(), matt);
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    double hyp = FHypot(x - _point.X, y - _point.Y);
                    int color = imageIn.getPixelColor(x, y);
                    color = mcolor(color, hyp); /* make color */
                    color = mglow(color, hyp);  /* make _glow  */
                    color = minner(color, hyp); /* make _inner */
                    color = mouter(color, hyp); /* make _outer */
                    color = mhalo(color, hyp);  /* make _halo  */

                    for (int i = 0; i < _numref; i++)
                    {
                        switch (_reflect[i].type)
                        {
                            case 1: { color = mrt1(color, _reflect[i], x, y); break; }
                            case 2: { color = mrt2(color, _reflect[i], x, y); break; }
                            case 3: { color = mrt3(color, _reflect[i], x, y); break; }
                            case 4: { color = mrt4(color, _reflect[i], x, y); break; }
                        }
                    }
                    imageIn.setPixelColor(x, y, color);
                }
            }
            return imageIn;
        }
        //@Override
        public Image process(Image imageIn)
        {
            int r, g, b;
              for(int x = 0 ; x < imageIn.getWidth() ; x++){
                  for(int y = 0 ; y < imageIn.getHeight() ; y++){
                       r = imageIn.getRComponent(x, y);
                       g = imageIn.getGComponent(x, y);
                       b = imageIn.getBComponent(x, y);

                       double  l = _lum_tab[GetGrayscale(r, g, b)] ;
                       int   cr = HLStoRGB (_hue, l, _saturation) ;
                       imageIn.setPixelColor(x, y, cr);
                  }
              }
            return imageIn;
        }
Example #17
0
 //@Override
 public override Image process(Image imageIn)
 {
     width  = imageIn.getWidth();
     height = imageIn.getHeight();
     buf2   = new short[width * height];
     buf1   = new short[width * height];
     source = imageIn.colorArray;
     temp   = new int[source.Length];
     DropStone(width / 2, height / 2, Math.Max(width, height) / 4, Math.Max(width, height));
     for (int i = 0; i < 170; i++)
     {
         RippleSpread();
         render();
     }
     imageIn.colorArray = temp;
     return(imageIn);
 }
 //@Override
 public override Image process(Image imageIn)
 {
     width = imageIn.getWidth();
     height = imageIn.getHeight();
     buf2 = new short[width * height];
     buf1 = new short[width * height];
     source = imageIn.colorArray;
     temp = new int[source.Length];
     DropStone(width / 2, height / 2, Math.Max(width, height) / 4, Math.Max(width, height));
     for (int i = 0; i < 170; i++)
     {
         RippleSpread();
         render();
     }
     imageIn.colorArray = temp;
     return imageIn;
 }
        public Image process(Image imageIn)
        {
            int r, g, b;
            HslColor hsl = new HslColor(HueFactor, 0, 0);

            for (int x = 0; x < imageIn.getWidth(); x++) {
                for (int y = 0; y < imageIn.getHeight(); y++) {
             	    r = imageIn.getRComponent(x, y);
                    g = imageIn.getGComponent(x, y);
                    b = imageIn.getBComponent(x, y);

                    HslColor.RgbToHsl(r, g, b, hsl);
                    hsl.h = this.HueFactor;
                    int color = HslColor.HslToRgb(hsl);
                    imageIn.setPixelColor(x, y, color);
                }
            }
            return imageIn;
        }
Example #20
0
        public Image process(Image imageIn)
        {
            // get source image size
            int width  = imageIn.getWidth();
            int height = imageIn.getHeight();

            // processing region's dimension
            int widthToProcess  = width;
            int heightToProcess = height;

            // if generator was specified, then generate a texture
            // otherwise use provided texture
            if (textureGenerator != null)
            {
                texture = textureGenerator.Generate(width, height);
            }
            else
            {
                widthToProcess  = Math.Min(width, texture.GetLength(1));
                heightToProcess = Math.Min(height, texture.GetLength(0));
            }

            int r, g, b;

            // texture
            for (int y = 0; y < heightToProcess; y++)
            {
                for (int x = 0; x < widthToProcess; x++)
                {
                    double t = texture[y, x];
                    r = imageIn.getRComponent(x, y);
                    g = imageIn.getGComponent(x, y);
                    b = imageIn.getBComponent(x, y);
                    // process each pixel

                    r = (byte)Math.Min(255.0f, (preserveLevel * r) + (filterLevel * r) * t);
                    g = (byte)Math.Min(255.0f, (preserveLevel * g) + (filterLevel * g) * t);
                    b = (byte)Math.Min(255.0f, (preserveLevel * b) + (filterLevel * b) * t);
                    imageIn.setPixelColor(x, y, r, g, b);
                }
            }
            return(imageIn);
        }
Example #21
0
        //@Override
        public Image process(Image imageIn)
        {
            int r, g, b;

            for (int x = 0; x < imageIn.getWidth(); x++)
            {
                for (int y = 0; y < imageIn.getHeight(); y++)
                {
                    r = imageIn.getRComponent(x, y);
                    g = imageIn.getGComponent(x, y);
                    b = imageIn.getBComponent(x, y);

                    double l  = _lum_tab[GetGrayscale(r, g, b)];
                    int    cr = HLStoRGB(_hue, l, _saturation);
                    imageIn.setPixelColor(x, y, cr);
                }
            }
            return(imageIn);
        }
        public override Image process(Image imageIn)
        {
            {
              int r, g, b;
              int width = imageIn.getWidth();
              int height = imageIn.getHeight();
              double hw = width / 2.0;
              double hh = imageIn.getHeight() / 2.0;
              for(int x = 0 ; x < width ; x++){
                  for(int y = 0 ; y < height ; y++){
                    int i = (int)(x - hw);
                    int j = (int)(y - hh);
                    b=0; g=0; r=0;
                    for (int mm=0 ; mm < aasamples ; mm++){
                        double   u = i + m_aapt[mm].X ;
                        double   v = j - m_aapt[mm].Y ;

                        double   s =  m_cos * u + m_sin * v ;
                        double   t = -m_sin * u + m_cos * v ;

                        s += m_curvature * Math.Tan(s * m_scale) ;
                        t += m_curvature * Math.Tan(t * m_scale) ;
                        u = m_cos * s - m_sin * t ;
                        v = m_sin * s + m_cos * t ;

                        int xSample = (int)(hw + u) ;
                        int ySample = (int)(hh + v) ;

                        xSample = Function.FClamp (xSample, 0, width -1) ;
                        ySample = Function.FClamp (ySample, 0, height-1) ;

                        r += imageIn.getRComponent(xSample, ySample);
                        g += imageIn.getGComponent(xSample, ySample);
                        b += imageIn.getBComponent(xSample, ySample);
                     }
                     imageIn.setPixelColor(x, y, Image.SAFECOLOR(r/aasamples), Image.SAFECOLOR(g/aasamples), Image.SAFECOLOR(b/aasamples));
                  }
              }
              return imageIn;
             }
        }
        public Image process(Image imageIn)
        {
            int      r, g, b;
            HslColor hsl = new HslColor(HueFactor, 0, 0);

            for (int x = 0; x < imageIn.getWidth(); x++)
            {
                for (int y = 0; y < imageIn.getHeight(); y++)
                {
                    r = imageIn.getRComponent(x, y);
                    g = imageIn.getGComponent(x, y);
                    b = imageIn.getBComponent(x, y);

                    HslColor.RgbToHsl(r, g, b, hsl);
                    hsl.h = this.HueFactor;
                    int color = HslColor.HslToRgb(hsl);
                    imageIn.setPixelColor(x, y, color);
                }
            }
            return(imageIn);
        }
        public override Image process(Image imageIn)
        {
            int ratio = imageIn.getWidth() > imageIn.getHeight() ? imageIn.getHeight() * 32768 / imageIn.getWidth() : imageIn.getWidth() * 32768 / imageIn.getHeight();

            // Calculate center, min and max
            int cx = imageIn.getWidth() >> 1;
            int cy = imageIn.getHeight() >> 1;
            int max = cx * cx + cy * cy;
            int min = (int)(max * (1 - Size));
            int diff = max - min;

            int width = imageIn.getWidth();
            int height = imageIn.getHeight();
            float[] imageArray = ConvertImageWithPadding(imageIn, width, height);
            imageArray = ApplyBlur(imageArray, width, height);
            int newwidth = width + Padding * 2;
            for (int i = 0; i < height; i++)
            {
                int num = ((i + 3) * newwidth) + 3;
                for (int j = 0; j < width; j++)
                {
                     // Calculate distance to center and adapt aspect ratio
                    int dx = cx - j;
                    int dy = cy - i;
                    if (imageIn.getWidth() > imageIn.getHeight())
                    {
                        dy = (dy * ratio) >> 14;
                    }
                    else
                    {
                        dx = (dx * ratio) >> 14;
                    }
                    int distSq = dx * dx + dy * dy;

                    if (distSq > min)
                    {
                        int pos = (num + j) * 3;
                        imageIn.setPixelColor(j, i, (byte)(imageArray[pos] * 255f), (byte)(imageArray[pos + 1] * 255f), (byte)(imageArray[pos + 2] * 255f));
                     }
                }
            }
            return imageIn;
        }
        // @Override
        public Image process(Image imageIn)
        {
            // Image size
            int width = imageIn.getWidth();
            int height = imageIn.getHeight();
            bool[,] mask = null;
            int[] grayMatrix = new int[256];

            // Init gray matrix
            int outlineCase = 1;
            double rand = new Random().NextDouble();
            if (rand>0.33 && rand<0.66){
            outlineCase=2;
            }
            else if (rand>0.66){
            outlineCase=3;
            }
            for (int i = 255; i >= 0; i--) {
            int red=i,green=i,blue=i;
            if (i>127)
            {
                switch(outlineCase){
                case 1 :
                    red = 255-i;
                    break;
                case 2 :
                    green = 255-i;
                    break;
                case 3 :
                    blue = 255-i;
                    break;
                }
            }
            grayMatrix[255 - i] = (255 << 24) + (red << 16) + (green << 8) + blue;
            }

            int [,] luminance = new int[width,height];
            for (int y = 0; y < height ; y++) {
            for (int x = 0; x < width ; x++) {
                if(mask != null && !mask[x,y]){
                    continue;
                }
                luminance[x, y] = (int)Luminance(imageIn.getRComponent(x, y), imageIn.getGComponent(x, y), imageIn.getBComponent(x, y));
            }
            }

            int grayX, grayY;
            int magnitude;
            for (int y = 1; y < height-1; y++) {
            for (int x = 1; x < width-1; x++) {
                if(mask != null && !mask[x,y]){
                    continue;
                }

                grayX = - luminance[x-1,y-1] + luminance[x-1,y-1+2] - 2* luminance[x-1+1,y-1] + 2* luminance[x-1+1,y-1+2] - luminance[x-1+2,y-1]+ luminance[x-1+2,y-1+2];
                grayY = luminance[x-1,y-1] + 2* luminance[x-1,y-1+1] + luminance[x-1,y-1+2] - luminance[x-1+2,y-1] - 2* luminance[x-1+2,y-1+1] - luminance[x-1+2,y-1+2];

                // Magnitudes sum
                magnitude = 255 - truncate(Math.Abs(grayX) + Math.Abs(grayY));
                int grayscaleColor = grayMatrix[magnitude];

                // Apply the color into a new image
                imageIn.setPixelColor(x, y, grayscaleColor);
            }
            }

            return imageIn;
        }
Example #26
0
        public override Image process(Image imageIn)
        {
            int    r, g, b;
            int    width  = imageIn.getWidth();
            int    height = imageIn.getHeight();
            double hw     = width / 2.0;
            double hh     = height / 2.0;

            int ratio = width > height ? height * 32768 / width : width * 32768 / height;

            // Calculate center, min and max
            int cx   = width >> 1;
            int cy   = height >> 1;
            int max  = cx * cx + cy * cy;
            int min  = (int)(max * 0.5);
            int diff = max - min;

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    if (m_focusType == 1)//椭圆
                    {
                        // Calculate distance to center and adapt aspect ratio
                        int dx = cx - x;
                        int dy = cy - y;
                        if (imageIn.getWidth() > imageIn.getHeight())
                        {
                            dy = (dy * ratio) >> 14;
                        }
                        else
                        {
                            dx = (dx * ratio) >> 14;
                        }
                        int distSq = dx * dx + dy * dy;

                        if (distSq <= min)
                        {
                            continue;
                        }
                    }
                    else if (m_focusType == 2)//长方框
                    {
                        bool inarray = false;
                        if ((x < m_size) && (y < height - x) && (y >= x))
                        {
                            inarray = true; // left
                        }
                        else if ((y < m_size) && (x < width - y) && (x >= y))
                        {
                            inarray = true; // top
                        }
                        else if ((x > width - m_size) && (y >= width - x) && (y < height + x - width))
                        {
                            inarray = true; // right
                        }
                        else if (y > height - m_size)
                        {
                            inarray = true; // bottom
                        }
                        if (!inarray)
                        {
                            continue;
                        }
                    }
                    int i = (int)(x - hw);
                    int j = (int)(y - hh);
                    b = 0; g = 0; r = 0;

                    for (int mm = 0; mm < aasamples; mm++)
                    {
                        double u = i + m_aapt[mm].X;
                        double v = j - m_aapt[mm].Y;

                        double s = m_cos * u + m_sin * v;
                        double t = -m_sin * u + m_cos * v;

                        s += m_curvature * Math.Tan(s * m_scale);
                        t += m_curvature * Math.Tan(t * m_scale);
                        u  = m_cos * s - m_sin * t;
                        v  = m_sin * s + m_cos * t;

                        int xSample = (int)(hw + u);
                        int ySample = (int)(hh + v);

                        xSample = Function.FClamp(xSample, 0, width - 1);
                        ySample = Function.FClamp(ySample, 0, height - 1);

                        r += imageIn.getRComponent(xSample, ySample);
                        g += imageIn.getGComponent(xSample, ySample);
                        b += imageIn.getBComponent(xSample, ySample);
                    }
                    imageIn.setPixelColor(x, y, Image.SAFECOLOR(r / aasamples), Image.SAFECOLOR(g / aasamples), Image.SAFECOLOR(b / aasamples));
                }
            }
            return(imageIn);
        }
        public Image process(Image imageIn)
        {
            // get source image size
            int width = imageIn.getWidth();
            int height = imageIn.getHeight();

            // processing region's dimension
            int widthToProcess = width;
            int heightToProcess = height;

            // if generator was specified, then generate a texture
            // otherwise use provided texture
            if ( textureGenerator != null )
            {
                texture = textureGenerator.Generate( width, height );
            }
            else
            {
                widthToProcess = Math.Min( width, texture.GetLength( 1 ) );
                heightToProcess = Math.Min( height, texture.GetLength( 0 ) );
            }

            int r, g, b;

            // texture
            for ( int y = 0; y < heightToProcess; y++ )
            {
                for ( int x = 0; x < widthToProcess; x++ )
                {
                    double t = texture[y, x];
                    r = imageIn.getRComponent(x, y);
                    g = imageIn.getGComponent(x, y);
                    b = imageIn.getBComponent(x, y);
                    // process each pixel

                    r = (byte) Math.Min( 255.0f, ( preserveLevel * r) + ( filterLevel * r) * t );
                    g = (byte) Math.Min( 255.0f, ( preserveLevel * g) + ( filterLevel * g) * t );
                    b = (byte) Math.Min( 255.0f, ( preserveLevel * b) + ( filterLevel * b) * t );
                    imageIn.setPixelColor(x, y, r, g, b);
                }
            }
            return imageIn;
        }
        //@Override
        public override Image process(Image imageIn)
        {
            int width = imageIn.getWidth();
            int height = imageIn.getHeight();
            int r = 0, g = 0, b = 0;

            Image clone = imageIn.clone();
            clone.clearImage((255 << 24) + (Colors.LightGray.R << 16) + (Colors.LightGray.G << 8) + Colors.LightGray.B);
            Point[] point = new Point[BannerNum];
            if (this.IsHorizontal)
            {//ˮƽ����
                int dh = height / BannerNum;
                int dw = width;
                for (int i = 0; i < BannerNum; i++)
                {
                    point[i] = new Point(0, i * dh);
                }
                for (int x = 0; x < dh; x++)
                {
                    for (int y = 0; y < BannerNum; y++)
                    {
                        for (int k = 0; k < dw; k++)
                        {
                            int xx = (int)point[y].X + k;
                            int yy = (int)point[y].Y + (int)(x / 1.1);
                            r = imageIn.getRComponent(xx, yy);
                            g = imageIn.getGComponent(xx, yy);
                            b = imageIn.getBComponent(xx, yy);
                            clone.setPixelColor(xx, yy, r, g, b);
                        }
                    }
                }
                //��ͼ�����ಿ�������
                for (int xx = 0; xx < width; xx++)
                {
                    for (int yy = (int)point[BannerNum - 1].Y + dh; yy < height; yy++)
                    {
                        r = imageIn.getRComponent(xx, yy);
                        g = imageIn.getGComponent(xx, yy);
                        b = imageIn.getBComponent(xx, yy);
                        clone.setPixelColor(xx, yy, r, g, b);
                    }
                }
            }
            else
            {//��ֱ����
                int dw = width / BannerNum;
                int dh = height;
                for (int i = 0; i < BannerNum; i++)
                {
                    point[i] = new Point(i * dw, 0);
                }
                for (int x = 0; x < dw; x++)
                {
                    for (int y = 0; y < BannerNum; y++)
                    {
                        for (int k = 0; k < dh; k++)
                        {
                            int xx = (int)point[y].X + (int)(x / 1.1);
                            int yy = (int)point[y].Y + k;
                            r = imageIn.getRComponent(xx, yy);
                            g = imageIn.getGComponent(xx, yy);
                            b = imageIn.getBComponent(xx, yy);
                            clone.setPixelColor(xx, yy, r, g, b);
                        }
                    }
                }
                //��ͼ�����ಿ�������
                for (int yy = 0; yy < height; yy++)
                {
                    for (int xx = (int)point[BannerNum - 1].X + dw; xx < width; xx++)
                    {
                        r = imageIn.getRComponent(xx, yy);
                        g = imageIn.getGComponent(xx, yy);
                        b = imageIn.getBComponent(xx, yy);
                        clone.setPixelColor(xx, yy, r, g, b);
                    }
                }
            }
            return clone;
        }
Example #29
0
        public Image process(Image imageIn)
        {
            Color rgb   = new Color();
            YCbCr ycbcr = new YCbCr();

            float ky = 0, by = 0;
            float kcb = 0, bcb = 0;
            float kcr = 0, bcr = 0;

            // Y line parameters
            if (inY.Max != inY.Min)
            {
                ky = (outY.Max - outY.Min) / (inY.Max - inY.Min);
                by = outY.Min - ky * inY.Min;
            }
            // Cb line parameters
            if (inCb.Max != inCb.Min)
            {
                kcb = (outCb.Max - outCb.Min) / (inCb.Max - inCb.Min);
                bcb = outCb.Min - kcb * inCb.Min;
            }
            // Cr line parameters
            if (inCr.Max != inCr.Min)
            {
                kcr = (outCr.Max - outCr.Min) / (inCr.Max - inCr.Min);
                bcr = outCr.Min - kcr * inCr.Min;
            }

            for (int x = 0; x < imageIn.getWidth(); x++)
            {
                for (int y = 0; y < imageIn.getHeight(); y++)
                {
                    rgb.R = (byte)imageIn.getRComponent(x, y);
                    rgb.G = (byte)imageIn.getGComponent(x, y);
                    rgb.B = (byte)imageIn.getBComponent(x, y);

                    // convert to YCbCr
                    ycbcr = YCbCr.FromRGB(rgb, ycbcr);

                    // correct Y
                    if (ycbcr.Y >= inY.Max)
                    {
                        ycbcr.Y = outY.Max;
                    }
                    else if (ycbcr.Y <= inY.Min)
                    {
                        ycbcr.Y = outY.Min;
                    }
                    else
                    {
                        ycbcr.Y = ky * ycbcr.Y + by;
                    }

                    // correct Cb
                    if (ycbcr.Cb >= inCb.Max)
                    {
                        ycbcr.Cb = outCb.Max;
                    }
                    else if (ycbcr.Cb <= inCb.Min)
                    {
                        ycbcr.Cb = outCb.Min;
                    }
                    else
                    {
                        ycbcr.Cb = kcb * ycbcr.Cb + bcb;
                    }

                    // correct Cr
                    if (ycbcr.Cr >= inCr.Max)
                    {
                        ycbcr.Cr = outCr.Max;
                    }
                    else if (ycbcr.Cr <= inCr.Min)
                    {
                        ycbcr.Cr = outCr.Min;
                    }
                    else
                    {
                        ycbcr.Cr = kcr * ycbcr.Cr + bcr;
                    }

                    // convert back to RGB
                    rgb = YCbCr.ToRGB(ycbcr, rgb);

                    imageIn.setPixelColor(x, y, rgb.R, rgb.G, rgb.B);
                }
            }
            return(imageIn);
        }
        public override Image process(Image imageIn)
        {
            int r, g, b;
            int width = imageIn.getWidth();
            int height = imageIn.getHeight();
            double hw = width / 2.0;
            double hh = height / 2.0;

            int ratio = width > height ? height * 32768 / width : width * 32768 / height;

            // Calculate center, min and max
            int cx = width >> 1;
            int cy = height >> 1;
            int max = cx * cx + cy * cy;
            int min = (int)(max * 0.5);
            int diff = max - min;

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    if (m_focusType == 1)//椭圆
                    {
                        // Calculate distance to center and adapt aspect ratio
                        int dx = cx - x;
                        int dy = cy - y;
                        if (imageIn.getWidth() > imageIn.getHeight())
                        {
                            dy = (dy * ratio) >> 14;
                        }
                        else
                        {
                            dx = (dx * ratio) >> 14;
                        }
                        int distSq = dx * dx + dy * dy;

                        if (distSq <= min)
                            continue;
                    }
                    else if (m_focusType == 2)//长方框
                    {
                        bool inarray = false;
                        if ((x < m_size) && (y < height - x) && (y >= x))
                            inarray = true; // left
                        else if ((y < m_size) && (x < width - y) && (x >= y))
                            inarray = true; // top
                        else if ((x > width - m_size) && (y >= width - x) && (y < height + x - width))
                            inarray = true; // right
                        else if (y > height - m_size)
                            inarray = true; // bottom
                        if (!inarray)
                            continue;
                    }
                    int i = (int)(x - hw);
                    int j = (int)(y - hh);
                    b = 0; g = 0; r = 0;

                    for (int mm = 0; mm < aasamples; mm++)
                    {
                        double u = i + m_aapt[mm].X;
                        double v = j - m_aapt[mm].Y;

                        double s = m_cos * u + m_sin * v;
                        double t = -m_sin * u + m_cos * v;

                        s += m_curvature * Math.Tan(s * m_scale);
                        t += m_curvature * Math.Tan(t * m_scale);
                        u = m_cos * s - m_sin * t;
                        v = m_sin * s + m_cos * t;

                        int xSample = (int)(hw + u);
                        int ySample = (int)(hh + v);

                        xSample = Function.FClamp(xSample, 0, width - 1);
                        ySample = Function.FClamp(ySample, 0, height - 1);

                        r += imageIn.getRComponent(xSample, ySample);
                        g += imageIn.getGComponent(xSample, ySample);
                        b += imageIn.getBComponent(xSample, ySample);
                    }
                    imageIn.setPixelColor(x, y, Image.SAFECOLOR(r / aasamples), Image.SAFECOLOR(g / aasamples), Image.SAFECOLOR(b / aasamples));
                }
            }
            return imageIn;
        }
        // @Override
        public Image process(Image imageIn)
        {
            // Image size
            int width  = imageIn.getWidth();
            int height = imageIn.getHeight();

            bool[,] mask = null;
            int[] grayMatrix = new int[256];

            // Init gray matrix
            int    outlineCase = 1;
            double rand        = new Random().NextDouble();

            if (rand > 0.33 && rand < 0.66)
            {
                outlineCase = 2;
            }
            else if (rand > 0.66)
            {
                outlineCase = 3;
            }
            for (int i = 255; i >= 0; i--)
            {
                int red = i, green = i, blue = i;
                if (i > 127)
                {
                    switch (outlineCase)
                    {
                    case 1:
                        red = 255 - i;
                        break;

                    case 2:
                        green = 255 - i;
                        break;

                    case 3:
                        blue = 255 - i;
                        break;
                    }
                }
                grayMatrix[255 - i] = (255 << 24) + (red << 16) + (green << 8) + blue;
            }

            int [,] luminance = new int[width, height];
            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    if (mask != null && !mask[x, y])
                    {
                        continue;
                    }
                    luminance[x, y] = (int)Luminance(imageIn.getRComponent(x, y), imageIn.getGComponent(x, y), imageIn.getBComponent(x, y));
                }
            }


            int grayX, grayY;
            int magnitude;

            for (int y = 1; y < height - 1; y++)
            {
                for (int x = 1; x < width - 1; x++)
                {
                    if (mask != null && !mask[x, y])
                    {
                        continue;
                    }

                    grayX = -luminance[x - 1, y - 1] + luminance[x - 1, y - 1 + 2] - 2 * luminance[x - 1 + 1, y - 1] + 2 * luminance[x - 1 + 1, y - 1 + 2] - luminance[x - 1 + 2, y - 1] + luminance[x - 1 + 2, y - 1 + 2];
                    grayY = luminance[x - 1, y - 1] + 2 * luminance[x - 1, y - 1 + 1] + luminance[x - 1, y - 1 + 2] - luminance[x - 1 + 2, y - 1] - 2 * luminance[x - 1 + 2, y - 1 + 1] - luminance[x - 1 + 2, y - 1 + 2];

                    // Magnitudes sum
                    magnitude = 255 - truncate(Math.Abs(grayX) + Math.Abs(grayY));
                    int grayscaleColor = grayMatrix[magnitude];

                    // Apply the color into a new image
                    imageIn.setPixelColor(x, y, grayscaleColor);
                }
            }

            return(imageIn);
        }
        //@Override
        public Image process(Image imageIn)
        {
            int[,] h = new int[3, 256];
            int[] array            = new int[3];
            int[] rgb              = new int[] { 255, 255, 255 };
            int[] bb               = new int[256];
            int[] gg               = new int[256];
            int[] rr               = new int[256];
            int   intensity        = (int)(this.Intensity * 255f);
            int   intensity_invert = 255 - intensity;

            for (int x = 0; x < imageIn.getWidth() - 1; x++)
            {
                for (int y = 0; y < imageIn.getHeight() - 1; y++)
                {
                    h[0, imageIn.getRComponent(x, y)]++;
                    h[1, imageIn.getGComponent(x, y)]++;
                    h[2, imageIn.getBComponent(x, y)]++;
                }
            }
            int[]   percentileColor = GetPercentileColor(h, 0.005f);
            int[]   meanColor       = GetMeanColor(h);
            int[]   hi    = GetPercentileColor(h, 0.995f);
            float[] gamma = ComputeGamma(percentileColor, meanColor, hi);
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 256; j++)
                {
                    int[] arr = new int[3];
                    for (int n = 0; n < 3; n++)
                    {
                        float percent = j - percentileColor[n];
                        if (percent < 0f)
                        {
                            arr[n] = array[n];
                        }
                        else if ((percent + percentileColor[n]) >= hi[n])
                        {
                            arr[n] = rgb[n];
                        }
                        else
                        {
                            double adjust = array[n] + ((rgb[n] - array[n]) * Math.Pow((double)(percent / ((float)(hi[n] - percentileColor[n]))), (double)gamma[n]));
                            arr[n] = (adjust > 255.0) ? ((int)255.0) : ((adjust < 0.0) ? ((int)0.0) : ((int)adjust));
                        }
                    }
                    rr[j] = arr[0];
                    gg[j] = arr[1];
                    bb[j] = arr[2];
                }
            }
            Image clone = imageIn.clone();
            int   r, g, b;

            for (int x = 0; x < imageIn.getWidth() - 1; x++)
            {
                for (int y = 0; y < imageIn.getHeight() - 1; y++)
                {
                    r = clone.getRComponent(x, y);
                    g = clone.getGComponent(x, y);
                    b = clone.getBComponent(x, y);
                    r = (r * intensity_invert + rr[r] * intensity) >> 8;
                    g = (g * intensity_invert + gg[g] * intensity) >> 8;
                    b = (b * intensity_invert + bb[b] * intensity) >> 8;
                    imageIn.setPixelColor(x, y, r, g, b);
                }
            }
            return(imageIn);//做直方图模式增强
        }
 //@Override
 public Image process(Image imageIn)
 {
     int[,] h = new int[3,256];
     int[] array = new int[3];
     int[] rgb = new int[] { 255, 255, 255 };
     int[] bb = new int[256];
     int[] gg = new int[256];
     int[] rr = new int[256];
     int intensity = (int) (this.Intensity * 255f);
     int intensity_invert = 255 - intensity;
     for (int x = 0; x < imageIn.getWidth() - 1; x++){
      for (int y = 0; y < imageIn.getHeight() - 1; y++)  {
        			  h[0,imageIn.getRComponent(x, y)]++;
       	          h[1,imageIn.getGComponent(x, y)]++;
       	          h[2,imageIn.getBComponent(x, y)]++;
      }
     }
     int[] percentileColor = GetPercentileColor(h, 0.005f);
     int[] meanColor = GetMeanColor(h);
     int[] hi = GetPercentileColor(h, 0.995f);
     float[] gamma = ComputeGamma(percentileColor, meanColor, hi);
     for (int i = 0; i < 3; i++){
     for (int j = 0; j < 256; j++){
         int[] arr = new int[3];
         for (int n = 0; n < 3; n++){
             float percent = j - percentileColor[n];
             if (percent < 0f){
                 arr[n] = array[n];
             }
             else if ((percent + percentileColor[n]) >= hi[n]){
                 arr[n] = rgb[n];
             }
             else {
                 double adjust = array[n] + ((rgb[n] - array[n]) * Math.Pow((double) (percent / ((float) (hi[n] - percentileColor[n]))), (double) gamma[n]));
                 arr[n] = (adjust > 255.0) ? ((int) 255.0) : ((adjust < 0.0) ? ((int) 0.0) : ((int) adjust));
             }
         }
         rr[j] = arr[0];
         gg[j] = arr[1];
         bb[j] = arr[2];
     }
     }
     Image clone = imageIn.clone();
     int r,g,b;
     for (int x = 0; x < imageIn.getWidth() - 1; x++){
       			 for (int y = 0; y < imageIn.getHeight() - 1; y++)  {
       				r = clone.getRComponent(x, y);
       				g = clone.getGComponent(x, y);
       				b = clone.getBComponent(x, y);
         r = (r * intensity_invert + rr[r] * intensity) >> 8;
         g = (g * intensity_invert + gg[g] * intensity) >> 8;
         b = (b * intensity_invert + bb[b] * intensity) >> 8;
         imageIn.setPixelColor(x, y, r, g, b);
      	 }
     }
     return imageIn;//��ֱ��ͼģʽ��ǿ
 }
        public override Image process(Image imageIn)
        {
            if ((_pt.X + _pt.Y) <= 0)
            {
                _pt.X = imageIn.getWidth() / 2;
                _pt.Y = imageIn.getHeight() / 2;
            }
            for (int x = 0; x < (imageIn.getWidth() - 1); x++)
            {
                for (int y = 0; y < (imageIn.getHeight() - 1); y++)
                {
                    int[] pixel = new int[3];
                    pixel[0] = imageIn.getRComponent(x, y);
                    pixel[1] = imageIn.getGComponent(x, y);
                    pixel[2] = imageIn.getBComponent(x, y);

                    double u = (x - _pt.X + 0.001) / _radius;
                    double v = (y - _pt.Y + 0.001) / _radius;

                    double t = (Math.Atan2(u, v) / (2 * Function.LIB_PI) + 0.51) * _count;
                    int    i = (int)Math.Floor(t);
                    t -= i;
                    i %= _count;

                    double w1 = _spoke[i] * (1 - t) + _spoke[(i + 1) % _count] * t;
                    w1 = w1 * w1;

                    double w      = 1.0 / Math.Sqrt(u * u + v * v) * 0.9;
                    double fRatio = Function.FClampDouble(w, 0.0, 1.0);

                    double ws = Function.FClampDouble(w1 * w, 0.0, 1.0);

                    for (int m = 0; m < 3; m++)
                    {
                        int[] _spokecolorm = new int[3];
                        _spokecolorm[0] = _spokecolor[i] & 0xFF0000 >> 16;
                        _spokecolorm[1] = _spokecolor[i] & 0x00FF00 >> 8;
                        _spokecolorm[2] = _spokecolor[i] & 0x0000FF;

                        int[] _spokecolorcount = new int[3];
                        _spokecolorcount[0] = _spokecolor[(i + 1) % _count] & 0xFF0000 >> 16;
                        _spokecolorcount[1] = _spokecolor[(i + 1) % _count] & 0x00FF00 >> 8;
                        _spokecolorcount[2] = _spokecolor[(i + 1) % _count] & 0x0000FF;

                        double spokecol = _spokecolorm[m] / 255.0 * (1 - t) + _spokecolorcount[m] / 255.0 * t;

                        double r;
                        if (w > 1.0)
                        {
                            r = Function.FClampDouble(spokecol * w, 0.0, 1.0);
                        }
                        else
                        {
                            r = pixel[m] / 255.0 * (1.0 - fRatio) + spokecol * fRatio;
                        }

                        r       += ws;
                        pixel[m] = Function.FClamp0255(r * 255);
                        imageIn.setPixelColor(x, y, pixel[0], pixel[1], pixel[2]);
                    }
                }
            }
            return(imageIn);
        }
        //@Override
        public override Image process(Image imageIn)
        {
            int width = imageIn.getWidth();
            int height = imageIn.getHeight();
            int r = 0, g = 0, b = 0;

            Image clone = imageIn.clone();

            clone.clearImage((255 << 24) + (Colors.LightGray.R << 16) + (Colors.LightGray.G << 8) + Colors.LightGray.B);
            Point[] point = new Point[BannerNum];
            if (this.IsHorizontal)
            {//水平方向
                int dh = height / BannerNum;
                int dw = width;
                for (int i = 0; i < BannerNum; i++)
                {
                    point[i] = new Point(0, i * dh);
                }
                for (int x = 0; x < dh; x++)
                {
                    for (int y = 0; y < BannerNum; y++)
                    {
                        for (int k = 0; k < dw; k++)
                        {
                            int xx = (int)point[y].X + k;
                            int yy = (int)point[y].Y + (int)(x / 1.1);
                            r = imageIn.getRComponent(xx, yy);
                            g = imageIn.getGComponent(xx, yy);
                            b = imageIn.getBComponent(xx, yy);
                            clone.setPixelColor(xx, yy, r, g, b);
                        }
                    }
                }
                //对图像其余部分做填充
                for (int xx = 0; xx < width; xx++)
                {
                    for (int yy = (int)point[BannerNum - 1].Y + dh; yy < height; yy++)
                    {
                        r = imageIn.getRComponent(xx, yy);
                        g = imageIn.getGComponent(xx, yy);
                        b = imageIn.getBComponent(xx, yy);
                        clone.setPixelColor(xx, yy, r, g, b);
                    }
                }
            }
            else
            {//垂直方向
                int dw = width / BannerNum;
                int dh = height;
                for (int i = 0; i < BannerNum; i++)
                {
                    point[i] = new Point(i * dw, 0);
                }
                for (int x = 0; x < dw; x++)
                {
                    for (int y = 0; y < BannerNum; y++)
                    {
                        for (int k = 0; k < dh; k++)
                        {
                            int xx = (int)point[y].X + (int)(x / 1.1);
                            int yy = (int)point[y].Y + k;
                            r = imageIn.getRComponent(xx, yy);
                            g = imageIn.getGComponent(xx, yy);
                            b = imageIn.getBComponent(xx, yy);
                            clone.setPixelColor(xx, yy, r, g, b);
                        }
                    }
                }
                //对图像其余部分做填充
                for (int yy = 0; yy < height; yy++)
                {
                    for (int xx = (int)point[BannerNum - 1].X + dw; xx < width; xx++)
                    {
                        r = imageIn.getRComponent(xx, yy);
                        g = imageIn.getGComponent(xx, yy);
                        b = imageIn.getBComponent(xx, yy);
                        clone.setPixelColor(xx, yy, r, g, b);
                    }
                }
            }
            return(clone);
        }
        //@Override
        public Image process(Image imageIn)
        {
            int width = imageIn.getWidth();
            int height = imageIn.getHeight();
            double d = this.OriginAngleDegree * 0.0174532925;
            float cos = (float)Math.Cos(d);
            float sin = (float)Math.Sin(d);
            float radio = (cos * width) + (sin * height);
            float dcos = cos * radio;
            float dsin = sin * radio;
            int dist = (int)Math.Sqrt((double)((dcos * dcos) + (dsin * dsin)));
            dist = Math.Max(Math.Max(dist, width), height);

            if ((this.palette == null) || (dist != this.palette.Length))
            {
                this.palette = this.Gradientf.CreatePalette(dist);
            }
            byte[] red = this.palette.Red;
            byte[] green = this.palette.Green;
            byte[] blue = this.palette.Blue;
            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    radio = (cos * j) + (sin * i);
                    dcos = cos * radio;
                    dsin = sin * radio;
                    dist = (int)Math.Sqrt((double)((dcos * dcos) + (dsin * dsin)));
                    imageIn.setPixelColor(j, i, red[dist], green[dist], blue[dist]);
                }
            }
            return imageIn;
        }
        public Image process(Image imageIn)
        {
            Color rgb = new Color();
            YCbCr ycbcr = new YCbCr();

            float ky = 0, by = 0;
            float kcb = 0, bcb = 0;
            float kcr = 0, bcr = 0;

            // Y line parameters
            if (inY.Max != inY.Min)
            {
                ky = (outY.Max - outY.Min) / (inY.Max - inY.Min);
                by = outY.Min - ky * inY.Min;
            }
            // Cb line parameters
            if (inCb.Max != inCb.Min)
            {
                kcb = (outCb.Max - outCb.Min) / (inCb.Max - inCb.Min);
                bcb = outCb.Min - kcb * inCb.Min;
            }
            // Cr line parameters
            if (inCr.Max != inCr.Min)
            {
                kcr = (outCr.Max - outCr.Min) / (inCr.Max - inCr.Min);
                bcr = outCr.Min - kcr * inCr.Min;
            }

            for (int x = 0; x < imageIn.getWidth(); x++)
            {
                for (int y = 0; y < imageIn.getHeight(); y++)
                {
                    rgb.R = (byte)imageIn.getRComponent(x, y);
                    rgb.G = (byte)imageIn.getGComponent(x, y);
                    rgb.B = (byte)imageIn.getBComponent(x, y);

                    // convert to YCbCr
                    ycbcr = YCbCr.FromRGB(rgb, ycbcr);

                    // correct Y
                    if (ycbcr.Y >= inY.Max)
                        ycbcr.Y = outY.Max;
                    else if (ycbcr.Y <= inY.Min)
                        ycbcr.Y = outY.Min;
                    else
                        ycbcr.Y = ky * ycbcr.Y + by;

                    // correct Cb
                    if (ycbcr.Cb >= inCb.Max)
                        ycbcr.Cb = outCb.Max;
                    else if (ycbcr.Cb <= inCb.Min)
                        ycbcr.Cb = outCb.Min;
                    else
                        ycbcr.Cb = kcb * ycbcr.Cb + bcb;

                    // correct Cr
                    if (ycbcr.Cr >= inCr.Max)
                        ycbcr.Cr = outCr.Max;
                    else if (ycbcr.Cr <= inCr.Min)
                        ycbcr.Cr = outCr.Min;
                    else
                        ycbcr.Cr = kcr * ycbcr.Cr + bcr;

                    // convert back to RGB
                    rgb = YCbCr.ToRGB(ycbcr, rgb);

                    imageIn.setPixelColor(x, y, rgb.R, rgb.G, rgb.B);
                }
            }
            return imageIn;
        }
        //@Override
        public virtual Image process(Image imageIn)
        {
            int r, g, b;
            int width = imageIn.getWidth();
            int height = imageIn.getHeight();
            int realxpos = (int)(width * Center.X);
            int realypos = (int)(height * Center.Y);
            float realradius = Math.Min(width, height) * Radius;
            Image clone = imageIn.clone();
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    float pos = 1f - ((float)Math.Sqrt((double)(((x - realxpos) * (x - realxpos)) + (y - realypos) * (y - realypos))) / realradius);
                    if (pos > 0f)
                    {
                        pos = 1f - (Distortion * pos * pos);
                        float pos1 = (x - realxpos) * pos + realxpos;
                        float pos2 = (y - realypos) * pos + realypos;
                        int x1 = (int)pos1;
                        float pos3 = pos1 - x1;
                        int x2 = (pos3 > 0f) ? (x1 + 1) : x1;
                        int y1 = (int)pos2;
                        float pos4 = pos2 - y1;
                        int y2 = (pos4 > 0f) ? (y1 + 1) : y1;
                        if (x1 < 0)
                        {
                            x1 = 0;
                        }
                        else if (x1 >= width)
                        {
                            x1 = width - 1;
                        }
                        if (x2 < 0)
                        {
                            x2 = 0;
                        }
                        else if (x2 >= width)
                        {
                            x2 = width - 1;
                        }
                        if (y1 < 0)
                        {
                            y1 = 0;
                        }
                        else if (y1 >= height)
                        {
                            y1 = height - 1;
                        }
                        if (y2 < 0)
                        {
                            y2 = 0;
                        }
                        else if (y2 >= height)
                        {
                            y2 = height - 1;
                        }
                        r = clone.getRComponent(x1, y1);
                        g = clone.getGComponent(x1, y1);
                        b = clone.getBComponent(x1, y1);

                        int r2 = clone.getRComponent(x2, y1);
                        int g2 = clone.getGComponent(x2, y1);
                        int b2 = clone.getBComponent(x2, y1);
                        int r3 = clone.getRComponent(x2, y2);
                        int g3 = clone.getGComponent(x2, y2);
                        int b3 = clone.getBComponent(x2, y2);
                        int r4 = clone.getRComponent(x1, y2);
                        int g4 = clone.getGComponent(x1, y2);
                        int b4 = clone.getBComponent(x1, y2);
                        r = (int)((r * (1f - pos4) * (1f - pos3) + r2 * (1f - pos4) * pos3 + r3 * pos4 * pos3) + r4 * pos4 * (1f - pos3));
                        g = (int)((g * (1f - pos4) * (1f - pos3) + g2 * (1f - pos4) * pos3 + g3 * pos4 * pos3) + g4 * pos4 * (1f - pos3));
                        b = (int)((b * (1f - pos4) * (1f - pos3) + b2 * (1f - pos4) * pos3 + b3 * pos4 * pos3) + b4 * pos4 * (1f - pos3));
                    }
                    else
                    {
                        r = clone.getRComponent(x, y);
                        g = clone.getGComponent(x, y);
                        b = clone.getBComponent(x, y);
                    }
                    imageIn.setPixelColor(x, y, r, g, b);
                }
            }
            return imageIn;
        }
        //@Override
        public virtual Image process(Image imageIn)
        {
            int   r, g, b;
            int   width      = imageIn.getWidth();
            int   height     = imageIn.getHeight();
            int   realxpos   = (int)(width * Center.X);
            int   realypos   = (int)(height * Center.Y);
            float realradius = Math.Min(width, height) * Radius;
            Image clone      = imageIn.clone();

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    float pos = 1f - ((float)Math.Sqrt((double)(((x - realxpos) * (x - realxpos)) + (y - realypos) * (y - realypos))) / realradius);
                    if (pos <= 0f)
                    {
                        pos = 1f - (Distortion * pos * pos);
                        float pos1 = (x - realxpos) * pos + realxpos;
                        float pos2 = (y - realypos) * pos + realypos;
                        int   x1   = (int)pos1;
                        float pos3 = pos1 - x1;
                        int   x2   = (pos3 > 0f) ? (x1 + 1) : x1;
                        int   y1   = (int)pos2;
                        float pos4 = pos2 - y1;
                        int   y2   = (pos4 > 0f) ? (y1 + 1) : y1;
                        if (x1 < 0)
                        {
                            x1 = 0;
                        }
                        else if (x1 >= width)
                        {
                            x1 = width - 1;
                        }
                        if (x2 < 0)
                        {
                            x2 = 0;
                        }
                        else if (x2 >= width)
                        {
                            x2 = width - 1;
                        }
                        if (y1 < 0)
                        {
                            y1 = 0;
                        }
                        else if (y1 >= height)
                        {
                            y1 = height - 1;
                        }
                        if (y2 < 0)
                        {
                            y2 = 0;
                        }
                        else if (y2 >= height)
                        {
                            y2 = height - 1;
                        }
                        r = clone.getRComponent(x1, y1);
                        g = clone.getGComponent(x1, y1);
                        b = clone.getBComponent(x1, y1);

                        int r2 = clone.getRComponent(x2, y1);
                        int g2 = clone.getGComponent(x2, y1);
                        int b2 = clone.getBComponent(x2, y1);
                        int r3 = clone.getRComponent(x2, y2);
                        int g3 = clone.getGComponent(x2, y2);
                        int b3 = clone.getBComponent(x2, y2);
                        int r4 = clone.getRComponent(x1, y2);
                        int g4 = clone.getGComponent(x1, y2);
                        int b4 = clone.getBComponent(x1, y2);
                        r = (int)((r * (1f - pos4) * (1f - pos3) + r2 * (1f - pos4) * pos3 + r3 * pos4 * pos3) + r4 * pos4 * (1f - pos3));
                        g = (int)((g * (1f - pos4) * (1f - pos3) + g2 * (1f - pos4) * pos3 + g3 * pos4 * pos3) + g4 * pos4 * (1f - pos3));
                        b = (int)((b * (1f - pos4) * (1f - pos3) + b2 * (1f - pos4) * pos3 + b3 * pos4 * pos3) + b4 * pos4 * (1f - pos3));
                    }
                    else
                    {
                        r = clone.getRComponent(x, y);
                        g = clone.getGComponent(x, y);
                        b = clone.getBComponent(x, y);
                    }
                    imageIn.setPixelColor(x, y, r, g, b);
                }
            }
            return(imageIn);
        }