MATLAB Answers


To write a single datatype image in .tif format.

Asked by Rana Banik on 12 Jun 2019
Latest activity Commented on by Rana Banik on 13 Jun 2019
I am trying to save an image without changing it's single data type and in .tif format. I have tried Matlab TIFF function and it worked good for int32 images. But it doesn't work with single type I figure. Also, when I tried to use simple imwrite function, it errored because single type must be converted to double. But when I change to double, I lose the image data as double scales the image to 255.
Would be great help if any hack suggested.


Sign in to comment.

1 Answer

Answer by Walter Roberson
on 13 Jun 2019

  1 Comment

Hey @Walter Roberson,
I just found the solution in the TIFF function. There is a function parameter called tagStruct.SampleFormat, which is 2 for int32 and all and 3 for single data type. Changing that from 2 to 3 worked really fine.
But I will also check the link you've provided. Thanks a lot.

Sign in to comment.