diff --git a/MatLab/interfaz.fig b/MatLab/interfaz.fig new file mode 100644 index 0000000..71303d1 Binary files /dev/null and b/MatLab/interfaz.fig differ diff --git a/MatLab/interfaz.m b/MatLab/interfaz.m new file mode 100644 index 0000000..f01600a --- /dev/null +++ b/MatLab/interfaz.m @@ -0,0 +1,105 @@ +function varargout = interfaz(varargin) +% INTERFAZ MATLAB code for interfaz.fig +% INTERFAZ, by itself, creates a new INTERFAZ or raises the existing +% singleton*. +% +% H = INTERFAZ returns the handle to a new INTERFAZ or the handle to +% the existing singleton*. +% +% INTERFAZ('CALLBACK',hObject,eventData,handles,...) calls the local +% function named CALLBACK in INTERFAZ.M with the given input arguments. +% +% INTERFAZ('Property','Value',...) creates a new INTERFAZ or raises the +% existing singleton*. Starting from the left, property value pairs are +% applied to the GUI before interfaz_OpeningFcn gets called. An +% unrecognized property name or invalid value makes property application +% stop. All inputs are passed to interfaz_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 interfaz + +% Last Modified by GUIDE v2.5 08-Feb-2018 14:51:57 + +% Begin initialization code - DO NOT EDIT +gui_Singleton = 1; +gui_State = struct('gui_Name', mfilename, ... + 'gui_Singleton', gui_Singleton, ... + 'gui_OpeningFcn', @interfaz_OpeningFcn, ... + 'gui_OutputFcn', @interfaz_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 interfaz is made visible. +function interfaz_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 interfaz (see VARARGIN) + +% Choose default command line output for interfaz +handles.output = hObject; + +% Update handles structure +guidata(hObject, handles); + +% UIWAIT makes interfaz wait for user response (see UIRESUME) +% uiwait(handles.figure1); + + +% --- Outputs from this function are returned to the command line. +function varargout = interfaz_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 Untitled_1_Callback(hObject, eventdata, handles) +% hObject handle to Untitled_1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +points = []; +[x, y] = getpts; + + +% --- Executes on button press in load. +function load_Callback(hObject, eventdata, handles) +% hObject handle to load (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';'*.png'},'File Selector'); + handles.myImage = strcat(pathname, filename); + axes(handles.image); + imshow(handles.myImage) + set(handles.edit1,'string',filename); + set(handles.edit2,'string',image); + + % save the updated handles object + guidata(hObject,handles); + + +% --- Executes on button press in test. +function test_Callback(hObject, eventdata, handles) +% hObject handle to test (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) diff --git a/iDeep/datos/imagenes.mat b/iDeep/datos/imagenes.mat new file mode 100644 index 0000000..7b4c629 Binary files /dev/null and b/iDeep/datos/imagenes.mat differ diff --git a/iDeep/datos/mascaras.mat b/iDeep/datos/mascaras.mat new file mode 100644 index 0000000..34649e6 Binary files /dev/null and b/iDeep/datos/mascaras.mat differ diff --git a/iDeep/iDeep.fig b/iDeep/iDeep.fig new file mode 100644 index 0000000..09f1e41 Binary files /dev/null and b/iDeep/iDeep.fig differ diff --git a/iDeep/iDeep.m b/iDeep/iDeep.m new file mode 100644 index 0000000..3fad2f1 --- /dev/null +++ b/iDeep/iDeep.m @@ -0,0 +1,151 @@ +function varargout = iDeep(varargin) +% IDEEP MATLAB code for iDeep.fig +% IDEEP, by itself, creates a new IDEEP or raises the existing +% singleton*. +% +% H = IDEEP returns the handle to a new IDEEP or the handle to +% the existing singleton*. +% +% IDEEP('CALLBACK',hObject,eventData,handles,...) calls the local +% function named CALLBACK in IDEEP.M with the given input arguments. +% +% IDEEP('Property','Value',...) creates a new IDEEP or raises the +% existing singleton*. Starting from the left, property value pairs are +% applied to the GUI before iDeep_OpeningFcn gets called. An +% unrecognized property name or invalid value makes property application +% stop. All inputs are passed to iDeep_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 iDeep + +% Last Modified by GUIDE v2.5 09-Feb-2018 21:54:55 + +% Begin initialization code - DO NOT EDIT +gui_Singleton = 1; +gui_State = struct('gui_Name', mfilename, ... + 'gui_Singleton', gui_Singleton, ... + 'gui_OpeningFcn', @iDeep_OpeningFcn, ... + 'gui_OutputFcn', @iDeep_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 iDeep is made visible. +function iDeep_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 iDeep (see VARARGIN) + +% Choose default command line output for iDeep +handles.output = hObject; + +% Update handles structure +guidata(hObject, handles); + +% UIWAIT makes iDeep wait for user response (see UIRESUME) +% uiwait(handles.figure1); + + +% --- Outputs from this function are returned to the command line. +function varargout = iDeep_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 selection change in popupmenu1. +function popupmenu1_Callback(hObject, eventdata, handles) +% hObject handle to popupmenu1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array +% contents{get(hObject,'Value')} returns selected item from popupmenu1 + + +% --- Executes during object creation, after setting all properties. +function popupmenu1_CreateFcn(hObject, eventdata, handles) +% hObject handle to popupmenu1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: popupmenu 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 + + +% --- 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) +[FileName,PathName] = uigetfile('*.mat','Select 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) +[file,path] = uiputfile('*.mat','Save file name'); + +% --- Executes on button press in pushbutton3. +function pushbutton3_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton3 (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('*.mat','Select network file'); + + +% --- Executes on button press in pushbutton4. +function pushbutton4_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton4 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +[file,path] = uiputfile('*.mat','Save network'); + + +% --- Executes on button press in pushbutton9. +function pushbutton9_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton9 (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 pushbutton10. +function pushbutton10_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton10 (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 checkbox1. +function checkbox1_Callback(hObject, eventdata, handles) +% hObject handle to checkbox1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of checkbox1 diff --git a/iDeep/trainCNN.m b/iDeep/trainCNN.m new file mode 100644 index 0000000..cd5fd35 --- /dev/null +++ b/iDeep/trainCNN.m @@ -0,0 +1,40 @@ +function [net]=trainCNN(X,T) + +% X=randn(32,32,1,5000); +% T=categorical(randn(5000,1)>0.5); +% [net]=trainCNN(X,T) + +%parameter +s1=size(X); %X puede ser un vector de 32x32x1xN +s2=size(T); %T pueder un verto de Nx1 + +num_clases=length(unique(T(:))); + +% Two class +% define network +ks=3; % kernel size (3x3) +numfilters=[32,64,128]; % cambiar a 128 +layers = [imageInputLayer([s1(1) s1(2) 1]); + convolution2dLayer(ks,numfilters(1)); %16 filtros de 5x5 + %batchNormalizationLayer(); + reluLayer(); + maxPooling2dLayer(2,'Stride',1); + convolution2dLayer(ks,numfilters(2)); %16 filtros de 5x5 + %batchNormalizationLayer(); + reluLayer(); + maxPooling2dLayer(2,'Stride',1); + convolution2dLayer(ks,numfilters(3)); %16 filtros de 5x5 + %batchNormalizationLayer(); + reluLayer(); + maxPooling2dLayer(2,'Stride',1); + fullyConnectedLayer(num_clases^2); + %dropoutLayer(0.5); + fullyConnectedLayer(num_clases); + softmaxLayer(); + classificationLayer()]; + +options = trainingOptions('sgdm','MaxEpochs',5,'InitialLearnRate',0.01); +rng('default') % For reproducibility +[net,traininfo] = trainNetwork(X,categorical(single(T)),layers,options); + + diff --git a/iDeep/trainRF.m b/iDeep/trainRF.m new file mode 100644 index 0000000..5470ca3 --- /dev/null +++ b/iDeep/trainRF.m @@ -0,0 +1,13 @@ +function [RF]=trainRF(X,T) + +% X=randn(5000,32*32); +% T=randn(5000,1)>0.5; +% RF =trainRF(X,T); + +%parameters +num_trees=50; + +%train +tic +RF = TreeBagger(num_trees,X,T); +toc