Is there a function in c++ using opencv which allows to convert an image to double precision as im2double in MATLAB? -


i'm translating code developed in matlab c++ using opencv. i'm loading image in rgb format like:

mat img;  img = imread('path directory', cv_load_image_color); 

i want convert image double precision im2double() in matlab. there function allows it? can use convertto() function?

i tried do:

img.convertto(img, cv_64fc3, 255.0); 

but it's not working. me?

update: thank answers. i'm doing like

int i, k; mat img, img_dbprec;  img = imread('path directory', cv_load_image_color); //loads image in rgb format img.convertto(img_dbprec, cv_64fc3,1.0/255.0);//convert image double precision for(i=0; i<img_dbprec.rows; i++){    for(k=0; k<img_dbprec.cols; k++){        cout << (double) img_dbprec.data[img_dbprec.step[0]*i + img_dbprec.step[1]* k + 0] << " ";        cout << (double) img_dbprec.data[img_dbprec.step[0]*i + img_dbprec.step[1]* k + 1] << " ";        cout << (double) img_dbprec.data[img_dbprec.step[0]*i + img_dbprec.step[1]* k + 2] << endl;     } } 

my output (i put final values):

...  150 150 150 21 21 21 85 85 85 214 213 213 22 22 22 22 22 22 214 213 213 85 85 85 21 21 21 

which not want. can tell me i'm doing wrong?

it seems scale factor inverted. try:

mat dimg; img.convertto( dimg, cv_64fc3, 1.0/255.0 ); 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -