实验4 图像几何变换—哈哈镜制作(8)
时间:2025-04-20
时间:2025-04-20
vc++实现图像放大、缩小、平移、旋转、各种哈哈镜变形
for(int k=0;k<pImg->nChannels;k++) {
pImg1->imageData[i*pImg1->widthStep+j*pImg->nChannels+k]=pImg->imageData[i*pImg->widthStep+s*pImg->nChannels+k];
} break;
}
}
// 梯形变形 case LADDER:
pImg1 = cvCreateImage(cvGetSize(pImg),pImg->depth,pImg->nChannels); for(i=0;i<pImg1->height;i++) {
tmp=(pImg1->width-RANGE)/2-i*(pImg1->width-RANGE)/(2*pImg1->height); for(j=tmp;j<pImg1->width-tmp;j++) {
int s=(int)((j-tmp)*(pImg->width)/(pImg->width-2*tmp)); for(int k=0;k<pImg->nChannels;k++) {
pImg1->imageData[i*pImg1->widthStep+j*pImg->nChannels+k]=pImg->imageData[i*pImg->widthStep+s*pImg->nChannels+k];
} break;
}
}
// 三角形变形 case TRIANGLE:
pImg1 = cvCreateImage(cvGetSize(pImg),pImg->depth,pImg->nChannels); for(i=1;i<pImg1->height;i++) {
for(j=1;j<i*pImg1->width/pImg1->height;j++) {
int s = (int)(pImg1->height*j/i); for(int k=0;k<pImg->nChannels;k++) {
pImg1->imageData[i*pImg1->widthStep+j*pImg->nChannels+k]=pImg->imageData[i*pImg->widthStep+s*pImg->nChannels+k];
}
}
}
上一篇:了不起的盖茨比英语毕业论文