数字图像处理代码.doc

上传人:豆**** 文档编号:17614667 上传时间:2022-05-25 格式:DOC 页数:18 大小:176.50KB
返回 下载 相关 举报
数字图像处理代码.doc_第1页
第1页 / 共18页
数字图像处理代码.doc_第2页
第2页 / 共18页
点击查看更多>>
资源描述

《数字图像处理代码.doc》由会员分享,可在线阅读,更多相关《数字图像处理代码.doc(18页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、【精品文档】如有侵权,请联系网站删除,仅供学习与交流数字图像处理代码.精品文档.灰度void CImageStuDlg:OnMenuitem32822() / TODO: Add your command handler code hereint width=_infoHeader.biWidth;int height=_infoHeader.biHeight;/分配新图象CBaseColorInfo*newColor=new CBaseColorInfowidth*height;/图象遍原for(int x=0;xwidth;+x)for(int y=0;yheight;+y)int ind

2、ex=y*width+x;/读取像素CBaseColorInfo info=_colorDataindex;/计算int gray =0.299*info.GetRed()+0.587*info.GetGreen()+0.114*info.GetBlue();/赋值newColorindex.SetRed(gray);newColorindex.SetGreen(gray);newColorindex.SetBlue(gray);/显示CDlgShowArray dlg;/颜色dlg.SetColorData( newColor );/图象大小dlg.SetWidth( width );/宽度

3、dlg.SetHeight( height );/高度dlg.DoModal();/释放deletenewColor;黑白图void CImageStuDlg:OnMenuitem32823() / TODO: Add your command handler code hereint width=_infoHeader.biWidth;int height=_infoHeader.biHeight;/分配新图象CBaseColorInfo*newColor=new CBaseColorInfowidth*height;/图象遍原int show=100;for(int x=0;xwidth;

4、+x)for(int y=0;y=show)gray=255;else gray=0;/读取像素CBaseColorInfo info=_colorDataindex;/计算/赋值newColorindex.SetRed(gray);newColorindex.SetGreen(gray);newColorindex.SetBlue(gray);/显示CDlgShowArray dlg;/颜色dlg.SetColorData( newColor );/图象大小dlg.SetWidth( width );/宽度dlg.SetHeight( height );/高度dlg.DoModal();/释

5、放deletenewColor;行删除void CImageStuDlg:OnZoom1() / TODO: Add your command handler code hereint newwidth = _infoHeader.biWidth/2; int newheight = _infoHeader.biHeight/2; CBaseColorInfo * newColor = new CBaseColorInfo newwidth * newheight ; for( int x = 0; x newwidth; +x ) for( int y = 0; y newheight;+y

6、 ) int newindex=y*newwidth+x;/新图象的INDEX int x1=x*2;int y1=y*2; int index = y1 * _infoHeader.biWidth + x1;/原图象的INDEX CBaseColorInfo info = _colorData index ; int gary = 0.299 * info.GetRed()+ 0.587 * info.GetGreen()+ 0.114 * info.GetBlue(); /赋值 newColor newindex .SetRed( gary ); newColor newindex.Set

7、Green( gary ); newColor newindex .SetBlue( gary ); CDlgShowArray dlg;/ dlg.SetColorData( newColor );/ 数据 dlg.SetWidth( newwidth );/宽度 dlg.SetHeight( newheight );/ 高度 dlg.DoModal(); delete newColor;行复制void CImageStuDlg:OnCopy() / TODO: Add your command handler code hereint newwidth = _infoHeader.biWi

8、dth*2; int newheight = _infoHeader.biHeight*2; CBaseColorInfo * newColor = new CBaseColorInfo newwidth * newheight ; for( int x = 0; x newwidth; +x ) for( int y = 0; y newheight;+y ) int newindex=y*newwidth+x;/新图象的INDEX int x1=x/2; int y1=y/2; int index = y1 * _infoHeader.biWidth + x1;/原图象的INDEX CBa

9、seColorInfo info = _colorData index ; int red=info.GetRed(); int blue=info.GetBlue(); int green=info.GetGreen(); /赋值 newColor newindex .SetRed( red ); newColor newindex.SetGreen( green ); newColor newindex .SetBlue( blue ); CDlgShowArray dlg;/ dlg.SetColorData( newColor );/ 数据 dlg.SetWidth( newwidth

10、 );/宽度 dlg.SetHeight( newheight );/ 高度 dlg.DoModal();delete newColor;灰度分辨率void CImageStuDlg:Onhuidufenbianlv() / TODO: Add your command handler code hereint width = _infoHeader.biWidth; int height = _infoHeader.biHeight; CBaseColorInfo * newColor = new CBaseColorInfo width * height ;int len=width*he

11、ight; for( int index = 0; index len; +index ) CBaseColorInfo info = _colorData index ;int red=info.GetRed();int newred=red/32*32;newColor index .SetRed( newred );int blue=info.GetBlue();int newblue=blue/32*32; newColor index .SetBlue( newblue );int green=info.GetGreen();int newgreen=green/32*32; new

12、Color index.SetGreen( newgreen ); CDlgShowArray dlg;/ dlg.SetColorData( newColor );/ 数据 dlg.SetWidth( width );/宽度 dlg.SetHeight( height );/ 高度 dlg.DoModal(); delete newColor;最新领插值void CImageStuDlg:OnChazhi() / TODO: Add your command handler code hereint newwidth = _infoHeader.biWidth*2; int newheigh

13、t = _infoHeader.biHeight*2; CBaseColorInfo * newColor = new CBaseColorInfo newwidth * newheight ; for( int x = 0; x newwidth; +x ) for( int y = 0; y newheight;+y ) int newindex=y*newwidth+x;/新图象的INDEX int x1=int(x/2+0.5);int y1=int(y/2+0.5); int index = y1 * _infoHeader.biWidth + x1;/原图象的INDEX CBase

14、ColorInfo info = _colorData index ; int red=info.GetRed(); int blue=info.GetBlue(); int green=info.GetGreen(); /赋值 newColor newindex .SetRed( red ); newColor newindex.SetGreen( green ); newColor newindex .SetBlue( blue ); CDlgShowArray dlg;/ dlg.SetColorData( newColor );/ 数据 dlg.SetWidth( newwidth )

15、;/宽度 dlg.SetHeight( newheight );/ 高度 dlg.DoModal(); delete newColor;双线性插值void CImageStuDlg:OnShuangchazhi() / TODO: Add your command handler code here double s=2.0;int newwidth = _infoHeader.biWidth*s; int newheight = _infoHeader.biHeight*s; CBaseColorInfo * newColor = new CBaseColorInfo newwidth *

16、newheight ;int oldLen = _infoHeader.biWidth * _infoHeader.biHeight; for( int x = 1; x newwidth-1 ; +x ) for( int y = 1; y newheight-1 ;+y ) int newindex = y * newwidth + x;/新图象的INDEX double y1 = y / s; double x1 = x / s; int left =int(x1); int top =int(y1); int gaIndex = top * _infoHeader.biWidth +

17、left; int gbIndex = gaIndex+1; int gcIndex = gaIndex+ _infoHeader.biWidth ; int gdIndex = gcIndex+1; int ga=_grayData gaIndex ; int gb=_grayData gbIndex ; int gc=_grayData gcIndex ; int gd=_grayData gdIndex ; int ge= (x1-left) *( gb - ga )+ga; int gf= (x1-left) * ( gd - gc )+gc; int newgray= ( y1 -

18、top ) *( gf - ge) +ge; newColor newindex .SetRed( newgray ); newColor newindex .SetGreen( newgray ); newColor newindex .SetBlue( newgray ); CDlgShowArray dlg;/ dlg.SetColorData( newColor );/ 数据 dlg.SetWidth( newwidth );/宽度 dlg.SetHeight( newheight );/ 高度 dlg.DoModal(); delete newColor;灰度取反void CImag

19、eStuDlg:OnQufan() / TODO: Add your command handler code hereint newwidth = _infoHeader.biWidth; int newheight = _infoHeader.biHeight; CBaseColorInfo * newColor = new CBaseColorInfo newwidth * newheight ; for( int x = 0; x newwidth; +x ) for( int y = 0; y newheight;+y ) int newindex = y*newwidth+x;/新

20、图象的INDEX int newgray=255-_grayDatanewindex; newColor newindex .SetRed( newgray ); newColor newindex.SetGreen( newgray ); newColor newindex .SetBlue( newgray ); CDlgShowArray dlg;/ dlg.SetColorData( newColor );/ 数据 dlg.SetWidth( newwidth );/宽度 dlg.SetHeight( newheight );/ 高度 dlg.DoModal(); delete new

21、Color;对数void CImageStuDlg:OnDuishu() / TODO: Add your command handler code hereint newwidth = _infoHeader.biWidth; int newheight = _infoHeader.biHeight; CBaseColorInfo * newColor = new CBaseColorInfo newwidth * newheight ; for( int x = 0; x newwidth; +x ) for( int y = 0; y newheight;+y ) int newinde

22、x = y*newwidth+x;/新图象的INDEX int newgray=255-log10(1+double(_grayDatanewindex)/40.0); newColor newindex .SetRed( newgray ); newColor newindex.SetGreen( newgray ); newColor newindex .SetBlue( newgray ); CDlgShowArray dlg;/ dlg.SetColorData( newColor );/ 数据 dlg.SetWidth( newwidth );/宽度 dlg.SetHeight( n

23、ewheight );/ 高度 dlg.DoModal(); delete newColor;冥次变换void CImageStuDlg:Onmingcibianhuan() / TODO: Add your command handler code hereint newwidth = _infoHeader.biWidth; int newheight = _infoHeader.biHeight; CBaseColorInfo * newColor = new CBaseColorInfo newwidth * newheight ; for( int x = 0; x newwidth

24、; +x ) for( int y = 0; y newheight;+y ) int newindex = y*newwidth+x;/新图象的INDEX int newgray=240*pow (_grayDatanewindex/255.0,2.0); newColor newindex .SetRed( newgray ); newColor newindex.SetGreen( newgray ); newColor newindex .SetBlue( newgray ); CDlgShowArray dlg;/ dlg.SetColorData( newColor );/ 数据

25、dlg.SetWidth( newwidth );/宽度 dlg.SetHeight( newheight );/ 高度 dlg.DoModal(); delete newColor;分段线性拉伸void CImageStuDlg:Onfenduan() / TODO: Add your command handler code hereint width=_infoHeader.biWidth;int height=_infoHeader.biHeight;CBaseColorInfo*newColor=new CBaseColorInfowidth*height;/建新图int width

26、1=80,height1=25;int width2=130,height2=230;int gray=0;for(int x=0;xwidth;+x)for(int y=0;yheight;+y)int index=y*width+x;int value=_grayDataindex;/赋值if(value=width1)gray=(height1/width1)*value;else if(width1=value&value=width2)gray=(height2-height1)/(width2-width1)*(value-width1)+height1;else gray=(25

27、5-height2)/(255-width2)*(value-width2)+height2;newColorindex.SetRed(gray);newColorindex.SetGreen(gray);newColorindex.SetBlue(gray);CDlgShowArray dlg;dlg.SetColorData(newColor);/颜色数据dlg.SetWidth(width);/宽dlg.SetHeight(height);/高dlg.DoModal();/释放delete newColor;位平面void CImageStuDlg:Onweipinmian() / TO

28、DO: Add your command handler code hereint width=_infoHeader.biWidth;int height=_infoHeader.biHeight;/分配新图象CBaseColorInfo*newColor=new CBaseColorInfowidth*height;int m=7; int newgray;/图象遍原for(int x=0;xwidth;+x)for(int y=0;y= m;if(1 = (a % 2)newgray = 255;else newgray = 0;/赋值newColorindex.SetRed(newgr

29、ay);newColorindex.SetGreen(newgray);newColorindex.SetBlue(newgray); CDlgShowArray dlg;/ dlg.SetColorData( newColor );/ 数据 dlg.SetWidth( width );/宽度 dlg.SetHeight( height );/ 高度 dlg.DoModal(); delete newColor;直方图均衡化void CImageStuDlg:Onzhufangtujunhenghua() / TODO: Add your command handler code herein

30、t yuanshi256;int index;int width = _infoHeader.biWidth; int height = _infoHeader.biHeight; CBaseColorInfo * newColor = new CBaseColorInfo width * height ;int len= _infoHeader.biWidth*_infoHeader.biHeight;for( index=0; index256; +index)yuanshiindex=0;for( index=0;indexlen;+index)int gray=_grayDataind

31、ex;yuanshigray+;/for( index=0;index256;+index)/TRACE( %d, %d; , index, yuanshi index );double guiyihua256;for( index=0;index256;+index)guiyihuaindex=yuanshiindex*1.0/len;double leiji256;leiji0=guiyihua0;for( index=1;index256;+index)leijiindex=leijiindex-1+guiyihuaindex;double guize256;for( index=0;i

32、ndex256;+index)guizeindex=int(256-1)*leijiindex+0.5) ;int *newgray=new intlen;for(index=0;indexlen;+index)newgrayindex=guize_grayDataindex;newColor index .SetRed( newgrayindex ); newColor index.SetGreen( newgrayindex ); newColor index .SetBlue( newgrayindex ); CDlgShowArray dlg;/ dlg.SetColorData( n

33、ewColor );/ 数据 dlg.SetWidth( width );/宽度 dlg.SetHeight( height );/ 高度 dlg.DoModal(); delete newColor;直方图规定化void CImageStuDlg:OnGuidinghua() / TODO: Add your command handler code hereint width=_infoHeader.biWidth;int height=_infoHeader.biHeight;CBaseColorInfo*newColor=new CBaseColorInfowidth*height;/

34、建新图int len=width*height;int index=0;int yuanshi256;double guiyihua256;double leiji256;double cha4;double u10=0.25,u76=0.25,u153=0.2,u230=0.3;int rude256;double leiji14;leiji10=u10;leiji11=u10+u76;leiji12=leiji11+u153;leiji13=leiji12+u230;int a=0;/赋初值for (a=0;a256;+a)yuanshia=0;guiyihuaa=0;leijia=0;r

35、udea=0;/读出原始值for (index=0;indexlen;+index)int gray=_grayDataindex;yuanshigray+; /归一化for (index=0;index256;+index)guiyihuaindex=yuanshiindex*1.0/len;/TRACE(归一化 :n);/for ( index=0;index256;+index)/TRACE(%d, %lf; , index, guiyihuaindex );TRACE(n);/累积leiji0=guiyihua0;for (index=1;index256;+index)leijiin

36、dex=leijiindex-1+guiyihuaindex;/TRACE(累积 :n);/for ( index=0;index256;+index)/TRACE(%d, %lf; , index, leijiindex );/TRACE(n);/规定化for (index=0;index256;+index)for (a=0;a4;+a)chaa=leijiindex-leiji1a;if (chaa0) chaa=0-chaa;else chaa=chaa;if( index % 10 = 0 )TRACE(a = %d, cha = %lfn, a, cha a );if (cha0=

37、cha1) rudeindex=10;else if (cha1=cha2) rudeindex=56;else if (cha2=cha3) rudeindex=123;else rudeindex=220;TRACE(规定化 :n);for ( index=0;index256;+index)TRACE(%d, %d; , index, rudeindex );TRACE(n);for (index=0;indexlen;+index)int gray=_grayDataindex;int newgray=rudegray;newColorindex.SetRed(newgray);new

38、Colorindex.SetGreen(newgray);newColorindex.SetBlue(newgray);CDlgShowArray dlg;dlg.SetColorData(newColor);/颜色数据dlg.SetWidth(width);/宽dlg.SetHeight(height);/高dlg.DoModal();/释放delete newColor;领域平均void CImageStuDlg:OnLingyupingjun() / TODO: Add your command handler code here/ TODO: Add your command hand

39、ler code hereint newwidth = _infoHeader.biWidth; int newheight = _infoHeader.biHeight;int s=3;int scale=s/2; CBaseColorInfo * newColor = new CBaseColorInfo newwidth * newheight ; for( int x = scale; x newwidth-scale; +x ) for( int y = scale; y newheight-scale;+y ) int gray=0; for(int x1=x-scale;x1=x

40、+scale;x1+) for(int y1=y-scale;y1=y+scale;y1+) int index=y1*newwidth+x1; gray+=_grayDataindex; gray=gray/9; int newindex=y*newwidth+x; newColor newindex .SetRed( gray ); newColor newindex.SetGreen( gray ); newColor newindex .SetBlue( gray ); CDlgShowArray dlg;/ dlg.SetColorData( newColor );/ 数据 dlg.SetWidth( newwidth );/宽度 dlg.SetHeight( newheight );/ 高度 dlg.DoModal(); delete newColor;加权平均void CImageStuDlg:OnJiayuanpingjun() / TODO: Add your command handler code here/ TODO: Add your command handler code hereint newwidth = _infoHeader.biWidth; int newheight = _infoHea

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 小学资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com