tags:

views:

40

answers:

1

Hi all,

How can i change the datatype used in storing the pixels in a Mat class instance?

For example after reading an image using the line below

Mat I = imread(file,0);

i obtain a grayscale image with pixels of type unsigned char. I want to change this to a double.

What's the best way to do the conversion? I wasn't able to find a function to do that.

Thanks in advance

A: 

It is very simple. See the documentation at OpenCV website.

Basically do

Mat double_I;
I.convertTo(double_I, CV_64F);
Dat Chu
Thanks for the answer. Now i see why i didn't see that method. Because it is wrongly typed as copyTo in the methods list on the left part of the page.
sct