已阅读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年呼伦贝尔阿荣旗市教师招聘笔试参考试题及答案解析
- 护理措施:甲亢危重病情突发处理及全面护理指导
- 2025年南京市建邺区中小学教师招聘笔试备考试题及答案解析
- 2025年郑州市上街区中小学教师招聘笔试备考试题及答案解析
- 2025年当涂县中小学教师招聘笔试参考题库及答案解析
- (新版)广东省地基与基桩承载力检测(静载荷试验)技术培训考核考试(重点)题库300题(含答案)
- 卫生院奖励与处罚
- 浙江省乐清市第二中学2026届数学高一上期末检测模拟试题含解析
- 上海市鲁迅中学2025-2026学年数学高一上期末教学质量检测试题含解析
- 上海市黄浦区格致中学2025年高一数学第一学期期末经典模拟试题含解析
- 2025-2026学年统编版三年级语文上册第六单元素养提优卷(含答案)
- 门窗安装施工资源配置方案
- 2025年内蒙古机电职业技术学院单招职业技能考试题库含答案
- GB/T 14748-2025儿童呵护用品安全儿童推车
- 2025年商用净水器行业分析报告及未来发展趋势预测
- 高分子化学期末考试试卷及答案
- DB1509∕T 0004-2023 东佛里生羊饲养管理技术规程
- (2)文学类文本阅读(小说)【课件篇】-2026届高考语文一轮复习讲学练全攻略
- 三年级上册口算练习题200道
- 造价咨询沟通和协调方案(3篇)
- 宝安区集体物业招商招租管理办法(征求意见稿)
评论
0/150
提交评论