annotate scripts/image/__img__.m @ 6356:8bb0d11c7a97

[project @ 2007-02-26 14:45:29 by dbateman]
author dbateman
date Mon, 26 Feb 2007 14:48:22 +0000
parents 725709ab0445
children 0eac3484e8df
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6312
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
1 ## Copyright (C) 1996, 1997 John W. Eaton
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
2 ##
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
4 ##
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
7 ## the Free Software Foundation; either version 2, or (at your option)
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
8 ## any later version.
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
9 ##
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
14 ##
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, write to the Free
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
18 ## 02110-1301, USA.
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
19
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
20 ## -*- texinfo -*-
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
21 ## @deftypefn {Function File} {} __img__ (@var{img})
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
22 ## @deftypefnx {Function File} {} __img__ (@var{x}, @var{y}, @var{img})
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
23 ## Generic image creation.
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
24 ##
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
25 ## The axis values corresponding to the matrix elements are specified in
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
26 ## @var{x} and @var{y}. If you're not using gnuplot 4.2 or later, these
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
27 ## variables are ignored.
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
28 ## @end deftypefn
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
29
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
30 ## Author: Tony Richardson <arichard@stark.cc.oh.us>
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
31 ## Created: July 1994
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
32 ## Adapted-By: jwe
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
33
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
34 function h = __img__ (x, y, img)
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
35
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
36 newplot ();
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
37
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
38 if (isempty (img))
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
39 error ("__img__: matrix is empty");
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
40 endif
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
41
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
42 if (isempty (x))
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
43 x = [1, columns(img)];
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
44 endif
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
45
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
46 if (isempty (y))
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
47 y = [1, rows(img)];
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
48 endif
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
49
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
50 xlim = [x(1), x(end)];
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
51 ylim = [y(1), y(end)];
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
52
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
53 ca = gca ();
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
54
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
55 s = __uiobject_image_ctor__ (ca);
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
56
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
57 s.cdata = img;
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
58 s.xdata = xlim;
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
59 s.ydata = ylim;
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
60
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
61 tmp = __uiobject_make_handle__ (s);
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
62
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
63 __uiobject_adopt__ (ca, tmp);
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
64
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
65 set (ca, "view", [0, 90], "xlim", xlim, "ylim", ylim);
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
66
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
67 if (nargout > 0)
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
68 h = tmp;
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
69 endif
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
70
725709ab0445 [project @ 2007-02-15 21:34:46 by jwe]
jwe
parents:
diff changeset
71 endfunction