How do I load in an image from a uint16 tiff file? (R2012b)

5 views (last 30 days)
I have a multi-image uint16 tiff file with 400 images, I want to analyze each individually.
>> numel(imfinfo('filename.tiff')) -> ans = 400
When I call imread with any image's "Index" it returns only a single uint16 matrix of that image rather than the whole image.
>> img = imread('filename.tiff','Index',1);
img is not the first image in the stack. I'm guessing it's just a single uint16 "frame"
>> img = imread('filename.tiff','Index',65536); -> returns an image even though there are only 400 images, but if input 65537 it errors.
>> img = imread('filename.tiff','Info',iminfo,'Index',n) -> doesn't fix my problem
Using R2012a (64bit MacOSX) on a different computer resulted in the proper image being loaded. Thus it's an issue with the most recent version or only with my computer (64bit Windows7). Are there any sort of work arounds?

Accepted Answer

Evan
Evan on 16 Nov 2012
The only issue, which is not really an issue, is that R2012b doesn't error when the index is greater than the number of images in the stack, it simply opens rem(index/# of images) until it reaches some large number which I'm guessing has something to do with the number of bytes of the file, and then it errors.
The reason I had a problem was because the code I received opens the images by running a loop incrementing the index by 1 each time until imread errors. It's a really stupid way to do it, I agree. I'm going to change it. Also imread(...,'Index',1) creates the correct image, I was just visualizing it with image(...) instead of imagesc(...) which was stupid of me. Dang.

More Answers (1)

Sean de Wolski
Sean de Wolski on 16 Nov 2012
Are you positive it is the same Tiff container and that it was not somehow corrupted?
I would recommend contacting us with the image in question.
Also, have you tried using LibTiff via the Tiff class?
Does it read it properly?
  1 Comment
Evan
Evan on 16 Nov 2012
It opens properly in ImageJ. I'm currently installing 64-bit R2011a to see if it is a computer issue.

Sign in to comment.

Categories

Find more on Large Files and Big Data in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!