zoukankan      html  css  js  c++  java
  • 图像处理-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;
                }
            }

  • 相关阅读:
    gitee之部署vue项目dist目录
    arcgis js 之 featureLayer创建模板
    arcgis js 之featureLayer服务查询及筛选
    video.js视频播放
    vue之监听对象、对象数组的改变
    Element-ui组件库Table表格导出Excel文件
    sublime 常用插件
    前端工具
    css 待处理
    移动前端开发:待处理
  • 原文地址:https://www.cnblogs.com/chenyongblog/p/3405552.html
Copyright © 2011-2022 走看看