how to load image to two axes with use of one push button

1 view (last 30 days)
Dear friends
I have to create color constancy program for using GUI in mat lab i want to load two images for using two axes(axes1,axes2) with the use of one pushbutton1(LoadImage) i have to try that following code
[File,Folder]=uigetfile('*.*','Multiselect','on');
handles.img=cell(1,length(File));
for iFile=1:length(File)
filename=strcat(Floder,File{iFile);
image=imread(filename);
axes(handles.axes(iFile));
imshow(image);
handles.img{iFile} =image;
end
guidata(hObject,handles);
Please any one help to me. How to execute that code ?

Accepted Answer

Walter Roberson
Walter Roberson on 5 Feb 2013
In the line
filename=strcat(Floder,File{iFile);
you have spelled Folder incorrectly, and you missed a '}', and you left out the '/' or '\' between the folder name and the file name.
It is safer to use fullfile() instead of building the name yourself:
filename = fullfile(Folder, File{iFile});
  2 Comments
Fathima Haleema
Fathima Haleema on 5 Feb 2013
i have to apply your suggestion but i got the following error result
??? Cell contents reference from a non-cell array object.
Error in ==> colrc>imagebtn_Callback at 84 filename=fullfile(Folder,File{iFile});
Error in ==> gui_mainfcn at 96 feval(varargin{:});
Error in ==> colrc at 42 gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)colrc('imagebtn_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
Code: function imagebtn_Callback(hObject, eventdata, handles)
% hObject handle to imagebtn (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[File,Folder]=uigetfile('*.*','Multiselect','on');
handles.img=cell(1,length(File));
for iFile=1:length(File)
filename=fullfile(Folder,File{iFile});
image=imread(filename);
axes(handles.axes{iFile});
imshow(image);
handles.img{iFile}=image;
end
guidata(hObject,handles);

Sign in to comment.

More Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!