




已阅读5页,还剩2页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
各种图像处理方法底片效果private void button1_Click(object sender, EventArgs e)/以底片效果显示图像tryint Height = this.pictureBox1.Image.Height;int Width = this.pictureBox1.Image.Width;Bitmap newbitmap = new Bitmap(Width, Height);Bitmap oldbitmap = (Bitmap)this.pictureBox1.Image;Color pixel;for (int x = 1; x Width; x+)for (int y = 1; y Height; y+)int r, g, b;pixel = oldbitmap.GetPixel(x, y);r = 255 - pixel.R;g = 255 - pixel.G;b = 255 - pixel.B;newbitmap.SetPixel(x, y, Color.FromArgb(r, g, b);this.pictureBox1.Image = newbitmap;catch (Exception ex)MessageBox.Show(ex.Message, 信息提示, MessageBoxButtons.OK, MessageBoxIcon.Information);柔化效果private void button1_Click(object sender, EventArgs e)/以柔化效果显示图像tryint Height = this.pictureBox1.Image.Height;int Width = this.pictureBox1.Image.Width;Bitmap bitmap = new Bitmap(Width, Height);Bitmap MyBitmap = (Bitmap)this.pictureBox1.Image;Color pixel;/高斯模板int Gauss = 1, 2, 1, 2, 4, 2, 1, 2, 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;for (int col = -1; col = 1; col+)for (int row = -1; row 255 ? 255 : r;r = r 255 ? 255 : g;g = g 255 ? 255 : b;b = b 0 ? 0 : b;bitmap.SetPixel(x - 1, y - 1, Color.FromArgb(r, g, b);this.pictureBox1.Image = bitmap;catch (Exception ex)MessageBox.Show(ex.Message, 信息提示);锐化效果private void button1_Click(object sender, EventArgs e)/以锐化效果显示图像tryint Height = this.pictureBox1.Image.Height;int Width = this.pictureBox1.Image.Width;Bitmap newBitmap = new Bitmap(Width, Height);Bitmap oldBitmap = (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;for (int col = -1; col = 1; col+)for (int row = -1; row 255 ? 255 : r;r = r 255 ? 255 : g;g = g 255 ? 255 : b;b = b 0 ? 0 : b;newBitmap.SetPixel(x - 1, y - 1, Color.FromArgb(r, g, b);this.pictureBox1.Image = newBitmap;catch (Exception ex)MessageBox.Show(ex.Message, 信息提示);雾化效果private void button1_Click(object sender, EventArgs e)/以雾化效果显示图像tryint Height = this.pictureBox1.Image.Height;int Width = this.pictureBox1.Image.Width;Bitmap newBitmap = new Bitmap(Width, Height);Bitmap oldBitmap = (Bitmap)this.pictureBox1.Image;Color pixel;for (int x = 1; x Width - 1; x+)for (int y = 1; y = Width)dx = Width - 1;if (dy = Height)dy = Height - 1;pixel = oldBitmap.GetPixel(dx, dy);newBitmap.SetPixel(x, y, pixel);this.pictureBox1.Image = newBitmap;catch (Exception ex)MessageBox.Show(ex.Message, 信息提示);光照效果private void button1_Click(object sender, EventArgs e)/以光照效果显示图像Graphics MyGraphics = this.pictureBox1.CreateGraphics();MyGraphics.Clear(Color.White);Bitmap MyBmp = new Bitmap(this.pictureBox1.Image, this.pictureBox1.Width, this.pictureBox1.Height);int MyWidth = MyBmp.Width;int MyHeight = MyBmp.Height;Bitmap MyImage = MyBmp.Clone(new RectangleF(0, 0, MyWidth, MyHeight), System.Drawing.Imaging.PixelFormat.DontCare);int A = Width / 2;int B = Height / 2;/MyCenter图片中心点,发亮此值会让强光中心发生偏移Point MyCenter = new Point(MyWidth / 2, MyHeight / 2);/R强光照射面的半径,即”光晕”int R = Math.Min(MyWidth / 2, MyHeight / 2);for (int i = MyWidth - 1; i = 1; i-)for (int j = MyHeight - 1; j = 1; j-)float MyLength = (float)Math.Sqrt(Math.Pow(i - MyCenter.X), 2) + Math.Pow(j - MyCenter.Y), 2);/如果像素位于”光晕”之内if (MyLength R)Color MyColor = MyImage.GetPixel(i, j);int r, g, b;/220亮度增加常量,该值越大,光亮度越强float MyPixel = 220.0f * (1.0f - MyLength / R);r = MyColor.R + (int)MyPixel;r = Math.Max(0, Math.Min(r, 255);g = MyColor.G + (int)MyPixel;g = Math.Max(0, Math.Min(g, 255);b = MyColor.B + (int)MyPixel;b = Math.Max(0, Math.Min(b, 255);/将增亮后的像素值回写到位图Color MyNewColor = Color.FromArgb(255, r, g, b);MyImage.SetPixel(i, j, MyNewColor);/重新绘制图片MyGraphics.DrawImage(MyImage, new Rectangle(0, 0, MyWidth, MyHeight);垂直百叶窗private void button1_Click(object sender, EventArgs e)/垂直百叶窗显示图像tryMyBitmap = (Bitmap)this.pictureBox1.Image.Clone();int dw = MyBitmap.Width / 30;int dh = MyBitmap.Height;Graphics g = this.pictureBox1.CreateGraphics();g.Clear(Color.Gray);Point MyPoint = new Point30;for (int x = 0; x 30; x+)MyPointx.Y = 0;MyPointx.X = x * dw;Bitmap bitmap = new Bitmap(MyBitmap.Width, MyBitmap.Height);for (int i = 0; i dw; i+)for (int j = 0; j 30; j+)for (int k = 0; k dh; k+)bitmap.SetPixel(MyPointj.X + i, MyPointj.Y + k,MyBitmap.GetPixel(MyPointj.X + i, MyPointj.Y + k);this.pictureBox1.Refresh();this.pictureBox1.Image = bitmap;System.Threading.Thread.Sleep(100);catch (Exception ex)MessageBox.Show(ex.Message, 信息提示);水平百叶窗private void button3_Click(object sender, EventArgs e)/水平百叶窗显示图像tryMyBitmap = (Bitmap)this.pictureBox1.Image.Clone();int dh = MyBitmap.Height / 20;int dw = MyBitmap.Width;Graphics g = this.pictureBox1.CreateGraphics();g.Clear(Color.Gray);Point MyPoint = new Point20;for (int y = 0; y 20; y+)MyPointy.X = 0;MyPointy.Y = y * dh;Bitmap bitmap = new Bitmap(MyBitmap.Width, MyBitmap.Height);for (int i = 0; i dh; i+)for (int j = 0; j 20; j+)for (int k
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 医疗机构医疗废物综合管理考核试题及答案
- 2025年药物临床试验及伦理相关知识培训试题及答案
- 2024年劳务员之劳务员基础知识模考模拟试题【附答案】
- 树的速写课件
- 重症护理知识考核试题及答案
- 临床护理技术操作常见并发症预防及处理习题(有答案)
- 2025年国家网络安全宣传周知识竞赛题库(试题及答案)
- (2025)全国安全生产月《安全知识》必刷题库及答案
- 宿舍安全知识竞赛题库(含答案)
- 2025年夏季消防安全知识竞赛试题库及答案
- 日立电梯常用零配件价格清单
- 单位人事证明(共7篇)
- 水泵设备单机试运转记录
- 保密管理-公司涉密人员保密自查表
- 日常安全检查记录
- 速成意大利语(上)
- 压型钢板组合楼板设计计算表格
- Q∕SY 1535-2012 海底管道混凝土配重层技术规范
- T∕CADERM 2002-2018 胸痛中心(基层版)建设与评估标准
- 项目评审检查清单(质量阀)
- 新建搅拌站策划方案样本21
评论
0/150
提交评论