function image_blur(command) %IMAGE_BLUR - Compute the Blur filter of the current image % % IMAGE_BLUR(COMMAND) % % COMMAND - valid commands: % % START - set up the button frame and initialize % DOIT - do the actual filtering % UNDO - undo the filtering % % Claudio 28 Sept. 1995 % % % Copyright (c) 1995 by Claudio Rivetti and Mark Young % claudio@alice.uoregon.edu, mark@alice.uoregon.edu % global I Handlefig Uibgcolor B_frame method_pop Undofun undo_bt exe_bt if isempty(I) return; end if nargin==0 command='START'; end figure(Handlefig); % Position variables------------------------------------- pos=get(B_frame, 'Position'); uiwidth=0.12; uithick=0.035; middle=pos(1)+(pos(3)-uiwidth)/2; %-------------------------------------------------------- % Positions of buttons ---------------------------------- undo_pos = [middle pos(2)+0.35 uiwidth, uithick]; exec_pos = [middle pos(2)+0.45 uiwidth, uithick]; mp_pos = [middle pos(2)+.55 uiwidth uithick]; mt_pos = [middle-.005 pos(2)+.59 uiwidth+.005 uithick]; %-------------------------------------------------------- % Callbacks for the buttons --------------------------- exec_cbk = 'image_blur(''DOIT'');'; undo_cbk = 'image_blur(''UNDO'');'; %-------------------------------------------------------- if strcmp(command,'START') if ~isimage setviewmode('TOPVIEW'); showimage; end initbuttons('Blur Filter', 'Done'); exe_bt = uicontrol(gcf,'Style','push',... 'String', 'Execute',... 'Units', 'normalized', ... 'Position', exec_pos,... 'CallBack',exec_cbk); undo_bt = uicontrol(gcf,'Style','push',... 'String','Undo',... 'Units', 'normalized', ... 'Enable', 'off',... 'Position', undo_pos,... 'CallBack',undo_cbk); uicontrol(gcf,'Style','text',... 'String','Neighborhood',... 'Units','normalized',... 'Horiz', 'center',... 'BackgroundColor', Uibgcolor,... 'Position',mt_pos); method_pop=uicontrol(gcf, 'Style', 'popup',... 'Units', 'normalized',... 'position', mp_pos,... 'String', '3x3|5x5|7x7',... 'Value', 1); end % START if strcmp(command,'DOIT') f=watchon; statusbar('Filtering image...'); v=get(method_pop, 'value'); nn=[2*v+1 2*v+1]; h = fspecial('gaussian',nn); setimage(filter2(h,I)); set(undo_bt, 'Enable', 'on'); set(exe_bt, 'String', 'Re-Execute'); clearstatusbar; watchoff(f); end % DOIT if strcmp(command,'UNDO') undo; set(undo_bt, 'Enable', 'off'); end % UNDO return