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

📄 fishdemo.m

📁 Edge detection with svm (doc and matlabcode)
💻 M
📖 第 1 页 / 共 2 页
字号:
case 'creatdata'   % == Invoke data set creator ============================================   creatset('finite',MAX_CLASS,'fishdemo','created',hfigure);case 'created'   % == Load new created data set ===========================================   % get handler and make this figure active   figure(hfigure);   h=get(hfigure,'UserData');   % get file name   path=varargin{1};   name=varargin{2};   pathname=strcat(path,name);   if checkdat(pathname,DATA_IDENT,2,0)==1,      file.pathname=pathname;      file.path=path;      file.name=name;      set(h.btload,'UserData',file);      fishdemo('loadsets',hfigure);      fishdemo('reset',hfigure);   else      errordlg('This file does not contain required data.','Bad file','modal');   endcase 'iterhandler'   % == Handler for edit line Iterations ====================================   h=get(hfigure,'UserData');   iter=round(str2num(get(h.editer,'String')));   if isempty(iter) | iter < 1, iter=1; end   set(h.editer,'String',num2str(iter));case 'getfile'   % == Invoke standard open file dialog ====================================   % Opens file and checks if contains appropriate data, if yes loads data.   h=get(hfigure,'UserData');   % change path to directory%%   wres=what('fisher');%%   cd(wres.path);   [name,path]=uigetfile('*.mat','Open file');   if name~=0,      file.pathname=strcat(path,name);      file.path=path;      file.name=name;      if checkdat(file.pathname,DATA_IDENT,2,0)==1,         set(h.btload,'UserData',file);         fishdemo('loadsets',hfigure);         fishdemo('reset',hfigure);      else         errordlg('This file does not contain required data.','Bad file','modal');      end   endcase 'reset'   % == Reset adaptation process, set t = 0 =====================================   h=get(hfigure,'UserData');          % get handlers   sets=get(h.axes1,'UserData');         % loaded sets   if isempty(sets)==0,     % zeroes the parameters of separation lines      h.lines.alphas=zeros(size(sets.K,2),2);      h.lines.t=0;      if isempty(h.lines.handlers)==1,         % create the new lines         h.lines.handlers=pfish2d(h.lines.alphas');         han=h.lines.handlers;      else         % change parameters of line         h.lines.handlers=pfish2d(h.lines.alphas',h.lines.handlers);      end % if h.lines==-1      % set up handlers      set(hfigure,'UserData',h);      file=get(h.btload,'UserData');      consoletext=sprintf('Step t=0\nNo separation line');      titletext=sprintf('File: %s, # of points K = %d',file.name,sum(sets.K));   else      consoletext=sprintf('No data loaded.\nPress Load data button.\n');      titletext='';      pos=get(h.axes1,'Position');      fsize=min(pos(3),pos(4))/10;      setaxis(h.axes1,[-1 1 -1 1]);      builtin('text',0,0,'Press ''Load data'' button.',...         'HorizontalAlignment','center',...         'FontUnits','normalized',...         'Clipping','on',...         'FontSize',fsize);   end   % show comment   set(h.console,'String',consoletext );   % print title   pos=get(h.axes1,'Position');   fsize=(1-pos(2)-pos(4))*1;   title(titletext,...      'VerticalAlignment','bottom',...      'HorizontalAlignment','left',...      'FontUnits','normalized',...      'Units','normalized',...      'Position',[0 1 0],...      'FontSize',fsize);case 'loadsets'   % == Load sets from file ========================================================   % Get a file name from pop up menu according to index in variable named value.   % Than clear axes, load new file and appear points from the file.   h=get(hfigure,'UserData');                   % uicontrol handlers   % Clear axes   clrchild(h.axes1);   set(h.axes1, ...      'DrawMode','fast',...      'Box','on');   xlabel('feature x');   ylabel('feature y');   % No separation lines    h.lines.handlers = [];   set(hfigure,'UserData',h);   % Get file name with sets X1 and X2   file=get(h.btload,'UserData');   % Load sets to structure sets   sets=load(file.pathname);   % store loaded sets   set(h.axes1,'UserData',sets);   % set axes according to current points   win=cmpwin(min(sets.X'),max(sets.X'),BORDER,BORDER);   %%%axis(win);   setaxis(h.axes1,win);   % plots sets of the points%%   pplot(sets.X,sets.I);   ppoints(sets.X,sets.I);case 'step'   % == Perform one adaptation step ================================================   h=get(hfigure,'UserData');                      % get handlers we will need...   % get sets   sets=get(h.axes1,'UserData');   if isempty(sets)==1,      return;   end   % get the current time (number of steps) and the current solution (vectors alpha)   t=h.lines.t;   alphas=h.lines.alphas;   % get # of iter.   iter=max(1,str2num(get(h.editer,'String')));   switch get(h.pualgo,'Value')   case 1      [alphas,solution,tplus1]=fisherp(sets.X,sets.I,size(sets.K,2),iter,t,alphas);   case 2      [alphas,solution,tplus1]=fisherk(sets.X,sets.I,size(sets.K,2),iter,t,alphas);   end   t=tplus1;   h.lines.t=t;   h.lines.alphas=alphas;   h.lines.handlers=pfish2d(alphas,h.lines.handlers);   % If the time is the same like before adaptation, it means that soulution is found.   if solution==0,      % appear time and line      text=sprintf('Step t=%d',t);   else      % Adaptation is done      text=sprintf('Step t=%d\nSolution is found.',t);   end %if t~=tplus1   set(h.console,'String',text );   % store handlers   set(hfigure,'UserData',h);   drawnow;case 'play'   % == Start up adaptation process =================================================   % Perform adaptation step by step until the separation line is found or the stop   % button is pushed down.   h=get(hfigure,'UserData');                     % get handlers   % get sets   sets=get(h.axes1,'UserData');   if isempty(sets)==1,      return;   end   % Disable the buttons and the popup menus.   set([h.btinfo h.btstep h.btclose h.btplay h.btreset h.btload h.btcreat h.pualgo],...      'Enable','off');   % Only stop button can be pushed down   set(h.btstop,'Enable','on');   % get the current time (number of steps) and the current solution (vectors alpha)   t=h.lines.t;   alphas=h.lines.alphas;   % The stop button was not pushed yet.   set(h.btstop,'UserData',0);   play=1;   % Play - adaptation process   while play==1 & get(h.btstop,'UserData')==0,      % get # of iter.      iter=max(1,str2num(get(h.editer,'String')));      switch get(h.pualgo,'Value')      case 1         [alphas,solution,tplus1]=fisherp(sets.X,sets.I,size(sets.K,2),iter,t,alphas);      case 2         [alphas,solution,tplus1]=fisherk(sets.X,sets.I,size(sets.K,2),iter,t,alphas);      end      t=tplus1;      h.lines.t=t;      h.lines.alphas=alphas;      h.lines.handlers=pfish2d(alphas,h.lines.handlers);      % If the time is the same like before adaptation, it means that soulution is found.      if solution==0,         % appear time and line         text=sprintf('Step t=%d',t);      else         % Adaptation is done         text=sprintf('Step t=%d\nSolution is found.',t);         play=0;      end %if t~=tplus1      set(h.console,'String',text );      % Flush the queue with graph. objects and events.      drawnow;   end   % Enable buttons and popup menus   set([h.btinfo h.btstep h.btclose h.btplay h.btreset h.pualgo h.btload h.btcreat],...      'Enable','on');   % disable stop button   set(h.btstop,'Enable','off');   % store handlers    set(hfigure,'UserData',h);case 'info'   helpwin(mfilename);end % switch(action)

⌨️ 快捷键说明

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