我第一次使用Matlab的GUIDE,我试图编辑两个按钮功能之一(都打开一个图像),但编辑一个更改所有这些功能。下面是一些代码:在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油漆或ImageJ。
阅读MATLAB中的图像('img = imread('...')'),并为这两个图像发布'size(img)'和'class(img)'的输出 – Amro 2012-07-24 16:24:47