手机版

实验4 图像几何变换—哈哈镜制作(6)

时间:2025-04-22   来源:未知    
字号:

vc++实现图像放大、缩小、平移、旋转、各种哈哈镜变形

pImg1->imageData[i*pImg1->widthStep+j*pImg1->nChannels+k]=(uchar)pImg->imageData[int_srcY*pImg->widthStep+int_srcX*pImg->nChannels+k];

b=(bUpLeft*(1-float_srcX)*(1-float_srcY)+bUpRight*float_srcX*(1-float_srcY)+

rUpLeft=pImg->imageData[int_srcY*pImg->widthStep+int_srcX*3+2]; rUpRight=pImg->imageData[int_srcY*pImg->widthStep+int_srcX*3+2]; rDownLeft=pImg->imageData[int_srcY*pImg->widthStep+int_srcX*3+2]; rDownRight=pImg->imageData[int_srcY*pImg->widthStep+int_srcX*3+2];

unsigned char bUpLeft, bUpRight, bDownLeft, bDownRight; unsigned char gUpLeft, gUpRight, gDownLeft, gDownRight; unsigned char rUpLeft, rUpRight, rDownLeft, rDownRight; unsigned char b, g, r;

bUpLeft=pImg->imageData[int_srcY*pImg->widthStep+int_srcX*3+0]; bUpRight=pImg->imageData[int_srcY*pImg->widthStep+int_srcX*3+0]; bDownLeft=pImg->imageData[int_srcY*pImg->widthStep+int_srcX*3+0]; bDownRight=pImg->imageData[int_srcY*pImg->widthStep+int_srcX*3+0]; gUpLeft=pImg->imageData[int_srcY*pImg->widthStep+int_srcX*3+1]; gUpRight=pImg->imageData[int_srcY*pImg->widthStep+int_srcX*3+1]; gDownLeft=pImg->imageData[int_srcY*pImg->widthStep+int_srcX*3+1]; gDownRight=pImg->imageData[int_srcY*pImg->widthStep+int_srcX*3+1];

}

}

break;

// 双线性插值图像放大 case UPRESIZE:

size=cvSize(z*pImg->width,z*pImg->height); for(i=0;i<pImg1->height;i++)

for(j=0;j<pImg1->width;j++) {

float srcX=(float)(j*((float)pImg->width/(float)pImg1->width)); float srcY=(float)(i*((float)pImg->height/(float)pImg1->height)); int int_srcX=(int)srcX; int int_srcY=(int)srcY; float float_srcX=srcX-int_srcX; float float_srcY=srcY-int_srcY;

pImg1 = cvCreateImage(size,pImg->depth,pImg->nChannels);

bDownLeft*(1-float_srcX)*float_srcY+bDownRight*float_srcX*float_srcY);

实验4 图像几何变换—哈哈镜制作(6).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
×
二维码
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)