图形图像处理课程设计报告_第1页
图形图像处理课程设计报告_第2页
图形图像处理课程设计报告_第3页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

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); this.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.平

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论