<opencv>第七课 调整裁剪

1
void cv::resize(InputArray src, OutputArray dst, Size dsize, double fx=0, double fy=0, int interpolation = INTER_LINEAR)

调整图像的大小。函数 resize 将图像 src 的大小缩小到或最大到指定的大小。请注意,不考虑初始 dst 类型或大小。相反,大小和类型是从 src、dsize、fx 和 fy 派生的。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
    std::string path = "../lesson1_pictureRead/img1.jpg";
    cv::Mat img = imread(path);
    cv::Mat imgResize, imgCrop;
    std::cout << img.size() << std::endl;
    resize(img, imgResize, Size(), 0.5, 0.5);
    Rect my_roi(200, 100, 300, 300);
    imgCrop = img(my_roi);
    imshow("Image", img);
    imshow("ImageResize", imgResize);
    imshow("ImageCrop", imgCrop);
    waitKey(0);
    return 0;
}


“觉得不错的话,给点打赏吧 ୧(๑•̀⌄•́๑)૭”

微信二维码

微信支付

支付宝二维码

支付宝支付

<opencv>第七课 调整裁剪
https://hermione20.github.io/2024/10/14/第7课 调整裁剪/
作者
TC
发布于
2024年10月14日
许可协议