📄 gui_test.asv
字号:
% Programming By Alireza Fasih.
% Spetial Thanks to
function varargout = gui_test(varargin)
% GUI_TEST M-file for gui_test.fig
% GUI_TEST, by itself, creates a new GUI_TEST or raises the existing
% singleton*.
%
% H = GUI_TEST returns the handle to a new GUI_TEST or the handle to
% the existing singleton*.
%
% GUI_TEST('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUI_TEST.M with the given input arguments.
%
% GUI_TEST('Property','Value',...) creates a new GUI_TEST or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before gui_test_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to gui_test_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 gui_test
% Last Modified by GUIDE v2.5 15-Mar-2008 19:29:46
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @gui_test_OpeningFcn, ...
'gui_OutputFcn', @gui_test_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 gui_test is made visible.
function gui_test_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 gui_test (see VARARGIN)
% Choose default command line output for gui_test
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes gui_test wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = gui_test_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;
% --- Executes on button press in btnLoad.
function btnLoad_Callback(hObject, eventdata, handles)
% hObject handle to btnLoad (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes1)
[filename, pathname] = ...
uigetfile({'*.jpg';'*.bmp';'*.*'},'File Selector');
fname=strcat(pathname,filename);
global Im1;
Im1=imread(fname);
imshow(Im1);
% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over btnLoad.
function btnLoad_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to btnLoad (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 btnRun.
function btnRun_Callback(hObject, eventdata, handles)
% hObject handle to btnRun (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global A B Bu I m n;
global Im1;
axes(handles.axes2)
if (isrgb(Im1))
Im1=rgb2gray(Im1);
end
imshow(Im1);
Ta=zeros(3,3);
Ta(1,1)=str2double(get(handles.a1,'String'));
Ta(1,2)=str2double(get(handles.a2,'String'));
Ta(1,3)=str2double(get(handles.a3,'String'));
Ta(2,1)=str2double(get(handles.a4,'String'));
Ta(2,2)=str2double(get(handles.a5,'String'));
Ta(2,3)=str2double(get(handles.a6,'String'));
Ta(3,1)=str2double(get(handles.a7,'String'));
Ta(3,2)=str2double(get(handles.a8,'String'));
Ta(3,3)=str2double(get(handles.a9,'String'));
Tb=zeros(3,3);
Tb(1,1)=str2double(get(handles.b1,'String'));
Tb(1,2)=str2double(get(handles.b2,'String'));
Tb(1,3)=str2double(get(handles.b3,'String'));
Tb(2,1)=str2double(get(handles.b4,'String'));
Tb(2,2)=str2double(get(handles.b5,'String'));
Tb(2,3)=str2double(get(handles.b6,'String'));
Tb(3,1)=str2double(get(handles.b7,'String'));
Tb(3,2)=str2double(get(handles.b8,'String'));
Tb(3,3)=str2double(get(handles.b9,'String'));
I=str2double(get(handles.bias,'String'));
A=Ta
B=Tb
u = im2double(Im1);
uu = im2double(max(max(u)));
ul = im2double(min(min(u)));
u = (u-ul)/(uu-ul)*2-1;
x0 = u;
colormap(gray(64))
t = 0;
Xt = x0;
tf = str2double(get(handles.time1,'String'));
dtime = str2double(get(handles.dt1,'String'));
m=0;
n=0;
global Im2;
%----------------- Start Calculation CNN ------------------------
while(t<tf)
Im2=image((pwlsig(Xt)+1)*32);
%axis('image');
drawnow
tnext = min([tf,t+dtime]);
Atem = A;
Bu = conv2(u,B,'same');
[m,n] = size(x0);
x0 = x0(:);
[t,y] = ode23('cnnderiv', [0, tf/2, tf], x0);
ly = size(y,1);
x0 = reshape(y(ly,:),m,n);
Xt=x0;
t = tnext
set(handles.showtime1,'String',num2str(t));
%pause(0.01);
end;
% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over btnRun.
function btnRun_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to btnRun (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
function a1_Callback(hObject, eventdata, handles)
% hObject handle to a1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of a1 as text
% str2double(get(hObject,'String')) returns contents of a1 as a double
% --- Executes during object creation, after setting all properties.
function a1_CreateFcn(hObject, eventdata, handles)
% hObject handle to a1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function a2_Callback(hObject, eventdata, handles)
% hObject handle to a2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of a2 as text
% str2double(get(hObject,'String')) returns contents of a2 as a double
% --- Executes during object creation, after setting all properties.
function a2_CreateFcn(hObject, eventdata, handles)
% hObject handle to a2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function a3_Callback(hObject, eventdata, handles)
% hObject handle to a3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of a3 as text
% str2double(get(hObject,'String')) returns contents of a3 as a double
% --- Executes during object creation, after setting all properties.
function a3_CreateFcn(hObject, eventdata, handles)
% hObject handle to a3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function a4_Callback(hObject, eventdata, handles)
% hObject handle to a4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of a4 as text
% str2double(get(hObject,'String')) returns contents of a4 as a double
% --- Executes during object creation, after setting all properties.
function a4_CreateFcn(hObject, eventdata, handles)
% hObject handle to a4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function a5_Callback(hObject, eventdata, handles)
% hObject handle to a5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of a5 as text
% str2double(get(hObject,'String')) returns contents of a5 as a double
% --- Executes during object creation, after setting all properties.
function a5_CreateFcn(hObject, eventdata, handles)
% hObject handle to a5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function a6_Callback(hObject, eventdata, handles)
% hObject handle to a6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of a6 as text
% str2double(get(hObject,'String')) returns contents of a6 as a double
% --- Executes during object creation, after setting all properties.
function a6_CreateFcn(hObject, eventdata, handles)
% hObject handle to a6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function a7_Callback(hObject, eventdata, handles)
% hObject handle to a7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -