• 图像处理-05-浮雕效果处理


    浮雕效果处理

    浮雕效果:是将图像的变化部分突出的表现出来,而相通的颜色部分则被淡化掉,使图像出现纵深感,从而达到浮雕的效果。

    采用的算法是:将要处理的像素与处于同一对角线上的另一个像素做差值,然后加上128,大于255就等于255,小于0就等于0,其他的不做处理

            public Bitmap Relife(Image image)
            {
                int width = image.Width;
                int height = image.Height;
    
                Bitmap temp = new Bitmap( width, height );
                Bitmap bitmap=(Bitmap)image;
                Color pixel1, pixel2;
                int r, g, b;
    
                for (int x = 0; x < width - 1; x++)
                {
                    for (int y = 0; y < height - 1; y++)
                    {
                        pixel1 = bitmap.GetPixel( x, y );
                        pixel2 = bitmap.GetPixel( x + 1, y + 1 );
    
                        r = Judge( pixel1.R - pixel2.R + 128 );
                        g = Judge( pixel1.G - pixel2.G + 128 );
                        b = Judge( pixel1.B - pixel2.B + 128 );
    
                        temp.SetPixel( x, y, Color.FromArgb( r, g, b ) );
                    }
                }
                return temp;
            }
    
            public int Judge(int number)
            {
                if (number > 255)
                {
                    return 255;
                }
                if (number < 0)
                {
                    return 0;
                }
                else
                {
                    return number;
                }
            }

  • 相关阅读:
    informix 外部表 pipe
    关于XML的一些解析操作
    oracle 导出导入数据库
    判断请求访问的浏览器类型设备
    git与SVN的区别
    Java获取文件路径
    <DIV>内容显示隐藏功能实现
    文件下载
    文件上传
    记录启动Nginx启动失败
  • 原文地址:https://www.cnblogs.com/chenyongblog/p/3405552.html
Copyright © 2020-2023  润新知