数字图像处理2
- 格式:pdf
- 大小:166.06 KB
- 文档页数:7
数字图像处理第二版夏良正著(经典版)编制人:__________________审核人:__________________审批人:__________________编制单位:__________________编制时间:____年____月____日序言下载提示:该文档是本店铺精心编制而成的,希望大家下载后,能够帮助大家解决实际问题。
文档下载后可定制修改,请根据实际需要进行调整和使用,谢谢!并且,本店铺为大家提供各种类型的经典范文,如条据书信、合同协议、演讲致辞、规章制度、应急预案、读后感、观后感、好词好句、教学资料、其他范文等等,想了解不同范文格式和写法,敬请关注!Download tips: This document is carefully compiled by this editor. I hope that after you download it, it can help you solve practical problems. The document can be customized and modified after downloading, please adjust and use it according to actual needs, thank you!Moreover, our store provides various types of classic sample essays, such as policy letters, contract agreements, speeches, rules and regulations, emergency plans, reading feedback, observation feedback, good words and sentences, teaching materials, other sample essays, etc. If you want to learn about different sample formats and writing methods, please pay attention!数字图像处理第二版夏良正著数字图像处理第二版(夏良正著)数字图像处理是通过计算机对图像进行去除噪声、增强、复原、分割、提取特征等处理的方法和技术。
数字图像处理第二版数字图像处理是对图像进行数字化处理来实现增强、压缩、重构等目的的技术。
与传统的图像处理相比,数字图像处理有很多的优点,如可重复性、自动化程度高、处理速度快等。
数字图像处理主要分为以下几个步骤:1. 图像获取:获取原始图像,包括摄像机、扫描仪、雷达等设备获得的数字图片;2. 图像预处理:对图像进行预处理,如去噪、平滑、锐化等操作,以改善图像质量和准确度;3. 特征提取:从处理后的图像中提取相关特征,如边缘、纹理、颜色等,以进行更深入的分析和处理;4. 图像分析:对提取出的图像特征进行分析和处理,如目标检测、分类、识别等;5. 图像重构:根据处理结果对图像进行重构或合成。
数字图像处理在很多领域都有应用,如医学图像处理、遥感图像处理、工业检测等。
其中医学图像处理应用最为广泛,包括CT、MRI 等医学影像的处理及分析、医学图像的自动识别等。
在遥感图像处理中,数字图像处理被用于解决图像失真、降噪、液化等问题,从而提高传感器的精度和稳定性。
在工业检测中,数字图像处理可用于识别和修复机器中的缺陷、实现无损检测等。
数字图像处理的研究范围很广,包括图像压缩、图像增强、图像识别等方面。
其中图像压缩是数字图像处理领域中的一项重要研究内容,合理地对图像进行压缩,可大大减少存储空间和传输带宽,并且保持图像的质量。
图像增强是另一个重要的工具,它通过对图像的局部增强、全局增强等方式来改善图像的质量,使得图像更加清晰、明亮。
总的来说,数字图像处理是一种重要的技术手段,它可以广泛应用于医学、遥感、工业等各个领域。
随着技术的发展和研究的深入,数字图像处理的应用和研究将会更加广泛和深入。
使用C/C++进行图像处理本系列仅针对BMP格式的图像实现的功能包括读,存,二值化,缩放,反色,均值滤波,中值滤波,增强,腐蚀,膨胀功能:二值化(运行本程序需要参考“数字图像处理1”)源码:/*函数功能:彩色图像转化为灰度图象输入参数:RGBQUAD** dataOfBmp_src --- 原图像所有像素(以行为序)对应的RGBAlpha 四元素结构体指针;RGBQUAD** dataOfBmp_dst --- 转化为灰度图象后的图像所有像素(以行为序)对应的RGBAlpha 四元素结构体指针;BYTE** dataOfBmp_gray --- 转化为灰度图象后的图像所有像素(以行为序)对应的灰度值;DWORD width, DWORD height --- 原图像和输出图像的宽度和高度(以像素为单位)输出值:没有*/void RGB2Gray(RGBQUAD** dataOfBmp_src, RGBQUAD** dataOfBmp_dst, BYTE** dataOfBmp_gray, DWORD width, DWORD height){double gray;for(DWORD i=0;i<height;i++){for(DWORD j=0;j<width;j++){gray = 0.299*dataOfBmp_src[i][j].rgbRed+0.587*dataOfBmp_src[i][j].rgbGreen+0.114*dataOfBmp_src[i ][j].rgbBlue;dataOfBmp_gray[i][j] = (BYTE)gray;dataOfBmp_dst[i][j].rgbRed = (BYTE)gray;dataOfBmp_dst[i][j].rgbGreen = (BYTE)gray;dataOfBmp_dst[i][j].rgbBlue = (BYTE)gray;}}}主函数:void main(){BITMAPFILEHEADER bitHead;BITMAPINFOHEADER bitInfoHead;int i, j;FILE* pfile;char strFile[50];printf("please input the .bmp source file name:\n");scanf("%s",strFile);pfile = fopen(strFile,"rb");//打开文件if(pfile!=NULL){printf("file %s open success.\n", strFile);//读取位图文件头信息fread(&bitHead,1,sizeof(BITMAPFILEHEADER),pfile);if(bitHead.bfType != 0x4d42){printf("file is not .bmp file!");return;}showBmpHead(&bitHead);printf("\n\n");//读取位图信息头信息fread(&bitInfoHead,1,sizeof(BITMAPINFOHEADER),pfile);showBmpInforHead(&bitInfoHead);printf("\n");}else{printf("file open fail!\n");return;}RGBQUAD* pRgb=NULL;if(bitInfoHead.biBitCount < 24)//有调色板{//读取调色盘结信息long nPlantNum = bitInfoHead.biClrUsed;if(!nPlantNum)nPlantNum = long(pow(2,double(bitInfoHead.biBitCount))); // Mix color Plant Number;pRgb=new RGBQUAD[nPlantNum*sizeof(RGBQUAD)];memset(pRgb,0,nPlantNum*sizeof(RGBQUAD));int num = fread(pRgb,4,nPlantNum,pfile);printf("Color Plate Number: %d\n",nPlantNum);printf("颜色板信息:\n");showRgbQuan(pRgb, nPlantNum);}int width = bitInfoHead.biWidth;int height = bitInfoHead.biHeight;//分配内存空间把源图存入内存int l_width = WIDTHBYTES(width* bitInfoHead.biBitCount);//计算位图的实际宽度并确保它为32的倍数long nData = height*l_width;BYTE *pColorData= new BYTE[nData];memset(pColorData,0,nData);//把位图数据信息读到数组里fread(pColorData,1,nData,pfile);//将位图数据转化为RGB数据RGBQUAD** dataOfBmp_src=NULL; //用于保存各像素对应的RGB数据dataOfBmp_src = new RGBQUAD*[height];for(i=0; i < height;i++)dataOfBmp_src[i] =new RGBQUAD[width];if(bitInfoHead.biBitCount<24)//有调色板,即位图为非真彩色{int k;if(bitInfoHead.biBitCount <= 8 && !bitInfoHead.biCompression){int pnum = 8/bitInfoHead.biBitCount;int mbnum = 8-bitInfoHead.biBitCount;for(int i=0;i<height;i++){int k0 = (height-i-1)*l_width;//k:取得该像素颜色数据在实际数据数组中的序号for(int j=0;j<width;j++){BYTE mixIndex= 0;k = k0+(j/pnum);mixIndex = pColorData[k];//mixIndex:提取当前像素的颜色的在颜色表中的索引值if(bitInfoHead.biBitCount < 8){mixIndex = mixIndex<<((j%pnum)*bitInfoHead.biBitCount);mixIndex = mixIndex>>mbnum;}//将像素颜色数据(RGBA)保存到数组中对应的位置dataOfBmp_src[i][j].rgbRed = pRgb[mixIndex].rgbRed;dataOfBmp_src[i][j].rgbGreen = pRgb[mixIndex].rgbGreen;dataOfBmp_src[i][j].rgbBlue = pRgb[mixIndex].rgbBlue;dataOfBmp_src[i][j].rgbReserved = pRgb[mixIndex].rgbReserved;}}}if(bitInfoHead.biBitCount == 16){if(!bitInfoHead.biCompression){for( i=0;i<height;i++){int k0 = (height-i-1)*l_width;for( j=0;j<width;j++){WORD mixIndex= 0;k = k0+j*2;WORD shortTemp;shortTemp = pColorData[k+1];shortTemp = shortTemp<<8;mixIndex = pColorData[k] + shortTemp;dataOfBmp_src[i][j].rgbRed = pRgb[mixIndex].rgbRed;dataOfBmp_src[i][j].rgbGreen = pRgb[mixIndex].rgbGreen;dataOfBmp_src[i][j].rgbBlue = pRgb[mixIndex].rgbBlue;dataOfBmp_src[i][j].rgbReserved = pRgb[mixIndex].rgbReserved;}}}}}else//位图为24/32位真彩色{int k;int index = 0;if(bitInfoHead.biBitCount == 16){for( i=0;i<height;i++){int k0 = (height-i-1)*l_width;for( j=0;j<width;j++){k = k0+j*2;if(!bitInfoHead.biCompression)//555格式{dataOfBmp_src[i][j].rgbBlue=pColorData[k]&0x1F;dataOfBmp_src[i][j].rgbGreen=(((pColorData[k+1]<<6)&0xFF)>>3)+(pColorData[k]>>5);dataOfBmp_src[i][j].rgbRed=(pColorData[k+1]<<1)>>3;dataOfBmp_src[i][j].rgbReserved = 0;}}}}if(bitInfoHead.biBitCount == 24 && !bitInfoHead.biCompression){for( i=0;i<height;i++){int k0 = (height-i-1)*l_width;for( j=0;j<width;j++){k = k0+(j*3);dataOfBmp_src[i][j].rgbRed = pColorData[k+2];dataOfBmp_src[i][j].rgbGreen = pColorData[k+1];dataOfBmp_src[i][j].rgbBlue = pColorData[k];dataOfBmp_src[i][j].rgbReserved = 0;}}}if(bitInfoHead.biBitCount == 32 && !bitInfoHead.biCompression){for( i=0;i<height;i++){int k0 = (height-i-1)*l_width;for( j=0;j<width;j++){k = k0+(j*4);dataOfBmp_src[i][j].rgbRed = pColorData[k+2];dataOfBmp_src[i][j].rgbGreen = pColorData[k+1];dataOfBmp_src[i][j].rgbBlue = pColorData[k];dataOfBmp_src[i][j].rgbReserved = pColorData[k+3];}}}}dataOfBmp_dst = new RGBQUAD*[height];for(i=0; i<height; i++)dataOfBmp_dst[i] = new RGBQUAD[width];BYTE** dataOfBmp_gray=NULL;dataOfBmp_gray = new BYTE*[height];for(i=0; i<height; i++)dataOfBmp_gray[i] = new BYTE[width];RGB2Gray(dataOfBmp_src, dataOfBmp_dst, dataOfBmp_gray, width, height);saveBmp(dataOfBmp_dst, width, height);fclose(pfile);if (bitInfoHead.biBitCount<24 && pRgb){delete []pRgb;}for(i=0; i<height; i++)if(dataOfBmp_src[i])delete dataOfBmp_src[i];if(dataOfBmp_src)delete dataOfBmp_src;for(i=0; i<height; i++)if(dataOfBmp_dst[i])delete dataOfBmp_dst[i];if(dataOfBmp_dst)delete dataOfBmp_dst;for(i=0; i<height; i++)if(dataOfBmp_gray[i])delete dataOfBmp_gray[i];if(dataOfBmp_gray)delete dataOfBmp_gray;if(pColorData)delete []pColorData;}。