필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
Manoj Kumar
Manoj Kumar 2014년 6월 19일
댓글: Manoj Kumar 2014년 6월 20일
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...

채택된 답변

Sean de Wolski
Sean de Wolski 2014년 6월 19일
편집: Sean de Wolski 2014년 6월 19일
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)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by