Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

looking at the docs for imread, it seems, that raw files are not supported.

you'll have to load the pixels manually, and then build a Mat from that:

#include <stdio.h>
char * imgpath = "1.IMG";
FILE * f = fopen(imgpath,"rb");
if ( ! f )
    printf("bad path : %s\n",imgpath);
    return -1;
char pixels[256*256];

Mat img(256,256,CV_U8C1,pixels);

if there's any chance, that your original pixel ptr will go out of scope, you'll have to additionally clone the Mat, to have its own copy of the pixels:

Mat img = Mat(256,256,CV_U8C1,pixels).clone();