I use OpenCV to read the image. Then I use Matlab to load the same image. Then I display the images. For OpenCV loaded image, the image is has no picture inside and just gray plane. For Matlab loaded image, it has the image what I want. The image pixel values are very small floating point data like 0.0021. The code I used to load the image is shown as follow.
`Mat image(IMAGE_ROW, IMAGE_COL, CV_64FC3);
Mat gray(IMAGE_ROW, IMAGE_COL, CV_64FC1);
image = imread(filespath, CV_LOAD_IMAGE_COLOR );// Read the file
cv::imshow("Image", image);
cvtColor( image, gray, CV_BGR2GRAY, 1);
cv::imshow("gray", gray);`
Why I can't have the same image as loaded by Matlab?
well you can't do it with imwrite()/imread() as stated before.
but you can save/load floating point Mats using the FileStorage, like this:
Mat fm = Mat::ones(3,3,CV_32FC3); // dummy data
FileStorage fs("my.yml", FileStorage::WRITE );
fs << "mat1" << fm; //choose any key here, just be consistant with the one below
and read back in:
Mat fm;
FileStorage fs("my.yml", FileStorage::READ );
fs["mat1"] >> fm;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With