DSP课程设计报告最终版_第1页
DSP课程设计报告最终版_第2页
DSP课程设计报告最终版_第3页
DSP课程设计报告最终版_第4页
DSP课程设计报告最终版_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

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

文档简介

郑州轻工业学院课程设计报告书题目:Reverse图像求反学院:计算机与通信工程学院专业:电子信息科学与技术姓名:学号:指导老师:一、实验目的了解数字图像处理的基本原理;学习灰度图像求反处理技术;3掌握数字图像处理在DSP上的实现。二、实验设备计算机,CCS2.0版软件,DSP仿真器,实验箱。三、实验要求.了解使用DSP实现图像求反的方法.分析图像如何输入,并存储在什么位置。.修改程序,实现图像对比度增强。四、实验设计流程图五、程序代码:1、主程序:#defineIMAGEWIDTH80#defineIMAGEHEIGHT80#defineMODEGRAYBAR0#defineMODEGRAY1#defineMODEPHOTO12#defineMODEPHOTO23#defineMODEPHOTO34#defineMODEPHOTO45voidInitImage(unsignedintnMode,unsignedchar*pImage,intnWidth,intnHeight);unsignedchardbImage[IMAGEWIDTH*IMAGEHEIGHT];unsignedchardbTargetImage[IMAGEWIDTH*IMAGEHEIGHT];/*直方图统计实验程序*/intmain()(InitImage(MODEGRAYBAR,dbImage,IMAGEWIDTH,IMAGEHEIGHT);Reverse(IMAGEWIDTH,IMAGEHEIGHT);InitImage(MODEGRAY,dbImage,IMAGEWIDTH,IMAGEHEIGHT);//BreakpointReverse(IMAGEWIDTH,IMAGEHEIGHT);InitImage(MODEPHOTO1,dbImage,IMAGEWIDTH,IMAGEHEIGHT);//BreakPointReverse(IMAGEWIDTH,IMAGEHEIGHT);InitImage(MODEPHOTO2,dbImage,IMAGEWIDTH,IMAGEHEIGHT);//BreakPointReverse(IMAGEWIDTH,IMAGEHEIGHT);InitImage(MODEPHOTO3,dbImage,IMAGEWIDTH,IMAGEHEIGHT);//BreakPointReverse(IMAGEWIDTH,IMAGEHEIGHT);InitImage(MODEPHOTO4,dbImage,IMAGEWIDTH,IMAGEHEIGHT);//BreakPointReverse(IMAGEWIDTH,IMAGEHEIGHT);while(1);}//BreakPoint2、初始化程序#include<stdio.h>#defineMODEGRAYBAR0#defineMODEGRAY1#defineMODEPHOTO12#defineMODEPHOTO23#defineMODEPHOTO34#defineMODEPHOTO45#defineMODEBLOCK6#defineMODEINCLINE7#defineMODEFPHOTO8#defineGRAYBARLEVEL16voidReadImage(unsignedchar*pImage,char*cFileName,intnWidth,intnHeight);voidInitImage(unsignedintnMode,unsignedchar*pImage,intnWidth,intnHeight)(intx,y,nWork,nWork1;unsignedchar*pWork;intnPointx二nWidth/2;intnPointy二nHeight/2;floatfWork;switch(nMode)(caseMODEGRAYBAR:pWork二pImage;nWork=256/GRAYBARLEVEL;nWork1二nHeight/GRAYBARLEVEL;for(y=0;y<nHeight;y++)(for(x=0;x<nWidth;x++,pWork++)((*pWork)=(y/nWork1)*nWork;}}break;//里面的灰度caseMODEGRAY:pWork二pImage;nWork1二nHeight-nPointy;nWork二nWork1*nWork1;//(40,40)nWork1二nWidth-nPointx;nWork+=(nWork1*nWork1);//(40,3200)nWork/=256;//12for(y=0;y<nHeight;y++)(for(x=0;x<nWidth;x++,pWork++)(nWork1=(x-nPointx)*(x-nPointx)+(y-nPointy)*(y-nPointy);nWork1=255-nWork1/nWork;//0到255之间的一个灰度的园,以圆象中心为圆心,255-nwork1/nwork为中心if(nWork1<0)nWork1=0;elseif(nWork1>255)nWork1=255;(*pWork)=nWork1;//pWork=pImage;}}break;caseMODEPHOTO1:ReadImage(pImage,〃..\\DSP.bmp〃,nWidth,nHeight);break;caseMODEPHOTO2:ReadImage(pImage,〃..\\1.bmp〃,nWidth,nHeight);break;caseMODEPHOTO3:ReadImage(pImage,〃..\\2.bmp〃,nWidth,nHeight);break;caseMODEPHOTO4:ReadImage(pImage,〃..\\3.bmp〃,nWidth,nHeight);break;caseMODEBLOCK:pWork=pImage;for(y=0;y<nHeight;y++)for(x=0;x<nWidth;x++,pWork++)(*pWork)=0;//全黑pWork=pImage+(nHeight/4-1)*nWidth;for(y=nHeight/4;y<nHeight*3/4;y++,pWork+=nWidth)//20,60for(x=nWidth/4;x<nWidth*3/4;x++)//20,60pWork[x]=255;break;//白框caseMODEINCLINE:pWork二pImage;for(y=0;y<nHeight;y++)for(x=0;x<nWidth;x++,pWork++)(*pWork)=0;//全黑pWork二pImage;fWork二nWidth/nHeight;for(y=0;y<nHeight/4;y++)for(x=nWidth/2-fWork*y;x<nWidth/2+fWork*y;x++)(pWork[(y+nHeight/4)*nWidth+x]=255;//1719pWork[(nHeight*3/4-y-1)*nWidth+x]=255;}break;//菱形caseMODEFPHOTO:ReadImage(pImage,〃..\\fourier.bmp〃,nWidth,nHeight);break;default:break;}}voidReadImage(unsignedchar*pImage,char*cFileName,intnWidth,intnHeight)(intj;unsignedchar*pWork;FILE*fp;if(fp=fopen(cFileName,"rb"))//读取一二进制文件(fseek(fp,1078L,SEEK_SET);//,从文件开头执行,将指针移到1078位pWork=pImage+(nHeight-1)*nWidth;//p指向image最后一彳亍for(j=0;j<nHeight;j++,pWork-二nWidth)fread(pWork,nWidth,1,fp);fclose(fp);}}3、Reverse#include<stdio.h>#defineMODEGRAYBAR0#defineMODEGRAY1#defineMODEPHOTO12#defineMODEPHOTO23#defineMODEPHOTO34#defineMODEPHOTO45#defineMODEBLOCK6#defineMODEINCLINE7#defineMODEFPHOTO8#defineGRAYBARLEVEL16voidReadImage(unsignedchar*pImage,char*cFileName,intnWidth,intnHeight);voidInitImage(unsignedintnMode,unsignedchar*pImage,intnWidth,intnHeight)(intx,y,nWork,nWork1;unsignedchar*pWork;intnPointx二nWidth/2;intnPointy二nHeight/2;floatfWork;switch(nMode)(caseMODEGRAYBAR:pWork二pImage;nWork=256/GRAYBARLEVEL;nWorkl二nHeight/GRAYBARLEVEL;for(y=0;y<nHeight;y++)(for(x=0;x<nWidth;x++,pWork++)((*pWork)=(y/nWork1)*nWork;}}break;//里面的灰度caseMODEGRAY:pWork=pImage;nWorkl二nHeight-nPointy;nWork二nWork1*nWork1;//(40,40)nWorkl二nWidth-nPointx;nWork+=(nWork1*nWork1);//(40,3200)nWork/=256;//12for(y=0;y<nHeight;y++)(for(x=0;x<nWidth;x++,pWork++)(nWork1=(x-nPointx)*(x-nPointx)+(y-nPointy)*(y-nPointy);nWork1=255-nWork1/nWork;//0到255之间的一个灰度的园,以圆象中心为圆心,255-nwork1/nwork为中心if(nWork1<0)nWork1=0;elseif(nWork1>255)nWork1=255;(*pWork)=nWork1;//pWork=pImage;}break;caseMODEPHOTO1:ReadImage(pImage,〃..\\DSP.bmp〃,nWidth,nHeight);break;caseMODEPHOTO2:ReadImage(pImage,〃..\\1.bmp〃,nWidth,nHeight);break;caseMODEPHOTO3:ReadImage(pImage,〃..\\2.bmp〃,nWidth,nHeight);break;caseMODEPHOTO4:ReadImage(pImage,〃..\\3.bmp〃,nWidth,nHeight);break;caseMODEBLOCK:pWork二pImage;for(y=0;y<nHeight;y++)for(x=0;x<nWidth;x++,pWork++)(*pWork)=0;//全黑pWork二pImage+(nHeight/4-1)*nWidth;for(y=nHeight/4;y<nHeight*3/4;y++,pWork+=nWidth)//20,60for(x=nWidth/4;x<nWidth*3/4;x++)//20,60pWork[x]=255;break;//白框caseMODEINCLINE:pWork=pImage;for(y=0;y<nHeight;y++)for(x=0;x<nWidth;x++,pWork++)(*pWork)=0;//全黑pWork=pImage;fWork二nWidth/nHeight;for(y=0;y<nHeight/4;y++)for(x=nWidth/2-fWork*y;x<nWidth/2+fWork*y;x++)(pWork[(y+nHeight/4)*nWidth+x]=255;//1719pWork[(nHeight*3/4-y-1)*nWidth+x]=255;}break;//菱形caseMODEFPHOTO:ReadImage(pImage,〃..\\fourier.bmp〃,nWidth,nHeight);break;default:break;}}voidReadImage(unsignedchar*pImage,char*cFileName,intnWidth,intnHeight)(intj;unsignedchar*pWork;FILE*fp;if(fp二fopen(cFileName,〃rb"))//读取一二进制文件(fseek(fp,1078L,SEEK_SET);//,从文件开头执行,将指针移到1078位pWork=pImage+(nHeight-1)*nWidth;//p指向image最后一彳亍for(j=0;j<nHeight;j++,pWork-二nWidth)fread(pWork,nWidth,1,fp);fclose(fp);}}六、实验现象

▼DebugInitlmage(MODEPHOTO3,dbIma3e,IMAiReverse1:IMAGEWIDIH,IMAGEHEIGHT);Imtlmage(MODEPHOTO4,dbIma3e,IMAiReverse(IMAGEWIDTH,IMAGEHEIGHT);Initlmage(MODEPHOTO2,dblmaige,IMAiReverse(IMAGEWIDIH,IMAGEHEIGHT);Initlmage(MODEPHOTOl,dblmage,IMAiReverse(IMAGEWIDTH,IMAGEHEIGHT);Initlmage(MODEGRAYBAR,dbImage,IKReverse(IMAGEWIDIH,IMAGEHEIGHT);Initlmage(MODEGRAY,dblinage,IMAGE'Reverse(IMAGEWIDTH,IMAGEHEIGHT);■■…Include|ZZ|Librari□,■■€3Source:ti]Imag闵Initlmage.c闵ReverstVC5509.CMDImage.pjt-DebugGELfil成-日PreBI»age.pjt(Debu;IDependentProj«'IDocumenteQDSP/BIOSConfig■…uGeneratedFiles■--*直方图统计实验程序intmain()修改程序,实现图像对比度增强#defineIMAGEWIDTH80#defineIMAGEHEIGHT80externunsignedchardbImage[IMAGEWIDTH*IMAGEHEIGHT];externunsignedchardbTargetImage[IMAGEWIDTH*IMAGEHEIGHT];intmi,mj;unsignedintm_nWork;unsignedchar*pImg,*pImg1;voidReverse(intnWidth,intnHeight)(for(mi=0;mi<nWidth;mi++,pImg++,pImg1++)if((*pImg)<30)(*pImg1)=(unsignedchar)((*pImg)*0.5);elseif((*pImg)<225)(*pImg1)=(unsignedchar)(1.15*((*pImg))-19);else(*pImg1

温馨提示

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

评论

0/150

提交评论