hs100
hs100

Reputation: 496

Big tiff read and view in Matlab

I have downloaded a btf file (big tiff) from the links below, how can I read it and "imshow" it? is there a way to convert it to tiff format as the btf is not that common?

Link:

https://drive.google.com/file/d/0ByhuP_NuuARtSW9aeTdPUTlRdWM/view?usp=drive_web

http://www.photomacrography.net/forum/viewtopic.php?t=28990&sid=cca737a2e0bc7ea3e2e41f0d6e75f5a9

I used this code:

t = Tiff('d:/Image_687.btf','w8');
imageData = read(t);

and got this error:

Error using tifflib Unable to retrieve PhotometricInterpretation.

Error in Tiff/getTag (line 838) tagValue = tifflib('getField',obj.FileID,Tiff.TagID.(tagId));

Error in Tiff/read (line 1487) photo = obj.getTag('Photometric');

Error in Untitled2 (line 2) imageData = read(t);

Upvotes: 2

Views: 1783

Answers (1)

Suever
Suever

Reputation: 65460

The real issue with your code is the second parameter that you have passed to Tiff. As the documentation states, the second parameter indicates in what mode to open the file. You have specified w8 which the documentation states is:

open TIFF file for writing a BigTIFF file; discard existing contents.

This means that it is deleting your image before you even start! If you want to use the Tiff class, you'll want to either use no second parameter or the r parameter to open the file for reading.

t = Tiff('Image_687.btf');
t = Tiff('Image_687.btf', 'r');

That being said, in general it is better to try to load it with a higher level function such as imread. The Tiff class is a much lower-level function that can be a little harder to manipulate but may provide some needed specialty functionality.

 im = imread('Image_687.btf');
 size(im)

     3072   4080   3

I had to do a little manipulation for display because the RGB values weren't between 0 and 255

im = double(im);
im = uint8(255 * im ./ max(im(:)));
imshow(im);

Resulting Image

Upvotes: 6

Related Questions