Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

yes, say you got a 16 bit grayscale ( CV_16S ) , you can just convert it to a 32bit one:

Mat m16; // from somewhere
Mat m32; // our new one (no, you don't have to alloc anything before )

m16.convertTo(m32,CV_32S);

yes, say you got a 16 bit grayscale ( CV_16S ) , you can just convert it to a 32bit one:

Mat m16; // from somewhere
Mat m32; // our new one (no, you don't have to alloc anything before )

m16.convertTo(m32,CV_32S);

for gradients, you probably want floats:

m16.convertTo(m32,CV_32F);

maybe even in the [0-1] range:

m16.convertTo(m32,CV_32F, 1.0/65536.0);  

// do your calculations, (maybe normalize your results) and convert back

m32.convertTo(m16,CV_16S);

say you got a 16 bit grayscale ( CV_16S ) , you can just convert it to a 32bit one:

Mat m16; // from somewhere
Mat m32; // our new one (no, you don't have to alloc anything before )

m16.convertTo(m32,CV_32S);

for gradients, you probably want floats:

m16.convertTo(m32,CV_32F);

maybe even in the [0-1] range:

m16.convertTo(m32,CV_32F, 1.0/65536.0);  1.0/65536.0);
//

do your calculations, (maybe normalize your results) and convert back back

m32.convertTo(m16,CV_16S);