在下面显示的我的 GUI 中http://s1273.photobucket.com/user/Chethan_tv/media/CBIR_zpsb48bce14.jpg.html
打开按钮用于查看显示在各个轴上的图像。轴显示图像,打开按钮应以更大的尺寸显示相应的图像。
%below 3 lines are in GUI *_opening function
handles.MyData.ListFileName = 'FileName';
handles.MyData.FileNames = {}; % here we store all the image names
handles.MyData.Images = {}; % here we store all images
下面的代码在 display_results 函数中
function displayResults(filename,hObject, eventdata, handles)
fid=fopen(handles.MyData.ListFileName);
for N=6:1:10
imagename = fgetl(fid);
if ~ischar(imagename), break, end % Meaning: End of File...
[x,map]=imread(imagename);
rgb=ind2rgb(x,map);
ax = handles.(sprintf('axes%d', N));
image(rgb, 'Parent', ax);
set(ax, 'Visible','off');
%xlabel(imagename);
% store file name and image itself for later use
handles.MyData.Images{N} = rgb;
handles.MyData.FileNames{N} = imagename;
% we have buttons like open1 open2 open3 etc...
% add some info to the open buttons
% so they will be aware which image they display
btn = handles.(sprintf('open%d', N));
set(btn, 'UserData',N);
end
fclose(fid);
% Update handles structure
guidata(hObject, handles);
我的open
按钮功能是
function open1_Callback(hObject, eventdata, handles)
% hObject handle to open1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
N = get(hObject,'UserData');
rgb = handles.MyData.Images{N};
ax = handles.(sprintf('axes%d', N));
% create figure in 'modal' mode, so user have to close it to continue
figure('WindowStyle','modal', 'Name',handles.MyData.FileNames{N} );
% show image
image(rgb, 'Parent', ax);
set(ax, 'Visible','off');
guidata(hObject, handles);
但是当我按下open
轴 6 下方的按钮时,我收到了类似的错误
??? Index exceeds matrix dimensions.
Error in ==> Fig5>open6_Callback at 163
rgb = handles.MyData.Images{N};
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> Fig5 at 42
gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)Fig5('open6_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
我的代码的哪一部分是错误的?