Ask Your Question

Calculation on 16 bit images

asked 2013-03-14 06:21:54 -0500

eyal gravatar image

Hi All,

Does openCV support 16 bit image calculations? say for example I have 16 bit image and I want to compute gradient of the image now the result may be greater than 16 bit image...any ideas?

Thank u in advance

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-03-14 06:30:53 -0500

berak gravatar image

updated 2013-03-14 06:41:02 -0500

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 )


for gradients, you probably want floats:


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

edit flag offensive delete link more


i see....thank u for ur answer!

eyal gravatar imageeyal ( 2013-03-14 13:37:03 -0500 )edit
Login/Signup to Answer

Question Tools


Asked: 2013-03-14 06:21:54 -0500

Seen: 2,283 times

Last updated: Mar 14 '13