Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I eventually decided to get my multichannel matrix by looping through the entire array. Below, m_textures is the 1D array. Not sure if this will be good enough in terms of speed.

//fill up m_textures array whose dimension is [512,512,100]

//convert back to opencv format
cv::Mat cv_textures = cv::Mat(cv::Size(image.cols, image.rows), CV_64FC(100));  
for (int row = 0; row < image.rows; row++)  
for (int col = 0; col < image.cols; col++)
    for (int channel = 0; channel < n_channels; channel++)
    {
        cv_textures.at<cv::Vec<double, n_channels>>(row, col)[channel]
            = m_textures->data[col + row * image.col+ channel * image.rows * image.cols];
    }

I eventually decided to get my multichannel matrix by looping through the entire array. Below, m_textures is the 1D array. Not sure if this will be good enough in terms of speed.

//fill up m_textures array whose dimension is [512,512,100]

//convert back to opencv format
cv::Mat cv_textures = cv::Mat(cv::Size(image.cols, image.rows), CV_64FC(100));  
for (int row = 0; row < image.rows; 512; row++)  
for (int col = 0; col < image.cols; 512; col++)
    for (int channel = 0; channel < n_channels; 100; channel++)
    {
        cv_textures.at<cv::Vec<double, n_channels>>(row, 100>>(row, col)[channel]
            = m_textures->data[col + row * image.col+ 512 + channel * image.rows 512 * image.cols];
512];
    }