0
Ich habe eine 640 x 480 CV_8UC3
Mat image
und möchte die K-Means-Segmentierung durchführen. Also muss ich es in CV_32F
umwandeln (kein Problem hier), umgestalten und k-means ausführen.OpenCV: Mat :: reshape() tut nichts
Das Problem ist reshape()
tut nichts:
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
Bin ich etwas falsch?
Ja, ich habe gerade eine ähnliche Antwort geschrieben, nachdem ich [diese Frage] gelesen habe (http://stackoverflow.com/questions/13400239/reshaping-a-matrix-failed-in-opencv-2-4-3). Ihnen fehlt offensichtlich die Rückgabewertbeschreibung in der Dokumentation ... – Alex
Tatsächlich zeigt der [doc] (http://docs.opencv.org/master/d3/d63/classcv_1_1Mat.html#a4eb96e3251417fa88b78e2abd6cfd7d8), dass der Rückgabewert ein 'ist Mat', aber wahrscheinlich ist es nicht klar genug. – Miki