function varargout = auto_landmarking_gui(varargin)
%
%    GENERAL
%
%      varargout = auto_landmarking_gui(varargin)
%
%    INPUT/S
%
%      -varargin:
%          currently no use.
%           
%    OUTPUT/S
%
%      -
%
%    PENDING WORK
%
%      -
%
%    KNOWN BUG/S
%
%      -
%
%    COMMENT/S
%
%      -
%
%    RELATED FUNCTION/S
%
%      
%
%    ABOUT
%
%      -Created:     February 12th, 2004
%      -Last update: 
%      -Revision:    0.0.9
%      -Author:      R. S. Schestowitz, University of Manchester
% ==============================================================

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
    'gui_Singleton',  gui_Singleton, ...
    'gui_OpeningFcn', @auto_landmarking_gui_OpeningFcn, ...
    'gui_OutputFcn',  @auto_landmarking_gui_OutputFcn, ...
    'gui_LayoutFcn',  [] , ...
    'gui_Callback',   []);
if nargin & isstr(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

function auto_landmarking_gui_OpeningFcn(hObject, eventdata, handles, varargin)

handles.output = hObject;

guidata(hObject, handles);

if strcmp(get(hObject,'Visible'),'off')
    initialize_gui(hObject, handles);
end

set(handles.resume, 'cdata', playbutton);
set(handles.pause, 'cdata', stopbutton);
set(handles.start_button, 'cdata', startbutton);
set(handles.reset_button, 'cdata', resetbutton);
set(handles.exit_button, 'cdata', exitbutton);

function varargout = auto_landmarking_gui_OutputFcn(hObject, eventdata, handles)


varargout{1} = handles.output;

function start = startbutton

start = iconize(imread('reg.jpg'));
start(start>240) = .69*255;

% ==================================================================== %   

function reset = resetbutton

reset = iconize(imread('reset.jpg'));
reset(reset>240) = .69*255;

% ==================================================================== %   

function stop = stopbutton

stop = iconize(imread('stop.jpg'));
stop(stop>240) = .69*255;

% ==================================================================== %   

function play = playbutton

play = iconize(imread('play.jpg'));
play(play>240) = .69*255;

% ==================================================================== %   

function exit = exitbutton

exit = iconize(imread('exit.jpg'));
exit(exit>240) = .69*255;

% ==================================================================== %   
function out = iconize(a)

% Find the size of the acquired image and determine how much data will need
% to be lost in order to form a 18x18 icon
[r,c,d] = size(a);
r_skip = ceil(r/25);
c_skip = ceil(c/25);

% Create the 25x25 icon (RGB data)
out = a(1:r_skip:end,1:c_skip:end,:);


function initialize_gui(fig_handle, handles)

background = imread('background.jpg');

axes(handles.background);
axis off;
imshow(background,[0,255]);

axes(handles.background2);
axis off;
imshow(background,[0,255]);

set(handles.iterations_box, 'String', '50');
set(handles.number_of_sample_points_box, 'String', '100');
set(handles.number_of_shapes_box, 'String', '10');
set(handles.quiet_level_box, 'String', '4');
set(handles.height_variation_box, 'String', '0');
set(handles.save_frequency_box, 'String', '0');
set(handles.height_variation_box, 'String', '0');
set(handles.subsets_box, 'String', '3');
set(handles.min_position_box, 'String', '0.9');
set(handles.max_position_box, 'String', '1.1');
set(handles.disable_bar, 'Value', 0);
set(handles.force_mdl, 'Value', 0);
set(handles.alter_precision_button, 'Value', 0);
set(handles.open_hands, 'Value', 0);


function start_button_Callback(hObject, eventdata, handles)

start_callback(str2num(get(handles.iterations_box, 'String')), ...
    str2num(get(handles.number_of_sample_points_box, 'String')), ...
    str2num(get(handles.number_of_shapes_box, 'String')), ...
    str2num(get(handles.quiet_level_box, 'String')), ...
    str2num(get(handles.height_variation_box, 'String')), ...
    get(handles.disable_bar, 'Value'), ...
    get(handles.force_mdl, 'Value'), ...
    str2num(get(handles.save_frequency_box, 'String')), ...
    str2num(get(handles.subsets_box, 'String')), ...
    str2num(get(handles.min_position_box, 'String')), ...
    str2num(get(handles.max_position_box, 'String')), ...
    get(handles.alter_precision_button, 'Value'), ...
    get(handles.open_hands, 'Value') ...
    );

function reset_button_Callback(hObject, eventdata, handles)

initialize_gui(hObject, handles);

function exit_button_Callback(hObject, eventdata, handles)

close;

function pause_button_Callback(hObject, eventdata, handles)

uiwait;

function resume_button_Callback(hObject, eventdata, handles)

uiresume;

function exit_menu_Callback(hObject, eventdata, handles)

exit_button_Callback(hObject, eventdata, handles)

function reset_menu_Callback(hObject, eventdata, handles)

reset_button_Callback(hObject, eventdata, handles)

function start_menu_Callback(hObject, eventdata, handles)

start_button_Callback(hObject, eventdata, handles)
