-1

私は次のコードを持っています。これは私がフォローしているアルゴリズムの一部です。ご覧のとおり、10の異なるバンドについて計算を行う必要があります。そして、そこから画像を再作成する必要がある各バンドのマトリックスになります。問題は、whileループで10の異なるマトリックスを作成/保持する方法がわからないことです。その後、whileループの後に、画像を1枚ずつ。何かアイデアがあれば教えてくださいありがとうございます

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++;
}
4

1 に答える 1

7

あなたの質問は少し曖昧です。しかし、単純に質問している場合は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);

これがあなたが探しているものではない場合は、あなたの質問にもっと詳細を提供してください。

于 2012-05-23T14:05:52.477 に答える