Matlab GUIDE imread problem
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mikkel Davidsen
el 17 de En. de 2014
Comentada: Mikkel Davidsen
el 17 de En. de 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 comentarios
Respuesta aceptada
Image Analyst
el 17 de En. de 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);
Más respuestas (0)
Ver también
Categorías
Más información sobre Printing and Saving en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!