Ask Your Question
1

Calculation on 16 bit images

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

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
3

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

berak gravatar image

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

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);
edit flag offensive delete link more

Comments

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

eyal gravatar imageeyal ( 2013-03-14 13:37:03 -0600 )edit

Question Tools

Stats

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

Seen: 2,627 times

Last updated: Mar 14 '13