| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 797 人关注过本帖
标题:请问怎么样编写代码实现图片的锐化效果?
只看楼主 加入收藏
风弄无声
Rank: 1
等 级:新手上路
帖 子:31
专家分:0
注 册:2008-1-30
收藏
 问题点数:0 回复次数:0 
请问怎么样编写代码实现图片的锐化效果?
private void 锐化ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int Height = this.pictureBox1.Image.Height;
            int Width = this.pictureBox1.Image.Width;
            Bitmap bitmap = new Bitmap(Height, Width);
            Bitmap mybitmap = (Bitmap)this.pictureBox1.Image;
            Color pixel;
            int[] Laplacian ={ -1, -1, -1, -1, 9, -1, -1, -1, -1 };
            for(int x = 1; x < Width - 1; x++)
                for (int y = 1; y < Height - 1; y++)
                {
                    int r = 0, g = 0, b = 0;
                    int Index = 0;
                  // int a = 0;
                    for(int col = -1;col <= 1 ; col++)
                        for (int row = -1; row <= 1; row++)
                        {
                            pixel = mybitmap.GetPixel(x + row, y + col);
                            r += pixel.R * Laplacian[Index];
                            g += pixel.G * Laplacian[Index];
                            b += pixel.B * Laplacian[Index];
                            Index++;
                        }
                    r = r > 255 ? 255 : r;
                    r = r < 0 ? 0 : r;
                    g = g > 255 ? 255 : g;
                    g = g < 0 ? 0 : g;
                    b = b > 255 ? 255 : b;
                    b = b < 0 ? 0 : b;
                    bitmap.SetPixel(x , y , Color.FromArgb(r, g, b) );    //这一句总是提示出错了
                }
            this.pictureBox1.Image = bitmap;
        }
搜索更多相关主题的帖子: 效果 代码 编写 
2008-11-12 19:34
快速回复:请问怎么样编写代码实现图片的锐化效果?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.032852 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved