%%%%%%%%%% MENU 3 %%%%%%%%%%
function menu3(action,varargin)
if nargin<1,
action='Initialize';
end;
feval(action,varargin{:});
return;
function Initialize()
%%%% image processing variables
global Image1; % original image
global Image2; % blured image
global sigma;
global mu;
global NoGVFIterations; % number of iterations
global NoSnakeIterations; % number of Snake iterations
global VectorFieldButt;
global alpha beta gamma kappa dmin dmax; % parameters for the snake
global px py; % forse filed
global IncSnakeRadius; % inicializaton snake radius
global XSnake YSnake; % conture of the snake
%%%% interface variables
global VectorOfLocalMenuHD; %vector of local objects that can be arased in next step
global HDmainf; %main figure handle
global HDorigPic; %original picture axes handle
global HDbluredPic; %blured picture axes handle
global HDvectorFPic; %handle of vector field picture
global HDedit1 HDedit2 HDedit3 HDedit4 HDedit5 HDedit6 HDedit7; % handels of snake edit uicontrol
global HDSnakeLine; %vector of Handles of Snake lines on the picture
global HDedit8 HDedit9 HDRadioButton1 HDRadioButton2;
global HDButton1 HDButton2 HDButton4;
global SnakeON; %indicate if snake is visible
global CircleOn; % inicalization snake will be circle
global SnakeDotsON; % 1 if snake dots should be displeyed
global xsize ysize; %size of the picture
global adgeD MinSize MenuSizeX MenuSizeY MenuPosX MenuPosY;
global ButtHeight ButtWidth ButtDist TextHeight;
global DotsSize; % size in pixels of the dots on the snake
%%%%%% Close Old Objects %%%%%%%%
if ~isempty(VectorOfLocalMenuHD)
delete(VectorOfLocalMenuHD);
VectorOfLocalMenuHD=[];
end;
pause(0.1);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Define menu objects
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%plot the border for the menu
MenuSizeY=365;
MenuPosX=xsize*2+3*adgeD;
MenuPosY=ysize*2+3*adgeD-8-MenuSizeY;
HDMenuAxes=uicontrol( 'Parent',HDmainf , ...
'Style','frame', ...
'Units','pixels', ...
'Position',[MenuPosX MenuPosY MenuSizeX MenuSizeY],...
'BackgroundColor',[0.45 0.45 0.45]);
% Deform
labelStr='Deform';
ButtPosX=MenuPosX+0.5*ButtDist+MenuSizeX/2;
ButtPosY=MenuPosY+MenuSizeY-ButtDist-ButtHeight;
ButtWidth=MenuSizeX/2-1.5*ButtDist;
HDButton1=uicontrol('Parent', HDmainf, ...
'BusyAction','Queue','Interruptible','off',...
'Style','pushbutton', ...
'Units','pixels', ...
'Position',[ButtPosX ButtPosY ButtWidth ButtHeight], ...
'String',labelStr, ...
'Enable','on', ...
'Callback','SnakeIter');
% The BACK button
labelStr='<-- Back';
ButtPosX=MenuPosX+ButtDist;
HDButton2=uicontrol('Parent', HDmainf, ...
'BusyAction','Queue','Interruptible','off',...
'Style','pushbutton', ...
'Units','pixels', ...
'Position',[ButtPosX ButtPosY ButtWidth ButtHeight], ...
'String',labelStr, ...
'Enable','on', ...
'Callback','menu2');
% UICONTROL for alpha
ButtWidth=MenuSizeX-2*ButtDist;
ButtPosY = ButtPosY-ButtDist-ButtHeight;
labelPos=[ButtPosX+0.1*ButtWidth ButtPosY ButtWidth*0.5 TextHeight];
HDtext1 = uicontrol('Parent', HDmainf, ...
'Style','text', ...
'Units','pixels', ...
'Position',labelPos, ...
'Horiz','left', ...
'String','Alpha:', ...
'Interruptible','off', ...
'BackgroundColor',[0.45 0.45 0.45], ...
'ForegroundColor','white');
textPos=[ButtPosX+0.5*ButtWidth ButtPosY ButtWidth*0.35 TextHeight];
callbackStr = 'snakeset';
stringVal=num2str(alpha);
HDedit1 = uicontrol('Parent', HDmainf, ...
'BusyAction','Queue','Interruptible','off',...
'Style','edit', ...
'Units','pixel', ...
'Position',textPos, ...
'Units','normal', ...
'Horiz','right', ...
'Background','white', ...
'Foreground','black', ...
'String',stringVal,'Value',alpha, ...
'UserData',alpha,...
'Enable','on',...
'callback',callbackStr);
% UICONTROL for beta
ButtPosY = ButtPosY-ButtDist-ButtHeight;
labelPos=[ButtPosX+0.1*ButtWidth ButtPosY ButtWidth*0.5 TextHeight];
HDtext2 = uicontrol('Parent', HDmainf, ...
'Style','text', ...
'Units','pixels', ...
'Position',labelPos, ...
'Horiz','left', ...
'String','Beta:', ...
'Interruptible','off', ...
'BackgroundColor',[0.45 0.45 0.45], ...
'ForegroundColor','white');
textPos=[ButtPosX+0.5*ButtWidth ButtPosY ButtWidth*0.35 TextHeight];
stringVal=num2str(beta);
HDedit2 = uicontrol('Parent', HDmainf, ...
'BusyAction','Queue','Interruptible','off',...
'Style','edit', ...
'Units','pixel', ...
'Position',textPos, ...
'Units','normal', ...
'Horiz','right', ...
'Background','white', ...
'Foreground','black', ...
'String',stringVal,'Value',beta, ...
'UserData',beta,...
'Enable','on',...
'callback',callbackStr);
% UICONTROL for gamma
ButtPosY = ButtPosY-ButtDist-ButtHeight;
labelPos=[ButtPosX+0.1*ButtWidth ButtPosY ButtWidth*0.5 TextHeight];
HDtext3 = uicontrol('Parent', HDmainf, ...
'Style','text', ...
'Units','pixels', ...
'Position',labelPos, ...
'Horiz','left', ...
'String','Gamma:', ...
'Interruptible','off', ...
'BackgroundColor',[0.45 0.45 0.45], ...
'ForegroundColor','white');
textPos=[ButtPosX+0.5*ButtWidth ButtPosY ButtWidth*0.35 TextHeight];
stringVal=num2str(gamma);
HDedit3 = uicontrol('Parent', HDmainf, ...
'BusyAction','Queue','Interruptible','off',...
'Style','edit', ...
'Units','pixel', ...
'Position',textPos, ...
'Units','normal', ...
'Horiz','right', ...
'Background','white', ...
'Foreground','black', ...
'String',stringVal,'Value',gamma, ...
'UserData',gamma,...
'Enable','on',...
'callback',callbackStr);
% UICONTROL for kappa
ButtPosY = ButtPosY-ButtDist-ButtHeight;
labelPos=[ButtPosX+0.1*ButtWidth ButtPosY ButtWidth*0.5 TextHeight];
HDtext4 = uicontrol('Parent', HDmainf, ...
'Style','text', ...
'Units','pixels', ...
'Position',labelPos, ...
'Horiz','left', ...
'String','Kappa:', ...
'Interruptible','off', ...
'BackgroundColor',[0.45 0.45 0.45], ...
'ForegroundColor','white');
textPos=[ButtPosX+0.5*ButtWidth ButtPosY ButtWidth*0.35 TextHeight];
stringVal=num2str(kappa);
HDedit4 = uicontrol('Parent', HDmainf, ...
'BusyAction','Queue','Interruptible','off',...
'Style','edit', ...
'Units','pixel', ...
'Position',textPos, ...
'Units','normal', ...
'Horiz','right', ...
'Background','white', ...
'Foreground','black', ...
'String',stringVal,'Value',kappa, ...
'UserData',kappa,...
'Enable','on',...
'callback',callbackStr);
% UICONTROL for dmin
ButtPosY = ButtPosY-ButtDist-ButtHeight;
labelPos=[ButtPosX+0.1*ButtWidth ButtPosY ButtWidth*0.5 TextHeight];
HDtext5 = uicontrol('Parent', HDmainf, ...
'Style','text', ...
'Units','pixels', ...
'Position',labelPos, ...
'Horiz','left', ...
'String','Dmin:', ...
'Interruptible','off', ...
'BackgroundColor',[0.45 0.45 0.45], ...
'ForegroundColor','white');
textPos=[ButtPosX+0.5*ButtWidth ButtPosY ButtWidth*0.35 TextHeight];
stringVal=num2str(dmin);
HDedit5 = uicontrol('Parent', HDmainf, ...
'BusyAction','Queue','Interruptible','off',...
'Style','edit', ...
'Units','pixel', ...
'Position',textPos, ...
'Units','normal', ...
'Horiz','right', ...
'Background','white', ...
'Foreground','black', ...
'String',stringVal,'Value',dmin, ...
'UserData',dmin,...
'Enable','on',...
'callback',callbackStr);
% UICONTROL for dmax
ButtPosY = ButtPosY-ButtDist-ButtHeight;
labelPos=[ButtPosX+0.1*ButtWidth ButtPosY ButtWidth*0.5 TextHeight];
HDtext6 = uicontrol('Parent', HDmainf, ...
'Style','text', ...
'Units','pixels', ...
'Position',labelPos, ...
'Horiz','left', ...
'St