how get the information of the image instead of using imfinfo?

4 visualizzazioni (ultimi 30 giorni)
Hi,
I used imfinfo to get the details of width, height, colortype and bitspersample for the selected image with the following code:
[baseFileName,folder]=uigetfile('*'); % read the input image
ImageOriginal=imread([folder,baseFileName]);
info=imfinfo(baseFileName);
% To pull out the BitsPerSample since few images don't have that info
hasField = isfield(info, 'BitsPerSample');
if hasField % We can print it.
details= sprintf(' \n \n \n \n Width= %d \n Height=%d \n ColorType=%s \n BitsPerSample= %d %d %d \n', info.Width, info.Height,info.ColorType, info.BitsPerSample);
else % we can't print it.
details= sprintf(' \n \n \n \n Width= %d \n Height=%d \n ColorType=%s \n', info.Width, info.Height,info.ColorType);
end
But the problem is, to use imfinfo the file must be in the currentfolder or in a folder on the MATLAB path.
But when I try to pick an image in another folder, I am facing an error. How can I get the details of the image even if it is not in the current folder or current directory? Is there any other function to get those details?
Thank you...

Risposta accettata

Sean de Wolski
Sean de Wolski il 19 Giu 2014
Modificato: Sean de Wolski il 19 Giu 2014
How are you getting the image? Most of the interactive tools, such as uigetfile return the full path as the second output. You can then use fullfile to build the full path.
For example:
[filename,filepath] = uigetfile('*.png')
fullpath = fullfile(filepath,filename)
imfinfo(fullpath)

Più risposte (0)

Categorie

Scopri di più su File Operations in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by