Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
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...

Respuesta aceptada

Sean de Wolski
Sean de Wolski el 19 de Jun. de 2014
Editada: Sean de Wolski el 19 de Jun. de 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)

Más respuestas (0)

Categorías

Más información sobre File Operations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by