Filter löschen
Filter löschen

Matlab GUIDE imread problem

1 Ansicht (letzte 30 Tage)
Mikkel Davidsen
Mikkel Davidsen am 17 Jan. 2014
Kommentiert: Mikkel Davidsen am 17 Jan. 2014
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.

Akzeptierte Antwort

Image Analyst
Image Analyst am 17 Jan. 2014
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 Kommentar
Mikkel Davidsen
Mikkel Davidsen am 17 Jan. 2014
Thank you. This solved a long chain of errors! :)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Printing and Saving finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by