![西安交通大学大学数字图像处理大作业_第1页](http://file2.renrendoc.com/fileroot_temp3/2021-10/26/b93e8941-6f4d-4d0c-8bc9-db2d096be2a8/b93e8941-6f4d-4d0c-8bc9-db2d096be2a81.gif)
![西安交通大学大学数字图像处理大作业_第2页](http://file2.renrendoc.com/fileroot_temp3/2021-10/26/b93e8941-6f4d-4d0c-8bc9-db2d096be2a8/b93e8941-6f4d-4d0c-8bc9-db2d096be2a82.gif)
![西安交通大学大学数字图像处理大作业_第3页](http://file2.renrendoc.com/fileroot_temp3/2021-10/26/b93e8941-6f4d-4d0c-8bc9-db2d096be2a8/b93e8941-6f4d-4d0c-8bc9-db2d096be2a83.gif)
![西安交通大学大学数字图像处理大作业_第4页](http://file2.renrendoc.com/fileroot_temp3/2021-10/26/b93e8941-6f4d-4d0c-8bc9-db2d096be2a8/b93e8941-6f4d-4d0c-8bc9-db2d096be2a84.gif)
![西安交通大学大学数字图像处理大作业_第5页](http://file2.renrendoc.com/fileroot_temp3/2021-10/26/b93e8941-6f4d-4d0c-8bc9-db2d096be2a8/b93e8941-6f4d-4d0c-8bc9-db2d096be2a85.gif)
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、数字图像处理目录作业一1一 作业要求1二 源代码1三 运行结果3作业二5一 作业要求5二 算法描述5三 源代码7四 运行结果10作业一一 作业要求在图像的空间域滤波操作中,会出现有部分掩膜矩阵在图像外面的情况,所以需要给图像先加入一个边界,执行完操作之后,再去掉这个边界,保证图像中所有的像素都参与矩阵运算。二 源代码byte, filter(byte,f,float,mask) int w = f.GetLength(0); int h = f.GetLength(1); byte, g = new bytew,h; int M = mask.GetLength(0)/2; int N = m
2、ask.GetLength(1)/2; for (int y=N;yh-N;y+) for (int x=M;xw-M;x+) float s = 0; for (int m=-M;m=M;m+) for (int n=-N;n255) return 255; if (v0) return 0; return (byte)v; float, averagingMask(int M,int N) float, mask = new float2*M+1,2*N+1; for (int m=-M;m=M;m+) for (int n=-N;n=N;n+) maskM+m,N+n = 1.0f/(2
3、*M+1)*(2*N+1); return mask;byte, addboard(byte, f,int M,int N)int w=f.GetLength(0);int h=f.GetLength(1);int gw=w+2*M;int gh=h+2*N;byte, g=new bytegw,gh;/add top board and bottom boardfor(int i=0;iN;i+)for(int j=0;jw;j+)gM+j,i=fj,0;for(int i=0;iN;i+)for(int j=0;jw;j+)gM+j,i+h+N=fj,h-1;/copy the image
4、for(int i=0;iw;i+)for (int j=0;jh;j+)gi+M,j+N=fi,j;/add left and right boardfor(int i=0;iM;i+)for (int j=0;jgh;j+)gi,j=gM,j;for(int i=0;iM;i+)for (int j=0;jgh;j+)gw+M+i,j=ggw-1-M,j;return g;byte, removeboard(byte,f,int M,int N)int w=f.GetLength(0);int h=f.GetLength(1);int gw=w-2*M;int gh=h-2*N;byte,
5、 g=new bytegw,gh;for(int i=0;igw;i+)for(int j=0;jgh;j+)gi,j=fi+M,j+N;return g;void main()byte, f = LoadImg();ShowImg(f,f);int w=f.GetLength(0);int h=f.GetLength(1);int M=10,N=20;int gw=w-2*M;int gh=h-2*N;byte, boardimage=new bytegw,gh;byte, filterimage=new bytegw,gh;boardimage=addboard(f,M,N);ShowIm
6、g(boardimage,boardimage);filterimage=filter(boardimage,averagingMask(M,N);ShowImg(result,removeboard(filterimage,M,N);三 运行结果原图像:加边界之后的图像:均值滤波并且去除边界的图像:作业二一 作业要求给定图像与处理结果,如图一所示,思考算法并编程实现。图一 左边为原图,右边为处理结果二 算法描述Compare the result and the original image, we can see that the program change the contrast o
7、f image and enhance the edge of Lena. Consider using intensity transform and Sobel edge detection to achieve the goal. After many experiments, I choose following intensity transform function.The graph of this function is Fig 1.Fig 1 Graph of intensity transform function Use Sobel to detect the edge
8、of the original image.Sobel in x direction can be written as the following transform matrix:SobleX= Similar, Sobel in y direction can be written as the following transform matrix:SobleY= We can use SobelX and SobelY to compute the gradient image. is the value of pixels in the gradient image, is the
9、value of pixels in image processed by SobelX, and is the value of pixels in image processed by SobelY. In order to decrease noise, I use the following function to process gradient image:After processing, I use 0 to replace these negative values.Because the gradient image has a very high contrast, so
10、 I use intensity transform again. After that, the final result can be calculated: All the function is chosen through experiment, maybe the result isnt the same with the teachers result, but its very similar.三 源代码byte, filter(byte,f,float,mask) int w = f.GetLength(0); int h = f.GetLength(1); int M =
11、mask.GetLength(0)/2; int N = mask.GetLength(1)/2; byte, g = new bytew,h; for (int y=N;yh-N;y+) for (int x=M;xw-M;x+) float r = 0;for (int m=-M;m=M;m+)for (int n=-N;n255) return 255; if(f0) return 0; return (byte)f;byte, Scale(byte,f,double a)int w = f.GetLength(0); int h = f.GetLength(1);for(int i=0
12、;iw;i+)for(int j=0;jh;j+)fi,j=(byte)(fi,j*a);return f;byte, Subnum(byte,f,int a)int w = f.GetLength(0); int h = f.GetLength(1);for(int i=0;iw;i+)for(int j=0;jh;j+)fi,j=S(fi,j-a);return f;byte, Sub(byte,f,byte,g) int w = f.GetLength(0); int h = f.GetLength(1); byte, p = new bytew,h; for(int x=0;xw;x+
13、) for(int y=0;yh;y+) px,y=S(fx,y-gx,y); return p; byte, Mix(byte,fx,byte,fy) int w = fx.GetLength(0); int h = fx.GetLength(1); byte, g = new bytew,h; for (int y=0;yh;y+) for (int x=0;xw;x+) float px =(fxx,y); float py =(fyx,y); gx,y = S(Sqrt(px*px+py*py); return g; byte, IntensityTransform(byte,f) i
14、nt w = f.GetLength(0); int h = f.GetLength(1); byte, g = new bytew,h; for(int i=0;iw;i+) for(int j=0;jh;j+) gi,j = S(0.25*fi,j+110); return g;void main() byte , I = LoadImg(); ShowImg(Original,I); byte , I1 = IntensityTransform(I); ShowImg(IntensityTransform,I1); byte , I2 = SobelX(I); byte , I3 = SobelY(I); byte , I4 = Mix(I2,I3); ShowImg(Gradient,I
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 电子商务战略合作框架协议
- 电商托盘采购合同
- 企业文化建设与员工活动策划方案书
- 在厂员工免责协议书
- 建筑安装工程承包合同
- 工程项目合作协议书人
- 办公大楼物业服务合同
- 医疗器械产品分销代理合同
- 小学二年级机械结构课程教学设计 29独轮车走钢管
- 第21课 世界殖民体系的瓦解与新兴国家的发展 教学设计-2023-2024学年高中历史统编版(2019)必修中外历史纲要下册
- 小肠系膜肿瘤的CT表现 及其鉴别诊断课件3
- 幕墙工程项目管理手册施工管理标准化手册
- 环境保护与水土保持措施
- 变电站一次系统图
- 《思想道德修养与法律基础》说课(获奖版)课件
- 网页设计和制作说课稿市公开课金奖市赛课一等奖课件
- 《新媒体营销》新媒体营销与运营
- 食用油营销整合规划(含文字方案)
- 苏教版科学五年级下15《升旗的方法》教案
- 现代工业发酵调控绪论
- 超高性能混凝土项目立项申请(参考模板)
评论
0/150
提交评论