使用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;//縮放倍數(shù)
CvSize czSize; //目標(biāo)圖像尺寸
//從文件中讀取圖像
IplImage *pSrcImage = cvLoadImage(pstrImageName, CV_LOAD_IMAGE_UNCHANGED);
IplImage *pDstImage = NULL;
//計算目標(biāo)圖像大小
czSize.width = pSrcImage->width * fScale;
czSize.height = pSrcImage->height * fScale;
//創(chuàng)建圖像并縮放
pDstImage = cvCreateImage(czSize, pSrcImage->depth, pSrcImage->nChannels);
cvResize(pSrcImage, pDstImage, CV_INTER_AREA);
//創(chuàng)建窗口
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;
}
相關(guān)文章
C語言的可變參數(shù)函數(shù)實現(xiàn)詳解
某些情況下我們希望函數(shù)的參數(shù)個數(shù)可以根據(jù)需要確定,因此c語言引入可變參數(shù)函數(shù)。典型的可變參數(shù)函數(shù)的例子有printf()、scanf()等,下面我就開始講解2021-08-08C語言三種函數(shù)調(diào)用約定_cdecl與_stdcall及_fastcall詳細(xì)講解
本篇文章使用的工具是vs2010,內(nèi)容可能涉及到匯編的知識,建議有一些匯編基礎(chǔ)的再來看,不過沒有匯編基礎(chǔ)也沒有關(guān)系,了解一下這三種調(diào)用約定即可2022-10-10Windows下sentry接入C/C++程序的詳細(xì)過程
sentry作為一個開源的軟件,發(fā)展至今,已經(jīng)非常成熟。它支持的平臺眾多,甚至于針對不同的工作者(后臺、前端、客戶端)都有相應(yīng)的內(nèi)容,這篇文章主要介紹了Windows下sentry接入C/C++程序,需要的朋友可以參考下2022-09-09