Matlab GUIDE imread problem
2 views (last 30 days)
Show older comments
Mikkel Davidsen
on 17 Jan 2014
Commented: Mikkel Davidsen
on 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.
0 Comments
Accepted Answer
Image Analyst
on 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);
More Answers (0)
See Also
Categories
Find more on Printing and Saving in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!