Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 882
kadu Avatar asked Feb 19 '14 05:02

kadu


People also ask

How do I combine two images in OpenCV?

OpenCV-Python uses the addWeighted() function to blend images. The function and its parameters are as follows. src1- first input array. alpha- weight of the first array elements.

What format is the image read in using OpenCV?

OpenCV offers support for the image formats Windows bitmap (bmp), portable image formats (pbm, pgm, ppm) and Sun raster (sr, ras).

What is cv2 addWeighted?

The addWeighted function is a function that helps in adding two images and also blending those by passing the alpha, beta and gamma values. In order to analyse images, this helps in adjusting the gradients and in the processing of the image.

What is Vec3b OpenCV?

Vec3b is the abbreviation for "vector with 3 byte entries" Here those byte entries are unsigned char values to represent values between 0 .. 255.


1 Answers

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
    
like image 151
herohuyongtao Avatar answered Oct 10 '22 06:10

herohuyongtao