Read grayscale image into array
Hi all, I am absolutely new to openCV, and I need to read tif grayscale image into array of floats in order process it with my GPU kernel. Here is the code:
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
Mat image,image1;
string a = "C:\\programs\\misha\\pic-1.tif";
image = imread(a, CV_32F); // Read the file
float *b;
b = image.data;
return 0;
}
The error is: cannot convert from *uchar to *float. I tried to to do b = (float*)image.data
, but there was a trash in array b after that.
I tried also to convert image to CV_32F
. As I understand, Image.data must return me pointer to the data. I use 0-based row-major order in my GPU code. The speed of reading is also very important for me, so I need the fastest way to do it.
Thanks