这是我的读取图像和翻转处理的函数为什么只能对灰度处理后的图像翻转对彩色图像会报错?我用的是7.0的!我是初学者啊求大神!!!!!!functionwenjian_open_Callback(hObject,event...
这是我的读取图像和翻转处理的函数为什么只能对灰度处理后的图像翻转对彩色图像会报错?我用的是7.0的!我是初学者啊 求大神!!!!!!
function wenjian_open_Callback(hObject, eventdata, handles)
% hObject handle to wenjian_open (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename,pathname]=uigetfile({'*.jpg';'*.bmp';'*.tif';'*.*'},'载入图像');
if isequal(filename,0)|isequal(pathname,0)
errordlg('没有选中文件','出错');
return;
else
file=[pathname,filename];
global S %设置一个全局变量S,保存初始图像路径,以便之后的还原操作
S=file;
x=imread(file);
set(handles.axes1,'HandleVisibility','ON');
axes(handles.axes1);
imshow(x);
set(handles.axes1,'HandleVisibility','OFF');
axes(handles.axes2);
imshow(x);
handles.img=x;
guidata(hObject,handles);
end
图像翻转:
function uipanel7_SelectionChangeFcn(hObject, eventdata, handles) %图像翻转
% hObject handle to uipanel7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
str=get(hObject,'string');
axes(handles.axes2);
global T
switch str
case '左右翻转'
T=handles.img;
f=fliplr(handles.img);
imshow(f);
handles.img=f;
guidata(hObject,handles);
case '上下翻转'
T=handles.img;
f=flipud(handles.img);
imshow(f);
handles.img=f;
guidata(hObject,handles);
end
set(handles.uipanel7,'Visible','on');
if strcmp(get(gcbo, 'Checked'),'on')
set(handles.uipanel7,'Visible','on');
set(gcbo, 'Checked', 'off');
set(handles.uipanel7,'Visible','off');
else
set(gcbo, 'Checked', 'on');
end
展开