数字图像处理代码精编版.docx
《数字图像处理代码精编版.docx》由会员分享,可在线阅读,更多相关《数字图像处理代码精编版.docx(32页珍藏版)》请在冰点文库上搜索。
数字图像处理代码精编版
灰度
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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth/2;intnewheight=_infoHeader.biHeight/2;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintx1=x*2;inty1=y*2;intindex=y1*_infoHeader.biWidth+x1;//原图象的INDEXCBaseColorInfoinfo=_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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth*2;intnewheight=_infoHeader.biHeight*2;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintx1=x/2;inty1=y/2;intindex=y1*_infoHeader.biWidth+x1;//原图象的INDEXCBaseColorInfoinfo=_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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth*2;intnewheight=_infoHeader.biHeight*2;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintx1=int(x/2+0.5);inty1=int(y/2+0.5);intindex=y1*_infoHeader.biWidth+x1;//原图象的INDEXCBaseColorInfoinfo=_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;//新图象的INDEXdoubley1=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintyuanshi[256];intindex;intwidth=_i
{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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth/2;intnewheight=_infoHeader.biHeight/2;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintx1=x*2;inty1=y*2;intindex=y1*_infoHeader.biWidth+x1;//原图象的INDEXCBaseColorInfoinfo=_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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth*2;intnewheight=_infoHeader.biHeight*2;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintx1=x/2;inty1=y/2;intindex=y1*_infoHeader.biWidth+x1;//原图象的INDEXCBaseColorInfoinfo=_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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth*2;intnewheight=_infoHeader.biHeight*2;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintx1=int(x/2+0.5);inty1=int(y/2+0.5);intindex=y1*_infoHeader.biWidth+x1;//原图象的INDEXCBaseColorInfoinfo=_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;//新图象的INDEXdoubley1=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintyuanshi[256];intindex;intwidth=_i
{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;}
黑白图
OnMenuitem32823()
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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth/2;intnewheight=_infoHeader.biHeight/2;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintx1=x*2;inty1=y*2;intindex=y1*_infoHeader.biWidth+x1;//原图象的INDEXCBaseColorInfoinfo=_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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth*2;intnewheight=_infoHeader.biHeight*2;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintx1=x/2;inty1=y/2;intindex=y1*_infoHeader.biWidth+x1;//原图象的INDEXCBaseColorInfoinfo=_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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth*2;intnewheight=_infoHeader.biHeight*2;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintx1=int(x/2+0.5);inty1=int(y/2+0.5);intindex=y1*_infoHeader.biWidth+x1;//原图象的INDEXCBaseColorInfoinfo=_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;//新图象的INDEXdoubley1=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintyuanshi[256];intindex;intwidth=_i
{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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth/2;intnewheight=_infoHeader.biHeight/2;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintx1=x*2;inty1=y*2;intindex=y1*_infoHeader.biWidth+x1;//原图象的INDEXCBaseColorInfoinfo=_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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth*2;intnewheight=_infoHeader.biHeight*2;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintx1=x/2;inty1=y/2;intindex=y1*_infoHeader.biWidth+x1;//原图象的INDEXCBaseColorInfoinfo=_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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth*2;intnewheight=_infoHeader.biHeight*2;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintx1=int(x/2+0.5);inty1=int(y/2+0.5);intindex=y1*_infoHeader.biWidth+x1;//原图象的INDEXCBaseColorInfoinfo=_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;//新图象的INDEXdoubley1=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintyuanshi[256];intindex;intwidth=_i
{intindex=y*width+x;
intvalue=_colorData[index].GetGreen();intgray=255;
if(value>=show){gray=255;}
elsegray=0;//读取像素
CBaseColorInfoinfo=_colorData[index];//计算//赋值
delete[]newColor;
}
行删除
OnZoom1()
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;//新图象的INDEXintx1=x*2;inty1=y*2;intindex=y1*_infoHeader.biWidth+x1;//原图象的INDEXCBaseColorInfoinfo=_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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth*2;intnewheight=_infoHeader.biHeight*2;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintx1=x/2;inty1=y/2;intindex=y1*_infoHeader.biWidth+x1;//原图象的INDEXCBaseColorInfoinfo=_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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth*2;intnewheight=_infoHeader.biHeight*2;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintx1=int(x/2+0.5);inty1=int(y/2+0.5);intindex=y1*_infoHeader.biWidth+x1;//原图象的INDEXCBaseColorInfoinfo=_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;//新图象的INDEXdoubley1=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintyuanshi[256];intindex;intwidth=_i
{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintx1=x*2;inty1=y*2;intindex=y1*_infoHeader.biWidth+x1;//原图象的INDEXCBaseColorInfoinfo=_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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth*2;intnewheight=_infoHeader.biHeight*2;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintx1=x/2;inty1=y/2;intindex=y1*_infoHeader.biWidth+x1;//原图象的INDEXCBaseColorInfoinfo=_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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth*2;intnewheight=_infoHeader.biHeight*2;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintx1=int(x/2+0.5);inty1=int(y/2+0.5);intindex=y1*_infoHeader.biWidth+x1;//原图象的INDEXCBaseColorInfoinfo=_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;//新图象的INDEXdoubley1=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintyuanshi[256];intindex;intwidth=_i
{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;}
行复制
OnCopy()
intnewwidth=_infoHeader.biWidth*2;
intnewheight=_infoHeader.biHeight*2;
for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintx1=x/2;inty1=y/2;intindex=y1*_infoHeader.biWidth+x1;//原图象的INDEXCBaseColorInfoinfo=_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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth*2;intnewheight=_infoHeader.biHeight*2;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintx1=int(x/2+0.5);inty1=int(y/2+0.5);intindex=y1*_infoHeader.biWidth+x1;//原图象的INDEXCBaseColorInfoinfo=_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;//新图象的INDEXdoubley1=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintyuanshi[256];intindex;intwidth=_i
{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintx1=x/2;inty1=y/2;intindex=y1*_infoHeader.biWidth+x1;//原图象的INDEXCBaseColorInfoinfo=_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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth*2;intnewheight=_infoHeader.biHeight*2;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintx1=int(x/2+0.5);inty1=int(y/2+0.5);intindex=y1*_infoHeader.biWidth+x1;//原图象的INDEXCBaseColorInfoinfo=_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;//新图象的INDEXdoubley1=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintyuanshi[256];intindex;intwidth=_i
intx1=x/2;inty1=y/2;
intred=info.GetRed();
intblue=info.GetBlue();
intgreen=info.GetGreen();//赋值
newColor[newindex].SetRed(red);
newColor[newindex].SetGreen(green);
newColor[newindex].SetBlue(blue);}}
灰度分辨率
Onhuidufenbianlv()
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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth*2;intnewheight=_infoHeader.biHeight*2;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintx1=int(x/2+0.5);inty1=int(y/2+0.5);intindex=y1*_infoHeader.biWidth+x1;//原图象的INDEXCBaseColorInfoinfo=_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;//新图象的INDEXdoubley1=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintyuanshi[256];intindex;intwidth=_i
{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);}
最新领插值
OnChazhi()
for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintx1=int(x/2+0.5);inty1=int(y/2+0.5);intindex=y1*_infoHeader.biWidth+x1;//原图象的INDEXCBaseColorInfoinfo=_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;//新图象的INDEXdoubley1=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintyuanshi[256];intindex;intwidth=_i
{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintx1=int(x/2+0.5);inty1=int(y/2+0.5);intindex=y1*_infoHeader.biWidth+x1;//原图象的INDEXCBaseColorInfoinfo=_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;//新图象的INDEXdoubley1=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintyuanshi[256];intindex;intwidth=_i
intx1=int(x/2+0.5);inty1=int(y/2+0.5);
intred=info.GetRed();intblue=info.GetBlue();
dlg.DoModal();
双线性插值
OnShuangchazhi()
Addyourcommandhandlercodeheredoubles=2.0;
intnewwidth=_infoHeader.biWidth*s;
intnewheight=_infoHeader.biHeight*s;
intoldLen=_infoHeader.biWidth*_infoHeader.biHeight;
for(intx=1;x{for(inty=1;y{intnewindex=y*newwidth+x;//新图象的INDEXdoubley1=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintyuanshi[256];intindex;intwidth=_i
{for(inty=1;y{intnewindex=y*newwidth+x;//新图象的INDEXdoubley1=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintyuanshi[256];intindex;intwidth=_i
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);}}
灰度取反
OnQufan()
intnewwidth=_infoHeader.biWidth;
intnewheight=_infoHeader.biHeight;
for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintyuanshi[256];intindex;intwidth=_i
{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintyuanshi[256];intindex;intwidth=_i
intnewgray=255-_grayData[newindex];
对数
OnDuishu()
for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintyuanshi[256];intindex;intwidth=_i
{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintnewwidth=_infoHeader.biWidth;intnewheight=_infoHeader.biHeight;CBaseColorInfo*newColor=newCBaseColorInfo[newwidth*newheight];for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintyuanshi[256];intindex;intwidth=_i
intnewgray=255-log10((1+double(_grayData[newindex]))/40.0);
冥次变换
Onmingcibianhuan()
CBaseColorInfo*newColor
=newCBaseColorInfo[newwidth*newheight];
for(intx=0;x{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintyuanshi[256];intindex;intwidth=_i
{for(inty=0;y{intnewindex=y*newwidth+x;//新图象的INDEXintnewgray=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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintyuanshi[256];intindex;intwidth=_i
intnewgray=240*pow(_grayData[newindex]/255.0,2.0);
newColor[newindex].SetBlue(newgray);
分段线性拉伸
Onfenduan()
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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintyuanshi[256];intindex;intwidth=_i
{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:Addyourcommandhandlercodehereintwidth=_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:Addyourcommandhandlercodehereintyuanshi[256];intindex;intwidth=_i
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].SetBlue(gray);}}
CDlgShowArraydlg;
dlg.SetColorData(newColor);//颜色数据
dlg.SetWidth(width);//宽
dlg.SetHeight(height);//高dlg.DoModal();//释放
位平面
Onweipinmian()
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:Addyourcommandhandlercodehereintyuanshi[256];intindex;intwidth=_i
{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:Addyourcommandhandlercodehereintyuanshi[256];intindex;intwidth=_i
{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);}}
直方图均衡化
Onzhufangtujunhenghua()
intyuanshi[256];intindex;
intwidth=_i
copyright@ 2008-2023 冰点文库 网站版权所有
经营许可证编号:鄂ICP备19020893号-2