#include <iostream> #include <opencv2\opencv.hpp> #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include "stdio.h" using namespace std; using namespace cv; int main(int argc,char *argv[]) { Mat img1=imread("1.JPG"); Mat img2; //将原图像变为40×30 resize(img1,img2,Size(40,30),0,0,CV_INTER_LINEAR); namedWindow("WindowOrg"); namedWindow("WindowNew"); imshow("WindowOrg",img1); imshow("WindowNew",img2); imwrite( "改变后.JPG", img2); waitKey(); }
可以在项目文件中找到改变后的图像,可用photoshop查看图像像素大小已改变。
时间: 2024-11-13 06:46:22