, pImg );//显示图像
?printf("imageSize: %d height: %d, width: %d, nChannels: %d\n", pImg->imageSize, pImg->height, pImg->width, pImg->nChannels);
?//MaxFrame(pImg);
?//MinFrame(pImg);
?switch(method)
?{
? // 图像缩小
?case DOWNRESIZE:
? size = cvGetSize(pImg);
? size.width = (size.width>>3)<<2; // 在OpenCV里边,widthStep必须是4的倍数,从而实现字节对齐,有利于提高运算速度。
? size.height =? size.height>>1;
? pImg1 = cvCreateImage( size, IPL_DEPTH_8U, 1);
? printf("imageSize: %d height: %d, width: %d, nChannels: %d\n", pImg1->imageSize, pImg1->height, pImg1->width, pImg1->nChannels);
? for(i=0;iheight;i++)
? ?for(j=0;jwidth;j++)
? ?{
? ? pImg1->imageData[i*pImg1->width+j] = pImg->imageData[i*2*pImg->width+j*2];
? ?}
? ?break;
? ?// 图像放大
?case UPRESIZE:
? /* 添加代码 */
? break;
? // 水平外凹
?case HORAO:
? pImg1 = cvCreateImage( cvGetSize(pImg), IPL_DEPTH_8U, 1);
? printf("imageSize: %d height: %d, width: %d, nChannels: %d\n", pImg1->imageSize, pImg1->height, pImg1->width, pImg1->nChannels);
? for(i=0;iheight;i++)
? {
? ?tmp = RANGE*sin(i*PI/pImg1->height);
? ?for(j=tmp;jwidth-tmp;j++)
? ?{
? ? pImg1->imageData[i*pImg1->width+j] = pImg->imageData[i*pImg->width+(int)((j-tmp)*(pImg->width)/(pImg->width-2*tmp))];
? ?}
? }
? break;
? // 水平外凸
?case HORTU:
? /* 添加代码 */
? break;
? // 梯形变形
?case LADDER:
? /* 添加代码 */
? break;
? // 三角形变形
?case TRIANGLE:
? /* 添加代码 */
? break;
? // S形变形
?case SSHAPE:
? /* 添加代码 */
? break;
? // 波浪形变形
?case WAVESHAPE:
? /* 添加代码 */
? break;
?case Concentrated:
? MaxFrame(pImg);
? break;
?case Scattered:
? MinFrame(pImg);
? break;
?default:
? printf("no method support\n");
? break;
?}
?// 显示结果
?cvNamedWindow( "Image1", 1 );//创建窗口
?cvShowImage( "Image1", pImg );//显示图像
?cvWaitKey(0); //等待按键
?//销毁窗口 释放内存
?cvDestroyWindow( "Image" );//销毁窗口
?cvReleaseImage( &pImg ); //释放图像
?cvDestroyWindow( "Image1" );//销毁窗口
?cvReleaseImage( &pImg1 ); //释放图像
?return 0;
}
未完待续。。应该还有其他的算法,我再找找。
--------------------------------------分割线 --------------------------------------
--------------------------------------分割线 --------------------------------------