How to prevent imwrite from rounding my data?

1 view (last 30 days)
Harrison Biggs
Harrison Biggs on 11 Aug 2017
Edited: Jan on 11 Aug 2017
So, I am working with temperature data in a range of 0 to 500 degrees. This data is taken from a FLIR camera, so the data is saved in a multi frame tiff file. I run this data through my first script to single out my area of interest. I then save the data to another multi frame tiff file with the imwrite function. In my data, each value has at least 4 decimal points. imwrite can write data to a tiff in int8-64 format, and in double format. in the int formats it rounds to the nearest whole number. In double format it assumes a dynamic range of [0,1] and scales the data. So my question is: how do i write this data to a tiff file without loosing my decimals or limiting the data to a maximum of 255?
EDIT: The data goes through another script to pull temperatures at specific pixels, and those selected points are plotted on a 18-19 scaled plot and a 18-500 scaled plot
  1 Comment
Adam
Adam on 11 Aug 2017
What are you going to do with the tiff afterwards? You can scale the data to a 0-1 range and then just scale it back up again when you use the tiff.

Sign in to comment.

Answers (1)

Jan
Jan on 11 Aug 2017
TIFF images are not the best idea to store data in a high precision. You can use a 16-bit TIFF image, but a binary file might be much easier.
  2 Comments
Harrison Biggs
Harrison Biggs on 11 Aug 2017
Can I use a binary file for multiple frames? I've never used a binary file
Jan
Jan on 11 Aug 2017
Edited: Jan on 11 Aug 2017
If you want to store the values without any limitations in the precision, you can store the data as MAT file or by:
fid = fopen(FileName, 'w');
fwrite(fid, ndims(data), 'uint64');
fwrite(fid, size(data), 'uint64');
fwrite(fid, data, 'double');
fclose(fid);
You have to decide how to store the meta-data like array size and so on.
TIFFs are image files. I did not exactly understand, which demands you have for the precision, but perhaps the limitations are not sufficient. But if you want to store the data as image files, the binary format is not optimal. As far as I can see, Matlab's TIFF export allows 8 bits per channel only.

Sign in to comment.

Categories

Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!