load multipages TIF image
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
alfonso Davide pinelli
el 12 de Feb. de 2023
Respondida: alfonso Davide pinelli
el 16 de Feb. de 2023
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 comentarios
Walter Roberson
el 12 de Feb. de 2023
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.
Respuesta aceptada
Sulaymon Eshkabilov
el 12 de Feb. de 2023
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 comentarios
Steve Eddins
el 14 de Feb. de 2023
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
el 14 de Feb. de 2023
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.
Más respuestas (1)
Ver también
Categorías
Más información sobre Image Data en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!