function discrim(command,arg2) % % discrim(command,arg2): GUI for discrimination models % % Author: Michael Landy - landy@nyu.edu % % userdata for the figure window is a structure with fields: % %************************************************************************* % *** WHEN ANOTHER FIGURE WINDOW IS DEFINED, ADD IT TO THE FIGHANDLES LIST % AND, MORE IMPORTANTLY, CHANGE THE DEFINITION OF ud.fighandles in case % 'initialize' % ************************************************************************ % % fighandles: % 1 single filter uniform masking window % 2 image directory window % 3 save image window % 4 MTF display characteristics window % 5 add grating edit image window % 6 add Gabor edit image window % 7 add file edit image window % 8 add image edit image window % 9 viewing conditions display characteristics window % 10 load image window % 11 new image window % 12 scale edit image window % 13 clip edit image window % 14 undo edit image window % 15 input noise display characteristics window % 16 gamma display characteristics window % 17 output noise display characteristics window % mainhandles: % 1 main window: leftaxis % 2 main window: rightaxis % 3 main window: leftnumber % 4 main window: rightnumber % 5 main window: calcresult % 6 left image % 7 right image % 8 main window: leftname % 9 main window: rightname % 10 main window: left image size % 11 main window: right image size % 12 main window: display control % 13 main window: current model % mainmodelmenuhandles: % 1 SFUM % maindctrlmenuhandles: % 1 As Is % 2 Stretch % 3 Full Range % -------------- % 4 Raw Image % 5 After MTF % 6 After Poisson noise % 7 After Gamma % 8 After Gaussian noise % sfumhandles: % 1 sfum center spread % 2 sfum frequency cut % 3 sfum spread ratio % 4 sfum amplitude ratio % 5 sfum contrast sensitivity maximum % 6 sfum mask contrast threshold % 7 sfum beta % newimghandles: % 1 new image: image number % 2 new image: image name % 3 new image: rows % 4 new image: columns % loadimghandles: % 1 load image: image number % 2 load image: image name % 3 load image: path % 4 load image: filename % savimghandles: % 1 save image: image number % 2 save image: image name % 3 save image: path % 4 save image: filename % directoryhandles: % 1 "Left" heading % 2 "Right" heading % dstringhandles: array of text ui's % agrathandles: % 1 add grating: image number % 2 add grating: image name % 3 add grating: SF % 4 add grating: orientation editable text % 5 add grating: orientation slider % 6 add grating: phase editable text % 7 add grating: phase slider % 8 add grating: contrast editable text % 9 add grating: contrast slider % agabhandles: % 1 add Gabor: image number % 2 add Gabor: image name % 3 add Gabor: envelope orientation editable text % 4 add Gabor: envelope orientation slider % 5 add Gabor: sigma iso editable text % 6 add Gabor: sigma ortho editable text % 7 add Gabor: modulator SF % 8 add Gabor: modulator orientation editable text % 9 add Gabor: modulator orientation slider % 10 add Gabor: modulator phase editable text % 11 add Gabor: modulator phase slider % 12 add Gabor: modulator contrast editable text % 13 add Gabor: modulator contrast slider % 14 add Gabor: row offset % 15 add Gabor: column offset % afilehandles: % 1 add file: image number % 2 add file: image name % 3 add file: path % 4 add file: filename % 5 add file: row offset % 6 add file: column offset % aimghandles: % 1 add file: to image number % 2 add file: to image name % 3 add file: from image number % 4 add file: from image name % 5 add image: row offset % 6 add image: column offset % scalehandles: % 1 scale image: image number % 2 scale image: image name % 3 scale image: contrast scale % 4 scale image: contrast shift % cliphandles: % 1 clip image: image number % 2 clip image: image name % 3 clip image: low check box % 4 clip image: low contrast value % 5 clip image: high check box % 6 clip image: high contrast value % undohandles: % 1 undo image edit: op % 2 undo image edit: image number/name % mtfhandles: % 1 x=y toggle % 2 x sigma % 3 y sigma % 4 x sigma 2 % 5 y sigma 2 % 6 peak ratio % 7 path % 8 filename % 9 Browse button % 10 axes % inputhandles: % 1 mean pixel photon count % 2 mean luminance % 3 integration time % 4 dominant wavelength % 5 efficiency % 6 pupil diameter % gammahandles: % 1 liftoff editable text % 2 liftoff slider % 3 gamma editable text % 4 gamma slider % 5 mincontrast editable text % 6 mincontrast slider % 7 maxcontrast editable text % 8 maxcontrast slider % 9 axes % outputhandles: % 1 rms noise contrast % vgeomhandles: % 1 vgeom vdist % 2 vgeom hpixperdeg % 3 vgeom vpixperdeg % 4 vgeom hpixpercm % 5 vgeom vpixpercm % 6 vgeom hpixels % 7 vgeom vpixels % 8 vgeom hsizecm % 9 vgeom vsizecm % 10 vgeom hsizedeg % 11 vgeom vsizedeg % 12 vgeom square pixels checkbox % 13 vgeom square image checkbox % savimgradiohandles % 1 Matlab % 2 BMP % 3 HDF % 4 JPEG % 5 PCX % 6 TIFF % 7 XWD % dlradiohandles % drradiohandles % agratsfradiohandles % 1 cycles/degree % 2 cycles/cm % 3 cycles/image width % agrattyperadiohandles % 1 sine % 2 square % 3 triangle % agabsigradiohandles % 1 deg % 2 cm % 3 pixels % agabsfradiohandles % 1 cycles/degree % 2 cycles/cm % 3 cycles/image width % afileradiohandles % 1 add % 2 overlay % 3 overlay with transparency % 4 multiply % aimgradiohandles % 1 add % 2 overlay % 3 overlay with transparency % 4 multiply % mtftyperadiohandles % 1 flat % 2 Gaussian % 3 DOG % 4 empirical % mtfunitsradiohandles % 1 cycles/degree % 2 cycles/cm % 3 cycles/image width % 4 degrees % 5 cm % 6 image widths % inputradiohandles % 1 no noise % 2 based on mean photon count % 3 calculated % gammaradiohandles % 1 disable gamma % 2 enable gamma % outputradiohandles % 1 no noise % 2 Gaussian noise % fignums % figs{indx} % img (= raw image) % name % validity % 0 = only raw image % 1 = blur image (post MTF) % 2 = Poisson image % 3 = gamma image % 4 = noise image (post late Gaussian noise) % blurimg % poissonimg % gammaimg % noiseimg % currmodel % 1 SFUM % dctrl % 1 As Is % 2 Stretch % 3 Full Range % dlevel % 1 Raw % 2 post MTF % 3 post Poisson noise % 4 post Gamma % 5 post Gaussian noise % undo % op % num % img % mtf % type % 1=Flat, 2=Gaussian, 3=DoG, 4=Empirical % square % 1=square MTF (x=y) % xsigma % all stored in cycles/degree % ysigma % xsigma2 % ysigma2 % xratio % yratio % mtfarray - 1st column = SF (cpd), 2nd column = MT (x), % option 3rd column = MT(y) % mtfimg % imgvalid % input % type (1 = none, 2 = based on mean count, 3 = calculated) % meancount % lum % time % wl % eff % diam % gamma % enabled (1 = yes) % liftoff % gamma % mincontrast % maxcontrast % output % noise (1 = yes) % rms % noiseimg % imgvalid % conditions % vdist (cm) % hpixelsperdeg, vpixelsperdeg % hpixelspercm, vpixelspercm % hpixels, vpixels % hsize (cm), vsize (cm) % hsize (deg), vsize (deg) % params % simple % ... global ud; if nargin == 0 % if first call, it's an initialization command = 'initialize'; end if ~strcmp(command,'initialize') % get the user data from the top window h0 = gcf; while get(h0,'Parent') ~= 0 h0 = get(h0,'Parent'); end ud = get(h0,'userdata'); if ~isstruct(ud) h0 = get(h0,'userdata'); % will the real top window % please stand up? ud = get(h0,'userdata'); end else ud = []; end % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Main switch % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% switch(command) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Initialize - set up main window % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'initialize' % INITIALIZE top window ud.fighandles = zeros(1,17); % *** UPDATE THIS *** s = get(0,'Units'); set(0,'Units','characters'); dsize = get(0,'ScreenSize'); set(0,'Units',s); % reset root figure units to previous value ud.screenwidth = fix(dsize(3)); ud.screenheight = fix(dsize(4)); h0 = figure('Units','characters', ... 'Position',screenposn([20 8 135 50]),'Color',[.8 .8 .8], ... 'MenuBar','none','NumberTitle','off', ... 'Name','Image Discriminator', ... 'DeleteFcn','discrim(''delete-mainwin'')'); h1 = uimenu('Parent',h0,'Label','Model'); ud.mainmodelmenuhandles(1) = ... uimenu('Parent',h1,'Label', ... 'Single Filter, Unif. Masking', ... 'checked','on', ... 'CallBack','discrim(''menu-model'',1)'); h1 = uimenu('Parent',h0,'Label','Model Parameters'); uimenu('Parent',h1,'Label', ... 'Single Filter, Unif. Masking', ... 'CallBack','discrim(''menu-modelparam-sfum'')'); h1 = uimenu('Parent',h0,'Label','Image'); uimenu('Parent',h1,'Label','New', ... 'CallBack','discrim(''menu-image-new'')'); uimenu('Parent',h1,'Label','Load', ... 'CallBack','discrim(''menu-image-load'')'); uimenu('Parent',h1,'Label','Save', ... 'CallBack','discrim(''menu-image-save'')'); uimenu('Parent',h1,'Label','Delete', ... 'CallBack','discrim(''menu-image-delete'')'); uimenu('Parent',h1,'Label','Directory', ... 'CallBack','discrim(''menu-image-directory'')'); h1 = uimenu('Parent',h0,'Label','Edit Image'); uimenu('Parent',h1,'Label','Clear', ... 'CallBack','discrim(''menu-edimage-clear'')'); uimenu('Parent',h1,'Label','Add Grating', ... 'CallBack','discrim(''menu-edimage-agrat'')'); uimenu('Parent',h1,'Label','Add Gabor', ... 'CallBack','discrim(''menu-edimage-agab'')'); uimenu('Parent',h1,'Label','Combine File', ... 'CallBack','discrim(''menu-edimage-afile'')'); uimenu('Parent',h1,'Label','Combine Image', ... 'CallBack','discrim(''menu-edimage-aimg'')'); uimenu('Parent',h1,'Label','Scale', ... 'CallBack','discrim(''menu-edimage-scale'')'); uimenu('Parent',h1,'Label','Clip', ... 'CallBack','discrim(''menu-edimage-clip'')'); uimenu('Parent',h1,'Label','Undo', ... 'CallBack','discrim(''menu-edimage-undo'')'); h1 = uimenu('Parent',h0,'Label','Display Characteristics'); uimenu('Parent',h1, ... 'Label','Viewing Geometry', ... 'CallBack','discrim(''menu-dispchar-vgeom'')'); uimenu('Parent',h1, ... 'Label','MTF', ... 'CallBack','discrim(''menu-dispchar-mtf'')'); uimenu('Parent',h1, ... 'Label','Input Noise', ... 'CallBack','discrim(''menu-dispchar-input'')'); uimenu('Parent',h1, ... 'Label','Gamma', ... 'CallBack','discrim(''menu-dispchar-gamma'')'); uimenu('Parent',h1, ... 'Label','Output Noise', ... 'CallBack','discrim(''menu-dispchar-output'')'); h1 = uimenu('Parent',h0,'Label','Display Control'); ud.maindctrlmenuhandles(1) = ... uimenu('Parent',h1,'Label','As Is', ... 'checked','on', ... 'CallBack','discrim(''menu-dctrl'',1)'); ud.maindctrlmenuhandles(2) = ... uimenu('Parent',h1,'Label','Stretch', ... 'CallBack','discrim(''menu-dctrl'',2)'); ud.maindctrlmenuhandles(3) = ... uimenu('Parent',h1,'Label','Full Range', ... 'CallBack','discrim(''menu-dctrl'',3)'); ud.maindctrlmenuhandles(4) = ... uimenu('Parent',h1,'Label','Raw image', ... 'Separator','on','checked','on', ... 'CallBack','discrim(''menu-dctrl'',4)'); ud.maindctrlmenuhandles(5) = ... uimenu('Parent',h1,'Label','After MTF', ... 'CallBack','discrim(''menu-dctrl'',5)'); ud.maindctrlmenuhandles(6) = ... uimenu('Parent',h1,'Label','After Poisson noise', ... 'CallBack','discrim(''menu-dctrl'',6)'); ud.maindctrlmenuhandles(7) = ... uimenu('Parent',h1,'Label','After gamma curve', ... 'CallBack','discrim(''menu-dctrl'',7)'); ud.maindctrlmenuhandles(8) = ... uimenu('Parent',h1,'Label','After Gaussian noise', ... 'CallBack','discrim(''menu-dctrl'',8)'); uimenu('Parent',h1,'Label','New noise', ... 'Separator','on','CallBack','discrim(''menu-newnoise'')'); ud.mainhandles(1) = axes('Parent',h0,'Units','normalized', ... 'Position',[.07 .33 .4 .44],'Color',[.7 0 .7], ... 'XColor',[.8 .8 .8],'YColor',[.8 .8 .8], ... 'Box','off','DataAspectRatio',[1 1 1], ... 'PlotBoxAspectRatio',[1 1 1],'TickDir','out', ... 'Xlim',[0 1],'Ylim',[0 1],'Ydir','reverse', ... 'Clim',[-1 1]); ud.mainhandles(6) = image('Cdata',[0 0;0 0], ... 'CDataMapping','scaled','XData',calcxydata(.05,2), ... 'YData',calcxydata(.05,2), ... 'ButtonDownFcn','discrim(''main-select-left'')'); colormap(gray); ud.mainhandles(2) = axes('Parent',h0,'Units','normalized', ... 'Position',[.53 .33 .4 .44],'Color',[.7 .7 .7], ... 'XColor',[.8 .8 .8],'YColor',[.8 .8 .8], ... 'Box','off','DataAspectRatio',[1 1 1], ... 'PlotBoxAspectRatio',[1 1 1],'TickDir','out', ... 'Xlim',[0 1],'Ylim',[0 1],'Ydir','reverse', ... 'Clim',[-1 1]); ud.mainhandles(7) = image('Cdata',[0 0;0 0], ... 'CDataMapping','scaled','XData',calcxydata(.05,2), ... 'YData',calcxydata(.05,2), ... 'ButtonDownFcn','discrim(''main-select-right'')'); colormap(gray); uicontrol('Parent',h0, ... 'Units','normalized','Position',[.07 .9 .1 .05],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','text','String','Image #'); uicontrol('Parent',h0, ... 'Units','normalized','Position',[.21 .9 .26 .05],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','text','String','Name'); ud.mainhandles(3) = uicontrol('Parent',h0, ... 'Callback','discrim(''main-set-leftnum'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.07 .84 .1 .05],'Style','edit','String',''); ud.mainhandles(8) = uicontrol('Parent',h0, ... 'Callback','discrim(''main-set-leftname'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.21 .84 .26 .05],'Style','edit', ... 'HorizontalAlignment','left','String',''); ud.mainhandles(10) = uicontrol('Parent',h0, ... 'Units','normalized','Position',[.07 .78 .4 .05],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','text','String',''); uicontrol('Parent',h0, ... 'Units','normalized','Position',[.53 .9 .1 .05],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','text','String','Image #'); uicontrol('Parent',h0, ... 'Units','normalized','Position',[.67 .9 .26 .05],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','text','String','Name'); ud.mainhandles(4) = uicontrol('Parent',h0, ... 'Callback','discrim(''main-set-rightnum'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.53 .84 .1 .05],'Style','edit','String',''); ud.mainhandles(9) = uicontrol('Parent',h0, ... 'Callback','discrim(''main-set-rightname'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.67 .84 .26 .05],'Style','edit', ... 'HorizontalAlignment','left','String',''); ud.mainhandles(11) = uicontrol('Parent',h0, ... 'Units','normalized','Position',[.53 .78 .4 .05],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','text','String',''); uicontrol('Parent',h0, ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.1 .06 .14 .05], ... 'String','Calculate', ... 'Callback','discrim(''main-calculate'')'); ud.mainhandles(5) = uicontrol('Parent',h0, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'HorizontalAlignment','left', ... 'Position',[.3 .06 .4 .05],'Style','text'); uicontrol('Parent',h0, ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.76 .06 .14 .05], ... 'String','Quit','Callback','discrim(''main-quit'')'); ud.mainhandles(12) = uicontrol('Parent',h0, ... 'Units','normalized','Position',[.1 .22 .8 .09],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','text', ... 'String',{'Display contrast: As Is' 'Image Displayed: Raw Image'}); ud.mainhandles(13) = uicontrol('Parent',h0, ... 'Units','normalized','Position',[.1 .15 .9 .05],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','text','String', ... 'Current model: Single Filter, Uniform Masking'); ud.fignums = []; ud.figs = {}; ud.currmodel = 1; % SFUM is the default ud.dctrl = 1; % AS IS is the default ud.dlevel = 1; % Raw image is the default ud.vgeom.vdist = 100; % in cm ud.vgeom.hpixperdeg = 30; ud.vgeom.vpixperdeg = 30; ud.vgeom.hpixpercm = ... ud.vgeom.hpixperdeg/(ud.vgeom.vdist*tan(pi/180)); ud.vgeom.vpixpercm = ... ud.vgeom.vpixperdeg/(ud.vgeom.vdist*tan(pi/180)); ud.vgeom.hpixel = 128; ud.vgeom.vpixel = 128; ud.vgeom.hsizecm = ud.vgeom.hpixel/ud.vgeom.hpixpercm; ud.vgeom.vsizecm = ud.vgeom.vpixel/ud.vgeom.vpixpercm; ud.vgeom.hsizedeg = ud.vgeom.hpixel/ud.vgeom.hpixperdeg; ud.vgeom.vsizedeg = ud.vgeom.vpixel/ud.vgeom.vpixperdeg; ud.params.simple.ctrspr = 2; % center spread in min ud.params.simple.freqcut = 60/(sqrt(pi)*ud.params.simple.ctrspr); % freq cutoff in cpd ud.params.simple.sprdratio = 8; % surround spread/center spread ud.params.simple.ampratio = .685; % surround DC ampl/center DC ampl ud.params.simple.consensmax = 114; % contrast sensitivity maximum ud.params.simple.maskconthresh = .05; % masked contrast threshold ud.params.simple.beta = 2; % slope ud.mtf.type = 1; % Flat MTF ud.mtf.square = 1; % Square MTF ud.mtf.xsigma = 15; % in cycles/degree always ud.mtf.ysigma = 15; ud.mtf.xsigma2 = 8; ud.mtf.ysigma2 = 8; ud.mtf.ratio = .5; ud.mtf.mtfarray = [0 1 ; 60 1]; ud.mtf.imgvalid = 0; ud.input.type = 1; % no Poisson noise ud.input.meancount = 100; ud.input.lum = .1; ud.input.time = 40; ud.input.wl = 580; ud.input.eff = 10; ud.input.diam = 6; ud.gamma.enabled = 0; % no gamma curve ud.gamma.liftoff = 0; ud.gamma.gamma = 3; ud.gamma.mincontrast = -1; ud.gamma.maxcontrast = 1; ud.output.noise = 0; % no Gaussian noise ud.output.rms = .1; ud.output.imgvalid = 0; ud.currentside = 1; % 1 = left, 2 = right ud.dstringhandles = []; ud.dlradiohandles = []; ud.drradiohandles = []; ud.directoryhandles = zeros(1,2); ud.undo.op = ''; ud.undo.num = 0; ud.undo.img = []; rand('state',sum(100*clock)) % set random number generator to random % initial state ud.vlambda = [ 380, 3.9e-5 ; 385, 6.4e-5 ; 390, 1.2e-4 ; 395, 2.17e-4 ; 400, 3.96e-4 ; 405, 6.40e-4 ; 410, .0012100 ; 415, .0021800 ; 420, .0040000 ; 425, .0073000 ; 430, .011600 ; 435, .016840 ; 440, .023000 ; 445, .029800 ; 450, .038000 ; 455, .048000 ; 460, .060000 ; 465, .073900 ; 470, .090980 ; 475, .11260 ; 480, .13902 ; 485, .16930 ; 490, .20802 ; 495, .25860 ; 500, .32300 ; 505, .40730 ; 510, .50300 ; 515, .60820 ; 520, .71000 ; 525, .79320 ; 530, .86200 ; 535, .91485 ; 540, .95400 ; 545, .98030 ; 550, .99495 ; 555, 1 ; 560, .99500 ; 565, .97860 ; 570, .95200 ; 575, .91540 ; 580, .87000 ; 585, .81630 ; 590, .75700 ; 595, .69490 ; 600, .63100 ; 605, .56680 ; 610, .50300 ; 615, .44120 ; 620, .38100 ; 625, .32100 ; 630, .26500 ; 635, .21700 ; 640, .17500 ; 645, .13820 ; 650, .10700 ; 655, .081600 ; 660, .061000 ; 665, .044580 ; 670, .032000 ; 675, .023200 ; 680, .017000 ; 685, .011920 ; 690, .0082100 ; 695, .0057230 ; 700, .0041020 ; 705, .0029290 ; 710, .0020910 ; 715, .0014840 ; 720, .0010470 ; 725, 7.4e-4 ; 730, 5.2e-4 ]; % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Main window callbacks % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'main-select-left' selectleft; case 'main-select-right' selectright; case 'main-set-leftnum' if chkposint(ud.mainhandles(3),'Left image number') num = str2num(get(ud.mainhandles(3),'String')); if isempty(ud.fignums) indx = []; else indx = find(ud.fignums==num); end if length(indx) == 1 set(ud.mainhandles(8),'String',ud.figs{indx}.name); showimg(1,indx); [m,n] = size(ud.figs{indx}.img); set(ud.mainhandles(10),'String',fmtsize(m,n)); else indx = length(ud.fignums)+1; newfig.name = ''; newfig.img = zeros(ud.vgeom.vpixel,ud.vgeom.hpixel); newfig.validity = 0; % set size/lum/contrast/contrast scale? ud.fignums(indx) = num; ud.figs{indx} = newfig; set(ud.mainhandles(8),'String',''); showimg(1,indx); set(ud.mainhandles(10),'String', ... fmtsize(ud.vgeom.vpixel,ud.vgeom.hpixel)); end else set(ud.mainhandles(3),'String',''); set(ud.mainhandles(8),'String',''); set(ud.mainhandles(10),'String',''); set(ud.mainhandles(6),'Cdata',[0 0;0 0], ... 'XData',calcxydata(.05,2), ... 'YData',calcxydata(.05,2)); end update_directory; case 'main-set-leftname' if (isempty(get(ud.mainhandles(3),'String'))) msgbox('Select an image before naming it','Error window', ... 'error','modal'); set(ud.mainhandles(8),'String',''); elseif chkposint(ud.mainhandles(3),'Left image number') num = str2num(get(ud.mainhandles(3),'String')); if isempty(ud.fignums) indx = []; else indx = find(ud.fignums==num); end if length(indx) == 1 ud.figs{indx}.name = get(ud.mainhandles(8),'String'); s = get(ud.mainhandles(4),'String'); if (~isempty(s) & str2num(s)==num) set(ud.mainhandles(9),'String', ... ud.figs{indx}.name); end else msgbox(['Can''t find image ' num2str(num)], ... 'Error window','error','modal'); set(ud.mainhandles(3),'String',''); set(ud.mainhandles(8),'String',''); end update_directory; else set(ud.mainhandles(3),'String',''); set(ud.mainhandles(8),'String',''); set(ud.mainhandles(10),'String',''); set(ud.mainhandles(6),'Cdata',[0 0;0 0], ... 'XData',calcxydata(.05,2), ... 'YData',calcxydata(.05,2)); end case 'main-set-rightnum' if chkposint(ud.mainhandles(4),'Right image number') num = str2num(get(ud.mainhandles(4),'String')); if isempty(ud.fignums) indx = []; else indx = find(ud.fignums==num); end if length(indx) == 1 set(ud.mainhandles(9),'String',ud.figs{indx}.name); showimg(2,indx); [m,n] = size(ud.figs{indx}.img); set(ud.mainhandles(11),'String',fmtsize(m,n)); else indx = length(ud.fignums)+1; newfig.name = ''; newfig.img = zeros(ud.vgeom.vpixel,ud.vgeom.hpixel); newfig.validity = 0; % set size/lum/contrast/contrast scale? ud.fignums(indx) = num; ud.figs{indx} = newfig; set(ud.mainhandles(9),'String',newfig.name); showimg(2,indx); set(ud.mainhandles(11),'String', ... fmtsize(ud.vgeom.vpixel,ud.vgeom.hpixel)); end else set(ud.mainhandles(4),'String',''); set(ud.mainhandles(9),'String',''); set(ud.mainhandles(11),'String',''); set(ud.mainhandles(7),'Cdata',[0 0;0 0], ... 'XData',calcxydata(.05,2), ... 'YData',calcxydata(.05,2)); end update_directory; case 'main-set-rightname' if (isempty(get(ud.mainhandles(4),'String'))) msgbox('Select an image before naming it','Error window', ... 'error','modal'); set(ud.mainhandles(9),'String',''); elseif chkposint(ud.mainhandles(4),'Right image number') num = str2num(get(ud.mainhandles(4),'String')); if isempty(ud.fignums) indx = []; else indx = find(ud.fignums==num); end if length(indx) == 1 ud.figs{indx}.name = get(ud.mainhandles(9),'String'); s = get(ud.mainhandles(3),'String'); if (~isempty(s) & str2num(s)==num) set(ud.mainhandles(8),'String',ud.figs{indx}.name); end else msgbox(['Can''t find image ' num2str(num)], ... 'Error window','error','modal'); set(ud.mainhandles(4),'String',''); set(ud.mainhandles(9),'String',''); end update_directory; else set(ud.mainhandles(4),'String',''); set(ud.mainhandles(9),'String',''); set(ud.mainhandles(11),'String',''); set(ud.mainhandles(7),'Cdata',[0 0;0 0], ... 'XData',calcxydata(.05,2), ... 'YData',calcxydata(.05,2)); end case 'main-calculate' if ud.fighandles(9)==0 | strcmp(get(ud.fighandles(9),'Visible'),'off') i = 1; else i = vgeomset(h0,ud); end if i if isempty(get(ud.mainhandles(3),'String')) | ... isempty(get(ud.mainhandles(4),'String')) msgbox('Both images must be defined','Error window', ... 'error','modal'); elseif ~chkposint(ud.mainhandles(3),'Left image number') set(ud.mainhandles(3),'String',''); set(ud.mainhandles(8),'String',''); set(ud.mainhandles(10),'String',''); set(ud.mainhandles(6),'Cdata',[0 0;0 0], ... 'XData',calcxydata(.05,2), ... 'YData',calcxydata(.05,2)); elseif ~chkposint(ud.mainhandles(4),'Right image number') set(ud.mainhandles(4),'String',''); set(ud.mainhandles(9),'String',''); set(ud.mainhandles(11),'String',''); set(ud.mainhandles(7),'Cdata',[0 0;0 0], ... 'XData',calcxydata(.05,2), ... 'YData',calcxydata(.05,2)); else numl = str2num(get(ud.mainhandles(3),'String')); numr = str2num(get(ud.mainhandles(4),'String')); if numl == numr msgbox('Both images are identical','Error window', ... 'error','modal'); else indxl = find(ud.fignums==numl); indxr = find(ud.fignums==numr); if isempty(indxl) msgbox('Left image hasn''t been defined yet', ... 'Error window','error','modal'); elseif isempty(indxr) msgbox('Right image hasn''t been defined yet', ... 'Error window','error','modal'); elseif length(indxl)~=1 | length(indxr)~=1 error('Image defined twice!!!???'); else if ud.currmodel == 1 calcblurimage(indxl); calcblurimage(indxr); %this does resizing to display size % as well if needed imgl = ud.figs{indxl}.blurimg; imgr = ud.figs{indxr}.blurimg; if ud.input.type ~= 1 % apply same Poisson noise to both % based on average quantum catch avgcatch = ud.input.meancount*(1 + imgl); noisecontrimg = poissonnoise(avgcatch) - avgcatch; noisecontrimg = noisecontrimg/ud.input.meancount; imgl = imgl + noisecontrimg; imgr = imgr + noisecontrimg; end imgl = gammaimage(imgl); imgr = gammaimage(imgr); ud.output.imgvalid = 0; % use a new noise image imgl = noiseimage(imgl); % apply same output noise to imgr = noiseimage(imgr); % both images % possible addition: clip images here s = ['dprime = ', ... num2str(calcsfum(imgl,imgr))]; else % imgl = resizeimage(indxl); % for raw image only % imrg = resizeimage(indxr); s = 'Not yet implemented'; end set(ud.mainhandles(5),'String',s); end end end end case 'main-quit' for i = 1:length(ud.fighandles) if ud.fighandles(i) close(ud.fighandles(i)); end end close(h0); return; % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Main window - Model menu callbacks % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'menu-model' for i = 1:size(ud.mainmodelmenuhandles,2) if i == arg2 set(ud.mainmodelmenuhandles(i),'checked','on'); else set(ud.mainmodelmenuhandles(i),'checked','off'); end end ud.currmodel = arg2; if arg2 == 1 set(ud.mainhandles(13),'String', ... 'Current model: Single Filter, Uniform Masking'); % elseif arg2 == 2 % set(ud.mainhandles(13),'String', ... % 'Current model: MODEL NUMBER 2'); etc. etc. end % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Main window - Model parameter menu callbacks % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'menu-modelparam-sfum' if ud.fighandles(1) == 0 % if window doesn't exist, create it h1 = figure('Color',[.8 .8 .8],'userdata',h0,'Units','characters', ... 'Position',screenposn([50 18 81 36]), ... 'MenuBar','none','NumberTitle','off', ... 'Name','Single Filter with Uniform Masking', ... 'DeleteFcn','discrim(''delete-sfum'')'); ud.fighandles(1) = h1; % % Labels % uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'FontSize',13,'Units','normalized', ... 'Position',[.06 .88 .69 .065],'HorizontalAlignment','left', ... 'String','Center spread (min):','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'FontSize',13,'Units','normalized', ... 'Position',[.06 .76 .69 .065],'HorizontalAlignment','left', ... 'String','Frequency cut (cpd):','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'FontSize',13,'Units','normalized', ... 'Position',[.06 .64 .69 .065],'HorizontalAlignment','left', ... 'String','Spread ratio:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'FontSize',13,'Units','normalized', ... 'Position',[.06 .52 .69 .065],'HorizontalAlignment','left', ... 'String','Amplitude ratio:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'FontSize',13,'Units','normalized', ... 'Position',[.06 .40 .69 .065],'HorizontalAlignment','left', ... 'String','Contrast sensitivity maximum:', ... 'Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'FontSize',13,'Units','normalized', ... 'Position',[.06 .28 .69 .065],'HorizontalAlignment','left', ... 'String','Mask contrast threshold:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'FontSize',13,'Units','normalized', ... 'Position',[.06 .16 .69 .065],'HorizontalAlignment','left', ... 'String','Beta:','Style','text'); % % Editable text % ud.sfumhandles(1) = uicontrol('Parent',h1, ... 'Callback','discrim(''sfum-set-ctrspr'')', ... 'BackgroundColor',[1 1 1],'FontSize',13,'Units','normalized', ... 'Position',[.76 .88 .17 .065], ... 'Style','edit', ... 'String',num2str(ud.params.simple.ctrspr,4)); ud.sfumhandles(2) = uicontrol('Parent',h1, ... 'Callback','discrim(''sfum-set-freqcut'')', ... 'BackgroundColor',[1 1 1],'FontSize',13,'Units','normalized', ... 'Position',[.76 .76 .17 .065], ... 'Style','edit', ... 'String',num2str(ud.params.simple.freqcut,4)); ud.sfumhandles(3) = uicontrol('Parent',h1, ... 'Callback','discrim(''sfum-set'')', ... 'BackgroundColor',[1 1 1],'FontSize',13,'Units','normalized', ... 'Position',[.76 .64 .17 .065], ... 'Style','edit', ... 'String',num2str(ud.params.simple.sprdratio,4)); ud.sfumhandles(4) = uicontrol('Parent',h1, ... 'Callback','discrim(''sfum-set'')', ... 'BackgroundColor',[1 1 1],'FontSize',13,'Units','normalized', ... 'Position',[.76 .52 .17 .065], ... 'Style','edit', ... 'String',num2str(ud.params.simple.ampratio,4)); ud.sfumhandles(5) = uicontrol('Parent',h1, ... 'Callback','discrim(''sfum-set'')', ... 'BackgroundColor',[1 1 1],'FontSize',13,'Units','normalized', ... 'Position',[.76 .40 .17 .065], ... 'Style','edit', ... 'String',num2str(ud.params.simple.consensmax,4)); ud.sfumhandles(6) = uicontrol('Parent',h1, ... 'Callback','discrim(''sfum-set'')', ... 'BackgroundColor',[1 1 1],'FontSize',13,'Units','normalized', ... 'Position',[.76 .28 .17 .065], ... 'Style','edit', ... 'String',num2str(ud.params.simple.maskconthresh,4)); ud.sfumhandles(7) = uicontrol('Parent',h1, ... 'Callback','discrim(''sfum-set'')', ... 'BackgroundColor',[1 1 1],'FontSize',13,'Units','normalized', ... 'Position',[.76 .16 .17 .065], ... 'Style','edit', ... 'String',num2str(ud.params.simple.beta,4)); uicontrol('Parent',h1, ... 'Callback','discrim(''sfum-okay'')', ... 'BackgroundColor',[.7 .7 .7],'FontSize',13,'Units','normalized', ... 'Position',[.38 .05 .22 .065], ... 'String','Okay'); else % else simply make it visible set(ud.fighandles(1),'Visible','on') end % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Main window - Image menu callbacks % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'menu-image-new' num = 1; if ~isempty(ud.fignums) while length(find(ud.fignums==num))>0 num = num + 1; end end if ud.fighandles(11) == 0 h1 = figure('Color',[.8 .8 .8],'userdata',h0,'Units','characters', ... 'Position',screenposn([40 6 97 15]), ... 'MenuBar','none','NumberTitle','off', ... 'Name','New Image', ... 'DeleteFcn','discrim(''delete-newimg'')'); ud.fighandles(11) = h1; uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.05 .7 .3 .16], ... 'HorizontalAlignment','left', ... 'String','Image Number: ','Style','text'); ud.newimghandles(1) = uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.36 .7 .05 .16], ... 'HorizontalAlignment','left', ... 'String',num2str(num),'Style','text'); ud.newimghandles(2) = uicontrol('Parent',h1, ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.43 .7 .52 .16], ... 'HorizontalAlignment','left', ... 'String','','Style','edit'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.05 .4 .2 .16], ... 'HorizontalAlignment','left', ... 'String','Rows:','Style','text'); ud.newimghandles(3) = uicontrol('Parent',h1, ... 'Callback','discrim(''newimg-rows'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.28 .4 .15 .16],'Style','edit', ... 'String',num2str(ud.vgeom.vpixel)); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.47 .4 .2 .16], ... 'HorizontalAlignment','left', ... 'String','Columns:','Style','text'); ud.newimghandles(4) = uicontrol('Parent',h1, ... 'Callback','discrim(''newimg-cols'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.7 .4 .14 .16],'Style','edit', ... 'String',num2str(ud.vgeom.hpixel)); uicontrol('Parent',h1, ... 'Callback','discrim(''newimg-okay'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.2 .1 .2 .16],'String','Okay'); uicontrol('Parent',h1, ... 'Callback','discrim(''newimg-cancel'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.6 .1 .2 .16],'String','Cancel'); else set(ud.newimghandles(1),'String',num2str(num)); set(ud.newimghandles(2),'String',''); set(ud.newimghandles(3), ... 'String',num2str(ud.vgeom.vpixel)); set(ud.newimghandles(4), ... 'String',num2str(ud.vgeom.hpixel)); set(ud.fighandles(11),'Visible','on'); end case 'menu-image-load' % compute default image and its name if ud.currentside == 1 s = get(ud.mainhandles(3),'String'); else s = get(ud.mainhandles(4),'String'); end if isempty(s) s2 = ''; else num = str2num(s); indx = find(ud.fignums==num); if length(indx) ~= 1 error('Index length is not 1!!!'); end s2 = ud.figs{indx}.name; end if ud.fighandles(10) == 0 h1 = figure('Color',[.8 .8 .8],'userdata',h0,'Units','characters', ... 'Position',screenposn([40 8 115 20]), ... 'MenuBar','none','NumberTitle','off', ... 'Name','Load Image', ... 'DeleteFcn','discrim(''delete-loadimg'')'); ud.fighandles(10) = h1; uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .77 .25 .12], ... 'HorizontalAlignment','left', ... 'String','Image Number:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .55 .25 .12], ... 'HorizontalAlignment','left', ... 'String','Path:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .33 .25 .12], ... 'HorizontalAlignment','left', ... 'String','Filename:','Style','text'); ud.loadimghandles(1) = uicontrol('Parent',h1, ... 'Callback','discrim(''loadimg-imagenum'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.31 .77 .12 .12],'Style','edit','String',s); ud.loadimghandles(2) = uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.45 .77 .44 .12], ... 'HorizontalAlignment','left', ... 'String',s2,'Style','text'); ud.loadimghandles(3) = uicontrol('Parent',h1, ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.31 .55 .44 .12],'Style','edit', ... 'HorizontalAlignment','left', ... 'String',''); ud.loadimghandles(4) = uicontrol('Parent',h1, ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.31 .33 .44 .12],'Style','edit', ... 'HorizontalAlignment','left', ... 'String',''); uicontrol('Parent',h1, ... 'Callback','discrim(''loadimg-browse'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.8 .44 .16 .12],'String','Browse'); uicontrol('Parent',h1, ... 'Callback','discrim(''loadimg-okay'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.2 .11 .2 .12],'String','Okay'); uicontrol('Parent',h1, ... 'Callback','discrim(''loadimg-cancel'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.6 .11 .2 .12],'String','Cancel'); else set(ud.loadimghandles(1),'String',s); set(ud.loadimghandles(2),'String',s2); set(ud.fighandles(10),'Visible','on'); end case 'menu-image-save' % compute default image and its name if ud.currentside == 1 s = get(ud.mainhandles(3),'String'); else s = get(ud.mainhandles(4),'String'); end if isempty(s) s2 = ''; else num = str2num(s); indx = find(ud.fignums==num); if length(indx) ~= 1 error('Index length is not 1!!!'); end s2 = ud.figs{indx}.name; end if ud.fighandles(3) == 0 h1 = figure('Color',[.8 .8 .8],'userdata',h0,'Units','characters', ... 'Position',screenposn([40 8 140 25]), ... 'MenuBar','none','NumberTitle','off', ... 'Name','Save Image', ... 'DeleteFcn','discrim(''delete-savimg'')'); ud.fighandles(3) = h1; uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.03 .8 .2 .1], ... 'HorizontalAlignment','left', ... 'String','Image Number:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.03 .62 .2 .1], ... 'HorizontalAlignment','left', ... 'String','Path:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.03 .44 .2 .1], ... 'HorizontalAlignment','left', ... 'String','Filename:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.03 .26 .1 .1], ... 'HorizontalAlignment','left', ... 'String','Format:','Style','text'); ud.savimghandles(1) = uicontrol('Parent',h1, ... 'Callback','discrim(''savimg-imagenum'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.25 .8 .1 .1],'Style','edit','String',s); ud.savimghandles(2) = uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.37 .8 .4 .1], ... 'HorizontalAlignment','left', ... 'String',s2,'Style','text'); ud.savimghandles(3) = uicontrol('Parent',h1, ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.25 .62 .36 .1],'Style','edit', ... 'HorizontalAlignment','left', ... 'String',''); ud.savimghandles(4) = uicontrol('Parent',h1, ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.25 .44 .36 .1],'Style','edit', ... 'HorizontalAlignment','left', ... 'String',''); uicontrol('Parent',h1, ... 'Callback','discrim(''savimg-browse'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.65 .53 .13 .1],'String','Browse'); ud.savimgradiohandles(1) = uicontrol('Parent',h1, ... 'Fontsize',13,'Units','normalized', ... 'Position',[.15 .26 .11 .1],'BackgroundColor',[.7 .7 .7], ... 'Style','radio','Value',1, ... 'Callback','discrim(''savimg-radio'',1)', ... 'String','Matlab'); ud.savimgradiohandles(2) = uicontrol('Parent',h1, ... 'Fontsize',13,'Units','normalized', ... 'Position',[.27 .26 .11 .1],'BackgroundColor',[.7 .7 .7], ... 'Style','radio','Value',0, ... 'Callback','discrim(''savimg-radio'',2)', ... 'String','BMP'); ud.savimgradiohandles(3) = uicontrol('Parent',h1, ... 'Fontsize',13,'Units','normalized', ... 'Position',[.39 .26 .11 .1],'BackgroundColor',[.7 .7 .7], ... 'Style','radio','Value',0, ... 'Callback','discrim(''savimg-radio'',3)', ... 'String','HDF'); ud.savimgradiohandles(4) = uicontrol('Parent',h1, ... 'Fontsize',13,'Units','normalized', ... 'Position',[.51 .26 .11 .1],'BackgroundColor',[.7 .7 .7], ... 'Style','radio','Value',0, ... 'Callback','discrim(''savimg-radio'',4)', ... 'String','JPEG'); ud.savimgradiohandles(5) = uicontrol('Parent',h1, ... 'Fontsize',13,'Units','normalized', ... 'Position',[.63 .26 .11 .1],'BackgroundColor',[.7 .7 .7], ... 'Style','radio','Value',0, ... 'Callback','discrim(''savimg-radio'',5)', ... 'String','PCX'); ud.savimgradiohandles(6) = uicontrol('Parent',h1, ... 'Fontsize',13,'Units','normalized', ... 'Position',[.75 .26 .11 .1],'BackgroundColor',[.7 .7 .7], ... 'Style','radio','Value',0, ... 'Callback','discrim(''savimg-radio'',6)', ... 'String','TIFF'); ud.savimgradiohandles(7) = uicontrol('Parent',h1, ... 'Fontsize',13,'Units','normalized', ... 'Position',[.87 .26 .11 .1],'BackgroundColor',[.7 .7 .7], ... 'Style','radio','Value',0, ... 'Callback','discrim(''savimg-radio'',7)', ... 'String','XWD'); uicontrol('Parent',h1, ... 'Callback','discrim(''savimg-okay'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.2 .08 .2 .1],'String','Okay'); uicontrol('Parent',h1, ... 'Callback','discrim(''savimg-cancel'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.6 .08 .2 .1],'String','Cancel'); else set(ud.savimghandles(1),'String',s); set(ud.savimghandles(2),'String',s2); set(ud.fighandles(3),'Visible','on'); end case 'menu-image-delete' indx = chkcurrimdef; if indx num = ud.fignums(indx); ud.figs(indx) = []; ud.fignums(indx) = []; if ud.currentside == 1 set(ud.mainhandles(3),'String',''); set(ud.mainhandles(8),'String',''); set(ud.mainhandles(10),'String',''); set(ud.mainhandles(6),'Cdata',[0 0;0 0], ... 'XData',calcxydata(.05,2), ... 'YData',calcxydata(.05,2)); if ~isempty(get(ud.mainhandles(4),'String')) & ... str2num(get(ud.mainhandles(4),'String'))==num set(ud.mainhandles(4),'String',''); set(ud.mainhandles(9),'String',''); set(ud.mainhandles(11),'String',''); set(ud.mainhandles(7),'Cdata',[0 0;0 0], ... 'XData',calcxydata(.05,2), ... 'YData',calcxydata(.05,2)); end else set(ud.mainhandles(4),'String',''); set(ud.mainhandles(9),'String',''); set(ud.mainhandles(11),'String',''); set(ud.mainhandles(7),'Cdata',[0 0;0 0], ... 'XData',calcxydata(.05,2), ... 'YData',calcxydata(.05,2)); if ~isempty(get(ud.mainhandles(3),'String')) & ... str2num(get(ud.mainhandles(3),'String'))==num set(ud.mainhandles(3),'String',''); set(ud.mainhandles(8),'String',''); set(ud.mainhandles(10),'String',''); set(ud.mainhandles(6),'Cdata',[0 0;0 0], ... 'XData',calcxydata(.05,2), ... 'YData',calcxydata(.05,2)); end end update_directory; end case 'menu-image-directory' if ~ud.fighandles(2) ud.fighandles(2) = figure('Color',[.8 .8 .8],'userdata',h0, ... 'MenuBar','none','NumberTitle','off', ... 'Name','Image Directory', ... 'Visible','off','Units','characters', ... 'DeleteFcn','discrim(''delete-directory'')'); end update_directory; % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Main window - Edit Image menu callbacks % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'menu-edimage-clear' indx = chkcurrimdef; if indx num = ud.fignums(indx); ud.figs{indx}.img(:,:) = 0; ud.figs{indx}.validity = 0; updatecurdisplay; end case 'menu-edimage-agrat' % compute default image and its name if ud.currentside == 1 s = get(ud.mainhandles(3),'String'); else s = get(ud.mainhandles(4),'String'); end if isempty(s) s2 = ''; else num = str2num(s); indx = find(ud.fignums==num); if length(indx) ~= 1 error('Index length is not 1!!!'); end [m,n] = size(ud.figs{indx}.img); s2 = [fmtsize(m,n),': ',ud.figs{indx}.name]; end if ud.fighandles(5) == 0 h1 = figure('Color',[.8 .8 .8],'userdata',h0, ... 'Units','characters','Position',screenposn([20 8 110 40]), ... 'MenuBar','none','NumberTitle','off', ... 'Name','Add Grating', ... 'DeleteFcn','discrim(''delete-agrat'')'); ud.fighandles(5) = h1; uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .89 .3 .06], ... 'HorizontalAlignment','left', ... 'String','Image Number:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .77 .3 .06], ... 'HorizontalAlignment','left', ... 'String','Spatial Frequency:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .5 .3 .06], ... 'HorizontalAlignment','left', ... 'String','Orientation (deg):','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .36 .32 .1], ... 'HorizontalAlignment','left', ... 'String', ... {'Phase (deg, relative' 'to image center):'}, ... 'Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .27 .3 .06], ... 'HorizontalAlignment','left', ... 'String','Type:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .16 .3 .06], ... 'HorizontalAlignment','left', ... 'String','Peak Contrast:','Style','text'); ud.agrathandles(1) = uicontrol('Parent',h1, ... 'Callback','discrim(''agrat-imagenum'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.37 .89 .13 .06],'Style','edit','String',s); ud.agrathandles(2) = uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.52 .89 .46 .06], ... 'HorizontalAlignment','left', ... 'String',s2,'Style','text'); ud.agrathandles(3) = uicontrol('Parent',h1, ... 'Callback','discrim(''agrat-sf'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.37 .77 .13 .06],'Style','edit','String','1'); ud.agratsfradiohandles(1) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.52 .77 .36 .06],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',1, ... 'Callback','discrim(''agrat-radioagsf'',1)', ... 'String','cycles/degree'); ud.agratsfradiohandles(2) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.52 .69 .36 .06],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',0, ... 'Callback','discrim(''agrat-radioagsf'',2)', ... 'String','cycles/cm'); ud.agratsfradiohandles(3) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.52 .61 .36 .06],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',0, ... 'Callback','discrim(''agrat-radioagsf'',3)', ... 'String','cycles/image width'); ud.agrathandles(4) = uicontrol('Parent',h1, ... 'Callback','discrim(''agrat-orient'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.37 .5 .13 .06],'Style','edit','String','0'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.52 .5 .05 .06], ... 'HorizontalAlignment','right', ... 'String','0','Style','text'); ud.agrathandles(5) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.57 .5 .18 .06],'Fontsize',13, ... 'BackgroundColor',[.7 .7 .7], ... 'Style','slider','min',0,'max',180,'Value',0, ... 'sliderstep',[1/180 15/180], ... 'Callback','discrim(''agrat-orientsl'')', ... 'String',''); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.75 .5 .06 .06], ... 'HorizontalAlignment','left', ... 'String','180','Style','text'); ud.agrathandles(6) = uicontrol('Parent',h1, ... 'Callback','discrim(''agrat-phase'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.37 .38 .13 .06],'Style','edit','String','0'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.52 .38 .05 .06], ... 'HorizontalAlignment','right', ... 'String','0','Style','text'); ud.agrathandles(7) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.57 .38 .18 .06],'Fontsize',13, ... 'BackgroundColor',[.7 .7 .7], ... 'Style','slider','min',0,'max',360,'Value',0, ... 'sliderstep',[1/360 15/360], ... 'Callback','discrim(''agrat-phasesl'')', ... 'String',''); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.75 .38 .06 .06], ... 'HorizontalAlignment','left', ... 'String','360','Style','text'); ud.agrattyperadiohandles(1) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.37 .27 .18 .06],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',1, ... 'Callback','discrim(''agrat-radioagtype'',1)', ... 'String','sine'); ud.agrattyperadiohandles(2) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.57 .27 .18 .06],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',0, ... 'Callback','discrim(''agrat-radioagtype'',2)', ... 'String','square'); ud.agrattyperadiohandles(3) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.77 .27 .18 .06],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',0, ... 'Callback','discrim(''agrat-radioagtype'',3)', ... 'String','triangle'); ud.agrathandles(8) = uicontrol('Parent',h1, ... 'Callback','discrim(''agrat-contr'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.37 .16 .13 .06],'Style','edit','String','.5'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.52 .16 .05 .06], ... 'HorizontalAlignment','right', ... 'String','0','Style','text'); ud.agrathandles(9) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.57 .16 .18 .06],'Fontsize',13, ... 'BackgroundColor',[.7 .7 .7], ... 'Style','slider','min',0,'max',1,'Value',.5, ... 'sliderstep',[.005 .1], ... 'Callback','discrim(''agrat-contrsl'')', ... 'String',''); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.75 .16 .06 .06], ... 'HorizontalAlignment','left', ... 'String','1','Style','text'); uicontrol('Parent',h1, ... 'Callback','discrim(''agrat-okay'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.2 .05 .2 .06],'String','Okay'); uicontrol('Parent',h1, ... 'Callback','discrim(''agrat-cancel'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.6 .05 .2 .06],'String','Cancel'); else set(ud.agrathandles(1),'String',s); set(ud.agrathandles(2),'String',s2); set(ud.fighandles(5),'Visible','on'); end case 'menu-edimage-agab' % compute default image and its name if ud.currentside == 1 s = get(ud.mainhandles(3),'String'); else s = get(ud.mainhandles(4),'String'); end if isempty(s) s2 = ''; else num = str2num(s); indx = find(ud.fignums==num); if length(indx) ~= 1 error('Index length is not 1!!!'); end [m,n] = size(ud.figs{indx}.img); s2 = [fmtsize(m,n),': ',ud.figs{indx}.name]; end if ud.fighandles(6) == 0 h1 = figure('Color',[.8 .8 .8],'userdata',h0,'Units','characters', ... 'Position',screenposn([10 8 125 45]), ... 'MenuBar','none','NumberTitle','off', ... 'Name','Add Gabor', ... 'DeleteFcn','discrim(''delete-agab'')'); ud.fighandles(6) = h1; uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .93 .28 .05], ... 'HorizontalAlignment','left', ... 'String','Image Number:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .86 .28 .05], ... 'HorizontalAlignment','left', ... 'String','Spatial Offset:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .79 .28 .05], ... 'HorizontalAlignment','left', ... 'String','Gaussian Envelope:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .72 .28 .05], ... 'HorizontalAlignment','left', ... 'String',' Orientation (deg):','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .65 .28 .05], ... 'HorizontalAlignment','left', ... 'String',' Sigma (along):','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .58 .28 .05], ... 'HorizontalAlignment','left', ... 'String',' Sigma (across):','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .47 .28 .05], ... 'HorizontalAlignment','left', ... 'String','Sine Wave Modulator:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .4 .3 .05], ... 'HorizontalAlignment','left', ... 'String',' Spatial Frequency:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .22 .28 .05], ... 'HorizontalAlignment','left', ... 'String',' Orientation (deg):','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .13 .28 .085], ... 'HorizontalAlignment','left', ... 'String', ... {'Phase (deg, relative' 'to Gabor center):'}, ... 'Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .08 .28 .05], ... 'HorizontalAlignment','left', ... 'String','Peak Contrast:','Style','text'); ud.agabhandles(1) = uicontrol('Parent',h1, ... 'Callback','discrim(''agab-imagenum'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.35 .93 .11 .05],'Style','edit','String',s); ud.agabhandles(2) = uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.49 .93 .4 .05], ... 'HorizontalAlignment','left', ... 'String',s2,'Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.35 .86 .16 .05], ... 'HorizontalAlignment','left', ... 'String','Rows:','Style','text'); ud.agabhandles(14) = uicontrol('Parent',h1, ... 'Callback','discrim(''agab-rowoffset'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.54 .86 .11 .05],'Style','edit','String','0'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.68 .86 .15 .05], ... 'HorizontalAlignment','left', ... 'String','Columns:','Style','text'); ud.agabhandles(15) = uicontrol('Parent',h1, ... 'Callback','discrim(''agab-coloffset'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.86 .86 .11 .05],'Style','edit','String','0'); ud.agabhandles(3) = uicontrol('Parent',h1, ... 'Callback','discrim(''agab-envorient'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.35 .72 .11 .05],'Style','edit','String','0'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.48 .72 .04 .05], ... 'HorizontalAlignment','right', ... 'String','0','Style','text'); ud.agabhandles(4) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.53 .72 .16 .05],'Fontsize',13, ... 'BackgroundColor',[.7 .7 .7], ... 'Style','slider','min',0,'max',180,'Value',0, ... 'sliderstep',[1/180 15/180], ... 'Callback','discrim(''agab-envorientsl'')', ... 'String',''); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.7 .72 .06 .05], ... 'HorizontalAlignment','left', ... 'String','180','Style','text'); ud.agabhandles(5) = uicontrol('Parent',h1, ... 'Callback','discrim(''agab-envsigiso'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.35 .65 .11 .05],'Style','edit','String','1'); ud.agabhandles(6) = uicontrol('Parent',h1, ... 'Callback','discrim(''agab-envsigortho'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.35 .58 .11 .05],'Style','edit','String','1'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.5 .65 .11 .05], ... 'HorizontalAlignment','left', ... 'String','Units:','Style','text'); ud.agabsigradiohandles(1) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.63 .65 .26 .05],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',1, ... 'Callback','discrim(''agab-radiosig'',1)', ... 'String','deg'); ud.agabsigradiohandles(2) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.63 .59 .26 .05],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',0, ... 'Callback','discrim(''agab-radiosig'',2)', ... 'String','cm'); ud.agabsigradiohandles(3) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.63 .53 .26 .05],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',0, ... 'Callback','discrim(''agab-radiosig'',3)', ... 'String','horizontal pixels'); ud.agabhandles(7) = uicontrol('Parent',h1, ... 'Callback','discrim(''agab-modsf'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.35 .4 .11 .05],'Style','edit','String','1'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.5 .4 .11 .05], ... 'HorizontalAlignment','left', ... 'String','Units:','Style','text'); ud.agabsfradiohandles(1) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.63 .4 .3 .05],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',1, ... 'Callback','discrim(''agab-radiosf'',1)', ... 'String','cycles/deg'); ud.agabsfradiohandles(2) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.63 .34 .3 .05],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',0, ... 'Callback','discrim(''agab-radiosf'',2)', ... 'String','cycles/cm'); ud.agabsfradiohandles(3) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.63 .28 .3 .05],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',0, ... 'Callback','discrim(''agab-radiosf'',3)', ... 'String','cycles/image width'); ud.agabhandles(8) = uicontrol('Parent',h1, ... 'Callback','discrim(''agab-modorient'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.35 .22 .11 .05],'Style','edit','String','0'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.48 .22 .04 .05], ... 'HorizontalAlignment','right', ... 'String','0','Style','text'); ud.agabhandles(9) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.53 .22 .16 .05],'Fontsize',13, ... 'BackgroundColor',[.7 .7 .7], ... 'Style','slider','min',0,'max',180,'Value',0, ... 'sliderstep',[1/180 15/180], ... 'Callback','discrim(''agab-modorientsl'')', ... 'String',''); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.7 .22 .06 .05], ... 'HorizontalAlignment','left', ... 'String','180','Style','text'); ud.agabhandles(10) = uicontrol('Parent',h1, ... 'Callback','discrim(''agab-modphase'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.35 .15 .11 .05],'Style','edit','String','0'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.48 .15 .04 .05], ... 'HorizontalAlignment','right', ... 'String','0','Style','text'); ud.agabhandles(11) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.53 .15 .16 .05],'Fontsize',13, ... 'BackgroundColor',[.7 .7 .7], ... 'Style','slider','min',0,'max',360,'Value',0, ... 'sliderstep',[1/360 15/360], ... 'Callback','discrim(''agab-modphasesl'')', ... 'String',''); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.7 .15 .06 .05], ... 'HorizontalAlignment','left', ... 'String','360','Style','text'); ud.agabhandles(12) = uicontrol('Parent',h1, ... 'Callback','discrim(''agab-contr'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.35 .08 .11 .05],'Style','edit','String','.5'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.48 .08 .04 .05], ... 'HorizontalAlignment','right', ... 'String','0','Style','text'); ud.agabhandles(13) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.53 .08 .16 .05],'Fontsize',13, ... 'BackgroundColor',[.7 .7 .7], ... 'Style','slider','min',0,'max',1,'Value',.5, ... 'sliderstep',[.005 .1], ... 'Callback','discrim(''agab-contrsl'')', ... 'String',''); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.7 .08 .06 .05], ... 'HorizontalAlignment','left', ... 'String','1','Style','text'); uicontrol('Parent',h1, ... 'Callback','discrim(''agab-okay'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.2 .015 .2 .05],'String','Okay'); uicontrol('Parent',h1, ... 'Callback','discrim(''agab-cancel'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.6 .015 .2 .05],'String','Cancel'); else set(ud.agabhandles(1),'String',s); set(ud.agabhandles(2),'String',s2); set(ud.fighandles(6),'Visible','on'); end case 'menu-edimage-afile' % compute default image and its name if ud.currentside == 1 s = get(ud.mainhandles(3),'String'); else s = get(ud.mainhandles(4),'String'); end if isempty(s) s2 = ''; else num = str2num(s); indx = find(ud.fignums==num); if length(indx) ~= 1 error('Index length is not 1!!!'); end [m,n] = size(ud.figs{indx}.img); s2 = [fmtsize(m,n),': ',ud.figs{indx}.name]; end if ud.fighandles(7) == 0 h1 = figure('Color',[.8 .8 .8],'userdata',h0,'Units','characters', ... 'Position',screenposn([50 8 120 36]), ... 'MenuBar','none','NumberTitle','off', ... 'Name','Combine Image from File', ... 'DeleteFcn','discrim(''delete-afile'')'); ud.fighandles(7) = h1; uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .9 .3 .06], ... 'HorizontalAlignment','left', ... 'String','Image Number:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .77 .3 .06], ... 'HorizontalAlignment','left', ... 'String','Spatial Offset:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .64 .17 .06], ... 'HorizontalAlignment','left', ... 'String','Path:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .51 .17 .06], ... 'HorizontalAlignment','left', ... 'String','Filename:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .38 .12 .06], ... 'HorizontalAlignment','left', ... 'String','Action:','Style','text'); ud.afilehandles(1) = uicontrol('Parent',h1, ... 'Callback','discrim(''afile-imagenum'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.37 .9 .12 .06],'Style','edit','String',s); ud.afilehandles(2) = uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.52 .9 .44 .06], ... 'HorizontalAlignment','left', ... 'String',s2,'Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.34 .77 .1 .06], ... 'HorizontalAlignment','right', ... 'String','Rows:','Style','text'); ud.afilehandles(5) = uicontrol('Parent',h1, ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.46 .77 .12 .06],'Style','edit', ... 'Callback','discrim(''afile-rowoffset'')', ... 'String','0'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.63 .77 .17 .06], ... 'HorizontalAlignment','right', ... 'String','Columns:','Style','text'); ud.afilehandles(6) = uicontrol('Parent',h1, ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.82 .77 .12 .06],'Style','edit', ... 'Callback','discrim(''afile-coloffset'')', ... 'String','0'); ud.afilehandles(3) = uicontrol('Parent',h1, ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.23 .64 .44 .06],'Style','edit', ... 'HorizontalAlignment','left', ... 'String',''); ud.afilehandles(4) = uicontrol('Parent',h1, ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.23 .51 .44 .06],'Style','edit', ... 'HorizontalAlignment','left', ... 'String',''); uicontrol('Parent',h1, ... 'Callback','discrim(''afile-browse'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.72 .575 .16 .06],'String','Browse'); ud.afileradiohandles(1) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.2 .38 .45 .06],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',1, ... 'Callback','discrim(''afile-radio'',1)', ... 'String','Add'); ud.afileradiohandles(2) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.2 .3 .45 .06],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',0, ... 'Callback','discrim(''afile-radio'',2)', ... 'String','Overlay'); ud.afileradiohandles(3) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.2 .22 .45 .06],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',0, ... 'Callback','discrim(''afile-radio'',3)', ... 'String','Overlay with Transparency'); ud.afileradiohandles(4) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.2 .14 .45 .06],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',0, ... 'Callback','discrim(''afile-radio'',4)', ... 'String','Multiply'); uicontrol('Parent',h1, ... 'Callback','discrim(''afile-okay'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.2 .05 .2 .06],'String','Okay'); uicontrol('Parent',h1, ... 'Callback','discrim(''afile-cancel'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.6 .05 .2 .06],'String','Cancel'); else set(ud.afilehandles(1),'String',s); set(ud.afilehandles(2),'String',s2); set(ud.fighandles(7),'Visible','on'); end case 'menu-edimage-aimg' if ud.currentside == 1 s = get(ud.mainhandles(3),'String'); so = get(ud.mainhandles(4),'String'); else s = get(ud.mainhandles(4),'String'); so = get(ud.mainhandles(3),'String'); end if isempty(s) s2 = ''; else num = str2num(s); indx = find(ud.fignums==num); if length(indx) ~= 1 error('Index length is not 1!!!'); end [m,n] = size(ud.figs{indx}.img); s2 = [fmtsize(m,n),': ',ud.figs{indx}.name]; end if isempty(so) so2 = ''; else num = str2num(so); indx = find(ud.fignums==num); if length(indx) ~= 1 error('Index length is not 1!!!'); end [m,n] = size(ud.figs{indx}.img); so2 = [fmtsize(m,n),': ',ud.figs{indx}.name]; end if ud.fighandles(8) == 0 h1 = figure('Color',[.8 .8 .8],'userdata',h0,'Units','characters', ... 'Position',screenposn([60 8 120 32]), ... 'MenuBar','none','NumberTitle','off', ... 'Name','Combine Image to Image', ... 'DeleteFcn','discrim(''delete-aimg'')'); ud.fighandles(8) = h1; uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .86 .34 .07], ... 'HorizontalAlignment','left', ... 'String','To Image Number:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .73 .34 .07], ... 'HorizontalAlignment','left', ... 'String','From Image Number:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .6 .3 .07], ... 'HorizontalAlignment','left', ... 'String','Spatial Offset:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .47 .11 .07], ... 'HorizontalAlignment','left', ... 'String','Action:','Style','text'); ud.aimghandles(1) = uicontrol('Parent',h1, ... 'Callback','discrim(''aimg-toimagenum'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.4 .86 .12 .07],'Style','edit','String',s); ud.aimghandles(2) = uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.54 .86 .42 .07], ... 'HorizontalAlignment','left', ... 'String',s2,'Style','text'); ud.aimghandles(3) = uicontrol('Parent',h1, ... 'Callback','discrim(''aimg-fromimagenum'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.4 .73 .12 .07],'Style','edit','String',so); ud.aimghandles(4) = uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.54 .73 .42 .07], ... 'HorizontalAlignment','left', ... 'String',so2,'Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.33 .6 .1 .07], ... 'HorizontalAlignment','right', ... 'String','Rows:','Style','text'); ud.aimghandles(5) = uicontrol('Parent',h1, ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.45 .6 .12 .07], ... 'Callback','discrim(''aimg-rowoffset'')', ... 'String','0','Style','edit'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.61 .6 .17 .07], ... 'HorizontalAlignment','right', ... 'String','Columns:','Style','text'); ud.aimghandles(6) = uicontrol('Parent',h1, ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.8 .6 .12 .07], ... 'Callback','discrim(''aimg-coloffset'')', ... 'String','0','Style','edit'); ud.aimgradiohandles(1) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.19 .47 .44 .07],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',1, ... 'Callback','discrim(''aimg-radio'',1)', ... 'String','Add'); ud.aimgradiohandles(2) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.19 .38 .44 .07],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',0, ... 'Callback','discrim(''aimg-radio'',2)', ... 'String','Overlay'); ud.aimgradiohandles(3) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.19 .29 .44 .07],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',0, ... 'Callback','discrim(''aimg-radio'',3)', ... 'String','Overlay with Transparency'); ud.aimgradiohandles(4) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.19 .2 .44 .07],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',0, ... 'Callback','discrim(''aimg-radio'',4)', ... 'String','Multiply'); uicontrol('Parent',h1, ... 'Callback','discrim(''aimg-okay'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.2 .08 .2 .07],'String','Okay'); uicontrol('Parent',h1, ... 'Callback','discrim(''aimg-cancel'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.6 .08 .2 .07],'String','Cancel'); else set(ud.aimghandles(1),'String',s); set(ud.aimghandles(2),'String',s2); set(ud.aimghandles(3),'String',so); set(ud.aimghandles(4),'String',so2); set(ud.fighandles(8),'Visible','on'); end case 'menu-edimage-scale' if ud.currentside == 1 s = get(ud.mainhandles(3),'String'); else s = get(ud.mainhandles(4),'String'); end if isempty(s) s2 = ''; else num = str2num(s); indx = find(ud.fignums==num); if length(indx) ~= 1 error('Index length is not 1!!!'); end [m,n] = size(ud.figs{indx}.img); s2 = [fmtsize(m,n),': ',ud.figs{indx}.name]; end if ud.fighandles(12) == 0 h1 = figure('Color',[.8 .8 .8],'userdata',h0,'Units','characters', ... 'Position',screenposn([60 8 110 20]), ... 'MenuBar','none','NumberTitle','off', ... 'Name','Scale Image', ... 'DeleteFcn','discrim(''delete-scale'')'); ud.fighandles(12) = h1; uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .77 .26 .12], ... 'HorizontalAlignment','left', ... 'String','Image Number:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .55 .26 .12], ... 'HorizontalAlignment','left', ... 'String','Contrast Scale:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .33 .26 .12], ... 'HorizontalAlignment','left', ... 'String','Contrast Shift:','Style','text'); ud.scalehandles(1) = uicontrol('Parent',h1, ... 'Callback','discrim(''scale-imagenum'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.33 .77 .13 .12],'Style','edit','String',s); ud.scalehandles(2) = uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.48 .77 .47 .12], ... 'HorizontalAlignment','left', ... 'String',s2,'Style','text'); ud.scalehandles(3) = uicontrol('Parent',h1, ... 'Callback','discrim(''scale-contrscale'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.33 .55 .13 .12],'Style','edit','String','1'); ud.scalehandles(4) = uicontrol('Parent',h1, ... 'Callback','discrim(''scale-contrshift'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.33 .33 .13 .12],'Style','edit','String','0'); uicontrol('Parent',h1, ... 'Callback','discrim(''scale-okay'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.2 .11 .2 .12],'String','Okay'); uicontrol('Parent',h1, ... 'Callback','discrim(''scale-cancel'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.6 .11 .2 .12],'String','Cancel'); else set(ud.scalehandles(1),'String',s); set(ud.scalehandles(2),'String',s2); set(ud.fighandles(12),'Visible','on'); end case 'menu-edimage-clip' if ud.currentside == 1 s = get(ud.mainhandles(3),'String'); else s = get(ud.mainhandles(4),'String'); end if isempty(s) s2 = ''; else num = str2num(s); indx = find(ud.fignums==num); if length(indx) ~= 1 error('Index length is not 1!!!'); end [m,n] = size(ud.figs{indx}.img); s2 = [fmtsize(m,n),': ',ud.figs{indx}.name]; end if ud.fighandles(13) == 0 h1 = figure('Color',[.8 .8 .8],'userdata',h0,'Units','characters', ... 'Position',screenposn([60 8 110 20]), ... 'MenuBar','none','NumberTitle','off', ... 'Name','Clip Image', ... 'DeleteFcn','discrim(''delete-clip'')'); ud.fighandles(13) = h1; uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .77 .26 .12], ... 'HorizontalAlignment','left', ... 'String','Image Number:','Style','text'); ud.cliphandles(1) = uicontrol('Parent',h1, ... 'Callback','discrim(''clip-imagenum'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.33 .77 .13 .12],'Style','edit','String',s); ud.cliphandles(2) = uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.48 .77 .47 .12], ... 'HorizontalAlignment','left', ... 'String',s2,'Style','text'); ud.cliphandles(3) = uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .57 .3 .12],'Style','checkbox', ... 'String','Clip low values','Value',1); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.37 .55 .42 .12], ... 'HorizontalAlignment','left', ... 'String','Threshold Contrast Level:','Style','text'); ud.cliphandles(4) = uicontrol('Parent',h1, ... 'Callback','discrim(''clip-lowvalue'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.81 .55 .13 .12],'Style','edit', ... 'String','-1'); ud.cliphandles(5) = uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.04 .35 .3 .12],'Style','checkbox', ... 'String','Clip high values','Value',0); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.37 .33 .42 .12], ... 'HorizontalAlignment','left', ... 'String','Threshold Contrast Level:','Style','text'); ud.cliphandles(6) = uicontrol('Parent',h1, ... 'Callback','discrim(''clip-highvalue'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.81 .33 .13 .12],'Style','edit', ... 'String','1'); uicontrol('Parent',h1, ... 'Callback','discrim(''clip-okay'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.2 .11 .2 .12],'String','Okay'); uicontrol('Parent',h1, ... 'Callback','discrim(''clip-cancel'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.6 .11 .2 .12],'String','Cancel'); else set(ud.cliphandles(1),'String',s); set(ud.cliphandles(2),'String',s2); set(ud.fighandles(13),'Visible','on'); end case 'menu-edimage-undo' if ~ud.undo.num | isempty(ud.fignums) | ... length(find(ud.fignums==ud.undo.num)) ~= 1 msgbox('Nothing to Undo','Error window','error','modal'); else indx = find(ud.fignums==ud.undo.num); if ud.fighandles(14) == 0 h1 = figure('Color',[.8 .8 .8],'userdata',h0,'Units','characters', ... 'Position',screenposn([50 8 90 15]), ... 'MenuBar','none','NumberTitle','off', ... 'Name','Undo Image Edit', ... 'DeleteFcn','discrim(''delete-undo'')'); ud.fighandles(14) = h1; ud.undohandles(1) = uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.05 .7 .9 .16], ... 'HorizontalAlignment','center', ... 'String',['Operation: ',ud.undo.op], ... 'Style','text'); ud.undohandles(2) = uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.05 .4 .9 .16], ... 'HorizontalAlignment','center', ... 'String',['Image ',num2str(ud.undo.num),': ', ... ud.figs{indx}.name], ... 'Style','text'); uicontrol('Parent',h1, ... 'Callback','discrim(''undo-okay'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.2 .1 .2 .16],'String','Okay'); uicontrol('Parent',h1, ... 'Callback','discrim(''undo-cancel'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.6 .1 .2 .16],'String','Cancel'); else set(ud.undohandles(1), ... 'String',['Operation: ',ud.undo.op]); set(ud.undohandles(2), ... 'String',['Image ',num2str(ud.undo.num), ... ud.figs{indx}.name]); set(ud.fighandles(14),'Visible','on'); end end % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Main window - Display Characteristics menu callbacks % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'menu-dispchar-mtf' if ud.fighandles(4) == 0 % if window doesn't exist, create it h1 = figure('Color',[.8 .8 .8],'userdata',h0,'Units','characters', ... 'Position',screenposn([50 10 170 70]), ... 'MenuBar','none','NumberTitle','off', ... 'Name','MTF', ... 'DeleteFcn','discrim(''delete-mtf'')'); ud.fighandles(4) = h1; ud.mtftyperadiohandles(1) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.04 .92 .19 .04],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',ud.mtf.type==1, ... 'Callback','discrim(''mtftype-radio'',1)', ... 'String','Flat'); ud.mtftyperadiohandles(2) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.04 .8 .19 .04],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',ud.mtf.type==2, ... 'Callback','discrim(''mtftype-radio'',2)', ... 'String','Gaussian'); ud.mtftyperadiohandles(3) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.04 .68 .19 .1],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',ud.mtf.type==3, ... 'Callback','discrim(''mtftype-radio'',3)', ... 'String','DoG'); ud.mtftyperadiohandles(4) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.04 .59 .19 .04],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',ud.mtf.type==4, ... 'Callback','discrim(''mtftype-radio'',4)', ... 'String','Empirical'); if ud.mtf.type == 1 | ud.mtf.type == 4 e = 'off'; else e = 'on'; end ud.mtfhandles(1) = uicontrol('Parent',h1, ... 'Callback','discrim(''mtf-squaremtf'')', ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.33 .92 .21 .04], ... 'Callback','discrim(''mtfsquare'')', ... 'String','x MTF = y MTF','Style','checkbox', ... 'Value',ud.mtf.square,'Enable',e); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.36 .86 .06 .04], ... 'String','x:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.45 .86 .06 .04], ... 'String','y:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.2 .8 .13 .04],'HorizontalAlignment','left', ... 'String','Sigma:','Style','text'); if ud.mtf.type == 2 | ud.mtf.type == 3 e = 'on'; if ud.mtf.square e1 = 'off'; else e1 = 'on'; end else e = 'off'; e1 = 'off'; end ud.mtfhandles(2) = uicontrol('Parent',h1, ... 'Callback','discrim(''mtf-set-xsigma'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.36 .8 .06 .04], ... 'Style','edit','Enable',e, ... 'String',num2str(ud.mtf.xsigma,4)); ud.mtfhandles(3) = uicontrol('Parent',h1, ... 'Callback','discrim(''mtf-set-ysigma'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.45 .8 .06 .04], ... 'Style','edit','Enable',e1, ... 'String',num2str(ud.mtf.ysigma,4)); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.2 .74 .13 .04],'HorizontalAlignment','left', ... 'String','Sigma 2:','Style','text'); if ud.mtf.type == 3 e = 'on'; if ud.mtf.square e1 = 'off'; else e1 = 'on'; end else e = 'off'; e1 = 'off'; end ud.mtfhandles(4) = uicontrol('Parent',h1, ... 'Callback','discrim(''mtf-set-xsigma2'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.36 .74 .06 .04], ... 'Style','edit','Enable',e, ... 'String',num2str(ud.mtf.xsigma2,4)); ud.mtfhandles(5) = uicontrol('Parent',h1, ... 'Callback','discrim(''mtf-set-ysigma2'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.45 .74 .06 .04], ... 'Style','edit','Enable',e1, ... 'String',num2str(ud.mtf.ysigma2,4)); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.2 .68 .13 .04],'HorizontalAlignment','left', ... 'String','Peak Ratio:','Style','text'); ud.mtfhandles(6) = uicontrol('Parent',h1, ... 'Callback','discrim(''mtf-set-ratio'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.405 .68 .06 .04], ... 'Style','edit','Enable',e, ... 'String',num2str(ud.mtf.ratio,4)); ud.mtfunitsradiohandles(1) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.55 .8 .24 .04],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',1, ... 'Callback','discrim(''mtfunits-radio'',1)', ... 'String','cycles/degree'); ud.mtfunitsradiohandles(2) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.55 .74 .24 .04],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',0, ... 'Callback','discrim(''mtfunits-radio'',2)', ... 'String','cycles/cm'); ud.mtfunitsradiohandles(3) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.55 .68 .24 .04],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',0, ... 'Callback','discrim(''mtfunits-radio'',3)', ... 'String','cycles/image width'); ud.mtfunitsradiohandles(4) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.82 .8 .16 .04],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',0, ... 'Callback','discrim(''mtfunits-radio'',4)', ... 'String','degrees'); ud.mtfunitsradiohandles(5) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.82 .74 .16 .04],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',0, ... 'Callback','discrim(''mtfunits-radio'',5)', ... 'String','cm'); ud.mtfunitsradiohandles(6) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.82 .68 .16 .04],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',0, ... 'Callback','discrim(''mtfunits-radio'',6)', ... 'String','image widths'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.2 .62 .13 .04],'HorizontalAlignment','left', ... 'String','Path:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.2 .56 .13 .04],'HorizontalAlignment','left', ... 'String','Filename:','Style','text'); if ud.mtf.type == 4 e = 'on'; else e = 'off'; end ud.mtfhandles(7) = uicontrol('Parent',h1, ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.36 .62 .43 .04], ... 'Style','edit','Enable',e,'String',''); ud.mtfhandles(8) = uicontrol('Parent',h1, ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.36 .56 .43 .04], ... 'Callback','discrim(''mtf-file'')', ... 'Style','edit','Enable',e,'String',''); ud.mtfhandles(9) = uicontrol('Parent',h1, ... 'Callback','discrim(''mtf-browse'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.82 .59 .16 .04],'String','Browse','Enable',e); ud.mtfhandles(10) = axes('Position',[.15 .15 .7 .37]); uicontrol('Parent',h1, ... 'Callback','discrim(''mtf-okay'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.4 .04 .2 .04],'String','Okay'); plotmtf; else % else simply make it visible set(ud.fighandles(4),'Visible','on'); end case 'menu-dispchar-input' if ud.fighandles(15) == 0 % if window doesn't exist, create it h1 = figure('Color',[.8 .8 .8],'userdata',h0,'Units','characters', ... 'Position',screenposn([60 20 110 50]), ... 'MenuBar','none','NumberTitle','off', ... 'Name','Input Noise', ... 'DeleteFcn','discrim(''delete-input'')'); ud.fighandles(15) = h1; ud.inputradiohandles(1) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.04 .88 .8 .06],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',ud.input.type==1, ... 'Callback','discrim(''input-radio'',1)', ... 'String','No input noise'); ud.inputradiohandles(2) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.04 .79 .8 .06],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',ud.input.type==2, ... 'Callback','discrim(''input-radio'',2)', ... 'String','Based on mean photon count per pixel'); ud.inputradiohandles(3) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.04 .61 .8 .06],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',ud.input.type==3, ... 'Callback','discrim(''input-radio'',3)', ... 'String','Calculated'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.1 .7 .58 .06],'HorizontalAlignment','left', ... 'String','Mean photon count per pixel:','Style','text'); if ud.input.type == 2 e = 'on'; else e = 'off'; end ud.inputhandles(1) = uicontrol('Parent',h1, ... 'Callback','discrim(''input-set-count'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.6 .7 .2 .06], ... 'Style','edit','Enable',e, ... 'String',num2str(ud.input.meancount,5)); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.1 .52 .58 .06],'HorizontalAlignment','left', ... 'String','Mean luminance:','Style','text'); if ud.input.type == 3 e = 'on'; else e = 'off'; end ud.inputhandles(2) = uicontrol('Parent',h1, ... 'Callback','discrim(''input-set-lum'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.6 .52 .2 .06], ... 'Style','edit','Enable',e, ... 'String',num2str(ud.input.lum,5)); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.82 .52 .15 .06],'HorizontalAlignment','left', ... 'String','cd/m^2','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.1 .43 .58 .06],'HorizontalAlignment','left', ... 'String','Integration time:','Style','text'); ud.inputhandles(3) = uicontrol('Parent',h1, ... 'Callback','discrim(''input-set-time'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.6 .43 .2 .06], ... 'Style','edit','Enable',e, ... 'String',num2str(ud.input.time,5)); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.82 .43 .15 .06],'HorizontalAlignment','left', ... 'String','msec','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.1 .34 .58 .06],'HorizontalAlignment','left', ... 'String','Dominant wavelength:','Style','text'); ud.inputhandles(4) = uicontrol('Parent',h1, ... 'Callback','discrim(''input-set-wl'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.6 .34 .2 .06], ... 'Style','edit','Enable',e, ... 'String',num2str(ud.input.wl,5)); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.82 .34 .15 .06],'HorizontalAlignment','left', ... 'String','nm','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.1 .25 .58 .06],'HorizontalAlignment','left', ... 'String','Efficiency:','Style','text'); ud.inputhandles(5) = uicontrol('Parent',h1, ... 'Callback','discrim(''input-set-eff'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.6 .25 .2 .06], ... 'Style','edit','Enable',e, ... 'String',num2str(ud.input.eff,5)); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.82 .25 .15 .06],'HorizontalAlignment','left', ... 'String','%','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.1 .16 .58 .06],'HorizontalAlignment','left', ... 'String','Pupil diameter:','Style','text'); ud.inputhandles(6) = uicontrol('Parent',h1, ... 'Callback','discrim(''input-set-diam'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.6 .16 .2 .06], ... 'Style','edit','Enable',e, ... 'String',num2str(ud.input.diam,5)); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.82 .16 .15 .06],'HorizontalAlignment','left', ... 'String','mm','Style','text'); uicontrol('Parent',h1, ... 'Callback','discrim(''input-okay'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.4 .07 .2 .06],'String','Okay'); else % else simply make it visible set(ud.fighandles(15),'Visible','on'); end case 'menu-dispchar-gamma' if ud.fighandles(16) == 0 % if window doesn't exist, create it if ud.gamma.enabled enbl = 'on'; else enbl = 'off'; end h1 = figure('Color',[.8 .8 .8],'userdata',h0,'Units','characters', ... 'Position',screenposn([40 15 110 54]), ... 'MenuBar','none','NumberTitle','off', ... 'Name','Gamma', ... 'DeleteFcn','discrim(''delete-gamma'')'); ud.fighandles(16) = h1; ud.gammaradiohandles(1) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.05 .91 .4 .05],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',1-ud.gamma.enabled, ... 'Callback','discrim(''gamma-radio'',1)', ... 'String','Disabled'); ud.gammaradiohandles(2) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.05 .83 .4 .05],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',ud.gamma.enabled, ... 'Callback','discrim(''gamma-radio'',2)', ... 'String','Enabled'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.1 .75 .25 .05], ... 'String','Liftoff:','Style','text'); ud.gammahandles(1) = uicontrol('Parent',h1, ... 'Callback','discrim(''gamma-set-liftoff'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.4 .75 .15 .05], ... 'Style','edit','Enable',enbl, ... 'String',num2str(ud.gamma.liftoff,3)); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.6 .75 .05 .05], ... 'String','0','Style','text'); ud.gammahandles(2) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.65 .75 .25 .05],'Fontsize',13, ... 'BackgroundColor',[.7 .7 .7], ... 'Style','slider','min',0,'max',.999,'Value',ud.gamma.liftoff, ... 'sliderstep',[.01 .1],'Enable',enbl, ... 'Callback','discrim(''gamma-set-liftoffsl'')', ... 'String',''); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.9 .75 .05 .05], ... 'String','1','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.1 .67 .25 .05], ... 'String','Gamma:','Style','text'); ud.gammahandles(3) = uicontrol('Parent',h1, ... 'Callback','discrim(''gamma-set-gamma'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.4 .67 .15 .05], ... 'Style','edit','Enable',enbl, ... 'String',num2str(ud.gamma.gamma,3)); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.6 .67 .05 .05], ... 'String','0','Style','text'); ud.gammahandles(4) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.65 .67 .25 .05],'Fontsize',13, ... 'BackgroundColor',[.7 .7 .7], ... 'Style','slider','min',.001,'max',5,'Value',ud.gamma.gamma, ... 'sliderstep',[.01 .1],'Enable',enbl, ... 'Callback','discrim(''gamma-set-gammasl'')', ... 'String',''); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.9 .67 .05 .05], ... 'String','5','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.1 .59 .25 .05], ... 'String','Min Contrast:','Style','text'); ud.gammahandles(5) = uicontrol('Parent',h1, ... 'Callback','discrim(''gamma-set-mincontr'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.4 .59 .15 .05], ... 'Style','edit','Enable',enbl, ... 'String',num2str(ud.gamma.mincontrast,3)); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.6 .59 .05 .05], ... 'String','-1','Style','text'); ud.gammahandles(6) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.65 .59 .25 .05],'Fontsize',13, ... 'BackgroundColor',[.7 .7 .7], ... 'Style','slider','min',-1,'max',.999,'Value',ud.gamma.mincontrast, ... 'sliderstep',[.01 .1],'Enable',enbl, ... 'Callback','discrim(''gamma-set-mincontrsl'')', ... 'String',''); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.9 .59 .05 .05], ... 'String','1','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.1 .51 .25 .05], ... 'String','Max Contrast:','Style','text'); ud.gammahandles(7) = uicontrol('Parent',h1, ... 'Callback','discrim(''gamma-set-maxcontr'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.4 .51 .15 .05], ... 'Style','edit','Enable',enbl, ... 'String',num2str(ud.gamma.maxcontrast,3)); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.6 .51 .05 .05], ... 'String','-1','Style','text'); ud.gammahandles(8) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.65 .51 .25 .05],'Fontsize',13, ... 'BackgroundColor',[.7 .7 .7], ... 'Style','slider','min',-.999,'max',1,'Value',ud.gamma.maxcontrast, ... 'sliderstep',[.01 .1],'Enable',enbl, ... 'Callback','discrim(''gamma-set-maxcontrsl'')', ... 'String',''); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.9 .51 .05 .05], ... 'String','1','Style','text'); ud.gammahandles(9) = axes('Position',[.15 .18 .7 .29]); uicontrol('Parent',h1, ... 'Callback','discrim(''gamma-okay'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.4 .05 .2 .05],'String','Okay'); plotgamma; else % else simply make it visible set(ud.fighandles(16),'Visible','on'); end case 'menu-dispchar-output' if ud.fighandles(17) == 0 % if window doesn't exist, create it h1 = figure('Color',[.8 .8 .8],'userdata',h0,'Units','characters', ... 'Position',screenposn([35 5 90 20]), ... 'MenuBar','none','NumberTitle','off', ... 'Name','Output Noise', ... 'DeleteFcn','discrim(''delete-output'')'); ud.fighandles(17) = h1; ud.outputradiohandles(1) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.1 .8 .6 .15],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',ud.output.noise==0, ... 'Callback','discrim(''output-radio'',1)', ... 'String','No output noise'); ud.outputradiohandles(2) = uicontrol('Parent',h1, ... 'Units','normalized','Position',[.1 .55 .6 .15],'Fontsize',13, ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio','Value',ud.output.noise==1, ... 'Callback','discrim(''output-radio'',2)', ... 'String','Gaussian noise'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.3 .3 .4 .15],'HorizontalAlignment','left', ... 'String','RMS noise contrast:','Style','text'); if ud.output.noise e = 'on'; else e = 'off'; end ud.outputhandles(1) = uicontrol('Parent',h1, ... 'Callback','discrim(''output-set-rms'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.75 .3 .15 .15], ... 'Style','edit','Enable',e, ... 'String',num2str(ud.output.rms,4)); uicontrol('Parent',h1, ... 'Callback','discrim(''output-okay'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.4 .05 .2 .15],'String','Okay'); else % else simply make it visible set(ud.fighandles(17),'Visible','on'); end case 'menu-dispchar-vgeom' if ud.fighandles(9) == 0 % if window doesn't exist, create it h1 = figure('Color',[.8 .8 .8],'userdata',h0,'Units','characters', ... 'Position',screenposn([40 6 110 40]), ... 'MenuBar','none','NumberTitle','off', ... 'Name','Viewing Geometry', ... 'DeleteFcn','discrim(''delete-vgeom'')'); ud.fighandles(9) = h1; % % Labels % uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.03 .88 .45 .06], ... 'String','Viewing distance (cm):','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.03 .81 .45 .06], ... 'String','Horizontal pixels/deg:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.03 .74 .45 .06], ... 'String','Vertical pixels/deg:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.03 .67 .45 .06], ... 'String','Horizontal pixels/cm:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.03 .6 .45 .06], ... 'String','Vertical pixels/cm:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.03 .53 .45 .06], ... 'String','Number of image columns:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.03 .46 .45 .06], ... 'String','Number of image rows:','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.03 .39 .45 .06], ... 'String','Horizontal image size (cm):','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.03 .32 .45 .06], ... 'String','Vertical image size (cm):','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.03 .25 .45 .06], ... 'String','Horizontal image size (deg):','Style','text'); uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.03 .18 .45 .06], ... 'String','Vertical image size (deg):','Style','text'); % % Editable text % ud.vgeomhandles(1) = uicontrol('Parent',h1, ... 'Callback','discrim(''vgeom-set-vdist'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.5 .88 .15 .06], ... 'Style','edit', ... 'String',num2str(ud.vgeom.vdist,4)); ud.vgeomhandles(2) = uicontrol('Parent',h1, ... 'Callback','discrim(''vgeom-set-hpixperdeg'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.5 .81 .15 .06], ... 'Style','edit', ... 'String',num2str(ud.vgeom.hpixperdeg,4)); ud.vgeomhandles(3) = uicontrol('Parent',h1, ... 'Callback','discrim(''vgeom-set-vpixperdeg'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.5 .74 .15 .06], ... 'Style','edit', ... 'String',num2str(ud.vgeom.vpixperdeg,4)); ud.vgeomhandles(4) = uicontrol('Parent',h1, ... 'Callback','discrim(''vgeom-set-hpixpercm'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.5 .67 .15 .06], ... 'Style','edit', ... 'String',num2str(ud.vgeom.hpixpercm,4)); ud.vgeomhandles(5) = uicontrol('Parent',h1, ... 'Callback','discrim(''vgeom-set-vpixpercm'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.5 .6 .15 .06], ... 'Style','edit', ... 'String',num2str(ud.vgeom.vpixpercm,4)); ud.vgeomhandles(6) = uicontrol('Parent',h1, ... 'Callback','discrim(''vgeom-set-hpixel'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.5 .53 .15 .06], ... 'Style','edit', ... 'String',num2str(ud.vgeom.hpixel,4)); ud.vgeomhandles(7) = uicontrol('Parent',h1, ... 'Callback','discrim(''vgeom-set-vpixel'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.5 .46 .15 .06], ... 'Style','edit', ... 'String',num2str(ud.vgeom.vpixel,4)); ud.vgeomhandles(8) = uicontrol('Parent',h1, ... 'Callback','discrim(''vgeom-set-hsizecm'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.5 .39 .15 .06], ... 'Style','edit', ... 'String',num2str(ud.vgeom.hsizecm,4)); ud.vgeomhandles(9) = uicontrol('Parent',h1, ... 'Callback','discrim(''vgeom-set-vsizecm'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.5 .32 .15 .06], ... 'Style','edit', ... 'String',num2str(ud.vgeom.vsizecm,4)); ud.vgeomhandles(10) = uicontrol('Parent',h1, ... 'Callback','discrim(''vgeom-set-hsizedeg'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.5 .25 .15 .06], ... 'Style','edit', ... 'String',num2str(ud.vgeom.hsizedeg,4)); ud.vgeomhandles(11) = uicontrol('Parent',h1, ... 'Callback','discrim(''vgeom-set-vsizedeg'')', ... 'BackgroundColor',[1 1 1],'Fontsize',13,'Units','normalized', ... 'Position',[.5 .18 .15 .06], ... 'Style','edit', ... 'String',num2str(ud.vgeom.vsizedeg,4)); ud.vgeomhandles(12) = uicontrol('Parent',h1, ... 'Callback','discrim(''vgeom-squarepixels'')', ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.69 .81 .28 .07], ... 'String','Square pixels','Style','checkbox', ... 'Value',1); ud.vgeomhandles(13) = uicontrol('Parent',h1, ... 'Callback','discrim(''vgeom-squareimage'')', ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','normalized', ... 'Position',[.69 .53 .28 .07], ... 'String','Square image','Style','checkbox', ... 'Value',1); uicontrol('Parent',h1, ... 'Callback','discrim(''vgeom-okay'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','normalized', ... 'Position',[.4 .08 .2 .07],'String','Okay'); else % else simply make it visible set(ud.fighandles(9),'Visible','on'); end % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Main window - Display Control menu callbacks % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'menu-dctrl' if arg2 < 4 for i = 1:3 if i == arg2 set(ud.maindctrlmenuhandles(i),'checked','on'); else set(ud.maindctrlmenuhandles(i),'checked','off'); end end if ud.dctrl ~= arg2 update_displays; end ud.dctrl = arg2; else for i = 4:8 if i == arg2 set(ud.maindctrlmenuhandles(i),'checked','on'); else set(ud.maindctrlmenuhandles(i),'checked','off'); end end olddl = ud.dlevel; ud.dlevel = arg2-3; if ud.dlevel ~= olddl update_displays; end end switch(ud.dctrl) case 1 s1 = 'As Is'; case 2 s1 = 'Stretch'; case 3 s1 = 'Full Range'; end switch(ud.dlevel) case 1 s2 = 'Raw Image'; case 2 s2 = 'After MTF'; case 3 s2 = 'After Poisson Noise'; case 4 s2 = 'After Gamma Curve'; case 5 s2 = 'After Gaussian Noise'; end set(ud.mainhandles(12),'String',{['Display contrast: ' s1] ... ['Image displayed: ' s2]}); case 'menu-newnoise' if ~isempty(get(ud.mainhandles(3),'String')) if ~chkposint(ud.mainhandles(3),'Left image number') set(ud.mainhandles(3),'String',''); set(ud.mainhandles(8),'String',''); set(ud.mainhandles(10),'String',''); set(ud.mainhandles(6),'Cdata',[0 0;0 0], ... 'XData',calcxydata(.05,2), ... 'YData',calcxydata(.05,2)); else numl = str2num(get(ud.mainhandles(3),'String')); indxl = find(ud.fignums==numl); if length(indxl)~=1 error('Left image defined twice!!!???'); elseif ~isempty(indxl) if ud.input.type ~= 1 ud.figs{indxl}.validity = min(ud.figs{indxl}.validity,1); end if ud.output.noise ud.figs{indxl}.validity = min(ud.figs{indxl}.validity,3); ud.output.imgvalid = 0; end end end end if ~isempty(get(ud.mainhandles(4),'String')) if ~chkposint(ud.mainhandles(4),'Right image number') set(ud.mainhandles(4),'String',''); set(ud.mainhandles(9),'String',''); set(ud.mainhandles(11),'String',''); set(ud.mainhandles(7),'Cdata',[0 0;0 0], ... 'XData',calcxydata(.05,2), ... 'YData',calcxydata(.05,2)); else numr = str2num(get(ud.mainhandles(4),'String')); indxr = find(ud.fignums==numr); if length(indxr)~=1 error('Right image defined twice!!!???'); elseif ~isempty(indxr) if ud.input.type ~= 1 ud.figs{indxr}.validity = min(ud.figs{indxr}.validity,1); end if ud.output.noise ud.figs{indxr}.validity = min(ud.figs{indxr}.validity,3); ud.output.imgvalid = 0; end end end end update_displays; % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % SFUModel window callbacks % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'sfum-set' sfumset(h0,ud); case 'sfum-set-ctrspr' if chknumeric(ud.sfumhandles(1),'Center spread') ud.params.simple.ctrspr = str2num(get(ud.sfumhandles(1), ... 'String')); set(ud.sfumhandles(2),'String', ... num2str(60/(sqrt(pi)*ud.params.simple.ctrspr),4)); sfumset(h0,ud); end case 'sfum-set-freqcut' if chknumeric(ud.sfumhandles(2),'Frequency cut') ud.params.simple.freqcut = ... str2num(get(ud.sfumhandles(2),'String')); set(ud.sfumhandles(1),'String', ... num2str(60/(sqrt(pi)*ud.params.simple.freqcut),4)); sfumset(h0,ud); end case 'sfum-okay' if sfumset(h0,ud) set(ud.fighandles(1),'Visible','off'); end % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Save Image window callbacks % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'savimg-imagenum' if chkposint2(ud.savimghandles(1),'Image number') num = str2num(get(ud.savimghandles(1),'String')); if isempty(ud.fignums) indx = []; else indx = find(ud.fignums==num); end if length(indx) == 1 [m,n] = size(ud.figs{indx}.img); s2 = [fmtsize(m,n),': ',ud.figs{indx}.name]; set(ud.savimghandles(2),'String',s2); else set(ud.savimghandles(2),'String',''); end else set(ud.savimghandles(2),'String',''); end case 'savimg-browse' [file,path] = uiputfile([get(ud.savimghandles(3),'String'), ... get(ud.savimghandles(4),'String')],'Save File'); if length(file)~=1 | file~=0 set(ud.savimghandles(3),'String',path); set(ud.savimghandles(4),'String',file); end case 'savimg-radio' setradio(ud.savimgradiohandles,arg2); case 'savimg-okay' fname = [get(ud.savimghandles(3),'String'), ... get(ud.savimghandles(4),'String')]; if chkposint(ud.savimghandles(1),'Image number') num = str2num(get(ud.savimghandles(1),'String')); if isempty(ud.fignums) msgbox('Undefined image','Error window','error','modal'); else errflag = 0; indx = find(ud.fignums==num); if length(indx) ~= 1 error('Image defined twice!!!???'); else if get(ud.savimgradiohandles(1),'Value') discrim_img = ud.figs{indx}.img; eval(['save ''',fname,''' discrim_img;'],'errflag=1;'); if errflag msgbox(['Error writing file'], ... 'Error window','error','modal'); end else if get(ud.savimgradiohandles(2),'Value') type = 'bmp'; elseif get(ud.savimgradiohandles(3),'Value') type = 'hdf'; elseif get(ud.savimgradiohandles(4),'Value') type = 'jpg'; elseif get(ud.savimgradiohandles(5),'Value') type = 'pcx'; elseif get(ud.savimgradiohandles(6),'Value') type = 'tiff'; else type = 'xwd'; end img = .5 + .5*ud.figs{indx}.img; eval('imwrite(img,fname,type);','errflag=1;'); if errflag msgbox(['Error writing file'], ... 'Error window','error','modal'); end end if ~errflag set(ud.fighandles(3),'Visible','off'); end end end else set(ud.savimghandles(1),'String',''); set(ud.savimghandles(2),'String',''); end case 'savimg-cancel' set(ud.fighandles(3),'Visible','off'); % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % New Image window callbacks % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'newimg-rows' chkposint(ud.newimghandles(3),'Number of rows'); case 'newimg-cols' chkposint(ud.newimghandles(4),'Number of rows'); case 'newimg-okay' if chkposint(ud.newimghandles(3),'Number of rows') & ... chkposint(ud.newimghandles(4),'Number of rows') num = str2num(get(ud.newimghandles(1),'String')); if isempty(ud.fignums) | length(find(ud.fignums==num))<1 indx = length(ud.fignums) + 1; ud.figs{indx}.name = get(ud.newimghandles(2),'String'); nr = str2num(get(ud.newimghandles(3),'String')); nc = str2num(get(ud.newimghandles(4),'String')); ud.figs{indx}.img = zeros(nr,nc); ud.figs{indx}.validity = 0; % set size/lum/contrast/contrast scale? ud.fignums(indx) = num; set(ud.fighandles(11),'Visible','off'); trytodisplay(indx); else msgbox(['Image number ' num2str(num) ... ' already defined, try again'], ... 'Error window','error','modal'); set(ud.fighandles(11),'Visible','off'); end end case 'newimg-cancel' set(ud.fighandles(11),'Visible','off'); % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Load Image window callbacks % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'loadimg-imagenum' if ~isempty(get(ud.loadimghandles(1),'String')) & ... chkposint2(ud.loadimghandles(1),'Image number') num = str2num(get(ud.loadimghandles(1),'String')); if isempty(ud.fignums) indx = []; else indx = find(ud.fignums==num); end if length(indx) == 1 [m,n] = size(ud.figs{indx}.img); s2 = [fmtsize(m,n),': ',ud.figs{indx}.name]; set(ud.loadimghandles(2),'String',s2); else set(ud.loadimghandles(2),'String',''); end else set(ud.loadimghandles(2),'String',''); end case 'loadimg-browse' [file,path] = uigetfile([get(ud.loadimghandles(3),'String'),'*.*'], ... 'Load File'); if length(file)~=1 | file~=0 set(ud.loadimghandles(3),'String',path); set(ud.loadimghandles(4),'String',file); end case 'loadimg-okay' fname = [get(ud.loadimghandles(3),'String'), ... get(ud.loadimghandles(4),'String')]; if isempty(get(ud.loadimghandles(1),'String')) | ... chkposint(ud.loadimghandles(1),'Image number') if isempty(get(ud.loadimghandles(1),'String')) num = 1; if ~isempty(ud.fignums) while length(find(ud.fignums==num))>0 num = num + 1; end end else num = str2num(get(ud.loadimghandles(1),'String')); end if isempty(ud.fignums) indx = []; else indx = find(ud.fignums==num); end newflag = 0; if length(indx) > 1 error('Image defined twice!!!???'); elseif length(indx) == 0 newflag = 1; indx = length(ud.fignums)+1; end errflag = 0; l = length(fname); if l > 4 & strcmp(fname(l-3:l),'.mat') clear discrim_img; eval(['load ''',fname,''';'], ... 'errflag=1;errmsg=''Can''''t load file'';'); if ~errflag eval('type=class(discrim_img);', ... 'errflag=1;errmsg=''discrim_img undefined'';'); end if ~errflag & (~strcmp(type,'double') | ... ndims(discrim_img) > 2) errflag = 1; errmsg = 'discrim_img is not a double array'; end if ~errflag discrim_img = double(discrim_img); end else eval('discrim_img=imread(fname);', ... 'errflag=1;errmsg=''Can''''t imread file'';'); if ~errflag discrim_img = (double(discrim_img)-128)/128; end end if errflag msgbox(errmsg,'Error window','error','modal'); else ud.figs{indx}.img = discrim_img; ud.figs{indx}.validity = 0; if newflag ud.fignums(indx) = num; ud.figs{indx}.name = get(ud.loadimghandles(4),'String'); trytodisplay(indx); end if strcmp(get(ud.mainhandles(3),'String'),num2str(num)) set(ud.mainhandles(8),'String',ud.figs{indx}.name); showimg(1,indx); [m,n] = size(ud.figs{indx}.img); set(ud.mainhandles(10),'String',fmtsize(m,n)); selectleft; update_directory; end if strcmp(get(ud.mainhandles(4),'String'),num2str(num)) set(ud.mainhandles(9),'String',ud.figs{indx}.name); showimg(2,indx); [m,n] = size(ud.figs{indx}.img); set(ud.mainhandles(11),'String',fmtsize(m,n)); selectright; update_directory; end set(ud.fighandles(10),'Visible','off'); end else set(ud.loadimghandles(1),'String',''); set(ud.loadimghandles(2),'String',''); end case 'loadimg-cancel' set(ud.fighandles(10),'Visible','off'); % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Image Directory window callbacks % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'directory-okay' if isempty(get(ud.mainhandles(3),'String')) currleft = 0; else currleft = str2num(get(ud.mainhandles(3),'String')); end if isempty(get(ud.mainhandles(4),'String')) currright = 0; else currright = str2num(get(ud.mainhandles(4),'String')); end numfigs = length(ud.figs); [ordfigs,figindx]=sort(ud.fignums); newleft = 0; newright = 0; for i = 1:numfigs if get(ud.dlradiohandles(i),'Value') newleftindx = figindx(i); newleft = ordfigs(i); end if get(ud.drradiohandles(i),'Value') newrightindx = figindx(i); newright = ordfigs(i); end end if newleft ~= currleft set(ud.mainhandles(3),'String',newleft); set(ud.mainhandles(8),'String',ud.figs{newleftindx}.name); showimg(1,newleftindx); [m,n] = size(ud.figs{newleftindx}.img); set(ud.mainhandles(10),'String',fmtsize(m,n)); end if newright ~= currright set(ud.mainhandles(4),'String',newright); set(ud.mainhandles(9),'String',ud.figs{newrightindx}.name); showimg(2,newrightindx); [m,n] = size(ud.figs{newrightindx}.img); set(ud.mainhandles(11),'String',fmtsize(m,n)); end delete(ud.fighandles(2)); ud.fighandles(2) = 0; ud.dstringhandles = []; ud.dlradiohandles = []; ud.drradiohandles = []; ud.directoryhandles = zeros(1,2); case 'directory-cancel' delete(ud.fighandles(2)); ud.fighandles(2) = 0; ud.dstringhandles = []; ud.dlradiohandles = []; ud.drradiohandles = []; ud.directoryhandles = zeros(1,2); case 'directory-radiol' setradio(ud.dlradiohandles,arg2); case 'directory-radior' setradio(ud.drradiohandles,arg2); % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Add Grating window callbacks % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'agrat-imagenum' if ~isempty(get(ud.agrathandles(1),'String')) & ... chkposint2(ud.agrathandles(1),'Image number') num = str2num(get(ud.agrathandles(1),'String')); if isempty(ud.fignums) indx = []; else indx = find(ud.fignums==num); end if length(indx) == 1 [m,n] = size(ud.figs{indx}.img); s2 = [fmtsize(m,n),': ',ud.figs{indx}.name]; set(ud.agrathandles(2),'String',s2); else set(ud.agrathandles(2),'String',''); end else set(ud.agrathandles(2),'String',''); end case 'agrat-sf' chknumeric(ud.agrathandles(3),'Spatial Frequency'); case 'agrat-radioagsf' setradio(ud.agratsfradiohandles,arg2); case 'agrat-orient' if chknumeric(ud.agrathandles(4),'Orientation'); o = str2num(get(ud.agrathandles(4),'String')); o2 = mod(o,180); set(ud.agrathandles(5),'Value',o2); if o ~= o2 set(ud.agrathandles(4),'String',num2str(o2)); end end case 'agrat-orientsl' set(ud.agrathandles(4),'String', ... num2str(get(ud.agrathandles(5),'Value'))); case 'agrat-phase' if chknumeric(ud.agrathandles(6),'Phase'); p = str2num(get(ud.agrathandles(6),'String')); p2 = mod(p,360); set(ud.agrathandles(7),'Value',p2); if p ~= p2 set(ud.agrathandles(6),'String',num2str(p2)); end end case 'agrat-phasesl' set(ud.agrathandles(6),'String', ... num2str(get(ud.agrathandles(7),'Value'))); case 'agrat-radioagtype' setradio(ud.agrattyperadiohandles,arg2); case 'agrat-contr' if chknumeric(ud.agrathandles(8),'Contrast'); c = str2num(get(ud.agrathandles(8),'String')); if c < 0 | c > 1 msgbox(['Contrast must lie between 0 and 1'], ... 'Error window','error','modal'); c = .5; set(ud.agrathandles(8),'String',num2str(c)); end set(ud.agrathandles(9),'Value',c); end case 'agrat-contrsl' set(ud.agrathandles(8),'String', ... num2str(get(ud.agrathandles(9),'Value'))); case 'agrat-okay' if ~isempty(get(ud.agrathandles(1),'String')) & ... ~chkposint(ud.agrathandles(1),'Image number') set(ud.agrathandles(1),'String',''); set(ud.agrathandles(2),'String',''); elseif chknumeric(ud.agrathandles(3),'Spatial Frequency') & ... chknumeric(ud.agrathandles(4),'Orientation') & ... chknumeric(ud.agrathandles(6),'Phase') & ... chknumeric(ud.agrathandles(8),'Contrast') if isempty(get(ud.agrathandles(1),'String')) img = 1; if ~isempty(ud.fignums) while length(find(ud.fignums==img))>0 img = img + 1; end end else img = str2num(get(ud.agrathandles(1),'String')); end if isempty(ud.fignums) indx = []; else indx = find(ud.fignums==img); end if length(indx) > 1 error('More than one copy of this image'); elseif length(indx) == 0 indx = length(ud.fignums)+1; newfig.name = ''; newfig.img = zeros(ud.vgeom.vpixel,ud.vgeom.hpixel); % set size/lum/contrast/contrast scale? ud.fignums(indx) = img; ud.figs{indx} = newfig; end ud.undo.op = 'Add Grating'; ud.undo.num = img; ud.undo.img = ud.figs{indx}.img; [vpix hpix] = size(ud.figs{indx}.img); % convert to cycles per horizontal pixel sf = str2num(get(ud.agrathandles(3),'String')); if (get(ud.agratsfradiohandles(1),'Value')) % sf is in cycles/deg sf = sf / ud.vgeom.hpixperdeg; elseif (get(ud.agratsfradiohandles(2),'Value')) % sf is in cycles/cm sf = sf / ud.vgeom.hpixpercm; else % sf is in cycles/image window width sf = sf / ud.vgeom.hpixel; end phaserad = str2num(get(ud.agrathandles(6),'String'))*pi/180; contr = str2num(get(ud.agrathandles(8),'String')); orientrad = str2num(get(ud.agrathandles(4),'String'))*pi/180; hwid = hpix/2; hht = vpix/2; twopi = 2*pi; hscale=twopi*sf*cos(orientrad); vscale=twopi*sf*sin(orientrad)*ud.vgeom.hpixpercm/ ... ud.vgeom.vpixpercm; if (get(ud.agrattyperadiohandles(1),'Value')) %compute/add sine grating for i=1:hpix for j=1:vpix ud.figs{indx}.img(j,i) = ud.figs{indx}.img(j,i) ... + contr * cos(((i-hwid)*hscale + ... (j-hht)*vscale) - phaserad); end end elseif (get(ud.agrattyperadiohandles(2),'Value')) %compute/add square grating for i=1:hpix for j=1:vpix ph = mod(((i-hwid)*hscale + ... (j-hht)*vscale) - phaserad,twopi); val = 1; if ph >= pi/2 & ph < 3*pi/2 val = -1; end ud.figs{indx}.img(j,i) = ud.figs{indx}.img(j,i) ... + contr * val; end end else %compute/add triangle grating for i=1:hpix for j=1:vpix ph = mod(((i-hwid)*hscale + ... (j-hht)*vscale) - phaserad,twopi); val = 1; if ph <= pi val = 1 - 2*ph/pi; else val = (2*ph/pi) - 3; end ud.figs{indx}.img(j,i) = ud.figs{indx}.img(j,i) ... + contr * val; end end end ud.figs{indx}.validity = 0; trytodisplay(indx); set(ud.fighandles(5),'Visible','off'); end case 'agrat-cancel' set(ud.fighandles(5),'Visible','off'); % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Add Gabor window callbacks % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'agab-imagenum' if ~isempty(get(ud.agabhandles(1),'String')) & ... chkposint2(ud.agabhandles(1),'Image number') num = str2num(get(ud.agabhandles(1),'String')); if isempty(ud.fignums) indx = []; else indx = find(ud.fignums==num); end if length(indx) == 1 [m,n] = size(ud.figs{indx}.img); s2 = [fmtsize(m,n),': ',ud.figs{indx}.name]; set(ud.agabhandles(2),'String',s2); else set(ud.agabhandles(2),'String',''); end else set(ud.agabhandles(2),'String',''); end case 'agab-rowoffset' chkint(ud.agabhandles(14),'Row Offset'); case 'agab-coloffset' chkint(ud.agabhandles(15),'Column Offset'); case 'agab-envorient' if chknumeric(ud.agabhandles(3),'Orientation'); o = str2num(get(ud.agabhandles(3),'String')); o2 = mod(o,180); set(ud.agabhandles(4),'Value',o2); if o ~= o2 set(ud.agabhandles(3),'String',num2str(o2)); end end case 'agab-envorientsl' set(ud.agabhandles(3),'String', ... num2str(get(ud.agabhandles(4),'Value'))); case 'agab-envsigiso' chknumeric(ud.agabhandles(5),'Sigma (along)'); case 'agab-envsigortho' chknumeric(ud.agabhandles(6),'Sigma (across)'); case 'agab-radiosig' setradio(ud.agabsigradiohandles,arg2); case 'agab-modsf' chknumeric(ud.agabhandles(7),'Spatial Frequency'); case 'agab-radiosf' setradio(ud.agabsfradiohandles,arg2); case 'agab-modorient' if chknumeric(ud.agabhandles(8),'Orientation'); o = str2num(get(ud.agabhandles(8),'String')); o2 = mod(o,180); set(ud.agabhandles(9),'Value',o2); if o ~= o2 set(ud.agabhandles(8),'String',num2str(o2)); end end case 'agab-modorientsl' set(ud.agabhandles(8),'String', ... num2str(get(ud.agabhandles(9),'Value'))); case 'agab-modphase' if chknumeric(ud.agabhandles(10),'Phase'); p = str2num(get(ud.agabhandles(10),'String')); p2 = mod(p,360); set(ud.agabhandles(11),'Value',p2); if p ~= p2 set(ud.agabhandles(10),'String',num2str(p2)); end end case 'agab-modphasesl' set(ud.agabhandles(10),'String', ... num2str(get(ud.agabhandles(11),'Value'))); case 'agab-contr' if chknumeric(ud.agabhandles(12),'Contrast'); c = str2num(get(ud.agabhandles(12),'String')); if c < 0 | c > 1 msgbox(['Contrast must lie between 0 and 1'], ... 'Error window','error','modal'); c = .5; set(ud.agabhandles(12),'String',num2str(c)); end set(ud.agabhandles(13),'Value',c); end case 'agab-contrsl' set(ud.agabhandles(12),'String', ... num2str(get(ud.agabhandles(13),'Value'))); case 'agab-okay' if ~isempty(get(ud.agabhandles(1),'String')) & ... ~chkposint(ud.agabhandles(1),'Image number') set(ud.agabhandles(1),'String',''); set(ud.agabhandles(2),'String',''); elseif chknumeric(ud.agabhandles(3),'Envelope Orientation') & ... chknumeric(ud.agabhandles(5),'Sigma (along)') & ... chknumeric(ud.agabhandles(6),'Sigma (across)') & ... chknumeric(ud.agabhandles(7),'Modulator Spatial Frequency') & ... chknumeric(ud.agabhandles(8),'Modulator Orientation') & ... chknumeric(ud.agabhandles(10),'Modulator Phase') & ... chknumeric(ud.agabhandles(12),'Contrast') & ... chkint(ud.agabhandles(14),'Row Offset') & ... chkint(ud.agabhandles(15),'Column Offset') if isempty(get(ud.agabhandles(1),'String')) img = 1; if ~isempty(ud.fignums) while length(find(ud.fignums==img))>0 img = img + 1; end end else img = str2num(get(ud.agabhandles(1),'String')); end if isempty(ud.fignums) indx = []; else indx = find(ud.fignums==img); end if length(indx) > 1 error('More than one copy of this image'); elseif length(indx) == 0 indx = length(ud.fignums)+1; newfig.name = ''; newfig.img = zeros(ud.vgeom.vpixel,ud.vgeom.hpixel); % set size/lum/contrast/contrast scale? ud.fignums(indx) = img; ud.figs{indx} = newfig; end ud.undo.op = 'Add Gabor'; ud.undo.num = img; ud.undo.img = ud.figs{indx}.img; [vpix hpix] = size(ud.figs{indx}.img); sigmaiso = str2num(get(ud.agabhandles(5),'String')); sigmaortho = str2num(get(ud.agabhandles(6),'String')); if (get(ud.agabsigradiohandles(1),'Value')) % sigmas are in deg sigmaiso = sigmaiso * ud.vgeom.hpixperdeg; sigmaortho = sigmaortho * ud.vgeom.hpixperdeg; elseif (get(ud.agabsigradiohandles(2),'Value')) % sigmas are in cm sigmaiso = sigmaiso * ud.vgeom.hpixpercm; sigmaortho = sigmaortho * ud.vgeom.hpixpercm; end sf = str2num(get(ud.agabhandles(7),'String')); if (get(ud.agabsfradiohandles(1),'Value')) % sf is in cycles/deg sf = sf / ud.vgeom.hpixperdeg; elseif (get(ud.agabsfradiohandles(2),'Value')) % sf is in cycles/cm sf = sf / ud.vgeom.hpixpercm; else % sf is in cycles/image window width % convert to cycles/actual image width sf = sf / ud.vgeom.hpixel; end envorientrad = str2num(get(ud.agabhandles(3),'String'))*pi/180; modorientrad = str2num(get(ud.agabhandles(8),'String'))*pi/180; phaserad = str2num(get(ud.agabhandles(10),'String'))*pi/180; contr = str2num(get(ud.agabhandles(12),'String')); cosenvth = cos(envorientrad); sinenvth = sin(envorientrad); cosmodth = cos(modorientrad); sinmodth = sin(modorientrad); roff = str2num(get(ud.agabhandles(14),'String')); coff = str2num(get(ud.agabhandles(15),'String')); hctr = (hpix/2) + coff; % these might not be integers vctr = (vpix/2) + roff; twopi = 2*pi; vscale=ud.vgeom.hpixpercm/ud.vgeom.vpixpercm; xmodscale=twopi*sf*cos(modorientrad); ymodscale=twopi*sf*sin(modorientrad); xisoscale = cosenvth/sigmaiso; yisoscale = sinenvth/sigmaiso; xorthoscale = -sinenvth/sigmaortho; yorthoscale = cosenvth/sigmaortho; di = max(ceil(abs(3*sigmaiso*cosenvth)), ... ceil(abs(3*sigmaortho*sinenvth))); dj = max(ceil(abs(3*sigmaiso*sinenvth)), ... ceil(abs(3*sigmaortho*cosenvth))); ilow = fix(hctr)-di; if ilow < 1 ilow = 1; end ihigh = ceil(hctr)+di; if ihigh > hpix ihigh = hpix; end jlow = fix(vctr)-dj; if jlow < 1 jlow = 1; end jhigh = ceil(vctr)+dj; if jhigh > vpix jhigh = vpix; end for i=ilow:ihigh for j=jlow:jhigh x = i - hctr; y = (j - vctr)*vscale; modul = cos((x*xmodscale + ... y*ymodscale) - phaserad); xiso = x*xisoscale + y*yisoscale; xortho = x*xorthoscale + y*yorthoscale; env = exp(-(xiso^2 + xortho^2)/2); ud.figs{indx}.img(j,i) = ud.figs{indx}.img(j,i) ... + contr * env * modul; end end ud.figs{indx}.validity = 0; trytodisplay(indx); set(ud.fighandles(6),'Visible','off'); end case 'agab-cancel' set(ud.fighandles(6),'Visible','off'); % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Add File window callbacks % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'afile-imagenum' if ~isempty(get(ud.afilehandles(1),'String')) & ... chkposint2(ud.afilehandles(1),'Image number') num = str2num(get(ud.afilehandles(1),'String')); if isempty(ud.fignums) indx = []; else indx = find(ud.fignums==num); end if length(indx) == 1 [m,n] = size(ud.figs{indx}.img); s2 = [fmtsize(m,n),': ',ud.figs{indx}.name]; set(ud.afilehandles(2),'String',s2); else set(ud.afilehandles(2),'String',''); end else set(ud.afilehandles(2),'String',''); end case 'afile-rowoffset' chkint(ud.afilehandles(5),'Row Offset'); case 'afile-coloffset' chkint(ud.afilehandles(6),'Column Offset'); case 'afile-browse' [file,path] = uigetfile([get(ud.afilehandles(3),'String'),'*.*'], ... 'Add File'); if length(file)~=1 | file~=0 set(ud.afilehandles(3),'String',path); set(ud.afilehandles(4),'String',file); end case 'afile-radio' setradio(ud.afileradiohandles,arg2); case 'afile-okay' fname = [get(ud.afilehandles(3),'String'), ... get(ud.afilehandles(4),'String')]; if ~isempty(get(ud.afilehandles(1),'String')) & ... ~chkposint(ud.afilehandles(1),'Image number') set(ud.afilehandles(1),'String',''); set(ud.afilehandles(2),'String',''); elseif chkint(ud.afilehandles(5),'Row Offset') & ... chkint(ud.afilehandles(6),'Column Offset') if isempty(get(ud.afilehandles(1),'String')) img = 1; if ~isempty(ud.fignums) while length(find(ud.fignums==img))>0 img = img + 1; end end set(ud.afilehandles(1),'String',num2str(img)); else img = str2num(get(ud.afilehandles(1),'String')); end if isempty(ud.fignums) indx = []; else indx = find(ud.fignums==img); end newflag = 0; if length(indx) > 1 error('More than one copy of this image'); elseif length(indx) == 0 indx = length(ud.fignums)+1; newflag = 1; end errflag = 0; l = length(fname); if l > 4 & strcmp(fname(l-3:l),'.mat') clear discrim_img; eval(['load ''',fname,''';'], ... 'errflag=1;errmsg=''Can''''t load file'';'); if ~errflag eval('type=class(discrim_img);', ... 'errflag=1;errmsg=''discrim_img undefined'';'); end if ~errflag & (~strcmp(type,'double') | ... ndims(discrim_img) > 2) errflag = 1; errmsg = 'discrim_img is not a double array'; end if ~errflag discrim_img = double(discrim_img); end else eval('discrim_img=imread(fname);', ... 'errflag=1;errmsg=''Can''''t imread file'';'); if ~errflag discrim_img = (double(discrim_img)-128)/128; end end if errflag msgbox(errmsg,'Error window','error','modal'); else if newflag ud.figs{indx}.img = discrim_img; ud.fignums(indx) = img; ud.figs{indx}.name = ''; else ud.undo.op = 'Combine File'; ud.undo.num = img; ud.undo.img = ud.figs{indx}.img; roff = str2num(get(ud.afilehandles(5),'String')); coff = str2num(get(ud.afilehandles(6),'String')); [irows icols] = size(discrim_img); [orows ocols] = size(ud.figs{indx}.img); dx = fix((ocols-icols)/2) + coff; dy = fix((orows-irows)/2) + roff; if dx >= 0 ficol = 1; focol = dx+1; else ficol = 1-dx; focol = 1; end if icols+dx >= ocols locol = ocols; licol = icols - (icols+dx-ocols); else licol = icols; locol = ocols - (ocols-(icols+dx)); end if dy >= 0 firow = 1; forow = dy+1; else firow = 1-dy; forow = 1; end if irows+dy >= orows lorow = orows; lirow = irows - (irows+dy-orows); else lirow = irows; lorow = orows - (orows-(irows+dy)); end if get(ud.afileradiohandles(1),'Value') ud.figs{indx}.img(forow:lorow,focol:locol) = ... ud.figs{indx}.img(forow:lorow,focol:locol) + ... discrim_img(firow:lirow,ficol:licol); elseif get(ud.afileradiohandles(2),'Value') ud.figs{indx}.img(forow:lorow,focol:locol) = ... discrim_img(firow:lirow,ficol:licol); elseif get(ud.afileradiohandles(3),'Value') nontransp = ... discrim_img(firow:lirow,ficol:licol) ~= 0; ud.figs{indx}.img(forow:lorow,focol:locol) = ... (1 - nontransp) .* ... ud.figs{indx}.img(forow:lorow,focol:locol) + ... nontransp .* ... discrim_img(firow:lirow,ficol:licol); else ud.figs{indx}.img(forow:lorow,focol:locol) = ... ud.figs{indx}.img(forow:lorow,focol:locol) .* ... discrim_img(firow:lirow,ficol:licol); end end ud.figs{indx}.validity = 0; trytodisplay(indx); set(ud.fighandles(7),'Visible','off'); end end case 'afile-cancel' set(ud.fighandles(7),'Visible','off'); % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Add Image window callbacks % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'aimg-toimagenum' if ~isempty(get(ud.aimghandles(1),'String')) & ... chkposint2(ud.aimghandles(1),'From Image number') num = str2num(get(ud.aimghandles(1),'String')); if isempty(ud.fignums) indx = []; else indx = find(ud.fignums==num); end if length(indx) == 1 [m,n] = size(ud.figs{indx}.img); set(ud.aimghandles(2),'String', ... [fmtsize(m,n),': ', ... ud.figs{indx}.name]); else set(ud.aimghandles(2),'String',''); end else set(ud.aimghandles(2),'String',''); end case 'aimg-fromimagenum' if chkposint2(ud.aimghandles(3),'To Image number') num = str2num(get(ud.aimghandles(3),'String')); if isempty(ud.fignums) indx = []; else indx = find(ud.fignums==num); end if length(indx) == 1 [m,n] = size(ud.figs{indx}.img); set(ud.aimghandles(4),'String', ... [fmtsize(m,n),': ', ... ud.figs{indx}.name]); else set(ud.aimghandles(4),'String',''); end else set(ud.aimghandles(4),'String',''); end case 'aimg-rowoffset' chkint(ud.aimghandles(5),'Row Offset'); case 'aimg-coloffset' chkint(ud.aimghandles(6),'Column Offset'); case 'aimg-radio' setradio(ud.aimgradiohandles,arg2); case 'aimg-okay' if ~isempty(get(ud.aimghandles(1),'String')) & ... ~chkposint(ud.aimghandles(1),'From Image number') set(ud.aimghandles(1),'String',''); set(ud.aimghandles(2),'String',''); elseif ~chkposint(ud.aimghandles(3),'Image number') set(ud.aimghandles(3),'String',''); set(ud.aimghandles(4),'String',''); elseif chkint(ud.aimghandles(5),'Row Offset') & ... chkint(ud.aimghandles(6),'Column Offset') if isempty(get(ud.aimghandles(1),'String')) img = 1; if ~isempty(ud.fignums) while length(find(ud.fignums==img))>0 img = img + 1; end end set(ud.aimghandles(1),'String',num2str(img)); else img = str2num(get(ud.aimghandles(1),'String')); end if isempty(ud.fignums) indx = []; else indx = find(ud.fignums==img); end newflag = 0; if length(indx) > 1 error('More than one copy of this image'); elseif length(indx) == 0 indx = length(ud.fignums)+1; newflag = 1; end errflag = 0; if isempty(get(ud.aimghandles(3),'String')) errflag = 1; else fimg = str2num(get(ud.aimghandles(3),'String')); if isempty(ud.fignums) findx = []; else findx = find(ud.fignums==fimg); end if length(findx) > 1 error('More than one copy of this image'); elseif length(findx) == 0 errflag = 1; end end if errflag msgbox('From Image must be defined', ... 'Error window','error','modal'); else if newflag ud.figs{indx}.img = ud.figs{findx}.img; ud.fignums(indx) = img; ud.figs{indx}.name = ''; else ud.undo.op = 'Combine Image'; ud.undo.num = img; ud.undo.img = ud.figs{indx}.img; roff = str2num(get(ud.aimghandles(5),'String')); coff = str2num(get(ud.aimghandles(6),'String')); [irows icols] = size(ud.figs{findx}.img); [orows ocols] = size(ud.figs{indx}.img); dx = fix((ocols-icols)/2) + coff; dy = fix((orows-irows)/2) + roff; if dx >= 0 ficol = 1; focol = dx+1; else ficol = 1-dx; focol = 1; end if icols+dx >= ocols locol = ocols; licol = icols - (icols+dx-ocols); else licol = icols; locol = ocols - (ocols-(icols+dx)); end if dy >= 0 firow = 1; forow = dy+1; else firow = 1-dy; forow = 1; end if irows+dy >= orows lorow = orows; lirow = irows - (irows+dy-orows); else lirow = irows; lorow = orows - (orows-(irows+dy)); end if get(ud.aimgradiohandles(1),'Value') ud.figs{indx}.img(forow:lorow,focol:locol) = ... ud.figs{indx}.img(forow:lorow,focol:locol) + ... ud.figs{findx}.img(firow:lirow,ficol:licol); elseif get(ud.aimgradiohandles(2),'Value') ud.figs{indx}.img(forow:lorow,focol:locol) = ... ud.figs{findx}.img(firow:lirow,ficol:licol); elseif get(ud.aimgradiohandles(3),'Value') nontransp = ... ud.figs{findx}.img(firow:lirow,ficol:licol) ~= 0; ud.figs{indx}.img(forow:lorow,focol:locol) = ... (1 - nontransp) .* ... ud.figs{indx}.img(forow:lorow,focol:locol) + ... nontransp .* ... ud.figs{findx}.img(firow:lirow,ficol:licol); else ud.figs{indx}.img(forow:lorow,focol:locol) = ... ud.figs{indx}.img(forow:lorow,focol:locol) .* ... ud.figs{findx}.img(firow:lirow,ficol:licol); end end ud.figs{indx}.validity = 0; trytodisplay(indx); set(ud.fighandles(8),'Visible','off'); end end case 'aimg-cancel' set(ud.fighandles(8),'Visible','off'); % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Scale Image window callbacks % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'scale-imagenum' if chkposint2(ud.scalehandles(1),'Image number') num = str2num(get(ud.scalehandles(1),'String')); if isempty(ud.fignums) indx = []; else indx = find(ud.fignums==num); end if length(indx) == 1 [m,n] = size(ud.figs{indx}.img); set(ud.scalehandles(2),'String', ... [fmtsize(m,n),': ', ... ud.figs{indx}.name]); else set(ud.scalehandles(2),'String',''); end else set(ud.scalehandles(2),'String',''); end case 'scale-contrscale' chknumeric(ud.scalehandles(3),'Contrast Scale'); case 'scale-contrshift' chknumeric(ud.scalehandles(4),'Contrast Shift'); case 'scale-okay' if ~chkposint(ud.scalehandles(1),'Image number') set(ud.scalehandles(1),'String',''); set(ud.scalehandles(2),'String',''); elseif chknumeric(ud.scalehandles(3),'Contrast Scale') & ... chknumeric(ud.scalehandles(4),'Contrast Shift') img = str2num(get(ud.scalehandles(1),'String')); if isempty(ud.fignums) indx = []; else indx = find(ud.fignums==img); end if length(indx) > 1 error('More than one copy of this image'); elseif length(indx) == 0 msgbox('Image must be defined', ... 'Error window','error','modal'); else ud.undo.op = 'Scale Image'; ud.undo.num = img; ud.undo.img = ud.figs{indx}.img; a = str2num(get(ud.scalehandles(3),'String')); b = str2num(get(ud.scalehandles(4),'String')); ud.figs{indx}.img = a*ud.figs{indx}.img + b; ud.figs{indx}.validity = 0; trytodisplay(indx); set(ud.fighandles(12),'Visible','off'); end end case 'scale-cancel' set(ud.fighandles(12),'Visible','off'); % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Clip Image window callbacks % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'clip-imagenum' if chkposint2(ud.cliphandles(1),'Image number') num = str2num(get(ud.cliphandles(1),'String')); if isempty(ud.fignums) indx = []; else indx = find(ud.fignums==num); end if length(indx) == 1 [m,n] = size(ud.figs{indx}.img); set(ud.cliphandles(2),'String', ... [fmtsize(m,n),': ', ... ud.figs{indx}.name]); else set(ud.cliphandles(2),'String',''); end else set(ud.cliphandles(2),'String',''); end case 'clip-lowvalue' chknumeric(ud.cliphandles(4),'Low Threshold Contrast'); case 'clip-highvalue' chknumeric(ud.cliphandles(6),'High Threshold Contrast'); case 'clip-okay' if ~chkposint(ud.cliphandles(1),'Image number') set(ud.cliphandles(1),'String',''); set(ud.cliphandles(2),'String',''); elseif chknumeric(ud.cliphandles(4),'Low Threshold Contrast') & ... chknumeric(ud.cliphandles(6),'High Threshold Contrast') img = str2num(get(ud.cliphandles(1),'String')); if isempty(ud.fignums) indx = []; else indx = find(ud.fignums==img); end if length(indx) > 1 error('More than one copy of this image'); elseif length(indx) == 0 msgbox('Image must be defined', ... 'Error window','error','modal'); else ud.undo.op = 'Clip Image'; ud.undo.num = img; ud.undo.img = ud.figs{indx}.img; if get(ud.cliphandles(3),'Value') lev = str2num(get(ud.cliphandles(4),'String')); ud.figs{indx}.img = max(ud.figs{indx}.img,lev); end if get(ud.cliphandles(5),'Value') lev = str2num(get(ud.cliphandles(6),'String')); ud.figs{indx}.img = min(ud.figs{indx}.img,lev); end ud.figs{indx}.validity = 0; trytodisplay(indx); set(ud.fighandles(13),'Visible','off'); end end case 'clip-cancel' set(ud.fighandles(13),'Visible','off'); % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Undo Image Edit window callbacks % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'undo-okay' indx = find(ud.fignums==ud.undo.num); if ~ud.undo.num msgbox('Nothing to Undo','Error window','error','modal'); elseif length(indx) ~= 1 msgbox('Undo is no longer possible','Error window', ... 'error','modal'); else ud.figs{indx}.img = ud.undo.img; ud.figs{indx}.validity = 0; trytodisplay(indx); ud.undo.op = ''; ud.undo.num = 0; ud.undo.img = []; end set(ud.fighandles(14),'Visible','off'); case 'undo-cancel' set(ud.fighandles(14),'Visible','off'); % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % MTF window callbacks % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'mtftype-radio' setradio(ud.mtftyperadiohandles,arg2); ud.mtf.type = arg2; switch(arg2) case 1 % Flat ioff = 1:9; ion = []; case 2 % Gaussian ioff = 4:9; ion = 1:3; case 3 % DoG ioff = 7:9; ion = 1:6; case 4 % Empirical ioff = 1:6; ion = 7:9; end for i=ion set(ud.mtfhandles(i),'Enable','on'); end for i=ioff set(ud.mtfhandles(i),'Enable','off'); end if (get(ud.mtfhandles(1),'Value')) % if square MTF (x MTF = y MTF) for i = [3 5] set(ud.mtfhandles(i),'Enable','off'); end end plotmtf; setvalidities(0); ud.mtf.imgvalid = 0; if ud.dlevel > 1 update_displays; end case 'mtfsquare' ud.mtf.square = get(ud.mtfhandles(1),'Value'); if ud.mtf.square % if square MTF for i=[2 4] set(ud.mtfhandles(i+1),'String', ... get(ud.mtfhandles(i),'String')); end ud.mtf.ysigma = ud.mtf.xsigma; ud.mtf.ysigma2 = ud.mtf.xsigma2; newval = 'off'; else newval = 'on'; end if ud.mtf.type == 2 % if Gaussian items = [3]; else % DoG items = [3 5]; end for i=items set(ud.mtfhandles(i),'Enable',newval); end plotmtf; setvalidities(0); ud.mtf.imgvalid = 0; if ud.dlevel > 1 update_displays; end case 'mtf-set-xsigma' if chknumeric(ud.mtfhandles(2),'X Sigma') ud.mtf.xsigma = mtfdtos(str2num(get(ud.mtfhandles(2),'String'))); if ud.mtf.xsigma2 >= ud.mtf.xsigma ud.mtf.xsigma2 = ud.mtf.xsigma/2; set(ud.mtfhandles(4),'String',num2str(mtfstod(ud.mtf.xsigma2),4)); end if get(ud.mtfhandles(1),'Value') % if square MTF ud.mtf.ysigma = ud.mtf.xsigma; ud.mtf.ysigma2 = ud.mtf.xsigma2; set(ud.mtfhandles(3),'String',get(ud.mtfhandles(2),'String')); set(ud.mtfhandles(5),'String',get(ud.mtfhandles(4),'String')); end plotmtf; setvalidities(0); ud.mtf.imgvalid = 0; if ud.dlevel > 1 update_displays; end else set(ud.mtfhandles(2),'String',num2str(mtfstod(ud.mtf.xsigma),4)); end case 'mtf-set-ysigma' if chknumeric(ud.mtfhandles(3),'Y Sigma') ud.mtf.ysigma = mtfdtos(str2num(get(ud.mtfhandles(3),'String'))); if ud.mtf.ysigma2 >= ud.mtf.ysigma ud.mtf.ysigma2 = ud.mtf.ysigma/2; set(ud.mtfhandles(5),'String',num2str(mtfstod(ud.mtf.ysigma2),4)); end plotmtf; setvalidities(0); ud.mtf.imgvalid = 0; if ud.dlevel > 1 update_displays; end else set(ud.mtfhandles(3),'String',num2str(mtfstod(ud.mtf.ysigma),4)); end case 'mtf-set-xsigma2' if chknumeric(ud.mtfhandles(4),'X Sigma 2') ud.mtf.xsigma2 = mtfdtos(str2num(get(ud.mtfhandles(4),'String'))); if ud.mtf.xsigma2 >= ud.mtf.xsigma ud.mtf.xsigma = 2*ud.mtf.xsigma2; set(ud.mtfhandles(2),'String',num2str(mtfstod(ud.mtf.xsigma),4)); end if get(ud.mtfhandles(1),'Value') % if square MTF ud.mtf.ysigma2 = ud.mtf.xsigma2; ud.mtf.ysigma = ud.mtf.xsigma; set(ud.mtfhandles(5),'String',get(ud.mtfhandles(4),'String')); set(ud.mtfhandles(3),'String',get(ud.mtfhandles(2),'String')); end plotmtf; setvalidities(0); ud.mtf.imgvalid = 0; if ud.dlevel > 1 update_displays; end else set(ud.mtfhandles(4),'String',num2str(mtfstod(ud.mtf.xsigma2),4)); end case 'mtf-set-ysigma2' if chknumeric(ud.mtfhandles(5),'Y Sigma 2') ud.mtf.ysigma2 = mtfdtos(str2num(get(ud.mtfhandles(5),'String'))); if ud.mtf.ysigma2 >= ud.mtf.ysigma ud.mtf.ysigma = 2*ud.mtf.ysigma2; set(ud.mtfhandles(3),'String',num2str(mtfstod(ud.mtf.ysigma),4)); end plotmtf; setvalidities(0); ud.mtf.imgvalid = 0; if ud.dlevel > 1 update_displays; end else set(ud.mtfhandles(5),'String',num2str(mtfstod(ud.mtf.ysigma2),4)); end case 'mtf-set-ratio' if chknumeric(ud.mtfhandles(6),'Peak Ratio') ud.mtf.ratio = str2num(get(ud.mtfhandles(6),'String')); if ud.mtf.ratio < 0 | ud.mtf.ratio > 1 msgbox('Peak ratio must be between 0 and 1', ... 'Error window','error','modal'); set(ud.mtfhandles(6),'String',num2str(ud.mtf.ratio,4)); end plotmtf; setvalidities(0); ud.mtf.imgvalid = 0; if ud.dlevel > 1 update_displays; end else set(ud.mtfhandles(6),'String',num2str(ud.mtf.ratio,4)); end case 'mtfunits-radio' setradio(ud.mtfunitsradiohandles,arg2); set(ud.mtfhandles(2),'String',num2str(mtfstod(ud.mtf.xsigma),4)); set(ud.mtfhandles(3),'String',num2str(mtfstod(ud.mtf.ysigma),4)); set(ud.mtfhandles(4),'String',num2str(mtfstod(ud.mtf.xsigma2),4)); set(ud.mtfhandles(5),'String',num2str(mtfstod(ud.mtf.ysigma2),4)); case 'mtf-file' if mtfreadfile plotmtf; setvalidities(0); ud.mtf.imgvalid = 0; if ud.dlevel > 1 update_displays; end end case 'mtf-browse' [file,path] = uigetfile('*.*'); if length(file)~=1 | file~=0 set(ud.mtfhandles(7),'String',path); set(ud.mtfhandles(8),'String',file); if mtfreadfile plotmtf; setvalidities(0); ud.mtf.imgvalid = 0; if ud.dlevel > 1 update_displays; end end end case 'mtf-okay' set(ud.fighandles(4),'Visible','off'); % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Input noise window callbacks % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'input-radio' setradio(ud.inputradiohandles,arg2); ud.input.type = arg2; switch(arg2) case 1 % No noise ioff = 1:6; ion = []; case 2 % Mean count ioff = 2:6; ion = 1; case 3 % Calculate ioff = 1; ion = 2:6; end for i=ion set(ud.inputhandles(i),'Enable','on'); end for i=ioff set(ud.inputhandles(i),'Enable','off'); end if arg2 == 3 % Calculated i = calcmeancount; ud.input.meancount = i; set(ud.inputhandles(1),'String',num2str(i,5)); end setvalidities(1); if ud.dlevel > 2 update_displays; end case 'input-set-count' if chknumeric(ud.inputhandles(1),'Mean pixel count') i = str2num(get(ud.inputhandles(1),'String')); if i <= 0 msgbox('Mean count must be positive', ... 'Error window','error','modal'); set(ud.inputhandles(1),'String',num2str(ud.input.meancount,5)); else ud.input.meancount = i; setvalidities(1); if ud.dlevel > 2 update_displays; end end else set(ud.inputhandles(1),'String',num2str(ud.input.meancount,5)); end case 'input-set-lum' if chknumeric(ud.inputhandles(2),'Mean luminance') i = str2num(get(ud.inputhandles(2),'String')); if i <= 0 msgbox('Mean luminance must be positive', ... 'Error window','error','modal'); set(ud.inputhandles(2),'String','.1'); i = .1; end else i = .1; set(ud.inputhandles(2),'String','.1'); end ud.input.lum = i; i = calcmeancount; ud.input.meancount = i; set(ud.inputhandles(1),'String',num2str(i,5)); setvalidities(1); if ud.dlevel > 2 update_displays; end case 'input-set-time' if chknumeric(ud.inputhandles(3),'Integration time') i = str2num(get(ud.inputhandles(3),'String')); if i <= 0 msgbox('Integration time must be positive', ... 'Error window','error','modal'); set(ud.inputhandles(3),'String','40'); i = 40; end else set(ud.inputhandles(3),'String','40'); i = 40; end ud.input.time = i; i = calcmeancount; ud.input.meancount = i; set(ud.inputhandles(1),'String',num2str(i,5)); setvalidities(1); if ud.dlevel > 2 update_displays; end case 'input-set-wl' if chknumeric(ud.inputhandles(4),'Dominant wavelength') i = str2num(get(ud.inputhandles(4),'String')); if i < 300 | i > 1400 msgbox('Dominant wavelength must be between 300 and 1400', ... 'Error window','error','modal'); set(ud.inputhandles(4),'String','580'); i = 580; end else set(ud.inputhandles(4),'String','580'); i = 580; end ud.input.wl = i; i = calcmeancount; ud.input.meancount = i; set(ud.inputhandles(1),'String',num2str(i,5)); setvalidities(1); if ud.dlevel > 2 update_displays; end case 'input-set-eff' if chknumeric(ud.inputhandles(5),'Efficiency') i = str2num(get(ud.inputhandles(5),'String')); if i <= 0 | i > 100 msgbox('Efficiency must lie between 0 and 100', ... 'Error window','error','modal'); set(ud.inputhandles(5),'String','10'); i = 10; end else set(ud.inputhandles(5),'String','10'); i = 10; end ud.input.eff = i; i = calcmeancount; ud.input.meancount = i; set(ud.inputhandles(1),'String',num2str(i,5)); setvalidities(1); if ud.dlevel > 2 update_displays; end case 'input-set-diam' if chknumeric(ud.inputhandles(6),'Pupil diameter') i = str2num(get(ud.inputhandles(6),'String')); if i <= 0 msgbox('Pupil diameter must be positive', ... 'Error window','error','modal'); set(ud.inputhandles(6),'String','6'); i = 6; end else set(ud.inputhandles(6),'String','6'); i = 6; end ud.input.diam = i; i = calcmeancount; ud.input.meancount = i; set(ud.inputhandles(1),'String',num2str(i,5)); setvalidities(1); if ud.dlevel > 2 update_displays; end case 'input-okay' set(ud.fighandles(15),'Visible','off'); % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Gamma window callbacks % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'gamma-radio' setradio(ud.gammaradiohandles,arg2); ud.gamma.enabled = arg2-1; if arg2 == 1 s = 'off'; else s = 'on'; end for i=1:8 set(ud.gammahandles(i),'Enable',s); end plotgamma; setvalidities(2); if ud.dlevel > 3 update_displays; end case 'gamma-set-liftoff' if chknumeric(ud.gammahandles(1),'Liftoff') i = str2num(get(ud.gammahandles(1),'String')); if i < 0 | i >= 1 msgbox('Liftoff must lie between 0 and 1', ... 'Error window','error','modal'); set(ud.gammahandles(1),'String',num2str(ud.gamma.liftoff,3)); else ud.gamma.liftoff = i; set(ud.gammahandles(2),'Value',i); setvalidities(2); if ud.dlevel > 3 update_displays; end end else set(ud.gammahandles(1),'String',num2str(ud.gamma.liftoff,3)); end plotgamma; case 'gamma-set-liftoffsl' ud.gamma.liftoff = get(ud.gammahandles(2),'Value'); set(ud.gammahandles(1),'String',num2str(ud.gamma.liftoff,3)); plotgamma; setvalidities(2); if ud.dlevel > 3 update_displays; end case 'gamma-set-gamma' if chknumeric(ud.gammahandles(3),'Liftoff') i = str2num(get(ud.gammahandles(3),'String')); if i < 0 | i >= 5 msgbox('Gamma must lie between 0 and 5', ... 'Error window','error','modal'); set(ud.gammahandles(3),'String',num2str(ud.gamma.gamma,3)); else ud.gamma.gamma = i; set(ud.gammahandles(4),'Value',i); setvalidities(2); if ud.dlevel > 3 update_displays; end end else set(ud.gammahandles(3),'String',num2str(ud.gamma.gamma,3)); end plotgamma; case 'gamma-set-gammasl' ud.gamma.gamma = get(ud.gammahandles(4),'Value'); set(ud.gammahandles(3),'String',num2str(ud.gamma.gamma,3)); plotgamma; setvalidities(2); if ud.dlevel > 3 update_displays; end case 'gamma-set-mincontr' if chknumeric(ud.gammahandles(5),'Minimum Contrast') i = str2num(get(ud.gammahandles(5),'String')); if i < -1 | i >= 1 msgbox('Minimum Contrast must lie between -1 and 1', ... 'Error window','error','modal'); set(ud.gammahandles(5),'String',num2str(ud.gamma.mincontrast,3)); else ud.gamma.mincontrast = i; set(ud.gammahandles(6),'Value',i); setvalidities(2); if ud.dlevel > 3 update_displays; end end else set(ud.gammahandles(5),'String',num2str(ud.gamma.mincontrast,3)); end plotgamma; case 'gamma-set-mincontrsl' ud.gamma.mincontrast = get(ud.gammahandles(6),'Value'); set(ud.gammahandles(5),'String',num2str(ud.gamma.mincontrast,3)); plotgamma; setvalidities(2); if ud.dlevel > 3 update_displays; end case 'gamma-set-maxcontr' if chknumeric(ud.gammahandles(7),'Maximum Contrast') i = str2num(get(ud.gammahandles(7),'String')); if i <= -1 | i > 1 msgbox('Maximum Contrast must lie between -1 and 1', ... 'Error window','error','modal'); set(ud.gammahandles(7),'String',num2str(ud.gamma.maxcontrast,3)); else ud.gamma.maxcontrast = i; set(ud.gammahandles(8),'Value',i); setvalidities(2); if ud.dlevel > 3 update_displays; end end else set(ud.gammahandles(7),'String',num2str(ud.gamma.maxcontrast,3)); end plotgamma; case 'gamma-set-maxcontrsl' ud.gamma.maxcontrast = get(ud.gammahandles(8),'Value'); set(ud.gammahandles(7),'String',num2str(ud.gamma.maxcontrast,3)); plotgamma; setvalidities(2); if ud.dlevel > 3 update_displays; end case 'gamma-okay' set(ud.fighandles(16),'Visible','off'); % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Output noise window callbacks % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'output-radio' setradio(ud.outputradiohandles,arg2); ud.output.noise = arg2-1; if ud.output.noise set(ud.outputhandles(1),'Enable','on'); else set(ud.outputhandles(1),'Enable','off'); end setvalidities(3); if ud.dlevel > 4 update_displays; end case 'output-set-rms' if chknumeric(ud.outputhandles(1),'RMS noise contrast') i = str2num(get(ud.outputhandles(1),'String')); if i < 0 | i > 1 msgbox('RMS noise contrast must lie between 0 and 1', ... 'Error window','error','modal'); set(ud.outputhandles(1),'String',num2str(ud.output.rms,4)); else ud.output.rms = i; setvalidities(3); ud.output.imgvalid = 0; if ud.dlevel > 4 update_displays; end end else set(ud.outputhandles(1),'String',num2str(ud.output.rms,4)); end case 'output-okay' set(ud.fighandles(17),'Visible','off'); % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Viewing Conditions window callbacks % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'vgeom-set-vdist' if chknumeric(ud.vgeomhandles(1),'Viewing distance') ud.vgeom.vdist = str2num(get(ud.vgeomhandles(1),'String')); ud.vgeom.hpixperdeg = ud.vgeom.hpixpercm*ud.vgeom.vdist * ... tan(pi/180); set(ud.vgeomhandles(2),'String',num2str(ud.vgeom.hpixperdeg,4)); ud.vgeom.vpixperdeg = ud.vgeom.vpixpercm*ud.vgeom.vdist * ... tan(pi/180); set(ud.vgeomhandles(3),'String',num2str(ud.vgeom.vpixperdeg,4)); ud.vgeom.hsizedeg = ud.vgeom.hpixel/ud.vgeom.hpixperdeg; set(ud.vgeomhandles(10),'String',num2str(ud.vgeom.hsizedeg,4)); ud.vgeom.vsizedeg = ud.vgeom.vpixel/ud.vgeom.vpixperdeg; set(ud.vgeomhandles(11),'String',num2str(ud.vgeom.vsizedeg,4)); vgeomset(h0,ud); setvalidities(0); ud.mtf.imgvalid = 0; if ud.dlevel > 1 update_displays; end end case 'vgeom-set-hpixperdeg' if chknumeric(ud.vgeomhandles(2),'Horizontal pixels/deg') ud.vgeom.hpixperdeg = str2num(get(ud.vgeomhandles(2),'String')); ud.vgeom.hpixpercm = ... ud.vgeom.hpixperdeg/(ud.vgeom.vdist*tan(pi/180)); set(ud.vgeomhandles(4),'String',num2str(ud.vgeom.hpixpercm,4)); ud.vgeom.hsizecm = ud.vgeom.hpixel/ud.vgeom.hpixpercm; set(ud.vgeomhandles(8),'String',num2str(ud.vgeom.hsizecm,4)); ud.vgeom.hsizedeg = ud.vgeom.hpixel/ud.vgeom.hpixperdeg; set(ud.vgeomhandles(10),'String',num2str(ud.vgeom.hsizedeg,4)); if (get(ud.vgeomhandles(12),'Value')) % if square pixels ud.vgeom.vpixperdeg = ud.vgeom.hpixperdeg; set(ud.vgeomhandles(3), ... 'String',num2str(ud.vgeom.vpixperdeg,4)); ud.vgeom.vpixpercm = ud.vgeom.hpixpercm; set(ud.vgeomhandles(5), ... 'String',num2str(ud.vgeom.vpixpercm,4)); ud.vgeom.vsizecm = ud.vgeom.vpixel/ud.vgeom.vpixpercm; set(ud.vgeomhandles(9), ... 'String',num2str(ud.vgeom.vsizecm,4)); ud.vgeom.vsizedeg = ud.vgeom.vpixel/ud.vgeom.vpixperdeg; set(ud.vgeomhandles(11), ... 'String',num2str(ud.vgeom.vsizedeg,4)); end vgeomset(h0,ud); setvalidities(0); ud.mtf.imgvalid = 0; if ud.dlevel > 1 update_displays; end end case 'vgeom-set-vpixperdeg' if chknumeric(ud.vgeomhandles(3),'Vertical pixels/deg') ud.vgeom.vpixperdeg = str2num(get(ud.vgeomhandles(3),'String')); ud.vgeom.vpixpercm = ... ud.vgeom.vpixperdeg/(ud.vgeom.vdist*tan(pi/180)); set(ud.vgeomhandles(5),'String',num2str(ud.vgeom.vpixpercm,4)); ud.vgeom.vsizecm = ud.vgeom.vpixel/ud.vgeom.vpixpercm; set(ud.vgeomhandles(9),'String',num2str(ud.vgeom.vsizecm,4)); ud.vgeom.vsizedeg = ud.vgeom.vpixel/ud.vgeom.vpixperdeg; set(ud.vgeomhandles(11),'String',num2str(ud.vgeom.vsizedeg,4)); if (get(ud.vgeomhandles(12),'Value')) % if square pixels ud.vgeom.hpixperdeg = ud.vgeom.vpixperdeg; set(ud.vgeomhandles(2), ... 'String',num2str(ud.vgeom.hpixperdeg,4)); ud.vgeom.hpixpercm = ud.vgeom.vpixpercm; set(ud.vgeomhandles(4), ... 'String',num2str(ud.vgeom.hpixpercm,4)); ud.vgeom.hsizecm = ud.vgeom.hpixel/ud.vgeom.hpixpercm; set(ud.vgeomhandles(8), ... 'String',num2str(ud.vgeom.hsizecm,4)); ud.vgeom.hsizedeg = ud.vgeom.hpixel/ud.vgeom.hpixperdeg; set(ud.vgeomhandles(10), ... 'String',num2str(ud.vgeom.hsizedeg,4)); end vgeomset(h0,ud); setvalidities(0); ud.mtf.imgvalid = 0; if ud.dlevel > 1 update_displays; end end case 'vgeom-set-hpixpercm' if chknumeric(ud.vgeomhandles(4),'Horizontal pixels/cm') ud.vgeom.hpixpercm = str2num(get(ud.vgeomhandles(4),'String')); ud.vgeom.hpixperdeg = ... ud.vgeom.hpixpercm*ud.vgeom.vdist*tan(pi/180); set(ud.vgeomhandles(2),'String',num2str(ud.vgeom.hpixperdeg,4)); ud.vgeom.hsizecm = ud.vgeom.hpixel/ud.vgeom.hpixpercm; set(ud.vgeomhandles(8),'String',num2str(ud.vgeom.hsizecm,4)); ud.vgeom.hsizedeg = ud.vgeom.hpixel/ud.vgeom.hpixperdeg; set(ud.vgeomhandles(10),'String',num2str(ud.vgeom.hsizedeg,4)); if (get(ud.vgeomhandles(12),'Value')) % if square pixels ud.vgeom.vpixperdeg = ud.vgeom.hpixperdeg; set(ud.vgeomhandles(3), ... 'String',num2str(ud.vgeom.vpixperdeg,4)); ud.vgeom.vpixpercm = ud.vgeom.hpixpercm; set(ud.vgeomhandles(5), ... 'String',num2str(ud.vgeom.vpixpercm,4)); ud.vgeom.vsizecm = ud.vgeom.vpixel/ud.vgeom.vpixpercm; set(ud.vgeomhandles(9), ... 'String',num2str(ud.vgeom.vsizecm,4)); ud.vgeom.vsizedeg = ud.vgeom.vpixel/ud.vgeom.vpixperdeg; set(ud.vgeomhandles(11), ... 'String',num2str(ud.vgeom.vsizedeg,4)); end vgeomset(h0,ud); end case 'vgeom-set-vpixpercm' if chknumeric(ud.vgeomhandles(5),'Vertical pixels/cm') ud.vgeom.vpixpercm = str2num(get(ud.vgeomhandles(5),'String')); ud.vgeom.vpixperdeg = ... ud.vgeom.vpixpercm*ud.vgeom.vdist*tan(pi/180); set(ud.vgeomhandles(3),'String',num2str(ud.vgeom.vpixperdeg,4)); ud.vgeom.vsizecm = ud.vgeom.vpixel/ud.vgeom.vpixpercm; set(ud.vgeomhandles(9),'String',num2str(ud.vgeom.vsizecm,4)); ud.vgeom.vsizedeg = ud.vgeom.vpixel/ud.vgeom.vpixperdeg; set(ud.vgeomhandles(11),'String',num2str(ud.vgeom.vsizedeg,4)); if (get(ud.vgeomhandles(12),'Value')) % if square pixels ud.vgeom.hpixperdeg = ud.vgeom.vpixperdeg; set(ud.vgeomhandles(2), ... 'String',num2str(ud.vgeom.hpixperdeg,4)); ud.vgeom.hpixpercm = ud.vgeom.vpixpercm; set(ud.vgeomhandles(4), ... 'String',num2str(ud.vgeom.hpixpercm,4)); ud.vgeom.hsizecm = ud.vgeom.hpixel/ud.vgeom.hpixpercm; set(ud.vgeomhandles(8), ... 'String',num2str(ud.vgeom.hsizecm,4)); ud.vgeom.hsizedeg = ud.vgeom.hpixel/ud.vgeom.hpixperdeg; set(ud.vgeomhandles(10), ... 'String',num2str(ud.vgeom.hsizedeg,4)); end vgeomset(h0,ud); setvalidities(0); ud.mtf.imgvalid = 0; if ud.dlevel > 1 update_displays; end end case 'vgeom-set-hpixel' if chknumeric(ud.vgeomhandles(6),'Number of columns') newhpixel = str2num(get(ud.vgeomhandles(6),'String')); if mod(newhpixel,2) msgbox('Number of columns must be an even number','Error window', ... 'error','modal'); else oldhpixel = ud.vgeom.hpixel; oldvpixel = ud.vgeom.vpixel; ud.vgeom.hpixel = newhpixel; ud.vgeom.hpixpercm = ud.vgeom.hpixel/ud.vgeom.hsizecm; set(ud.vgeomhandles(4),'String',num2str(ud.vgeom.hpixpercm,4)); ud.vgeom.hpixperdeg = ... ud.vgeom.hpixpercm*ud.vgeom.vdist*tan(pi/180); set(ud.vgeomhandles(2),'String',num2str(ud.vgeom.hpixperdeg,4)); ud.vgeom.hsizedeg = ud.vgeom.hpixel/ud.vgeom.hpixperdeg; set(ud.vgeomhandles(10),'String',num2str(ud.vgeom.hsizedeg,4)); if (get(ud.vgeomhandles(13),'Value')) % if square image ud.vgeom.vpixel = ud.vgeom.hpixel; set(ud.vgeomhandles(7),'String', ... num2str(ud.vgeom.vpixel,4)); ud.vgeom.vpixpercm = ud.vgeom.vpixel/ud.vgeom.vsizecm; set(ud.vgeomhandles(5),'String', ... num2str(ud.vgeom.vpixpercm,4)); ud.vgeom.vpixperdeg = ... ud.vgeom.vpixpercm*ud.vgeom.vdist*tan(pi/180); set(ud.vgeomhandles(3),'String', ... num2str(ud.vgeom.vpixperdeg,4)); ud.vgeom.vsizedeg = ud.vgeom.vpixel/ud.vgeom.vpixperdeg; set(ud.vgeomhandles(11),'String', ... num2str(ud.vgeom.vsizedeg,4)); end vgeomset(h0,ud); setvalidities(0); ud.mtf.imgvalid = 0; ud.output.imgvalid = 0; if ud.dlevel > 1 | oldhpixel ~= ud.vgeom.hpixel ... | oldvpixel ~= ud.vgeom.vpixel update_displays; end end end case 'vgeom-set-vpixel' if chknumeric(ud.vgeomhandles(7),'Number of rows') newvpixel = str2num(get(ud.vgeomhandles(7),'String')); if mod(newvpixel,2) msgbox('Number of rows must be an even number','Error window', ... 'error','modal'); else oldhpixel = ud.vgeom.hpixel; oldvpixel = ud.vgeom.vpixel; ud.vgeom.vpixel = newvpixel; ud.vgeom.vpixpercm = ud.vgeom.vpixel/ud.vgeom.vsizecm; set(ud.vgeomhandles(5),'String',num2str(ud.vgeom.vpixpercm,4)); ud.vgeom.vpixperdeg = ... ud.vgeom.vpixpercm*ud.vgeom.vdist*tan(pi/180); set(ud.vgeomhandles(3),'String',num2str(ud.vgeom.vpixperdeg,4)); ud.vgeom.vsizedeg = ud.vgeom.vpixel/ud.vgeom.vpixperdeg; set(ud.vgeomhandles(11),'String',num2str(ud.vgeom.vsizedeg,4)); if (get(ud.vgeomhandles(13),'Value')) % if square image ud.vgeom.hpixel = ud.vgeom.vpixel; set(ud.vgeomhandles(6),'String', ... num2str(ud.vgeom.hpixel,4)); ud.vgeom.hpixpercm = ud.vgeom.hpixel/ud.vgeom.hsizecm; set(ud.vgeomhandles(4),'String', ... num2str(ud.vgeom.hpixpercm,4)); ud.vgeom.hpixperdeg = ... ud.vgeom.hpixpercm*ud.vgeom.vdist*tan(pi/180); set(ud.vgeomhandles(2),'String', ... num2str(ud.vgeom.hpixperdeg,4)); ud.vgeom.hsizedeg = ud.vgeom.hpixel/ud.vgeom.hpixperdeg; set(ud.vgeomhandles(10),'String', ... num2str(ud.vgeom.hsizedeg,4)); end vgeomset(h0,ud); setvalidities(0); ud.mtf.imgvalid = 0; ud.output.imgvalid = 0; if ud.dlevel > 1 | oldhpixel ~= ud.vgeom.hpixel ... | oldvpixel ~= ud.vgeom.vpixel update_displays; end end end case 'vgeom-set-hsizecm' if chknumeric(ud.vgeomhandles(8),'Horizontal size (cm)') ud.vgeom.hsizecm = str2num(get(ud.vgeomhandles(8),'String')); ud.vgeom.hpixpercm = ud.vgeom.hpixel/ud.vgeom.hsizecm; set(ud.vgeomhandles(4),'String',num2str(ud.vgeom.hpixpercm,4)); ud.vgeom.hpixperdeg = ... ud.vgeom.hpixpercm*ud.vgeom.vdist*tan(pi/180); set(ud.vgeomhandles(2),'String',num2str(ud.vgeom.hpixperdeg,4)); ud.vgeom.hsizedeg = ud.vgeom.hpixel/ud.vgeom.hpixperdeg; set(ud.vgeomhandles(10),'String',num2str(ud.vgeom.hsizedeg,4)); if (get(ud.vgeomhandles(12),'Value')) % if square pixels ud.vgeom.vpixperdeg = ud.vgeom.hpixperdeg; set(ud.vgeomhandles(3), ... 'String',num2str(ud.vgeom.vpixperdeg,4)); ud.vgeom.vpixpercm = ud.vgeom.hpixpercm; set(ud.vgeomhandles(5), ... 'String',num2str(ud.vgeom.vpixpercm,4)); ud.vgeom.vsizecm = ud.vgeom.vpixel/ud.vgeom.vpixpercm; set(ud.vgeomhandles(9), ... 'String',num2str(ud.vgeom.vsizecm,4)); ud.vgeom.vsizedeg = ud.vgeom.vpixel/ud.vgeom.vpixperdeg; set(ud.vgeomhandles(11), ... 'String',num2str(ud.vgeom.vsizedeg,4)); end vgeomset(h0,ud); setvalidities(0); ud.mtf.imgvalid = 0; if ud.dlevel > 1 update_displays; end end case 'vgeom-set-vsizecm' if chknumeric(ud.vgeomhandles(9),'Vertical size (cm)') ud.vgeom.vsizecm = str2num(get(ud.vgeomhandles(9),'String')); ud.vgeom.vpixpercm = ud.vgeom.vpixel/ud.vgeom.vsizecm; set(ud.vgeomhandles(5),'String',num2str(ud.vgeom.vpixpercm,4)); ud.vgeom.vpixperdeg = ... ud.vgeom.vpixpercm*ud.vgeom.vdist*tan(pi/180); set(ud.vgeomhandles(3),'String',num2str(ud.vgeom.vpixperdeg,4)); ud.vgeom.vsizedeg = ud.vgeom.vpixel/ud.vgeom.vpixperdeg; set(ud.vgeomhandles(11),'String',num2str(ud.vgeom.vsizedeg,4)); if (get(ud.vgeomhandles(12),'Value')) % if square pixels ud.vgeom.hpixperdeg = ud.vgeom.vpixperdeg; set(ud.vgeomhandles(2), ... 'String',num2str(ud.vgeom.hpixperdeg,4)); ud.vgeom.hpixpercm = ud.vgeom.vpixpercm; set(ud.vgeomhandles(4), ... 'String',num2str(ud.vgeom.hpixpercm,4)); ud.vgeom.hsizecm = ud.vgeom.hpixel/ud.vgeom.hpixpercm; set(ud.vgeomhandles(8), ... 'String',num2str(ud.vgeom.hsizecm,4)); ud.vgeom.hsizedeg = ud.vgeom.hpixel/ud.vgeom.hpixperdeg; set(ud.vgeomhandles(10), ... 'String',num2str(ud.vgeom.hsizedeg,4)); end vgeomset(h0,ud); setvalidities(0); ud.mtf.imgvalid = 0; if ud.dlevel > 1 update_displays; end end case 'vgeom-set-hsizedeg' if chknumeric(ud.vgeomhandles(10),'Horizontal size (deg)') ud.vgeom.hsizedeg = str2num(get(ud.vgeomhandles(10),'String')); ud.vgeom.hpixperdeg = ud.vgeom.hpixel/ud.vgeom.hsizedeg; set(ud.vgeomhandles(2),'String',num2str(ud.vgeom.hpixperdeg,4)); ud.vgeom.hpixpercm = ... ud.vgeom.hpixperdeg/(ud.vgeom.vdist*tan(pi/180)); set(ud.vgeomhandles(4),'String',num2str(ud.vgeom.hpixpercm,4)); ud.vgeom.hsizecm = ud.vgeom.hpixel/ud.vgeom.hpixpercm; set(ud.vgeomhandles(8),'String',num2str(ud.vgeom.hsizecm,4)); if (get(ud.vgeomhandles(12),'Value')) % if square pixels ud.vgeom.vpixperdeg = ud.vgeom.hpixperdeg; set(ud.vgeomhandles(3), ... 'String',num2str(ud.vgeom.vpixperdeg,4)); ud.vgeom.vpixpercm = ud.vgeom.hpixpercm; set(ud.vgeomhandles(5), ... 'String',num2str(ud.vgeom.vpixpercm,4)); ud.vgeom.vsizecm = ud.vgeom.vpixel/ud.vgeom.vpixpercm; set(ud.vgeomhandles(9), ... 'String',num2str(ud.vgeom.vsizecm,4)); ud.vgeom.vsizedeg = ud.vgeom.vpixel/ud.vgeom.vpixperdeg; set(ud.vgeomhandles(11), ... 'String',num2str(ud.vgeom.vsizedeg,4)); end vgeomset(h0,ud); setvalidities(0); ud.mtf.imgvalid = 0; if ud.dlevel > 1 update_displays; end end case 'vgeom-set-vsizedeg' if chknumeric(ud.vgeomhandles(11),'Vertical size (deg)') ud.vgeom.vsizedeg = str2num(get(ud.vgeomhandles(11),'String')); ud.vgeom.vpixperdeg = ud.vgeom.vpixel/ud.vgeom.vsizedeg; set(ud.vgeomhandles(3),'String',num2str(ud.vgeom.vpixperdeg,4)); ud.vgeom.vpixpercm = ... ud.vgeom.vpixperdeg/(ud.vgeom.vdist*tan(pi/180)); set(ud.vgeomhandles(5),'String',num2str(ud.vgeom.vpixpercm,4)); ud.vgeom.vsizecm = ud.vgeom.vpixel/ud.vgeom.vpixpercm; set(ud.vgeomhandles(9),'String',num2str(ud.vgeom.vsizecm,4)); if (get(ud.vgeomhandles(12),'Value')) % if square pixels ud.vgeom.hpixperdeg = ud.vgeom.vpixperdeg; set(ud.vgeomhandles(2), ... 'String',num2str(ud.vgeom.hpixperdeg,4)); ud.vgeom.hpixpercm = ud.vgeom.vpixpercm; set(ud.vgeomhandles(4), ... 'String',num2str(ud.vgeom.hpixpercm,4)); ud.vgeom.hsizecm = ud.vgeom.hpixel/ud.vgeom.hpixpercm; set(ud.vgeomhandles(8), ... 'String',num2str(ud.vgeom.hsizecm,4)); ud.vgeom.hsizedeg = ud.vgeom.hpixel/ud.vgeom.hpixperdeg; set(ud.vgeomhandles(10), ... 'String',num2str(ud.vgeom.hsizedeg,4)); end vgeomset(h0,ud); setvalidities(0); ud.mtf.imgvalid = 0; if ud.dlevel > 1 update_displays; end end case 'vgeom-squarepixels' if (get(ud.vgeomhandles(12),'Value')) % if square pixels ud.vgeom.vpixperdeg = ud.vgeom.hpixperdeg; set(ud.vgeomhandles(3), ... 'String',num2str(ud.vgeom.vpixperdeg,4)); ud.vgeom.vpixpercm = ud.vgeom.hpixpercm; set(ud.vgeomhandles(5), ... 'String',num2str(ud.vgeom.vpixpercm,4)); ud.vgeom.vsizecm = ud.vgeom.vpixel/ud.vgeom.vpixpercm; set(ud.vgeomhandles(9),'String',num2str(ud.vgeom.vsizecm,4)); ud.vgeom.vsizedeg = ud.vgeom.vpixel/ud.vgeom.vpixperdeg; set(ud.vgeomhandles(11),'String',num2str(ud.vgeom.vsizedeg,4)); vgeomset(h0,ud); setvalidities(0); ud.mtf.imgvalid = 0; if ud.dlevel > 1 update_displays; end end case 'vgeom-squareimage' if (get(ud.vgeomhandles(13),'Value')) % if square image ud.vgeom.vpixel = ud.vgeom.hpixel; set(ud.vgeomhandles(7),'String',num2str(ud.vgeom.vpixel,4)); ud.vgeom.vpixpercm = ud.vgeom.vpixel/ud.vgeom.vsizecm; set(ud.vgeomhandles(5), ... 'String',num2str(ud.vgeom.vpixpercm,4)); ud.vgeom.vpixperdeg = ud.vgeom.vpixel/ud.vgeom.vsizedeg; set(ud.vgeomhandles(3), ... 'String',num2str(ud.vgeom.vpixperdeg,4)); ud.vgeom.vsizedeg = ud.vgeom.vpixel/ud.vgeom.vpixperdeg; set(ud.vgeomhandles(11),'String',num2str(ud.vgeom.vsizedeg,4)); vgeomset(h0,ud); setvalidities(0); ud.mtf.imgvalid = 0; ud.output.imgvalid = 0; if ud.dlevel > 1 update_displays; end end case 'vgeom-okay' if vgeomset(h0,ud) set(ud.fighandles(9),'Visible','off'); end % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Window deletion callbacks % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'delete-mainwin' for i = 1:length(ud.fighandles) if ud.fighandles(i) close(ud.fighandles(i)); end end case 'delete-sfum' ud.fighandles(1) = 0; case 'delete-directory' ud.fighandles(2) = 0; ud.dstringhandles = []; ud.dlradiohandles = []; ud.drradiohandles = []; ud.directoryhandles = zeros(1,2); case 'delete-savimg' ud.fighandles(3) = 0; case 'delete-mtf' ud.fighandles(4) = 0; case 'delete-agrat' ud.fighandles(5) = 0; case 'delete-agab' ud.fighandles(6) = 0; case 'delete-afile' ud.fighandles(7) = 0; case 'delete-aimg' ud.fighandles(8) = 0; case 'delete-vgeom' ud.fighandles(9) = 0; case 'delete-loadimg' ud.fighandles(10) = 0; case 'delete-newimg' ud.fighandles(11) = 0; case 'delete-scale' ud.fighandles(12) = 0; case 'delete-clip' ud.fighandles(13) = 0; case 'delete-undo' ud.fighandles(14) = 0; case 'delete-input' ud.fighandles(15) = 0; case 'delete-gamma' ud.fighandles(16) = 0; case 'delete-output' ud.fighandles(17) = 0; otherwise error(['Invalid switch case ''',command,'''!!!']) end set(h0,'userdata',ud); % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Directory subroutines % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % update_directory - update directory window and make it visible % % for this window, unlike the others, all items are positioned in units of % characters, to allow for resizing the window based on the number of % available images function update_directory global ud; if ud.fighandles(2) numfigs = length(ud.figs); [ordfigs,figindx]=sort(ud.fignums); height = 9+3*numfigs; h1 = ud.fighandles(2); set(h1,'Position',screenposn([4 12 90 height])); if ud.directoryhandles(1) set(ud.directoryhandles(1),'Position',[10 (height-4) 9 2.3]); set(ud.directoryhandles(2),'Position',[21 (height-4) 9 2.3]); else % this is a new window, initialize it ud.directoryhandles(1) = uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','characters', ... 'Position',[10 (height-4) 9 2.3], ... 'HorizontalAlignment','center', ... 'String','Left','Style','text'); ud.directoryhandles(2) = uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','characters', ... 'Position',[21 (height-4) 9 2.3], ... 'HorizontalAlignment','center', ... 'String','Right','Style','text'); uicontrol('Parent',h1, ... 'Callback','discrim(''directory-okay'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','characters', ... 'Position',[18 2 18 2.3],'String','Okay'); uicontrol('Parent',h1, ... 'Callback','discrim(''directory-cancel'')', ... 'BackgroundColor',[.7 .7 .7],'Fontsize',13,'Units','characters', ... 'Position',[54 2 18 2.3],'String','Cancel'); end if isempty(get(ud.mainhandles(3),'String')) currleft = 0; else currleft = str2num(get(ud.mainhandles(3),'String')); if length(currleft) ~= 1 currleft = 0; end end if isempty(get(ud.mainhandles(4),'String')) currright = 0; else currright = str2num(get(ud.mainhandles(4),'String')); if length(currright) ~= 1 currright = 0; end end oldnumfigs = length(ud.dlradiohandles); if (oldnumfigs > numfigs) for i = numfigs+1:oldnumfigs delete(ud.dlradiohandles(i)); delete(ud.drradiohandles(i)); delete(ud.dstringhandles(i)); end end ud.dlradiohandles(oldnumfigs+1:numfigs) = 0; ud.drradiohandles(oldnumfigs+1:numfigs) = 0; ud.dstringhandles(oldnumfigs+1:numfigs) = 0; for i = 1:numfigs if ud.dlradiohandles(i) set(ud.dlradiohandles(i), ... 'Position',[12 (height-4-i*3) 5 2.3], ... 'Value',ud.fignums(figindx(i))==currleft, ... 'Callback', ... ['discrim(''directory-radiol'',',num2str(i),')']); set(ud.drradiohandles(i), ... 'Position',[23 (height-4-i*3) 5 2.3], ... 'Value',ud.fignums(figindx(i))==currright, ... 'Callback', ... ['discrim(''directory-radior'',',num2str(i),')']); [m,n] = size(ud.figs{figindx(i)}.img); set(ud.dstringhandles(i), ... 'Position',[30 (height-4-i*3) 50 2.3], ... 'String', ... [num2str(ordfigs(i)),' ',fmtsize(m,n),': ', ... ud.figs{figindx(i)}.name]); else ud.dlradiohandles(i) = uicontrol('Parent',h1, ... 'Units','characters','Position',[12 (height-4-i*3) 5 2.3], ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio', ... 'Value',ud.fignums(figindx(i))==currleft, ... 'Callback', ... ['discrim(''directory-radiol'',',num2str(i),')']); ud.drradiohandles(i) = uicontrol('Parent',h1, ... 'Units','characters','Position',[23 (height-4-i*3) 5 2.3], ... 'BackgroundColor',[.8 .8 .8], ... 'Style','radio', ... 'Value',ud.fignums(figindx(i))==currright, ... 'Callback', ... ['discrim(''directory-radior'',',num2str(i),')']); [m,n] = size(ud.figs{figindx(i)}.img); ud.dstringhandles(i) = uicontrol('Parent',h1, ... 'BackgroundColor',[.8 .8 .8],'Fontsize',13,'Units','characters', ... 'Position',[30 (height-4-i*3) 50 2.3], ... 'String', ... [num2str(ordfigs(i)),' ',fmtsize(m,n),': ', ... ud.figs{figindx(i)}.name], ... 'HorizontalAlignment','left','Style','text'); end end set(h1,'Visible','on'); end % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % MTF subroutines % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % mtfdtos: convert from displayed units to stored units % function sval = mtfdtos(dval) global ud; if get(ud.mtfunitsradiohandles(1),'Value') % cycles/degree sval = dval; elseif get(ud.mtfunitsradiohandles(2),'Value') % cycles/cm sval = dval*ud.vgeom.hpixperdeg/ud.vgeom.hpixpercm; elseif get(ud.mtfunitsradiohandles(3),'Value') % cycles/image width sval = dval/ud.vgeom.hsizedeg; elseif get(ud.mtfunitsradiohandles(4),'Value') % degrees sval = 1/(dval*sqrt(2*pi)); elseif get(ud.mtfunitsradiohandles(5),'Value') % cm xdeg = dval*ud.vgeom.hpixpercm/ud.vgeom.hpixperdeg; sval = 1/(xdeg*sqrt(2*pi)); else % image widths xdeg = dval*ud.vgeom.hsizedeg; sval = 1/(xdeg*sqrt(2*pi)); end % % mtfstod: convert from stored units to displayed units % function dval = mtfstod(sval) global ud; if get(ud.mtfunitsradiohandles(1),'Value') % cycles/degree dval = sval; elseif get(ud.mtfunitsradiohandles(2),'Value') % cycles/cm dval = sval*ud.vgeom.hpixpercm/ud.vgeom.hpixperdeg; elseif get(ud.mtfunitsradiohandles(3),'Value') % cycles/image width dval = sval*ud.vgeom.hsizedeg; elseif get(ud.mtfunitsradiohandles(4),'Value') % degrees dval = 1/(sval*sqrt(2*pi)); elseif get(ud.mtfunitsradiohandles(5),'Value') % cm xcm = sval*ud.vgeom.hpixpercm/ud.vgeom.hpixperdeg; dval = 1/(xcm*sqrt(2*pi)); else % image widths ximw = sval*ud.vgeom.hsizedeg; dval = 1/(ximw*sqrt(2*pi)); end % % mtfreadfile: Attempt to read an MTF file % % All x values in the file are in cycles/degree. If there are two columns % of data, the MTF is treated as square. Otherwise the 2nd column is % treated as horizontal and the 3rd as vertical modulation transfer % function rcode = mtfreadfile global ud; errflag = 0; [fid msg] = fopen([get(ud.mtfhandles(7),'String') get(ud.mtfhandles(8),'String')]); if fid == -1 errflag = 1; errmsg = {'Can''t open file' ['System message: ' msg]}; else iline = fgetl(fid); if iline == -1 errflag = 1; errmsg = 'End of file on first line!'; else [data numperline msg] = sscanf(iline,'%f',3); if size(msg) errflag = 1; errmsg = {'Error interpreting first line' ... ['Input line: ' iline] ['System message: ' msg]}; elseif numperline < 2 errflag = 1; errmsg = {'Too few data on first line' ... ['Input line: ' iline]}; else iline = fgetl(fid); while iline ~= -1 [newdata newnum msg] = sscanf(iline,'%f',numperline); if size(msg) errflag = 1; errmsg = {['Error interpreting line ' num2str(size(data,2)+1)] ... ['Input line: ' iline] ['System message: ' msg]}; break; elseif newnum ~= numperline errflag = 1; errmsg = {['Too few data on line ' num2str(size(data,2)+1)] ... ['Input line: ' iline]}; break; end data = [data newdata]; iline = fgetl(fid); end end end end if fid ~= -1 fclose(fid); end if ~errflag if size(data,2) < 2 errflag = 1; errmsg = 'Input had only one line'; elseif min(min(data(2:size(data,1),:))) < 0 errflag = 1; errmsg = 'Some modulation transfer values were negative'; else v = data(1,:); n = size(data,2); if sum(v(1:n-1) > v(2:n)) > 0 errflag = 1; errmsg = 'Data are not sorted by spatial frequency'; end end end if errflag msgbox(errmsg,'Error window','error','modal'); rcode = 0; else rcode = 1; ud.mtf.mtfarray = data'; end % % mtfconvandplot: re-store the displayed MTF geometry values and re-plot % % called whenever viewing geometry is changed and the MTF window exists. % Note: If you save MTF values using any units other than cpd, then kill % the MTF window, then change viewing geometry, the MTF values in cpd will % NOT change. % function mtfconvandplot global ud; if chknum(ud.mtfhandles(2)) ud.mtf.xsigma = mtfdtos(str2num(get(ud.mtfhandles(2),'String'))); end if chknum(ud.mtfhandles(3)) ud.mtf.ysigma = mtfdtos(str2num(get(ud.mtfhandles(3),'String'))); end if chknum(ud.mtfhandles(4)) ud.mtf.xsigma2 = mtfdtos(str2num(get(ud.mtfhandles(4),'String'))); end if chknum(ud.mtfhandles(5)) ud.mtf.ysigma2 = mtfdtos(str2num(get(ud.mtfhandles(5),'String'))); end plotmtf; % % plotmtf: Plot the MTF in the MTF window % function plotmtf global ud; x = logspace(log10(.1),log10(60),100); y = calcmtf(x); axes(ud.mtfhandles(10)); loglog(x,y(1,:),'b',x,y(2,:),'g'); set(gca,'XLim',[.1 60],'YLim',[.0001 2],'XTickLabel', ... [.1 1 10],'YTickLabel',[.0001 .001 .01 .1 1]); if (sum(sum(y(1,:) ~= y(2,:)))) xlabel('Spatial Frequency (blue=x, green=y)'); else xlabel('Spatial Frequency'); end ylabel('Modulation Transfer'); % % calcmtf: Calculate the MTF values % function mtfvals = calcmtf(x) global ud; mtfvals = [calcmtfx(x) ; calcmtfy(x)]; % % calcmtfx: Calculate horizontal MTF values % function mtfvals = calcmtfx(x) global ud; switch(ud.mtf.type) case 1 % Flat mtfvals = ones(1,size(x,2)); case 2 % Gaussian mtfvals = exp(-.5*(x/ud.mtf.xsigma).^2); case 3 % DoG mtfvals = exp(-.5*(x/ud.mtf.xsigma).^2) - ... ud.mtf.ratio*exp(-.5*(x/ud.mtf.xsigma2).^2); mtfvals = mtfvals/max(max(mtfvals)); case 4 % Empirical mtfvals = interp1(ud.mtf.mtfarray(:,1),ud.mtf.mtfarray(:,2), ... x,'spline'); end % % calcmtfy: Calculate vertical MTF values % function mtfvals = calcmtfy(x) global ud; switch(ud.mtf.type) case 1 % Flat mtfvals = ones(1,size(x,2)); case 2 % Gaussian mtfvals = exp(-.5*(x/ud.mtf.ysigma).^2); case 3 % DoG mtfvals = exp(-.5*(x/ud.mtf.ysigma).^2) - ... ud.mtf.ratio*exp(-.5*(x/ud.mtf.ysigma2).^2); mtfvals = mtfvals/max(max(mtfvals)); case 4 % Empirical if (size(ud.mtf.mtfarray,2) == 2) mtfvals = interp1(ud.mtf.mtfarray(:,1),ud.mtf.mtfarray(:,2), ... x,'spline'); else mtfvals = interp1(ud.mtf.mtfarray(:,1),ud.mtf.mtfarray(:,3), ... x,'spline'); end end % % calcmtfimage - calculate the MTF image used to multiply the transform of % the scene image % function calcmtfimage global ud; xposns = 1:ud.vgeom.hpixel; xposns = min(xposns-1,ud.vgeom.hpixel+1-xposns)/ud.vgeom.hsizedeg; yposns = 1:ud.vgeom.vpixel; yposns = min(yposns-1,ud.vgeom.vpixel+1-yposns)/ud.vgeom.vsizedeg; if ud.mtf.type == 3 % if DoG, then it's not really separable xvals1 = exp(-.5*(xposns/ud.mtf.xsigma).^2); xvals2 = exp(-.5*(xposns/ud.mtf.xsigma2).^2); yvals1 = exp(-.5*(yposns/ud.mtf.ysigma).^2); yvals2 = exp(-.5*(yposns/ud.mtf.ysigma2).^2); ud.mtf.mtfimg = (xvals1' * yvals1) - ud.mtf.ratio*(xvals2' * yvals2); ud.mtf.mtfimg = ud.mtf.mtfimg/max(max(ud.mtf.mtfimg)); else xvals = calcmtfx(xposns); yvals = calcmtfy(yposns); ud.mtf.mtfimg = xvals' * yvals; end ud.mtf.imgvalid = 1; % % calcblurimage - apply the MTF to an image % % note: if the raw image size is different from the display size % (hpixel/vpixel), then we need to extract the appropriate subimage and/or % embed the image in zeros % function calcblurimage(idx) global ud; if ud.figs{idx}.validity < 1 ud.figs{idx}.blurimg = resizeimage(ud.figs{idx}); if ud.mtf.type ~= 1 if ~ud.mtf.imgvalid calcmtfimage; end ud.figs{idx}.blurimg = ... real(ifft2(ud.mtf.mtfimg .* fft2(ud.figs{idx}.blurimg))); end ud.figs{idx}.validity = 1; end % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Input noise subroutines % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % calcmeancount: Calculate the mean photon count % function photoncnt = calcmeancount global ud; vlam = interp1(ud.vlambda(:,1),ud.vlambda(:,2),ud.input.wl); pixarea = 1/(ud.vgeom.hpixperdeg*ud.vgeom.vpixperdeg); photoncnt = ud.input.lum * pi * (ud.input.diam/2)^2 * ud.input.wl ... * pixarea * ud.input.time * ud.input.eff/(vlam*44.54); % % poissonnoise: Add Poisson noise to an image % % The input image is in expected photon counts % function pnoiseimg = poissonnoise(img) sz = size(img); img = img(:); oimg = zeros(size(img)); idx1=find(img<50); % Numerical Recipes rejection method for small counts if (~isempty(idx1)) timg=exp(-img(idx1)); em=-ones(size(timg)); t=ones(size(timg)); idx2=[1:length(idx1)]'; while ~isempty(idx2) em(idx2)=em(idx2)+1; % increment photon counts t(idx2)=t(idx2).*rand(size(idx2)); idx2=idx2(find(t(idx2)>timg(idx2))); end oimg(idx1)=em; % store counts end idx1=find(img>=50); % rounded Gaussian noise for large counts if (~isempty(idx1)) oimg(idx1)=round(img(idx1)+sqrt(img(idx1)).*randn(size(idx1))); end pnoiseimg = reshape(oimg,sz); % % calcpoissonimage: Apply current Poisson noise to a figure % % The input image is a contrast image, and the returned image is converted % back to contrast values, i.e., 0 = mean luminance. The values of % ud.input.type and ud.input.meancount are used to determine the amount of % noise % function calcpoissonimage(idx) global ud; if ud.figs{idx}.validity < 2 if ud.input.type == 1 % no Poisson noise, so do nothing ud.figs{idx}.poissonimg = ud.figs{idx}.blurimg; else % Poisson noise: rescale to counts, add noise % then scale back to contrast ud.figs{idx}.poissonimg = -1 + ... (poissonnoise(ud.input.meancount*(1 + ... ud.figs{idx}.blurimg))/ud.input.meancount); end ud.figs{idx}.validity = 2; end % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Gamma subroutines % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % plotgamma: Plot the gamma curve % function plotgamma global ud; x = 0:.01:1; if ud.gamma.enabled liftoff = ud.gamma.liftoff; gamma = ud.gamma.gamma; minc = ud.gamma.mincontrast; maxc = ud.gamma.maxcontrast; y = minc + (maxc-minc)*(max(x-liftoff,0).^gamma)/((1-liftoff)^gamma); else y = 2*x-1; end axes(ud.gammahandles(9)); plot(x,y); set(gca,'XLim',[0 1],'YLim',[-1 1]); xlabel('Input Level'); ylabel('Output Contrast'); % % calcgammaimage: Apply current gamma curve to a figure % % The input image is a contrast image, and the returned image is converted % back to contrast values % function calcgammaimage(idx) global ud; if ud.figs{idx}.validity < 3 ud.figs{idx}.gammaimg = gammaimage(ud.figs{idx}.poissonimg); ud.figs{idx}.validity = 3; end % % gammaimage: Apply current gamma curve to an image % % The input image is a contrast image, and the returned image is converted % back to contrast values % function oimg = gammaimage(img) global ud; if ~ud.gamma.enabled % no gamma curve, so do nothing oimg = img; else liftoff = ud.gamma.liftoff; gamma = ud.gamma.gamma; minc = ud.gamma.mincontrast; maxc = ud.gamma.maxcontrast; oimg = (1 + img)/2; oimg = minc + (maxc-minc)*(max(oimg-liftoff,0).^gamma)/((1-liftoff)^gamma); end % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Output noise subroutines % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % calcnoiseimage: Apply current output noise to a figure % function calcnoiseimage(idx) global ud; if ud.figs{idx}.validity < 4 ud.figs{idx}.noiseimg = noiseimage(ud.figs{idx}.gammaimg); ud.figs{idx}.validity = 4; end % % noiseimage: Apply current output noise to an image % function oimg = noiseimage(img) global ud; if ~ud.output.noise % no output noise, so do nothing oimg = img; else if ~ud.output.imgvalid ud.output.noiseimg = ud.output.rms*randn(size(img)); ud.output.imgvalid = 1; end oimg = img + ud.output.noiseimg; end % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Dprime calculation subroutines % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % calcsfum: Calculate the Single Filter Model with Uniform Masking % function dprime = calcsfum(img1,img2) global ud; rowpixperdeg = ud.vgeom.vpixperdeg; colpixperdeg = ud.vgeom.hpixperdeg; % % Contrast sensitivity function with unity peak gain. % The Difference of Gaussians filter with unity peak gain has three parameters: % i) the center spread in minutes of arc centerspread = ud.params.simple.ctrspr; % or the frequency cutoff in cycles per degree freqcutcpd = 60 /(sqrt(pi) * centerspread); % ii) the ratio of surround spread to center spread spreadratio = ud.params.simple.sprdratio; % iii) the ratio of surround DC amplitude to center DC amplitude ampratio = ud.params.simple.ampratio; % These parameter values are a DOG fit to Barten's contrast sensitivity % function for a luminance of 50 cd/m^2 % c) image size rows = ud.vgeom.vpixel; cols = ud.vgeom.hpixel; % Using the image size and resolution parameters, the frequency cut in % cycles per degree is converted to row and column frequency cut offs in % cycles per image. rowfreqcut = rows * freqcutcpd / rowpixperdeg ; colfreqcut = cols * freqcutcpd / colpixperdeg ; % The unscaled contrast sensitivity filter is csf = filtdog(rows,cols,rowfreqcut,colfreqcut,ampratio,spreadratio); % The unity peak gain contrast sensitivity filter is csf = csf/max(max(csf)) ; % 3) Example computation of model output % Viewing parameters are required in the model because the contrast % sensitivity parameter is set to make d'=1 for a signal that is one % degree on a side and a contrast after filtering that is constant at % 1/consensmax. consensmax=ud.params.simple.consensmax; maskconthresh=ud.params.simple.maskconthresh; beta=ud.params.simple.beta; % just noticeable differences between images dprime = filtmask(img1,img2,rowpixperdeg,colpixperdeg,csf,consensmax, ... maskconthresh,beta); % % filtmask, the model subroutine % function dprime = filtmask( image1,image2,rowpixperdeg,colpixperdeg,csf, ... consensmax,maskconthresh,beta) % list of local variables: % meanlum, con1, con2, fcon1, fcon2, dprime0, dprime % input images are already contrast images %meanlum = mean(mean(image1)); %con1 = image1/meanlum - 1; %con2 = image2/meanlum - 1; % filtered contrast images fcon1 = real(ifft2(fft2(image1).*csf)); fcon2 = real(ifft2(fft2(image2).*csf)); % d' without masking dprime0 =consensmax * (sum(sum(abs(fcon1-fcon2).^beta)) / ... (rowpixperdeg*colpixperdeg))^(1/beta); % background RMS contrast maskcontrast = sqrt(mean(mean(fcon1.*fcon1))); % value returned by the subroutine dprime = dprime0/sqrt(1 + (maskcontrast/maskconthresh)^2); % % filtdog: Difference of Gaussians filter % % r,c: # of rows and columns % rf,cf: row and column high frequency cutoffs % sr (spread ratio): wide spatial spread / narrow one % ar (amplitude ratio): surround DC level / center DC level function result = filtdog(r,c,rf,cf,ar,sr) result=filtgaus(r,c,rf,cf)-ar*filtgaus(r,c,rf/sr,cf/sr) ; % % filtgaus: 2D Gaussian filter (outer product of two 1D Gaussians) % function result = filtgaus(r, c, rf, cf) result=fltgaus1(r,rf)'*fltgaus1(c,cf); % % fltgaus1: generate a 1D Gaussian low pass filter % % n: spatial image length (must be even) % f: 1/e frequency cutoff in cycles per image function result = fltgaus1( n, f) result = [[0:n/2] [1:n/2-1]-n/2]; result = exp(-(result.*result)/(f*f)) ; % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Utility subroutines % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % setradio - common set-radio-button routine % function setradio(radiobuttons,i) if get(radiobuttons(i),'Value') == 1 l = length(radiobuttons); others = [1:(i-1),(i+1):l]; if length(others) set(radiobuttons(others),'Value',0); end else set(radiobuttons(i),'Value',1); end % % setvalidities - downgrade all image validities % function setvalidities(maxvalidity) global ud; for i = 1:length(ud.figs); idx = ud.fignums(i); ud.figs{idx}.validity = min(ud.figs{idx}.validity,maxvalidity); end % % posnspec = screenposn(iposnspec) - make sure window fits on display % monitor screen % function posnspec = screenposn(iposnspec) global ud; posnspec = iposnspec; if ud.screenheight < iposnspec(2)+iposnspec(4)+2; % leave slop for window bar posnspec(2) = ud.screenheight - iposnspec(4) - 2; if posnspec(2) < 0 posnspec(2) = 0; posnspec(4) = ud.screenheight - 2; end end if ud.screenwidth < iposnspec(1)+iposnspec(3); posnspec(1) = ud.screenwidth - iposnspec(3); if posnspec(1) < 0 posnspec(1) = 0; posnspec(3) = ud.screenheight; end end % % img = resizeimage(fig) - convert raw image to the display size % % resizeimage extract a subimage of the input figure's raw image if it % is larger than the display size, and embeds it in zeros if it is too small % function oimg = resizeimage(fig) global ud; rows = ud.vgeom.vpixel; hrow = fix(rows/2); cols = ud.vgeom.hpixel; hcol = fix(cols/2); [irow,icol] = size(fig.img); hirow = fix(irow/2); hicol = fix(icol/2); if irow>=rows & icol>=cols oimg(:,:) = fig.img( ... hirow - hrow + 1: ... hirow - hrow + rows, ... hicol - hcol + 1: ... hicol - hcol + cols); else oimg = zeros(rows,cols); if irow>=rows firow = hirow - hrow + 1; lirow = hirow - hrow + rows; forow = 1; lorow = rows; else firow = 1; lirow = irow; forow = hrow - hirow + 1; lorow = hrow - hicol + irow; end if icol>=cols ficol = hicol - hcol + 1; licol = hicol - hcol + cols; focol = 1; locol = cols; else ficol = 1; licol = icol; focol = hcol - hicol + 1; locol = hcol - hicol + icol; end oimg(forow:lorow,focol:locol) = fig.img(firow:lirow,ficol:licol); end % % fmtsize: format a string describing an image size % function s=fmtsize(m,n) s=['[',num2str(m),'x',num2str(n),']']; % % sfumset: copy sfum window data to the userdata % function rcode = sfumset(h,ud) rcode = 0; if chknumeric(ud.sfumhandles(1),'Center spread') ud.params.simple.ctrspr = str2num(get(ud.sfumhandles(1),'String')); else return; end if chknumeric(ud.sfumhandles(2),'Frequency cut') ud.params.simple.freqcut = str2num(get(ud.sfumhandles(2),'String')); else return; end if chknumeric(ud.sfumhandles(3),'Spread ratio') ud.params.simple.sprdratio = str2num(get(ud.sfumhandles(3),'String')); else return; end if chknumeric(ud.sfumhandles(4),'Amplitude ratio') ud.params.simple.ampratio = str2num(get(ud.sfumhandles(4),'String')); else return; end if chknumeric(ud.sfumhandles(5),'Contrast sensitivity maximum') ud.params.simple.consensmax = str2num(get(ud.sfumhandles(5),'String')); else return; end if chknumeric(ud.sfumhandles(6),'Mask contrast threshold') ud.params.simple.maskconthresh = str2num(get(ud.sfumhandles(6), ... 'String')); else return; end if chknumeric(ud.sfumhandles(7),'Beta') ud.params.simple.beta = str2num(get(ud.sfumhandles(7),'String')); else return; end rcode = 1; % % vgeomset: copy vgeom window data to the userdata % function rcode = vgeomset(h,ud) rcode = 1; if chknumeric(ud.vgeomhandles(1),'Viewing distance') ud.vgeom.vdist = str2num(get(ud.vgeomhandles(1),'String')); else rcode=0; end if chknumeric(ud.vgeomhandles(2),'Horizontal pixels/deg') ud.vgeom.hpixperdeg = str2num(get(ud.vgeomhandles(2),'String')); else rcode=0; end if chknumeric(ud.vgeomhandles(3),'Vertical pixels/deg') ud.vgeom.vpixperdeg = str2num(get(ud.vgeomhandles(3),'String')); else rcode=0; end if chknumeric(ud.vgeomhandles(4),'Horizontal pixels/cm') ud.vgeom.hpixpercm = str2num(get(ud.vgeomhandles(4),'String')); else rcode=0; end if chknumeric(ud.vgeomhandles(5),'Vertical pixels/cm') ud.vgeom.vpixpercm = str2num(get(ud.vgeomhandles(5),'String')); else rcode=0; end if chknumeric(ud.vgeomhandles(6),'Number of columns') newhpixel = str2num(get(ud.vgeomhandles(6),'String')); if mod(newhpixel,2) msgbox('Number of rows must be an even number','Error window', ... 'error','modal'); rcode=0; else ud.vgeom.hpixel = newhpixel; end else rcode=0; end if chknumeric(ud.vgeomhandles(7),'Number of rows') newvpixel = str2num(get(ud.vgeomhandles(7),'String')); if mod(newvpixel,2) msgbox('Number of columns must be an even number','Error window', ... 'error','modal'); rcode=0; else ud.vgeom.vpixel = newvpixel; end else rcode=0; end if chknumeric(ud.vgeomhandles(8),'Horizontal size (cm)') ud.vgeom.hsizecm = str2num(get(ud.vgeomhandles(8),'String')); else rcode=0; end if chknumeric(ud.vgeomhandles(9),'Vertical size (cm)') ud.vgeom.vsizecm = str2num(get(ud.vgeomhandles(9),'String')); else rcode=0; end if chknumeric(ud.vgeomhandles(10),'Horizontal size (deg)') ud.vgeom.hsizedeg = str2num(get(ud.vgeomhandles(10),'String')); else rcode=0; end if chknumeric(ud.vgeomhandles(11),'Vertical size (deg)') ud.vgeom.vsizedeg = str2num(get(ud.vgeomhandles(11),'String')); else rcode=0; end if ud.fighandles(4) mtfconvandplot; end % % chknumeric: check that a string is a legal number, warn if not % function rcode = chknumeric(h,name) n = str2num(get(h,'String')); if length(n) == 1 & imag(n) == 0 rcode = 1; else msgbox([name ' is not a number'],'Error window','error', ... 'modal'); rcode = 0; end % % chknum: check that a string is a legal number, no warning window % function rcode = chknum(h,name) n = str2num(get(h,'String')); if length(n) == 1 & imag(n) == 0 rcode = 1; else rcode = 0; end % % chkposint: check that a string is a positive integer, warn if not % function rcode = chkposint(h,name) n = str2num(get(h,'String')); if length(n) == 1 & n>0 & fix(n)==n & imag(n) == 0 rcode = 1; else msgbox([name ' is not a positive integer'],'Error window','error', ... 'modal'); rcode = 0; end % % chkposint2: check that a string is a positive integer, no warning window % function rcode = chkposint2(h,name) n = str2num(get(h,'String')); if length(n) == 1 & n>0 & fix(n)==n & imag(n) == 0 rcode = 1; else rcode = 0; end % % chkint: check that a string is an integer, warn if not % function rcode = chkint(h,name) n = str2num(get(h,'String')); if length(n) == 1 & fix(n)==n & imag(n) == 0 rcode = 1; else msgbox([name ' is not an integer'],'Error window','error', ... 'modal'); rcode = 0; end % % selectleft: set left image current % function selectleft global ud; ud.currentside = 1; set(ud.mainhandles(1),'Color',[.7 0 .7]); set(ud.mainhandles(2),'Color',[.7 .7 .7]); % % selectright: set right image current % function selectright global ud; ud.currentside = 2; set(ud.mainhandles(1),'Color',[.7 .7 .7]); set(ud.mainhandles(2),'Color',[.7 0 .7]); % % chkcurrimdef: check if currentside has an image, complain if not % function rcode = chkcurrimdef global ud; if (ud.currentside == 1 & isempty(get(ud.mainhandles(3),'String'))) | ... (ud.currentside == 2 & isempty(get(ud.mainhandles(4),'String'))) msgbox('Current image is undefined','Error window','error','modal'); rcode = 0; else if ud.currentside == 1 num = str2num(get(ud.mainhandles(3),'String')); else num = str2num(get(ud.mainhandles(4),'String')); end if isempty(ud.fignums) rcode = []; else rcode = find(ud.fignums==num); end if length(rcode) ~= 1 rcode = 0; msgbox('Figure number not found!!!???','Error window', ... 'error','modal'); end end % % getimgindx: get image index % function indx = getimgindx(side) global ud; if (side == 1 & isempty(get(ud.mainhandles(3),'String'))) | ... (side == 2 & isempty(get(ud.mainhandles(4),'String'))) indx = 0; else if side == 1 num = str2num(get(ud.mainhandles(3),'String')); else num = str2num(get(ud.mainhandles(4),'String')); end if isempty(ud.fignums) indx = []; else indx = find(ud.fignums==num); end if length(indx) ~= 1 error('Figure number not found!!!???'); end end % % trytodisplay: try to display image on main window and set to current % function trytodisplay(indx) global ud; num = ud.fignums(indx); if strcmp(get(ud.mainhandles(3),'String'),num2str(num)) showimg(1,indx); if strcmp(get(ud.mainhandles(4),'String'),num2str(num)) showimg(2,indx); end selectleft; elseif strcmp(get(ud.mainhandles(4),'String'),num2str(num)) showimg(2,indx); selectright; elseif ud.currentside == 1 & isempty(get(ud.mainhandles(3),'String')) showimg(1,indx); set(ud.mainhandles(3),'String',num2str(num)); set(ud.mainhandles(8),'String',ud.figs{indx}.name); [m,n] = size(ud.figs{indx}.img); set(ud.mainhandles(10),'String',fmtsize(m,n)); elseif ud.currentside == 2 & isempty(get(ud.mainhandles(4),'String')) showimg(2,indx); set(ud.mainhandles(4),'String',num2str(num)); set(ud.mainhandles(9),'String',ud.figs{indx}.name); [m,n] = size(ud.figs{indx}.img); set(ud.mainhandles(11),'String',fmtsize(m,n)); elseif isempty(get(ud.mainhandles(3),'String')) showimg(1,indx); set(ud.mainhandles(3),'String',num2str(num)); set(ud.mainhandles(8),'String',ud.figs{indx}.name); [m,n] = size(ud.figs{indx}.img); set(ud.mainhandles(10),'String',fmtsize(m,n)); selectleft; elseif isempty(get(ud.mainhandles(4),'String')) showimg(2,indx); set(ud.mainhandles(4),'String',num2str(num)); set(ud.mainhandles(9),'String',ud.figs{indx}.name); [m,n] = size(ud.figs{indx}.img); set(ud.mainhandles(11),'String',fmtsize(m,n)); selectright; end update_directory; % % updatecurdisplay: update the displayed image in the current image and, % if both are identical, in the other as well % function updatecurdisplay global ud; if ud.currentside == 1 indx = getimgindx(1); if indx showimg(1,indx) if indx == getimgindx(2) showimg(2,indx) end end else indx = getimgindx(2); if indx showimg(2,indx) if indx == getimgindx(1) showimg(1,indx) end end end % % update_displays: update both displayed images % function update_displays global ud; indx = getimgindx(1); if indx showimg(1,indx) end indx = getimgindx(2); if indx showimg(2,indx) end % % showimg: display an image in the main window % function showimg(w,idx) % w = 1 (left window) or 2 (right window) % idx is the index of the new array to display there global ud; if ~(w == 1 | w == 2) error('showimg: bad window number') end if ud.dlevel > 1 % apply blur, Poisson noise, gamma and output noise if % necessary calcblurimage(idx); end if ud.dlevel > 2 calcpoissonimage(idx); end if ud.dlevel > 3 calcgammaimage(idx); end if ud.dlevel > 4 calcnoiseimage(idx); end switch(ud.dlevel) % pick out the image to display case 1 displayimg = ud.figs{idx}.img; case 2 displayimg = ud.figs{idx}.blurimg; case 3 displayimg = ud.figs{idx}.poissonimg; case 4 displayimg = ud.figs{idx}.gammaimg; case 5 displayimg = ud.figs{idx}.noiseimg; end h = ud.mainhandles(5+w); [nrow,ncol] = size(displayimg); maxdim = max(ud.vgeom.vpixel,ud.vgeom.hpixel); frow = 1; lrow = nrow; rowmarg = .05; fcol = 1; lcol = ncol; colmarg = .05; if nrow > maxdim frow = 1+fix((nrow-maxdim)/2); lrow = frow+maxdim-1; else rowmarg = .5 - .45*nrow/maxdim; end if ncol > maxdim fcol = 1+fix((ncol-maxdim)/2); lcol = fcol+maxdim-1; else colmarg = .5 - .45*ncol/maxdim; end set(h,'Cdata',displayimg(frow:lrow,fcol:lcol), ... 'XData',calcxydata(colmarg,lcol-fcol+1), ... 'YData',calcxydata(rowmarg,lrow-frow+1)); minc = -1; maxc = 1; if ud.dctrl ~= 1 % if something other than "As Is" minpix = min(min(displayimg(frow:lrow,fcol:lcol))); maxpix = max(max(displayimg(frow:lrow,fcol:lcol))); if minpix ~= maxpix if ud.dctrl == 2 % if "Stretch" maxabs = max(abs(minpix),abs(maxpix)); minc = -maxabs; maxc = maxabs; else % "Full Range" minc = minpix; maxc = maxpix; end end end set(ud.mainhandles(w),'Clim',[minc maxc]); % % calcxydata: calculate image xdata/ydata to yield appropriate margins % function data = calcxydata(marg,num) x = marg+(1-2*marg)/(2*num) ; data = [ x 1-x ];