Create matrix from pixel array in opencv

I have an unsigned short array that I would like to process with a median using opencv (it seems to have one of the most efficient filters)

However, I cannot create a matrix from an array. I tried the Mat constructor (int _rows, int _cols, int _type, void * _data, size_t _step = AUTO_STEP) using:

Mat(rows,cols,IPL_DEPTH_16U,myShortArray,2);

But that does not work. What am I doing wrong?

+3
source share
1 answer

Try

Mat m(rows, cols, CV_16U, myShortArray);
+7
source