简体   繁体   English

OpenCV调整大小更改值

[英]OpenCV Resize changes values

maybe this is very simple, but somehow I can't figure out what's wrong. 也许这很简单,但是我不知道怎么了。 I have a single columns cv::Mat which I wish to resize to a square matrix. 我只有一列cv :: Mat,我希望将其调整为方形矩阵。 This is the code: 这是代码:

int matSize = 5;
Mat src(matSize, 1, CV_8UC1);
//Fill src with data...(all ones but one zero)
cout << "src:\n" << src << endl;

Mat output(matSize, matSize, CV_8UC1);
resize(src.t(), output, output.size());
cout << "output:\n"output << endl;

The output looks like this: 输出看起来像这样:

src:
[1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
output:
[1, 1, 1, 1, 1;
1, 1, 1, 1, 1;
1, 1, 1, 1, 1;
1, 1, 1, 1, 1;
1, 1, 1, 1, 1]

So the zero gets lost! 所以零迷路了! I need this in a bigger context, but wish to get it to work in a small scale first. 我需要在更大的范围内使用它,但希望首先使其在小规模下工作。 Please help! 请帮忙!

我自己解决了这个问题,正确的函数是“重塑”而不是“缩放”,后者用于“缩放”矩阵,而不是更改其标头以获取对数据的不同访问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM