Hi team, I work with a team that uses MATLAB for image analysis. They trade floating point TIFF files for analysis. I am working through the simple read/write tutorials but am frustrated by the fact that I cannot write out a floating point TIFF file.
here is some code I've been using:
#include <stdio.h>
#include <opencv2/opencv.hpp>
using namespace cv;
int main(int argc, char** argv )
{
if ( argc != 4 )
{
printf("usage: DisplayImage.out <Image_Path>\n");
return -1;
}
//read images from memory
Mat A;
A = imread( argv[1], CV_LOAD_IMAGE_UNCHANGED );
Mat B;
B = imread( argv[2], CV_LOAD_IMAGE_UNCHANGED );
Mat C;
C = imread( argv[3], CV_LOAD_IMAGE_UNCHANGED );
//create floating point images for image manipulation
Mat Aa;
A.convertTo(Aa,5);
Mat Bb;
B.convertTo(Bb,5);
Mat Cc;
C.convertTo(Cc,5);
if ( (!Aa.data) || (!Bb.data) || (!Cc.data) )
{
printf("Missing image data \n");
return -1;
}
//subtract dark field from source image
Mat D;
D = Aa - Bb;
Mat E;
E = Cc/D;
//save intermediate images
imwrite("D.tiff",D);
imwrite("E.tiff",E);
//save image
return 0;
}
This code compiles fine, and runs, yet it saves no images. If I rewrite the code to work with 16 bit images, it works fine. What's going on?
Thanks in advance!