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 |
7276
|
44 [ax, varargin, nargin] = __plt_get_axis_arg__ ("image", varargin{:}); |
|
45 |
|
46 firstnonnumeric = Inf; |
|
47 for i = 1 : nargin |
|
48 if (! isnumeric (varargin{i})) |
|
49 firstnonnumeric = i; |
|
50 break; |
7189
|
51 endif |
7276
|
52 endfor |
|
53 |
|
54 if (nargin == 0 || firstnonnumeric == 1) |
|
55 img = loadimage ("default.img"); |
|
56 x = y = []; |
|
57 elseif (nargin == 1 || firstnonnumeric == 2) |
|
58 img = varargin{1}; |
|
59 x = y = []; |
|
60 elseif (nargin == 2 || firstnonnumeric == 3) |
|
61 print_usage (); |
7189
|
62 else |
7276
|
63 x = varargin{1}; |
|
64 y = varargin{2}; |
|
65 img = varargin{3}; |
|
66 firstnonnumeric = 4; |
7189
|
67 endif |
|
68 |
7276
|
69 oldax = gca (); |
|
70 unwind_protect |
|
71 axes (ax); |
|
72 h = __img__ (x, y, img, varargin {firstnonnumeric:end}); |
|
73 unwind_protect_cleanup |
|
74 axes (oldax); |
|
75 end_unwind_protect |
|
76 |
7189
|
77 if (nargout > 0) |
7276
|
78 retval = h; |
7189
|
79 endif |
|
80 |
|
81 endfunction |