⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 menu3.m

📁 Snake模型源码
💻 M
📖 第 1 页 / 共 2 页
字号:
%%%%%%%%%% 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', ...
   'String','Dmax:', ...
   'Interruptible','off', ...
   'BackgroundColor',[0.45 0.45 0.45], ...
   'ForegroundColor','white');


textPos=[ButtPosX+0.5*ButtWidth ButtPosY ButtWidth*0.35 TextHeight];
stringVal=num2str(dmax);
HDedit6 = uicontrol('Parent', HDmainf, ...
   'BusyAction','Queue','Interruptible','off',...
   'Style','edit', ...
   'Units','pixel', ...
   'Position',textPos, ...
   'Units','normal', ...
   'Horiz','right', ...
   'Background','white', ...
   'Foreground','black', ...
   'String',stringVal,'Value',dmax, ...
   'UserData',dmax,...
   'Enable','on',...
   'callback',callbackStr);


% UICONTROL for number of snake iterations 

ButtPosY = ButtPosY-ButtDist-ButtHeight;
labelPos=[ButtPosX+0.1*ButtWidth ButtPosY ButtWidth*0.5 TextHeight];
HDtext7 = uicontrol('Parent', HDmainf, ...
   'Style','text', ...
   'Units','pixels', ...
   'Position',labelPos, ...
   'Horiz','left', ...
   'String','Iterat.:', ...
   'Interruptible','off', ...
   'BackgroundColor',[0.45 0.45 0.45], ...
   'ForegroundColor','white');


textPos=[ButtPosX+0.5*ButtWidth ButtPosY ButtWidth*0.35 TextHeight];
stringVal=num2str(NoSnakeIterations);
HDedit7 = uicontrol('Parent', HDmainf, ...
   'BusyAction','Queue','Interruptible','off',...
   'Style','edit', ...
   'Units','pixel', ...
   'Position',textPos, ...
   'Units','normal', ...
   'Horiz','right', ...
   'Background','white', ...
   'Foreground','black', ...
   'String',stringVal,'Value',NoSnakeIterations, ...
   'UserData',NoSnakeIterations,...
   'Enable','on',...
   'callback',callbackStr);

% The Manual
labelStr='Manual';
ButtPosX=MenuPosX+0.5*ButtDist+MenuSizeX/2;
ButtPosY = ButtPosY-ButtDist-ButtHeight;
ButtWidth=MenuSizeX/2-1.5*ButtDist;

HDButton3=uicontrol('Parent', HDmainf, ...
   'BusyAction','Queue','Interruptible','off',...
   'Style','pushbutton', ...
   'Units','pixels', ...
   'Position',[ButtPosX ButtPosY ButtWidth ButtHeight], ...
   'String',labelStr, ...
   'Enable','on', ...
   'Callback','menu3(''ManualSnakeON'')');

% The Inic
labelStr='Initial.';
ButtPosX=MenuPosX+ButtDist;
HDButton4=uicontrol('Parent', HDmainf, ...
   'BusyAction','Queue','Interruptible','off',...
   'Style','pushbutton', ...
   'Units','pixels', ...
   'Position',[ButtPosX ButtPosY ButtWidth ButtHeight], ...
   'String',labelStr, ...
   'Enable','on', ...
   'Callback','menu3(''InicSnake'')');


% UICONTROL for Radius of snake
ButtWidth=MenuSizeX-2*ButtDist;
ButtPosY = ButtPosY-ButtDist-ButtHeight;
labelPos=[ButtPosX ButtPosY ButtWidth*0.5 TextHeight];
HDRadioButton1 = uicontrol('Parent', HDmainf, ...
   'Style','CheckBox', ...
   'Units','pixels', ...
   'Position',labelPos, ...
   'Horiz','left', ...
   'String','Radius:', ...
   'Interruptible','off', ...
   'BackgroundColor',[0.45 0.45 0.45], ...
   'ForegroundColor','white',...
   'Callback','menu3(''CallbackRadius'')',...
   'Value',CircleOn);

if (CircleOn==1) 
   en='On'; 
else 
   en='Off'; 
end;
callbackStr='menu3(''RadiusChange'')';
textPos=[ButtPosX+0.5*ButtWidth ButtPosY ButtWidth*0.35 TextHeight];
stringVal=num2str(IncSnakeRadius);
HDedit8 = uicontrol('Parent', HDmainf, ...
   'BusyAction','Queue','Interruptible','off',...
   'Style','edit', ...
   'Units','pixel', ...
   'Position',textPos, ...
   'Units','normal', ...
   'Horiz','right', ...
   'Background','white', ...
   'Foreground','black', ...
   'String',stringVal,'Value',IncSnakeRadius, ...
   'UserData',IncSnakeRadius,...
   'Enable',en,...
   'callback',callbackStr);

% UICONTROL for Dots on the snake
if (SnakeDotsON==0 )
   value=0;
else value=1; end;
   
ButtPosY = ButtPosY-ButtDist-ButtHeight;
labelPos=[ButtPosX ButtPosY ButtWidth*0.5 TextHeight];
HDRadioButton2 = uicontrol('Parent', HDmainf, ...
   'Style','CheckBox', ...
   'Units','pixels', ...
   'Position',labelPos, ...
   'Horiz','left', ...
   'String','Dots', ...
   'Interruptible','off', ...
   'BackgroundColor',[0.45 0.45 0.45], ...
   'ForegroundColor','white',...
   'Callback','menu3(''CallbackDots'')',...
   'Value',value);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -