function varargout = Image_GUI(varargin)
% IMAGE_GUI MATLAB code for Image_GUI.fig
% IMAGE_GUI, by itself, creates a new IMAGE_GUI or raises the existing
% singleton*.
%
% H = IMAGE_GUI returns the handle to a new IMAGE_GUI or the handle to
% the existing singleton*.
%
% IMAGE_GUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in IMAGE_GUI.M with the given input arguments.
%
% IMAGE_GUI('Property','Value',...) creates a new IMAGE_GUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Image_GUI_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Image_GUI_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help Image_GUI
% Last Modified by GUIDE v2.5 22-Jul-2015 13:16:45
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Image_GUI_OpeningFcn, ...
'gui_OutputFcn', @Image_GUI_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before Image_GUI is made visible.
function Image_GUI_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to Image_GUI (see VARARGIN)
% Choose default command line output for Image_GUI
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
movegui(gcf,'center');
t=timer('executionmode','fixedrate','period',1,'TimerFcn',{@onTimer,handles});
start(t);
function onTimer(hObject, eventdata, handles)
% hObject handle to time (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
xingqi={'日','一','二','三','四','五','六'};
set(handles.time,'string',[datestr(now,'yyyy mm dd HH:MM:SS') ' 星期' xingqi{weekday(now)}]);
% --- Outputs from this function are returned to the command line.
function varargout = Image_GUI_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
%% --------------------------------------------------------------开始------------------------------------------------------------
function start_Callback(hObject, eventdata, handles)
% hObject handle to start (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% ---------------打开-----------------------------------------------------
function open_Callback(hObject, eventdata, handles)
% hObject handle to 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({'*.*';'*.png';'*.jpg';'*.bmp';'*.tif'},'载入图像');
if isequal(filename,0)||isequal(pathname,0)
%errordlg('没有打开文件!','error');
return;
else
file=[pathname,filename];
global S %设置一个全局变量,保存初始图像路径,便于还原
S=file;
I=imread(file);
axes(handles.axes1);%将Tag值为axes1的坐标轴置为当前
cla reset%清除原有内容
imshow(I);
axes(handles.axes2);%将Tag值为axes2的坐标轴置为当前
cla reset
imshow(I);
clear T map PSF;
end
% --------------储存------------------------------------------------------
function save_Callback(hObject, eventdata, handles)
% hObject handle to save (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global T
[sfilename,spathname]=uiputfile({'*.jpg';'*.png';'*.bmp';'*.tif';'*.*'},'储存图像');
if ~isequal([sfilename,spathname],[0,0])
sfilefullname=[spathname sfilename];%获得全路径的另一种方法
axes(handles.axes2);
T=getimage;%获得坐标轴2的图像信息,存入T
imwrite(T,sfilefullname);
else
% errordlg('没有储存图像!','error');
return
end
% --------------撤销------------------------------------------------------
function repeal_Callback(hObject, eventdata, handles)
% hObject handle to repeal (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global T;
axes(handles.axes2);
imshow(T);
% --------------初始化------------------------------------------------------
function initialize_Callback(hObject, eventdata, handles)
% hObject handle to initialize (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global S;
clear T map PSF;
axes(handles.axes1);
imshow(S);
axes(handles.axes2);
cla reset
imshow(S);
% --------------------------------------------------------------------
function print_Callback(hObject, eventdata, handles)
% hObject handle to print (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global T;
axes(handles.axes2);
T=getimage;
printpreview
% --------------关闭------------------------------------------------------
function close_Callback(hObject, eventdata, handles)
% hObject handle to close (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
B=questdlg('确认关闭数字图形处理演示系统?','提示','Yes','No','Yes')
switch B
case 'Yes'
close(gcf);
clear all;
clc;
end
%% -----------------------------------------------图像类型变换-------------------------------------------------------
function transformation_Callback(hObject, eventdata, handles)
% hObject handle to transformation (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Im2bw_Callback(hObject, eventdata, handles)
% hObject handle to Im2bw (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global T
axes(handles.axes2);
T=getimage;
if isrgb(T)==1
I=rgb2gray(T);
else
I=T;
end
%thresh=graythresh(I);
bw=im2bw(I,0.6);
imshow(bw);
% --------------------------------------------------------------------
function RGB2gray_Callback(hObject, eventdata, handles)
% hObject handle to RGB2gray (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global T
axes(handles.axes2);
T=getimage;
if isrgb(T)==1
I=rgb2gray(T);%将彩色图像转换为灰度图像
imshow(I);
else
msgbox('这不是RGB图像!','警告','error');
end
% --------------------------------------------------------------------
function Gray2ind_Callback(hObject, eventdata, handles)
%