数字图像处理代码精编版.docx

上传人:b****7 文档编号:15931237 上传时间:2023-07-09 格式:DOCX 页数:32 大小:20.55KB
下载 相关 举报
数字图像处理代码精编版.docx_第1页
第1页 / 共32页
数字图像处理代码精编版.docx_第2页
第2页 / 共32页
数字图像处理代码精编版.docx_第3页
第3页 / 共32页
数字图像处理代码精编版.docx_第4页
第4页 / 共32页
数字图像处理代码精编版.docx_第5页
第5页 / 共32页
数字图像处理代码精编版.docx_第6页
第6页 / 共32页
数字图像处理代码精编版.docx_第7页
第7页 / 共32页
数字图像处理代码精编版.docx_第8页
第8页 / 共32页
数字图像处理代码精编版.docx_第9页
第9页 / 共32页
数字图像处理代码精编版.docx_第10页
第10页 / 共32页
数字图像处理代码精编版.docx_第11页
第11页 / 共32页
数字图像处理代码精编版.docx_第12页
第12页 / 共32页
数字图像处理代码精编版.docx_第13页
第13页 / 共32页
数字图像处理代码精编版.docx_第14页
第14页 / 共32页
数字图像处理代码精编版.docx_第15页
第15页 / 共32页
数字图像处理代码精编版.docx_第16页
第16页 / 共32页
数字图像处理代码精编版.docx_第17页
第17页 / 共32页
数字图像处理代码精编版.docx_第18页
第18页 / 共32页
数字图像处理代码精编版.docx_第19页
第19页 / 共32页
数字图像处理代码精编版.docx_第20页
第20页 / 共32页
亲,该文档总共32页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

数字图像处理代码精编版.docx

《数字图像处理代码精编版.docx》由会员分享,可在线阅读,更多相关《数字图像处理代码精编版.docx(32页珍藏版)》请在冰点文库上搜索。

数字图像处理代码精编版.docx

数字图像处理代码精编版

灰度

voidCImageStuDlg:

:

OnMenuitem32822()

{//TODO:

Addyourcommandhandlercodehere

intwidth=_infoHeader.biWidth;

intheight=_infoHeader.biHeight;//分配新图象

CBaseColorInfo*newColor=newCBaseColorInfo[width*height];//图象遍原

for(intx=0;x

{for(inty=0;y

{intindex=y*width+x;//读取像素

CBaseColorInfoinfo=_colorData[index];//计算

intgray=0.299*info.GetRed()+0.587*info.GetGreen()+0.114*info.GetBlue();//赋值

newColor[index].SetRed(gray);

newColor[index].SetGreen(gray);

newColor[index].SetBlue(gray);}}//显示

CDlgShowArraydlg;//颜色

dlg.SetColorData(newColor);//图象大小

dlg.SetWidth(width);//宽度

dlg.SetHeight(height);//高度

dlg.DoModal();//释放

delete[]newColor;}

黑白图

voidCImageStuDlg:

:

OnMenuitem32823()

{//TODO:

Addyourcommandhandlercodehere

intwidth=_infoHeader.biWidth;

intheight=_infoHeader.biHeight;//分配新图象

CBaseColorInfo*newColor=newCBaseColorInfo[width*height];//图象遍原

intshow=100;

for(intx=0;x

{for(inty=0;y

{intindex=y*width+x;

intvalue=_colorData[index].GetGreen();intgray=255;

if(value>=show){gray=255;}

elsegray=0;//读取像素

CBaseColorInfoinfo=_colorData[index];//计算//赋值

newColor[index].SetRed(gray);

newColor[index].SetGreen(gray);

newColor[index].SetBlue(gray);}}//显示

CDlgShowArraydlg;//颜色

dlg.SetColorData(newColor);//图象大小

dlg.SetWidth(width);//宽度

dlg.SetHeight(height);//高度

dlg.DoModal();//释放

delete[]newColor;

}

行删除

voidCImageStuDlg:

:

OnZoom1()

{//TODO:

Addyourcommandhandlercodehere

intnewwidth=_infoHeader.biWidth/2;

intnewheight=_infoHeader.biHeight/2;

CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];

for(intx=0;x

{for(inty=0;y

{intnewindex=y*newwidth+x;//新图象的INDEX

intx1=x*2;inty1=y*2;

intindex=y1*_infoHeader.biWidth+x1;//原图象的INDEX

CBaseColorInfoinfo=_colorData[index];

intgary=0.299*info.GetRed()+0.587*info.GetGreen()+0.114*info.GetBlue();//赋值

newColor[newindex].SetRed(gary);

newColor[newindex].SetGreen(gary);

newColor[newindex].SetBlue(gary);}}

CDlgShowArraydlg;//

dlg.SetColorData(newColor);//数据

dlg.SetWidth(newwidth);//宽度

dlg.SetHeight(newheight);//高度

dlg.DoModal();delete[]newColor;}

行复制

voidCImageStuDlg:

:

OnCopy()

{//TODO:

Addyourcommandhandlercodehere

intnewwidth=_infoHeader.biWidth*2;

intnewheight=_infoHeader.biHeight*2;

CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];

for(intx=0;x

{for(inty=0;y

{intnewindex=y*newwidth+x;//新图象的INDEX

intx1=x/2;inty1=y/2;

intindex=y1*_infoHeader.biWidth+x1;//原图象的INDEX

CBaseColorInfoinfo=_colorData[index];

intred=info.GetRed();

intblue=info.GetBlue();

intgreen=info.GetGreen();//赋值

newColor[newindex].SetRed(red);

newColor[newindex].SetGreen(green);

newColor[newindex].SetBlue(blue);}}

CDlgShowArraydlg;//

dlg.SetColorData(newColor);//数据

dlg.SetWidth(newwidth);//宽度

dlg.SetHeight(newheight);//高度

dlg.DoModal();delete[]newColor;}

灰度分辨率

voidCImageStuDlg:

:

Onhuidufenbianlv()

{//TODO:

Addyourcommandhandlercodehere

intwidth=_infoHeader.biWidth;

intheight=_infoHeader.biHeight;

CBaseColorInfo*newColor=newCBaseColorInfo[width*height];

intlen=width*height;

for(intindex=0;index

{CBaseColorInfoinfo=_colorData[index];

intred=info.GetRed();intnewred=red/32*32;

newColor[index].SetRed(newred);

intblue=info.GetBlue();intnewblue=blue/32*32;

newColor[index].SetBlue(newblue);

intgreen=info.GetGreen();intnewgreen=green/32*32;

newColor[index].SetGreen(newgreen);}

CDlgShowArraydlg;//

dlg.SetColorData(newColor);//数据

dlg.SetWidth(width);//宽度

dlg.SetHeight(height);//高度

dlg.DoModal();delete[]newColor;}

最新领插值

voidCImageStuDlg:

:

OnChazhi()

{//TODO:

Addyourcommandhandlercodehere

intnewwidth=_infoHeader.biWidth*2;

intnewheight=_infoHeader.biHeight*2;

CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];

for(intx=0;x

{for(inty=0;y

{intnewindex=y*newwidth+x;//新图象的INDEX

intx1=int(x/2+0.5);inty1=int(y/2+0.5);

intindex=y1*_infoHeader.biWidth+x1;//原图象的INDEX

CBaseColorInfoinfo=_colorData[index];

intred=info.GetRed();intblue=info.GetBlue();

intgreen=info.GetGreen();//赋值

newColor[newindex].SetRed(red);

newColor[newindex].SetGreen(green);

newColor[newindex].SetBlue(blue);}}

CDlgShowArraydlg;//

dlg.SetColorData(newColor);//数据

dlg.SetWidth(newwidth);//宽度

dlg.SetHeight(newheight);//高度

dlg.DoModal();

delete[]newColor;}

双线性插值

voidCImageStuDlg:

:

OnShuangchazhi()

{//TODO:

Addyourcommandhandlercodeheredoubles=2.0;

intnewwidth=_infoHeader.biWidth*s;

intnewheight=_infoHeader.biHeight*s;

CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];

intoldLen=_infoHeader.biWidth*_infoHeader.biHeight;

for(intx=1;x

{for(inty=1;y

{intnewindex=y*newwidth+x;//新图象的INDEX

doubley1=y/s;doublex1=x/s;

intleft=int(x1);inttop=int(y1);

intgaIndex=top*_infoHeader.biWidth+left;intgbIndex=gaIndex+1;

intgcIndex=gaIndex+_infoHeader.biWidth;intgdIndex=gcIndex+1;

intga=_grayData[gaIndex];intgb=_grayData[gbIndex];

intgc=_grayData[gcIndex];intgd=_grayData[gdIndex];

intge=(x1-left)*(gb-ga)+ga;intgf=(x1-left)*(gd-gc)+gc;

intnewgray=(y1-top)*(gf-ge)+ge;

newColor[newindex].SetRed(newgray);

newColor[newindex].SetGreen(newgray);

newColor[newindex].SetBlue(newgray);}}

CDlgShowArraydlg;//

dlg.SetColorData(newColor);//数据

dlg.SetWidth(newwidth);//宽度

dlg.SetHeight(newheight);//高度

dlg.DoModal();delete[]newColor;}

灰度取反

voidCImageStuDlg:

:

OnQufan()

{//TODO:

Addyourcommandhandlercodehere

intnewwidth=_infoHeader.biWidth;

intnewheight=_infoHeader.biHeight;

CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];

for(intx=0;x

{for(inty=0;y

{intnewindex=y*newwidth+x;//新图象的INDEX

intnewgray=255-_grayData[newindex];

newColor[newindex].SetRed(newgray);

newColor[newindex].SetGreen(newgray);

newColor[newindex].SetBlue(newgray);}}

CDlgShowArraydlg;//

dlg.SetColorData(newColor);//数据

dlg.SetWidth(newwidth);//宽度

dlg.SetHeight(newheight);//高度

dlg.DoModal();delete[]newColor;}

对数

voidCImageStuDlg:

:

OnDuishu()

{//TODO:

Addyourcommandhandlercodehere

intnewwidth=_infoHeader.biWidth;

intnewheight=_infoHeader.biHeight;

CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];

for(intx=0;x

{for(inty=0;y

{intnewindex=y*newwidth+x;//新图象的INDEX

intnewgray=255-log10((1+double(_grayData[newindex]))/40.0);

newColor[newindex].SetRed(newgray);

newColor[newindex].SetGreen(newgray);

newColor[newindex].SetBlue(newgray);}}

CDlgShowArraydlg;//

dlg.SetColorData(newColor);//数据

dlg.SetWidth(newwidth);//宽度

dlg.SetHeight(newheight);//高度

dlg.DoModal();

delete[]newColor;

}

冥次变换

voidCImageStuDlg:

:

Onmingcibianhuan()

{//TODO:

Addyourcommandhandlercodehere

intnewwidth=_infoHeader.biWidth;

intnewheight=_infoHeader.biHeight;

CBaseColorInfo*newColor

=newCBaseColorInfo[newwidth*newheight];

for(intx=0;x

{for(inty=0;y

{intnewindex=y*newwidth+x;//新图象的INDEX

intnewgray=240*pow(_grayData[newindex]/255.0,2.0);

newColor[newindex].SetRed(newgray);

newColor[newindex].SetGreen(newgray);

newColor[newindex].SetBlue(newgray);

}

}

CDlgShowArraydlg;//

dlg.SetColorData(newColor);//数据

dlg.SetWidth(newwidth);//宽度

dlg.SetHeight(newheight);//高度

dlg.DoModal();

delete[]newColor;

}

分段线性拉伸

voidCImageStuDlg:

:

Onfenduan()

{//TODO:

Addyourcommandhandlercodehere

intwidth=_infoHeader.biWidth;

intheight=_infoHeader.biHeight;

CBaseColorInfo*newColor=newCBaseColorInfo[width*height];//建新图

intwidth1=80,height1=25;

intwidth2=130,height2=230;intgray=0;

for(intx=0;x

{for(inty=0;y

{intindex=y*width+x;

intvalue=_grayData[index];//赋值

if(value<=width1)gray=(height1/width1)*value;

elseif(width1<=value&&value<=width2)

gray=((height2-height1)/(width2-width1))*(value-width1)+height1;

elsegray=((255-height2)/(255-width2))*(value-width2)+height2;

newColor[index].SetRed(gray);

newColor[index].SetGreen(gray);

newColor[index].SetBlue(gray);}}

CDlgShowArraydlg;

dlg.SetColorData(newColor);//颜色数据

dlg.SetWidth(width);//宽

dlg.SetHeight(height);//高dlg.DoModal();//释放

delete[]newColor;}

位平面

voidCImageStuDlg:

:

Onweipinmian()

{//TODO:

Addyourcommandhandlercodehere

intwidth=_infoHeader.biWidth;

intheight=_infoHeader.biHeight;//分配新图象

CBaseColorInfo*newColor=newCBaseColorInfo[width*height];intm=7;

intnewgray;//图象遍原

for(intx=0;x

{for(inty=0;y

{intindex=y*width+x;inta=_grayData[index];

a>>=m;if(1==(a%2))newgray=255;

elsenewgray=0;//赋值

newColor[index].SetRed(newgray);

newColor[index].SetGreen(newgray);

newColor[index].SetBlue(newgray);}}

CDlgShowArraydlg;//

dlg.SetColorData(newColor);//数据

dlg.SetWidth(width);//宽度

dlg.SetHeight(height);//高度

dlg.DoModal();delete[]newColor;}

直方图均衡化

voidCImageStuDlg:

:

Onzhufangtujunhenghua()

{//TODO:

Addyourcommandhandlercodehere

intyuanshi[256];intindex;

intwidth=_i

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

当前位置:首页 > 经管营销 > 经济市场

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2