Error using imfinfo()

조회 수: 17 (최근 30일)
Matt Morrison
Matt Morrison 2020년 4월 22일
답변: Walter Roberson 2020년 4월 22일
Every time I run this code it says that for some reason there is an error in line 142 of the function imfinfo:
filename=uigetfile('*.tif');
[r c]=size(imfinfo(filename));
for i = 1:r
rgb = imread(filename, i);
set(handles.textSlidenumber, 'String', i);
status = get(radiobuttonRBG, 'Value');
if status
imshow(rgb);
else
gray = rgb2gray(rgb);
imshow(gray);
end
line 142 in imfinfo is:
error(message('MATLAB:imagesci:imfinfo:fileOpen', filename));

답변 (1개)

Walter Roberson
Walter Roberson 2020년 4월 22일
filename=uigetfile('*.tif');
The output you get from that call will not include any directory information. If the user chooses something that is not in the current directory, you will have difficulty.
[filename, pathname] = uigetfile('*.tif');
if ~ischar(filename)
%user canceled
return
end
filename = fullfile(pathname, filename);

카테고리

Help CenterFile Exchange에서 Numeric Types에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by