필터 지우기
필터 지우기

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 CenterFile Exchange에서 Image Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by