% FIG2DIP Retrieve DIP images from figures via handles or indices % % DIP = FIG2DIP(FIGH) % % INPUT % FIGH vector with figure handles or figure indices % % OUTPUT % DIP DIP image % % DESCRIPTION % Retrieves 2D DIP images via figure handles or indices. If a vector of % handles (indices) is given, the function returns a multi-band image. % Copyright: Pavel Paclik, pavel@ph.tn.tudelft.nl % Faculty of Applied Physics, Delft University of Technology % P.O. Box 5046, 2600 GA Delft, The Netherlands % $Id: fig2dip.m,v 1.5 2005/11/02 14:29:17 pavel Exp $ function dip=fig2dip(figh) if ~all(ishandle(figh)) if all(round(figh)==figh) % assuming these are figure numbers % construct the vector with figure handles t=[]; for i=1:length(figh) t=[t figure(i)]; end figh=t; else error(['if number are supplied, these must be' ... ' integers (figure numbers)']); end end dip=get_one_dip(figh(1)); if length(figh)>1 t=dip; dip=dip_image(zeros(size(t,2),size(t,1),length(figh))); dip(:,:,0)=t; clear t; for i=2:length(figh) dip(:,:,i-1)=get_one_dip(figh(i)); end end return function d=get_one_dip(figh) if ishandle(figh) ud=get(figh,'userdata'); % if isfield(ud,'slices') % % multidiomensional dip_image % d=ud.slices; if isfield(ud,'imagedata') % single band dip_image d=ud.imagedata; else error('unknown format'); end else error('figure handle required'); end return