Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I want to convert 16UC3 image to 1 dimensional array?

I'm unable to access the values in the matrix properly. for (int i = 0; i < image.rows; i++) { for (int j = 0; j < image.cols; j++) { img[j + image.colsi + image.colsimage.rows * 0] = image.at<cv::vec3b>(i, j)[0]; img[j + image.colsi + image.colsimage.rows * 1] = image.at<cv::vec3b>(i, j)[1]; img[j + image.colsi + image.colsimage.rows * 2] = image.at<cv::vec3b>(i, j)[2]; } }

I want How to convert 16UC3 image to 1 dimensional array?

I'm unable to access the values in the matrix properly. for (int i = 0; i < image.rows; i++) { for (int j = 0; j < image.cols; j++) { img[j + image.colsi + image.colsimage.rows * 0] = image.at<cv::vec3b>(i, j)[0]; img[j + image.colsi + image.colsimage.rows * 1] = image.at<cv::vec3b>(i, j)[1]; img[j + image.colsi + image.colsimage.rows * 2] = image.at<cv::vec3b>(i, j)[2]; } }

click to hide/show revision 3
No.3 Revision

updated 2016-10-26 02:02:46 -0600

berak gravatar image

How I want to convert 16UC3 image to 1 dimensional array?

I'm unable to access the values in the matrix properly. properly.

for (int i = 0; i < image.rows; i++)
    {
        for (int j = 0; j < image.cols; j++)
        {
            img[j + image.colsi image.cols*i + image.colsimage.rows image.cols*image.rows * 0] = image.at<cv::vec3b>(i, image.at<cv::Vec3b>(i, j)[0];
            img[j + image.colsi image.cols*i + image.colsimage.rows image.cols*image.rows * 1] = image.at<cv::vec3b>(i, image.at<cv::Vec3b>(i, j)[1];
            img[j + image.colsi image.cols*i + image.colsimage.rows image.cols*image.rows * 2] = image.at<cv::vec3b>(i, image.at<cv::Vec3b>(i, j)[2];
        }
    }

}