I have a 640 x 480 CV_8UC3
Mat image
and want to perform the k-means segmentation. So I need to convert it to CV_32F
(no problem here), reshape it, and run k-means.
The problem is reshape()
does nothing:
cv::Mat colorMat;
image.convertTo (colorMat, CV_32FC3);
std::cout << colorMat.size () << "; ch: " << colorMat.channels () << std::endl; // [640 x 480]; ch: 3
colorMat.reshape (1, colorMat.rows * colorMat.cols); // Here I expect it to become [307200 x 3], 1 channel - each column representing a color component
std::cout << colorMat.size () << "; ch: " << colorMat.channels () << std::endl; // [640 x 480]; ch: 3
Am I doing something wrong?