十六、GDI+实例——柔化与锐化
柔化就是对图像进行平滑处理,减少相邻像素问的颜色差别,一般选用3*3像素块,将中间的像素值改成这9个像素的平均像素。从而达到柔化效果。
图像的锐化处理正好与柔化处理相反,它的目的是突比图像的变化部分,这里采用的算法是将要处理的像素与它左对角线的像素之间的差值乘上一个锐化系数,然后再加上原先的像素值就能够做出锐化效果。
private void button1_Click(object sender, EventArgs e)
{
Bitmap bmp = new Bitmap(Application.StartupPath + "//1.jpg");
Graphics g = this.CreateGraphics();
g.TranslateTransform(205, 0);
g.ScaleTransform(0.5f, 0.5f);
int width = bmp.Width;
int height = bmp.Height;
Bitmap bmp2 = bmp.Clone(new Rectangle(0, 0, width, height), System.Drawing.Imaging.PixelFormat.DontCare);
Color colorTemp;
Color[,] color = new Color[3, 3];
int tmpp;
for (int i = 1; i