7017
|
1 ## Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003, |
|
2 ## 2004, 2005, 2006, 2007 John W. Eaton |
2313
|
3 ## |
|
4 ## This file is part of Octave. |
|
5 ## |
|
6 ## Octave is free software; you can redistribute it and/or modify it |
|
7 ## under the terms of the GNU General Public License as published by |
7016
|
8 ## the Free Software Foundation; either version 3 of the License, or (at |
|
9 ## your option) any later version. |
2313
|
10 ## |
|
11 ## Octave is distributed in the hope that it will be useful, but |
|
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 ## General Public License for more details. |
|
15 ## |
|
16 ## You should have received a copy of the GNU General Public License |
7016
|
17 ## along with Octave; see the file COPYING. If not, see |
|
18 ## <http://www.gnu.org/licenses/>. |
1024
|
19 |
3381
|
20 ## -*- texinfo -*- |
6257
|
21 ## @deftypefn {Function File} {} image (@var{img}) |
|
22 ## @deftypefnx {Function File} {} image (@var{x}, @var{y}, @var{img}) |
3373
|
23 ## Display a matrix as a color image. The elements of @var{x} are indices |
7189
|
24 ## into the current colormap, and the colormap will be scaled so that the |
|
25 ## extremes of @var{x} are mapped to the extremes of teh colormap. |
3651
|
26 ## |
6164
|
27 ## It first tries to use @code{gnuplot}, then @code{display} from |
|
28 ## @code{ImageMagick}, then @code{xv}, and then @code{xloadimage}. |
|
29 ## The actual program used can be changed using the @code{image_viewer} |
|
30 ## function. |
3714
|
31 ## |
3651
|
32 ## The axis values corresponding to the matrix elements are specified in |
6164
|
33 ## @var{x} and @var{y}. If you're not using gnuplot 4.2 or later, these |
|
34 ## variables are ignored. |
|
35 ## @seealso{imshow, imagesc, colormap, image_viewer} |
3373
|
36 ## @end deftypefn |
559
|
37 |
3202
|
38 ## Author: Tony Richardson <arichard@stark.cc.oh.us> |
2312
|
39 ## Created: July 1994 |
|
40 ## Adapted-By: jwe |
904
|
41 |
7189
|
42 function retval = image (varargin) |
|
43 |
7203
|
44 if (nargin == 0) |
|
45 __image__ (gca ()); |
|
46 elseif (nargin == 1) |
7189
|
47 print_usage (); |
|
48 elseif (isscalar (varargin{1}) && ishandle (varargin{1})) |
7208
|
49 h = varargin{1}; |
7189
|
50 if (! strcmp (get (h, "type"), "axes")) |
|
51 error ("image: expecting first argument to be an axes object"); |
|
52 endif |
|
53 oldh = gca (); |
|
54 unwind_protect |
|
55 axes (h); |
|
56 tmp = __image__ (h, varargin{2:end}); |
|
57 unwind_protect_cleanup |
|
58 axes (oldh); |
|
59 end_unwind_protect |
|
60 else |
|
61 tmp = __image__ (gca (), varargin{:}); |
|
62 endif |
|
63 |
|
64 if (nargout > 0) |
|
65 retval = tmp; |
|
66 endif |
|
67 |
|
68 endfunction |
|
69 |
|
70 function h = __image__ (ax, x, y, img) |
6257
|
71 |
6368
|
72 ## Deprecated zoom. Remove this hunk of code if old zoom argument |
|
73 ## is outmoded. |
7189
|
74 if ((nargin == 3 && isscalar (y)) || nargin == 5) |
6368
|
75 warning ("image: zoom argument ignored -- use GUI features"); |
|
76 endif |
7189
|
77 if (nargin == 5) |
|
78 nargin = 4; |
6368
|
79 endif |
7189
|
80 if (nargin == 3 && isscalar (y)) |
|
81 nargin = 2; |
6368
|
82 endif |
559
|
83 |
7189
|
84 if (nargin == 1) |
2303
|
85 ## Load Bobbie Jo Richardson (Born 3/16/94) |
6257
|
86 img = loadimage ("default.img"); |
6088
|
87 x = y = []; |
7189
|
88 elseif (nargin == 2) |
6257
|
89 img = x; |
3651
|
90 x = y = []; |
7189
|
91 elseif (nargin == 3 || nargin > 4) |
6257
|
92 print_usage (); |
|
93 endif |
|
94 |
7189
|
95 h = __img__ (x, y, img); |
559
|
96 |
|
97 endfunction |