First time here? Check out the FAQ!

Ask Your Question
1

Calculation on 16 bit images

asked Mar 14 '13

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

Preview: (hide)

1 answer

Sort by » oldest newest most voted
3

answered Mar 14 '13

berak gravatar image

updated Mar 14 '13

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);
Preview: (hide)

Comments

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

eyal gravatar imageeyal (Mar 14 '13)edit

Question Tools

Stats

Asked: Mar 14 '13

Seen: 2,639 times

Last updated: Mar 14 '13