如何调整图像大小(使用 opencv resize 函数) [英] How to resize image size (use opencv resize function)

查看:85
本文介绍了如何调整图像大小(使用 opencv resize 函数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是原图.

例如,原始图像大小为 1280x720.红色矩形大小为 30x5.如果你知道矩形顶点坐标.

For example, original image size is 1280x720. Red rectangle size is 30x5. If you know the rectangle vertex coordinates.

我想使用 opencv 调整大小功能将矩形区域调整为 5x1.那么,该怎么做呢?

I want resize to rectangle area by 5x1 using opencv resize function. So, how to do it?

推荐答案

你说你已经知道红色矩形的坐标了.因此,使用 rect()<创建(感兴趣区域)ROI/a>.然后,使用 openCV 的 resize() 调整其大小.

You said that you already know the coordinates of red rectangle. So, create a (region of interest) ROI using rect(). And, then resize its size using the resize() of openCV.

Mat original_image;
----
----
----
Rect region_of_interest(x, y, w, h);
Mat image_roi = image(region_of_interest);

Size size(5,1);   //the dst image size,e.g.5 x 1
Mat dst;          //dstimage
resize(image_roi ,dst,size);  //resize image

这篇关于如何调整图像大小(使用 opencv resize 函数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆