多媒体信息技术课程设计报告.docx

上传人:b****5 文档编号:6196624 上传时间:2023-01-04 格式:DOCX 页数:22 大小:1.68MB
下载 相关 举报
多媒体信息技术课程设计报告.docx_第1页
第1页 / 共22页
多媒体信息技术课程设计报告.docx_第2页
第2页 / 共22页
多媒体信息技术课程设计报告.docx_第3页
第3页 / 共22页
多媒体信息技术课程设计报告.docx_第4页
第4页 / 共22页
多媒体信息技术课程设计报告.docx_第5页
第5页 / 共22页
点击查看更多>>
下载资源
资源描述

多媒体信息技术课程设计报告.docx

《多媒体信息技术课程设计报告.docx》由会员分享,可在线阅读,更多相关《多媒体信息技术课程设计报告.docx(22页珍藏版)》请在冰豆网上搜索。

多媒体信息技术课程设计报告.docx

多媒体信息技术课程设计报告

南京工程学院

课程设计报告书

 

课程名称多媒体信息技术

院(系、部、中心)

班级

学号

姓名

起止日期

指导教师

 

目录

一.课程设计目的…………………………………………3

二.课程设计题目及要求…………………………………3

三.概述……………………………………………………3

四.运行结果………………………………………………4

五.课程设计总结…………………………………………5

六.源程序代码……………………………………………6

七.参考文献………………………………………………18

一、课程设计目的

本次课程设计的目的是通过课程设计,达到理论与实际应用相结合,提高学生对多媒体信息的各种处理方法的理解和编写大型程序的能力,使学生能够根据处理的信息的特征,掌握数字图像处理、数字视频编码和数字音频编码的算法设计基本方法,并培养良好的程序设计能力。

二、课程设计题目及要求

图像滤波去噪和滤波增强

分别使用下面两个均值空域滤波模板对“电路板图.bmp”进行滤波,并输出滤波结果。

 

使用3X3中值滤波器对“带有噪声的电路板图.bmp”进行去噪滤波,并输出滤波结果。

使用下图复合拉普拉斯掩模和Sobel算子对“月球.bmp”进行空域滤波增强,并输出增强结果。

 

三、概述

1、均值滤波:

均值滤波时典型的线性滤波算法,它是指在图像上对目标像素给一个模板,该模板包括了其周围的临近像素(以目标像素为中心的周围8个像素,构成一个滤波模板,即去掉目标像素本身)再用模板中的全体像素的平均值来代替原来像素值。

2、中值滤波;

中值滤波器是一种非线性平滑技术,它将每一点像素的灰度值设置为该点某邻域窗口内的所有像素点灰度值的中值;

方法:

通过从图像中的某个采样窗口取出奇数个数据进行排序,用排序后的中值取代要处理的数据。

3、复合拉普拉斯掩模:

从模板形式容易看出,如果在图像中一个较暗的区域中出现了一个亮点,那么用拉普拉斯运算就会使这个亮点变得更亮,因为图像中的边缘就是那些灰度发生跳变的区域,所以拉普拉斯锐化模板在边缘检测中很有用。

4、Sobel算子:

主要用于作边缘检测,Sobel算子对于像素的位置影响做了加权,可以降低边缘模糊程度。

 

四、运行结果

原图:

结果图:

五、课程设计总结

这次通过c语言编写程序对图像进行滤波,去噪滤波、空域增强,了解了图像处理的原理和过程。

其中,均值滤波本身存在着固有的缺陷,即它不能很好地保护图像细节,在图像去噪的同时也破坏了图像的细节部分,从而使图像变得模糊,不能很好地去除噪声点;

中值滤波对消除椒盐噪声非常有效,在图像处理中,常用于保护边缘信息,是经典的平滑噪声的方法;

拉普拉斯是一种微分算子,它的应用可增强图像中灰度突变的区域,减弱灰度的缓慢变化区域

Sobel算子则用于边缘检测。

通过努力顺利完成了这次课程设计,学会了用c语言进行图像处理,在过程中遇到问题再解决使我成长了不少,收获了很多。

 

六、源程序代码

//BMPRW.H

#ifndefBMPRW_H

#defineBMPRW_H

typedefstruct

{

unsignedlongbfSize;

unsignedshortbfReserved1;

unsignedshortbfReserved2;

unsignedlongbfOffBits;

}ClBitMapFileHeader;

typedefstruct

{

unsignedlongbiSize;

longbiWidth;

longbiHeight;

unsignedshortbiPlanes;

unsignedshortbiBitCount;

unsignedlongbiCompression;

unsignedlongbiSizeImage;

longbiXPelsPerMeter;

longbiYPelsPerMeter;

unsignedlongbiClrUsed;

unsignedlongbiClrImportant;

}ClBitMapInfoHeader;

typedefstruct

{

unsignedcharrgbBlue;

unsignedcharrgbGreen;

unsignedcharrgbRed;

unsignedcharrgbReserved;

}ClRgbQuad;

typedefstruct

{

intwidth;

intheight;

intchannels;

unsignedchar*imageData;

}ClImage;

ClImage*clLoadImage(char*path);

boolclSaveImage(char*path,ClImage*bmpImg);

#endif

//pretreatment.cpp

#include

intmain()

{

longbmpwidth,bmpheight;

FILE*fp;

fp=fopen("FIVEANGL.bmp","rb");

fseek(fp,18L,SEEK_SET);

fread(&bmpwidth,4,1,fp);

fread(&bmpheight,4,1,fp);

fclose(fp);

printf("\n%swidthis%ld,heightis%ld","FIVEANGL.bmp",bmpwidth,bmpheight);

getchar();

return0;

}

//multimedia.cpp

#include

#include

#include"BMPRW.h"

ClImage*clLoadImage(char*path)

{

ClImage*bmpImg;

FILE*pFile;

unsignedshortfileType;

ClBitMapFileHeaderbmpFileHeader;

ClBitMapInfoHeaderbmpInfoHeader;

intchannels=1;

intwidth=0;

intheight=0;

intstep=0;

intoffset=0;

unsignedcharpixVal;

ClRgbQuad*quad;

inti,j,k;

bmpImg=(ClImage*)malloc(sizeof(ClImage));

pFile=fopen(path,"rb");

if(!

pFile)

{

free(bmpImg);

returnNULL;

}

fread(&fileType,sizeof(unsignedshort),1,pFile);

if(fileType==0x4D42)

{

fread(&bmpFileHeader,sizeof(ClBitMapFileHeader),1,pFile);

fread(&bmpInfoHeader,sizeof(ClBitMapInfoHeader),1,pFile);

if(bmpInfoHeader.biBitCount==8)

{

printf("该文件有调色板,即该位图为非真彩色\n\n");

channels=1;

width=bmpInfoHeader.biWidth;

height=bmpInfoHeader.biHeight;

offset=(channels*width)%4;

if(offset!

=0)

{

offset=4-offset;

}

bmpImg->width=width;

bmpImg->height=height;

bmpImg->channels=1;

bmpImg->imageData=(unsignedchar*)malloc(sizeof(unsignedchar)*width*height);

step=channels*width;

quad=(ClRgbQuad*)malloc(sizeof(ClRgbQuad)*256);

fread(quad,sizeof(ClRgbQuad),256,pFile);

free(quad);

for(i=0;i

{

for(j=0;j

{

fread(&pixVal,sizeof(unsignedchar),1,pFile);

bmpImg->imageData[(height-1-i)*step+j]=pixVal;

}

if(offset!

=0)

{

for(j=0;j

{

fread(&pixVal,sizeof(unsignedchar),1,pFile);

}

}

}

}

elseif(bmpInfoHeader.biBitCount==24)

{

printf("该位图为真彩色\n\n");

channels=3;

width=bmpInfoHeader.biWidth;

height=bmpInfoHeader.biHeight;

bmpImg->width=width;

bmpImg->height=height;

bmpImg->channels=3;

bmpImg->imageData=(unsignedchar*)malloc(sizeof(unsignedchar)*width*3*height);

step=channels*width;

offset=(channels*width)%4;

if(offset!

=0)

{

offset=4-offset;

}

for(i=0;i

{

for(j=0;j

{

for(k=0;k<3;k++)

{

fread(&pixVal,sizeof(unsignedchar),1,pFile);

bmpImg->imageData[(height-1-i)*step+j*3+k]=pixVal;

}

}

if(offset!

=0)

{

for(j=0;j

{

fread(&pixVal,sizeof(unsignedchar),1,pFile);

}

}

}

}

}

returnbmpImg;

}

boolclSaveImage(char*path,ClImage*bmpImg)

{

FILE*pFile;

unsignedshortfileType;

ClBitMapFileHeaderbmpFileHeader;

ClBitMapInfoHeaderbmpInfoHeader;

intstep;

intoffset;

unsignedcharpixVal='\0';

inti,j;

ClRgbQuad*quad;

pFile=fopen(path,"wb");

if(!

pFile)

{

returnfalse;

}

fileType=0x4D42;

fwrite(&fileType,sizeof(unsignedshort),1,pFile);

if(bmpImg->channels==3)

{

step=bmpImg->channels*bmpImg->width;

offset=step%4;

if(offset!

=4)

{

step+=4-offset;

}

bmpFileHeader.bfSize=bmpImg->height*step+54;

bmpFileHeader.bfReserved1=0;

bmpFileHeader.bfReserved2=0;

bmpFileHeader.bfOffBits=54;

fwrite(&bmpFileHeader,sizeof(ClBitMapFileHeader),1,pFile);

bmpInfoHeader.biSize=40;

bmpInfoHeader.biWidth=bmpImg->width;

bmpInfoHeader.biHeight=bmpImg->height;

bmpInfoHeader.biPlanes=1;

bmpInfoHeader.biBitCount=24;

bmpInfoHeader.biCompression=0;

bmpInfoHeader.biSizeImage=bmpImg->height*step;

bmpInfoHeader.biXPelsPerMeter=0;

bmpInfoHeader.biYPelsPerMeter=0;

bmpInfoHeader.biClrUsed=0;

bmpInfoHeader.biClrImportant=0;

fwrite(&bmpInfoHeader,sizeof(ClBitMapInfoHeader),1,pFile);

for(i=bmpImg->height-1;i>-1;i--)

{

for(j=0;jwidth;j++)

{

pixVal=bmpImg->imageData[i*bmpImg->width*3+j*3];

fwrite(&pixVal,sizeof(unsignedchar),1,pFile);

pixVal=bmpImg->imageData[i*bmpImg->width*3+j*3+1];

fwrite(&pixVal,sizeof(unsignedchar),1,pFile);

pixVal=bmpImg->imageData[i*bmpImg->width*3+j*3+2];

fwrite(&pixVal,sizeof(unsignedchar),1,pFile);

}

if(offset!

=0)

{

for(j=0;j

{

pixVal=0;

fwrite(&pixVal,sizeof(unsignedchar),1,pFile);

}

}

}

}

elseif(bmpImg->channels==1)

{

step=bmpImg->width;

offset=step%4;

if(offset!

=4)

{

step+=4-offset;

}

bmpFileHeader.bfSize=54+256*4+bmpImg->width;

bmpFileHeader.bfReserved1=0;

bmpFileHeader.bfReserved2=0;

bmpFileHeader.bfOffBits=54+256*4;

fwrite(&bmpFileHeader,sizeof(ClBitMapFileHeader),1,pFile);

bmpInfoHeader.biSize=40;

bmpInfoHeader.biWidth=bmpImg->width;

bmpInfoHeader.biHeight=bmpImg->height;

bmpInfoHeader.biPlanes=1;

bmpInfoHeader.biBitCount=8;

bmpInfoHeader.biCompression=0;

bmpInfoHeader.biSizeImage=bmpImg->height*step;

bmpInfoHeader.biXPelsPerMeter=0;

bmpInfoHeader.biYPelsPerMeter=0;

bmpInfoHeader.biClrUsed=256;

bmpInfoHeader.biClrImportant=256;

fwrite(&bmpInfoHeader,sizeof(ClBitMapInfoHeader),1,pFile);

quad=(ClRgbQuad*)malloc(sizeof(ClRgbQuad)*256);

for(i=0;i<256;i++)

{

quad[i].rgbBlue=i;

quad[i].rgbGreen=i;

quad[i].rgbRed=i;

quad[i].rgbReserved=0;

}

fwrite(quad,sizeof(ClRgbQuad),256,pFile);

free(quad);

for(i=bmpImg->height-1;i>-1;i--)

{

for(j=0;jwidth;j++)

{

pixVal=bmpImg->imageData[i*bmpImg->width+j];

fwrite(&pixVal,sizeof(unsignedchar),1,pFile);

}

if(offset!

=0)

{

for(j=0;j

{

pixVal=0;

fwrite(&pixVal,sizeof(unsignedchar),1,pFile);

}

}

}

}

fclose(pFile);

returntrue;

}

voidJunzhi(ClImage*img,inth,intw)

{

inti,j,k;

inta[500][500]={0};

for(i=0;i

{

for(j=0;j

{

a[i][j]=img->imageData[i*w*3+j*3];

}

}

for(i=1;i

{

for(j=1;j

{

for(k=0;k<3;k++)

{

img->imageData[(i+k)*w*3+j*3+k]=(a[i-1][j-1]+a[i-1][j]+a[i-1][j+1]+a[i][j-1]+a[i][j]+a[i][j+1]+a[i+1][j-1]+a[i+1][j]+a[i+1][j+1])/9;

}

}

}

printf("模板一\n");

boolflag=clSaveImage("D:

\\material\\1电路图.bmp",img);

if(flag)

{

printf("saveok...\n");

}

printf("\n");

for(i=1;i

{

for(j=2;j

{

for(k=0;k<3;k++)

{

img->imageData[(i+k)*w*3+j*3+k]=(a[i-1][j-1]+2*a[i-1][j]+a[i-1][j+1]+2*a[i][j-1]+4*a[i][j]+2*a[i][j+1]+a[i+1][j-1]+2*a[i+1][j]+a[i+1][j+1])/16;

}

}

}

printf("模板二\n");

boolflag0=clSaveImage("D:

\\material\\2电路图.bmp",img);

if(flag0)

{

printf("saveok...\n");

}

printf("\n");

}

voidZhongzhi(ClImage*img1,inth,intw)

{

intb[9]={0},a[500][500]={0};

inti,j,k,m,n,temp;

for(i=0;i

{

for(j=0;j

{

a[i][j]=img1->imageData[i*w*3+j*3];

}

}

for(i=1;i

{

for(j=1;j

{

b[0]=a[i-1][j-1];

b[1]=a[i-1][j];

b[2]=a[i-1][j+1];

b[3]=a[i][j-1];

b[4]=a[i][j];

b[5]=a[i][j+1];

b[6]=a[i+1][j-1];

b[7]=a[i+1][j];

b[8]=a[i+1][j+1];

for(m=0;m<8;m++)

{

for(n=m+1;n<9;n++)

{

if(b[m]>b[n])

{

temp=b[m];

b[m]=b[n];

b[n]=temp;

}

}

}

for(k=0;k<3;k++)

{

img1->imageData[(i+k)*w*3+j*3+k]=b[4];

}

}

}

printf("中值\n");

boolflag1=clSaveImage("D:

\\material\\3电路板.bmp",img1);

if(flag1)

{

printf("saveok...\n");

}

printf("\n");

}

voidSobel(ClImage*img2,inth,intw)

{

inta[550][470]={0};

inti,j,k;

for(i=0;i

{

for(j=0;j

{

a[i][j]=img2->imageData[i*w*3+j*3];

}

}

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

当前位置:首页 > 党团工作 > 入党转正申请

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1