How to read image as double in OpenCV?

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

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

I implemented something like this. How to convert it to double.

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

where arg[1]contains my image, which should be stored in the Matimage as a double. How to implement it.

+4
source share
1 answer

You are looking for . Mat::convertTo()

  • For grayscale images:

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

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

Source: https://habr.com/ru/post/1527648/


All Articles