kadu
kadu

Reputation: 513

How to read an image as double in OpenCV?

I want to implement a similar function as shown below using the opencv.

image=double(imread('mask.jpg'));

I have implemented something like this.How to convert this into double.

cv::Mat image= imread(arg[1]);

where arg[1] contains my image which is to be stored in Mat image as double. How to implement this.

Upvotes: 7

Views: 12398

Answers (1)

herohuyongtao
herohuyongtao

Reputation: 50657

You're looking for Mat::convertTo().

  • For gray-scale image:

    image.convertTo(image, CV_64FC1);
    
  • For color image:

    image.convertTo(image, CV_64FC3); // or CV_64FC4 for 4-channel image
    

Upvotes: 12

Related Questions