Ask Your Question

Revision history [back]

If it's an image:

cv::Mat myMat, myMatGrayScale;
cv::imread( "mypicture.jpg/png/tiff/...", myMat );
cv::cvtColor( myMat, myMatGrayScale, cv::COLOR_BGR2GRAY );

If it's a text file: load it into a char buffer, create a Mat with that buffer:

char* buffer;
// Allocate buffer, read pixel values from the text file (suppose grayscale)
cv::Mat myMat( NbRows, NbCols, CV_8UC1, buffer );