フィルターのクリア

load multipages TIF image

6 ビュー (過去 30 日間)
alfonso Davide pinelli
alfonso Davide pinelli 2023 年 2 月 12 日
回答済み: alfonso Davide pinelli 2023 年 2 月 16 日
Hello
I'm trying to open a multislices TIF image.
It works in GUI but when used in app designer it read only 1 slice.
What's wrong?
Many thanks for helps
I used this code:
function LoadImageButtonValueChanged(app, event)
value = app.LoadImageButton.Value;
% Selecting image file to process
[filename, pathname] = uigetfile('*.*', 'pick an image'); % pop up file open dialog to select image
filename = strcat(pathname,filename);
info = imfinfo(filename);
numberOfPages = length(info);
for k = 1 : numberOfPages
thisPage = imread(filename, k);
imshow(imadjust(thisPage),'Parent',app.UIAxes); %-show the kth image in this multipage tiff file
end
end
  2 件のコメント
Walter Roberson
Walter Roberson 2023 年 2 月 12 日
filename = strcat(pathname,filename);
should be
filename = fullfile(pathname, filename);
uigetfile does not promise that the directory name will have a directory separator at the end of it.
alfonso Davide pinelli
alfonso Davide pinelli 2023 年 2 月 12 日
Hello,
thanks for your support.
Still Not working. Command windows state
Warning: The next image file directory at byte position 117206199 is at or beyond the end of the file.

サインインしてコメントする。

採用された回答

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023 年 2 月 12 日
Here length() does not do the job. therefore, it is better to use tiffreadVolume()
Here is the corrected code:
function LoadImageButtonValueChanged(app, event)
value = app.LoadImageButton.Value;
% Selecting image file to process
[filename, pathname] = uigetfile('*.*', 'pick an image'); % pop up file open dialog to select image
filename = strcat(pathname,filename);
info = tiffreadVolume(filename);
Size_Tiff = size(info);
numberOfPages = Size_Tiff(4);
for k = 1 : numberOfPages
thisPage = imread(filename, k);
imshow(imadjust(thisPage),'Parent',app.UIAxes); %-show the kth image in this multipage tiff file
end
end
  11 件のコメント
Steve Eddins
Steve Eddins 2023 年 2 月 14 日
Without a sample file to examine, I can only guess. Based on the imfinfo output you posted, as well as Walter Roberson's comments, I guess that the slice data is hidden inside private TIFF tags created by ImageJ. See the ImageDescription and UnknownTags fields of the output of imfinfo. If that is really the case, then it will require custom code to convert the private tag ImageJ data. I'm not familiar with the method of storing extra slice data in a TIFF file, so I'm not sure how difficult it might be.
Walter Roberson
Walter Roberson 2023 年 2 月 14 日
You need to be careful using length(). length(A) is defined as
if isempty(A)
length is 0
else
length is max(size(A))
end
We see from your previous comments that size() of the tiffreadVolume is [512 512] . length() of that is not the number of pages: length() is going to be max([512 512]) which would be 512
Number of pages would, in the specific case of tiffreadVolume, be size(info,3) -- which would be 1 for that file.

サインインしてコメントする。

その他の回答 (1 件)

alfonso Davide pinelli
alfonso Davide pinelli 2023 年 2 月 16 日
The image was corrupted.
The code is ok.
Many thanks for all of you

カテゴリ

Help Center および File ExchangeImage Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by