图形图像处理课程设计报告.doc

上传人:laozhun 文档编号:2391558 上传时间:2023-02-17 格式:DOC 页数:10 大小:484KB
返回 下载 相关 举报
图形图像处理课程设计报告.doc_第1页
第1页 / 共10页
图形图像处理课程设计报告.doc_第2页
第2页 / 共10页
图形图像处理课程设计报告.doc_第3页
第3页 / 共10页
图形图像处理课程设计报告.doc_第4页
第4页 / 共10页
图形图像处理课程设计报告.doc_第5页
第5页 / 共10页
点击查看更多>>
资源描述

《图形图像处理课程设计报告.doc》由会员分享,可在线阅读,更多相关《图形图像处理课程设计报告.doc(10页珍藏版)》请在三一办公上搜索。

1、 Abstract Sketch picture processing has a very close contact with modernization life , so as the technology and research . As the sketch picture processing techniques fast development , peoples life are subjected to very big of influence. In the course design ,I have mainly practiced the basic opera

2、tion sketch picture processing , which contains ash degree square diagram ,the Rui turn of pictures and smooth etc. According to these principle of the picture processing , including the ash degree of picture , and the picture strengthen filter etc., I use the C# language realized the picture proces

3、sing operation. Key Word: Sketch picture processing,ash degree square diagram,Rui turn,smooth 摘 要 图形图像处理是和现代化生活紧密联系不可分的,还有对科研方面等都有很大的贡献。今年来随着图形图像处理技术的快速发展,人们的生活都受到了很大的影响。 在这次课程设计中,我主要练习了图像处理基本的操作,包括图像的灰度直方图,图像的锐化以及平滑等等。根据这些图像处理的原理,包括图像的灰度,图像增强滤波器等等,用C#语言实现了上述的图像处理操作。 关键词:图形图像处理,直方图,锐化,平滑图形图像处理课程设计报告

4、一. 实验要求(1). 读入一幅图像,要求统计各像素点灰度值并显示该图的灰度直方图(2). 读入一幅图像,要求输出该图锐化后的图像(3). 读入一幅图像,要求显示该图平滑后的图像二. 实验设计1.实验中的程序界面如下 Form1 Form2 2.图像处理设计 (1). 灰度直方图对一幅图所有像素点具有的不同灰度值进行统计并显示出来,给出了一股图的所有灰度值的整体描述。实验中,若以i表示某个灰度值,则有0=i=256,以pixi表示灰度为i的像素点的个数,当画直方图的命令由form1传递到form2时,即采用GDI+画出该直方图 (2). 锐化滤波器是图像增强滤波器中的一种,它能减弱或消除傅里叶

5、空间的低频分量,但不影响高频分量(从视觉效果上来看,就是突出有关形体的边缘)。实验中采用线性锐化滤波器,系数模板取拉普拉斯算子: (3). 平滑滤波器是图像增强滤波器中的另一种,它能减弱或消除傅里叶空间中的高频分量,但不影响高频分量(从视觉效果上来看,就是把图像给柔化了)。实验中采用线性的平滑滤波器,系数模板取高斯算子:三. 具体实现1. 程序中定义的全局参数有:From1: public int height, width; public int pix = new int256;Form2 : public int hei, wid; public int pie2.传参:既然涉及到两个窗

6、体,就必然要在两个窗体之间传递参数,当某副图片的像素与灰度信息已经采集好时,就将灰度值数组传递到Form2中,接着用图形设备接口函数画出灰度直方图/Form1中的代码private void button1_Click(object sender, EventArgs e) Form2 fm = new Form2(this); fm.Show();/Form2中的代码public Form2(Form1 fm) InitializeComponent(); hei = fm.height; wid = fm.width; pie = fm.pix;3.图像灰度直方图显示 先在Form1中定义

7、函数统计读入的图像的像素点灰度信息,然后调用Form2窗体进行绘图,代码如下:/Form1中的代码 height = this.pictureBox1.Image.Height; width = this.pictureBox1.Image.Width; Bitmap bitmap = (Bitmap)this.pictureBox1.Image; Color pixel; int r = 0, b = 0, g = 0; for (int i = 0; i 256; i+) pixi = 0; for (int i = 1; i width; i+) for (int j = 1; j he

8、ight; j+) pixel = bitmap.GetPixel(i, j); r = pixel.R; g = pixel.G; b = pixel.B; int a = (int)(r + b + g) / 3; pixa+; /统计灰度值为a的像素点数目 /Form2中的代码Bitmap image = new Bitmap(300, 300); Graphics g = Graphics.FromImage(image); g.Clear(Color.White); Font font = new Font(宋体, 10, FontStyle.Bold); Brush brush =

9、 Brushes.Blue; g.DrawString(灰度直方图, font, brush, new Point(15, 10); Pen mypen = new Pen(brush, 1); /绘制X轴; g.DrawLine(mypen, 10, 260, 280, 260); g.DrawLine(mypen, 276, 258, 280, 260); g.DrawLine(mypen, 276, 262, 280, 260); /绘制Y轴; g.DrawLine(mypen, 10, 10, 10, 260); g.DrawLine(mypen, 8, 16, 10, 10); g.

10、DrawLine(mypen, 12, 16, 10, 10); for (int i = 0; i 256; i+) g.DrawLine(mypen, 10 + i, 260, 10 + i, 260 - (int)(7000 * piei / (hei * wid); if (i % 50 = 0) g.DrawString(i.ToString(), new Font(正楷, 8, FontStyle.Regular), brush, new Point(10 + i, 262); this.pictureBox1.Image = image;4.图像锐化处理 如实验设计所描述的,采用

11、拉普拉斯算子对原图像进行锐化,程序如下:int 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

12、- 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, b, g); this.pictureBox2.Ima

13、ge = newBitmap;5.图像平滑处理如实验设计所描述的,采用高斯算子对原图像进行锐化,程序如下:int 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 Gauss = 1, 2, 1, 2, 4, 2, 1, 2, 1 ; /高斯算子 for (

14、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, b, g); t

15、his.pictureBox2.Image = newBitmap;6.变换后图像灰度直方图显示 这个模块同第三个模块差不多,只是读取图像的对象不同:height = this.pictureBox2.Image.Height; width = this.pictureBox2.Image.Width; Bitmap bitmap = (Bitmap)this.pictureBox2.Image;四. 实验结果1.实验中采用的图像如下所示: 2.原图直方图显示 3.锐化后的图像显示 4.锐化后的图像灰度直方图显示: 5.平滑后的图像显示: 6.平滑后图像灰度直方图显示: 五. 实验总结因为对C+语言的不熟悉,这次实验我是基于C#语言完成的,所以从效果上来说比不上用C+与语言做出的图像效果 。 在图形图像处理课程设计中,我学到了不少的东西,并且做出这些之后感觉很兴奋,比较有趣味性,突然发现对这方面比较感兴趣了。不过鉴于自己对于图像处理方面了解的知识还很少,以后会慢慢加强学习的。 谢谢童老师在这次课程设计中的指导!六. 参考资料 1.明日科技,图形图像技术,C#开发经验技巧宝典,2008年4月,320-322.

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 建筑/施工/环境 > 项目建议


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号