0
点赞
收藏
分享

微信扫一扫

opencv c++学习四(调整大小 裁剪)

青乌 2022-01-31 阅读 60
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <iostream>

using namespace cv;
using namespace std;

/// Resize and Crop //

void main() {

	string path = "Resources / test.png";
	Mat img = imread(path);
	Mat imgResize, imgCrop;

    /*Size可以自定义宽度与高度*/
    /*或者按比例缩放*/
	resize(img, imgResize, Size(), 0.5, 0.5);
    
    /*(200,100)理解成为出发点坐标*/
    /*300 300 是往外延伸的长度*/
	Rect roi(200, 100, 300, 300);
	imgCrop = img(roi);

	imshow("Image", img);
	imshow("Image Resize", imgResize);
	imshow("Image Crop", imgCrop);
	waitKey(0);
}
举报

相关推荐

0 条评论