我第一次使用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