필터 지우기
필터 지우기

Matlab GUIDE imread problem

조회 수: 1 (최근 30일)
Mikkel Davidsen
Mikkel Davidsen 2014년 1월 17일
댓글: Mikkel Davidsen 2014년 1월 17일
For a school project, we're to create an image analyzing tool in matlab 2013a, which applies various effects. These works individually, but putting them together causes some problems. I've seen and searches for likewise examples, but the answers are not well explained.
function findimage_Callback(hObject, eventdata, handles)
% load image:
[myimage,pathname] = uigetfile({'*.jpg';'*.png';'*.tif';'*.bmp'});
axis(handles.axes1); %setting the image in axes1 component
imshow(myimage) %displays image in axes1
This produces the following errors:
Cannot find the specified file: "mandril.tif". %This clearly does exists. I specified the path!
Error in imageDisplayParseInputs (line 74)
[common_args.CData,common_args.Map] = ...
Error in imshow (line 220)
[common_args,specific_args] = ...
Error in simple_gui>findimage_Callback (line 169)
imshow(myimage);
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in simple_gui (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)simple_gui('findimage_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback.
This push button takes a picture user specified by a selected file path. It then displays the picture in the axis window. I also want to store the picture so I can pass it to processing functions, which are already completed. The problem is i get an error each time the image is selected from the file selection window, and won't show it, thereby also not saving it for further processing.

채택된 답변

Image Analyst
Image Analyst 2014년 1월 17일
You did not specify the path. You did this:
imshow(myimage)
myimage is just the base file name, not the full filename with the folder prepended. Use fullfile() like this snippet:
% Get the name of the file that the user wants to use.
defaultFileName = fullfile(startingFolder, '*.*');
[baseFileName, folder] = uigetfile(defaultFileName, 'Select a file');
if baseFileName == 0
% User clicked the Cancel button.
return;
end
fullFileName = fullfile(folder, baseFileName)
imshow(fullFileName);
  댓글 수: 1
Mikkel Davidsen
Mikkel Davidsen 2014년 1월 17일
Thank you. This solved a long chain of errors! :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by