Fork me on GitHub

图像处理-06-图像的反色处理

图像的反色处理

反色的实际含义是将R、G、B值反转,如果颜色的量化级是256,则用255分别减去R、G、B的值作为新图的颜色。

        public Bitmap ReColor(Image image)
        {
            int width = image.Width;
            int height = image.Height;

            Bitmap bitmap = (Bitmap)image;
            Bitmap temp = new Bitmap( width, height );
            Color pixel;
            int r, g, b;

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    pixel = bitmap.GetPixel( x, y );
                    r = 255 - pixel.R;
                    g = 255 - pixel.G;
                    b = 255 - pixel.B;
                    temp.SetPixel( x, y, Color.FromArgb( r, g, b ) );
                }
            }

            return temp;
        }

 

posted @ 2013-11-04 10:55  种花生的读书人  阅读(1119)  评论(0编辑  收藏  举报

该博客仅作为记录笔记,转载随意