how get the information of the image instead of using imfinfo?
4 views (last 30 days)
Show older comments
Manoj Kumar
on 19 Jun 2014
Commented: Manoj Kumar
on 20 Jun 2014
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...
0 Comments
Accepted Answer
Sean de Wolski
on 19 Jun 2014
Edited: Sean de Wolski
on 19 Jun 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)
More Answers (0)
See Also
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!