應用opencv拉伸圖象擴展分辯率示例。本站提示廣大學習愛好者:(應用opencv拉伸圖象擴展分辯率示例)文章只能為提供參考,不一定能成為您想要的結果。以下是應用opencv拉伸圖象擴展分辯率示例正文
應用OPENCV圖象處置庫,拉伸圖象擴展分辯率
//縮放圖象文件
#include <opencv2/opencv.hpp>
using namespace std;
//隱蔽掌握台窗口
#pragma comment(linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"")
int main()
{
const char *pstrImageName = "airplane.jpg";
const char *pstrSaveImageName = "airplane縮放圖.jpg";
const char *pstrWindowsSrcTitle = "原圖";
const char *pstrWindowsDstTitle = "縮放圖";
double fScale = 2;//縮放倍數
CvSize czSize; //目的圖象尺寸
//從文件中讀取圖象
IplImage *pSrcImage = cvLoadImage(pstrImageName, CV_LOAD_IMAGE_UNCHANGED);
IplImage *pDstImage = NULL;
//盤算目的圖象年夜小
czSize.width = pSrcImage->width * fScale;
czSize.height = pSrcImage->height * fScale;
//創立圖象並縮放
pDstImage = cvCreateImage(czSize, pSrcImage->depth, pSrcImage->nChannels);
cvResize(pSrcImage, pDstImage, CV_INTER_AREA);
//創立窗口
cvNamedWindow(pstrWindowsSrcTitle, CV_WINDOW_AUTOSIZE);
cvNamedWindow(pstrWindowsDstTitle, CV_WINDOW_AUTOSIZE);
//在指定窗口中顯示圖象
cvShowImage(pstrWindowsSrcTitle, pSrcImage);
cvShowImage(pstrWindowsDstTitle, pDstImage);
//期待按鍵事宜
cvWaitKey();
//保留圖片
cvSaveImage(pstrSaveImageName, pDstImage);
cvDestroyWindow(pstrWindowsSrcTitle);
cvDestroyWindow(pstrWindowsDstTitle);
cvReleaseImage(&pSrcImage);
cvReleaseImage(&pDstImage);
return 0;
}