OpenCV :创建矩阵或矩阵向量
opencv : create matrix or vector of matrices
我有以下代码,这是我遵循的算法的一部分。 如您所见,我需要对 10 个不同的波段进行一些计算。 并且最终会为每个波段创建一个矩阵,我需要从中重新创建图像, 问题是我不知道如何在while循环中创建/保存10个不同的矩阵, 然后在while循环之后,我可以一一构建图像。如果您有任何想法,请告诉我谢谢
cv::Mat _reconstructionMatrix(height,width,CV_8UC1);
_reconsPointer = _reconstructionMatrix.ptr<uchar>(0);
while(_bandIteration<_bandsNumber){
if(_mainMatrix.isContinuous())
{
nCols *= nRows;
nRows = 1;
}
//for all the pixels
for(int i = 0; i < nRows; i++)
{
p = _mainMatrix.ptr<uchar>(i);
//in the images
for (int j = 0; j < nCols; j++)
{
if(_pCounter<_totalImgNO){
....
}else{
...
_reconsPointer[_resultFlag]=_summation;
_resultFlag++;
...
}
}
}
_bandIteration++;
}
你的问题有点模糊。但是,如果您只是问how to create/hold the 10 different matrix on the while loop?
那么您可以正常使用 STL 向量。
#include<vector>
...
std::vector<cv::Mat> listOfMatrices;
...
cv::Mat M = SomehowGetMatrix();
listOfMatrices.push_back(M);
如果这不是您要找的,那么请为您的问题提供更多详细信息。
相关文章:
- 如何在C++或OpenCV子矩阵中的2D子向量上使用OpenACC?
- OpenCV 向量 x 矩阵互相关
- 如何使用opencv从矩阵向量中构建图像
- OPENCV:将不同的向量附加为一行
- 调整OpenCV Mat向量向量的大小时出乎意料的结果
- 如何通过MEX将OpenCV C 垫的向量返回到MATLAB
- OPENCV图像处理,向量下标超出范围
- 在OpenCV中将向量转换为垫子
- 从矩阵复制列向量到OpenCV中另一个矩阵的每个col
- 如何初始化包含OpenCV的2D向量:矩阵
- 将垫子的向量转换为垫子文件,以便使用OpenCV SVM
- 如何使用OpenCV将向量向量的结构复制到另一个向量C++
- 从向量中擦除 opencv 矩形对象
- 如何将来自不同图像的多个描述符存储在C++和OpenCV中的向量向量中
- 在 OpenCV 中将向量转换为行或将空垫转换为行的有效方法
- OpenCV 角检测返回零角向量
- 在 opencv 中从每行矩阵中减去一个向量
- 如何在 OpenCV 中声明向量
- OpenCV查找轮廓的示例代码:向量释放问题
- Opencv C++读取分配给特征向量的Opencv Mat