C++ 调整图像大小 OpenCV

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23984191/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 00:36:45  来源:igfitidea点击:

Resize image OpenCV

c++opencvresize

提问by Clip

If I have an image called inImgand an image named outImghow can I resize outImgso that it is 75% the size of inImg?

如果我有一个名为的图像inImg和一个名为的图像,outImg我如何调整大小outImg使其为 75% 的大小inImg

回答by Yeraze

If you want 75% along each axis, you should be able to use cv::resizeto do:

如果你想沿着每个轴 75%,你应该能够使用cv::resize来做:

cv::resize(inImg, outImg, cv::Size(), 0.75, 0.75);

回答by Pervez Alam

Use cv::resize. Following code will resize outImg to 0.75 times the dimensions of inImg with CV_INTER_LINEAR type of interpolation.

使用cv::resize. 以下代码将使用 CV_INTER_LINEAR 类型的插值将 outImg 的大小调整为 inImg 尺寸的 0.75 倍。

cv::resize(outImg, outImg, cv::Size(inImg.cols * 0.75,inImg.rows * 0.75), 0, 0, CV_INTER_LINEAR);

4th and 5th argument should be left 0 or not assigned to take 3rd argument as size otherwise it will scale according to 4th and 5th arguments. (OpenCV3 resize)

第 4 个和第 5 个参数应保留为 0 或不分配以将第 3 个参数作为大小,否则它将根据第 4 个和第 5 个参数进行缩放。(OpenCV3 调整大小