function varargout = database_menu(varargin)
% DATABASE_MENU M-file for database_menu.fig
% DATABASE_MENU, by itself, creates a new DATABASE_MENU or raises the existing
% singleton*.
%
% H = DATABASE_MENU returns the handle to a new DATABASE_MENU or the handle to
% the existing singleton*.
%
% DATABASE_MENU('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in DATABASE_MENU.M with the given input arguments.
%
% DATABASE_MENU('Property','Value',...) creates a new DATABASE_MENU or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before database_menu_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to database_menu_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 database_menu
% Last Modified by GUIDE v2.5 12-Jun-2009 16:51:28
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @database_menu_OpeningFcn, ...
'gui_OutputFcn', @database_menu_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 database_menu is made visible.
function database_menu_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 database_menu (see VARARGIN)
% Choose default command line output for database_menu
clc;
%% use when done making database file
load women_nose_data.mat;%load database from disk
handles.women_nose_data = women_nose_data;%preserv previous data
handles.women_nose_data_index = size(women_nose_data,2);%data base index
load women_left_eye_data.mat;%load database from disk
handles.women_left_eye_data = women_left_eye_data;%preserv previous data
handles.women_left_eye_data_index = size(women_left_eye_data,2);%data base index
load women_right_eye_data.mat;%load database from disk
handles.women_right_eye_data = women_right_eye_data;%preserv previous data
handles.women_right_eye_data_index = size(women_right_eye_data,2);%data base index
load women_mouth_data.mat;%load database from disk
handles.women_mouth_data = women_mouth_data;%preserv previous data
handles.women_mouth_data_index = size(women_mouth_data,2);%data base index
guidata(hObject,handles);
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes database_menu wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = database_menu_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 Read_image.
function Read_image_Callback(hObject, eventdata, handles)
% hObject handle to Read_image (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename_temp filepath] = ...
uigetfile({'*.jpg';'*.png';'*.bmp';'*.*'},'Select an image to edit','GUI\image base');
filename = sprintf('%s%s',filepath,filename_temp);
%handles.image_file_name = filename;
img = imread(filename);
handles.sourceImg = img;
guidata(hObject,handles);
axes(handles.source_image_show);imshow(img);
% --- Executes on button press in choose_again.
function choose_again_Callback(hObject, eventdata, handles)
% hObject handle to choose_again (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.source_image_show);
img = handles.sourceImg;
h = impoly;
bw = createMask(h);
X = getPosition(h);
x_min = floor(min(X(:,1))-1);
x_max = ceil(max(X(:,1))+1);
y_min = floor(min(X(:,2))-1);
y_max = ceil(max(X(:,2))+1);
cutIm = img(y_min:y_max,x_min:x_max,:);
axes(handles.target_image_show);imshow(cutIm);
mask = double(cat(3,bw(y_min:y_max,x_min:x_max),bw(y_min:y_max,x_min:x_max),bw(y_min:y_max,x_min:x_max)));
axes(handles.target_mask_show);imshow(mask);
masked_img = uint8(double(mask).*double(cutIm));
axes(handles.target_masked_image_show);imshow(masked_img);
handles.target_image = cutIm;
handles.mask_image = mask;
% handles.masked_image = masked_img;
guidata(hObject,handles);
delete(h);
% --- Executes on button press in save_nose_database.
function save_nose_database_Callback(hObject, eventdata, handles)
% hObject handle to save_nose_database (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%% use when first making database file
% % index = 1;
% % guidata(hObject,handles);
%% use when done making database file
women_nose_data = handles.women_nose_data;
index = handles.women_nose_data_index+1;% update index for new file
handles.women_nose_data_index = index;%data base index update
guidata(hObject,handles);
tag = sprintf('woman_nose_%d',index);
a = handles.target_image;
b = handles.mask_image;
women_nose_data{index} = {tag,a,b};
handles.women_nose_data = women_nose_data;% update database in workspace
guidata(hObject,handles);
save women_nose_data.mat women_nose_data;
% --- Executes on button press in save_left_eye_database.
function save_left_eye_database_Callback(hObject, eventdata, handles)
% hObject handle to save_left_eye_database (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%% use when first making database file
% % index = 1;
% % guidata(hObject,handles);
%% use when done making database file
women_left_eye_data = handles.women_left_eye_data;
index = handles.women_left_eye_data_index+1;% update index for new file
handles.women_left_eye_data_index = index;%data base index
guidata(hObject,handles);
tag = sprintf('woman_left_eye_%d',index);
a = handles.target_image;
b = handles.mask_image;
women_left_eye_data{index} = {tag,a,b};
handles.women_left_eye_data = women_left_eye_data;% update database in workspace
guidata(hObject,handles);
save women_left_eye_data.mat women_left_eye_data;
% --- Executes on button press in save_right_eye_database.
function save_right_eye_database_Callback(hObject, eventdata, handles)
% hObject handle to save_right_eye_database (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%% use when first making database file
% % index = 1;
% % guidata(hObject,handles);
%% use when done making database file
women_right_eye_data = handles.women_right_eye_data;
index = handles.women_right_eye_data_index+1;% update index for new file
handles.women_right_eye_data_index = index;%data base index
guidata(hObject,handles);
tag = sprintf('woman_rig