如何重置当前轴以在MATLAB中显示同一轴上的彩色图像或灰度图像?
问题描述:
我有一些灰度图像,经过一些细分处理后,我将部分转换为彩色以用于显示目的。 但在同一轴上显示灰度图像后,我无法在轴上显示彩色图像。如何重置当前轴以在MATLAB中显示同一轴上的彩色图像或灰度图像?
例:
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global imB
global imF
global finalSegment_LE
i=38;
% imB = img2{i} ;% Background original image
tempSeg = finalSegment_LE{i};
tempSeg(finalSegment_LE{i} ==0) = min(finalSegment_LE{i}(:));
imF = tempSeg;
cla(handles.axes1,'reset');
[~,~] = imoverlay(imB,imF,[],[],'hsv',0.8,handles.axes1); % color image..
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% global imB
temp = imread('cameraman.tif');
cla(handles.axes1,'reset');
axes(handles.axes1);
imshow(temp,[]) % grayscale image...
如果我按pushbutton1
首先我看到彩色图像,但我按pushbutton2
后,轴变为灰度,甚至当我按下pushbutton1
,它仍然显示灰度图像,而不是彩色图像。
谢谢,
戈皮显示基于图像类型之前
答
%组颜色表
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[img,cmap] = imread('peppers.png');
cla(handles.axes1,'reset');
colormap(handles.axes1,cmap);
axes(handles.axes1);
imshow(img,[]);
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% global imB
temp = imread('cameraman.tif');
cla(handles.axes1,'reset');
colormap(handles.axes1,gray);
axes(handles.axes1);
imshow(temp,[])