1 | % FIG2DIP Retrieve DIP images from figures via handles or indices |
---|
2 | % |
---|
3 | % DIP = FIG2DIP(FIGH) |
---|
4 | % |
---|
5 | % INPUT |
---|
6 | % FIGH vector with figure handles or figure indices |
---|
7 | % |
---|
8 | % OUTPUT |
---|
9 | % DIP DIP image |
---|
10 | % |
---|
11 | % DESCRIPTION |
---|
12 | % Retrieves 2D DIP images via figure handles or indices. If a vector of |
---|
13 | % handles (indices) is given, the function returns a multi-band image. |
---|
14 | |
---|
15 | % Copyright: Pavel Paclik, pavel@ph.tn.tudelft.nl |
---|
16 | % Faculty of Applied Physics, Delft University of Technology |
---|
17 | % P.O. Box 5046, 2600 GA Delft, The Netherlands |
---|
18 | |
---|
19 | % $Id: fig2dip.m,v 1.5 2005/11/02 14:29:17 pavel Exp $ |
---|
20 | |
---|
21 | function dip=fig2dip(figh) |
---|
22 | |
---|
23 | if ~all(ishandle(figh)) |
---|
24 | if all(round(figh)==figh) |
---|
25 | % assuming these are figure numbers |
---|
26 | % construct the vector with figure handles |
---|
27 | t=[]; |
---|
28 | for i=1:length(figh) |
---|
29 | t=[t figure(i)]; |
---|
30 | end |
---|
31 | figh=t; |
---|
32 | else |
---|
33 | error(['if number are supplied, these must be' ... |
---|
34 | ' integers (figure numbers)']); |
---|
35 | end |
---|
36 | end |
---|
37 | |
---|
38 | dip=get_one_dip(figh(1)); |
---|
39 | if length(figh)>1 |
---|
40 | t=dip; |
---|
41 | dip=dip_image(zeros(size(t,2),size(t,1),length(figh))); |
---|
42 | dip(:,:,0)=t; |
---|
43 | clear t; |
---|
44 | for i=2:length(figh) |
---|
45 | dip(:,:,i-1)=get_one_dip(figh(i)); |
---|
46 | end |
---|
47 | end |
---|
48 | |
---|
49 | return |
---|
50 | |
---|
51 | function d=get_one_dip(figh) |
---|
52 | |
---|
53 | if ishandle(figh) |
---|
54 | |
---|
55 | ud=get(figh,'userdata'); |
---|
56 | |
---|
57 | % if isfield(ud,'slices') |
---|
58 | % % multidiomensional dip_image |
---|
59 | % d=ud.slices; |
---|
60 | if isfield(ud,'imagedata') |
---|
61 | % single band dip_image |
---|
62 | d=ud.imagedata; |
---|
63 | else |
---|
64 | error('unknown format'); |
---|
65 | end |
---|
66 | else |
---|
67 | error('figure handle required'); |
---|
68 | end |
---|
69 | |
---|
70 | return |
---|
71 | |
---|