我第一次使用 Matlab 的 GUIDE,我试图编辑两个按钮功能之一(都打开图像),但编辑一个会改变所有这些功能。这是一段代码:
% --- Executes on button press in Floating.
function Floating_Callback(hObject, eventdata, handles)
clc;
axes(handles.axes1);
[Float, PathName, FilterIndex] = uigetfile('*.bmp');
if(Float ~= 0)
Floating = fullfile(PathName, Float);
FloatArray = imread(Floating);
imshow(FloatArray);
axis on;
end
% Update handles structure
guidata(hObject, handles);
% hObject handle to Floating (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in Reference.
function Reference_Callback(hObject, eventdata, handles)
clc;
axes(handles.axes2);
[Ref, PathName, FilterIndex] = uigetfile('*.bmp');
if(Ref ~= 0)
Reference = fullfile(PathName, Ref);
ReferenceArray = imread(Reference);
image(ReferenceArray);
end
% Update handles structure
guidata(hObject, handles);
例如,
image(ReferenceArray)
将在 RBG 中打开图像,但是
imshow(FloatArray)
将以灰度打开(我也不明白为什么会这样)。但我主要担心的是开放后
imshow(FloatArray)
另一张图像会自动变成灰度。我很困惑...此外,据我所知,图像已经是灰度的,至少当我在 MS Paint 或 ImageJ 中打开它们时它们是灰度的。