2847
|
1 ## Copyright (C) 1996, 1997 John W. Eaton |
2313
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## any later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
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 |
|
24 ## into the current colormap and should have values between 1 and the |
6257
|
25 ## length of the 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 |
6257
|
42 function image (x, y, img) |
|
43 |
|
44 newplot (); |
559
|
45 |
|
46 if (nargin == 0) |
2303
|
47 ## Load Bobbie Jo Richardson (Born 3/16/94) |
6257
|
48 img = loadimage ("default.img"); |
6088
|
49 x = y = []; |
6259
|
50 elseif (nargin == 1 || nargin == 2) |
|
51 ## FIXME -- should we handle the old zoom argument? How? What |
|
52 ## figure property should we be setting? |
6257
|
53 img = x; |
3651
|
54 x = y = []; |
6257
|
55 elseif (nargin > 3) |
|
56 print_usage (); |
|
57 endif |
|
58 |
|
59 if (isempty (img)) |
|
60 error ("image: matrix is empty"); |
|
61 endif |
|
62 |
|
63 ## Use the newly added mode of "plot" called "with image". |
|
64 if (isempty (x)) |
|
65 x = [1, columns(img)]; |
|
66 endif |
|
67 |
|
68 if (isempty (y)) |
|
69 y = [1, rows(img)]; |
559
|
70 endif |
|
71 |
6257
|
72 ca = gca (); |
|
73 |
|
74 s = __uiobject_image_ctor__ (ca); |
|
75 |
|
76 s.cdata = img; |
|
77 |
|
78 tmp = __uiobject_make_handle__ (s); |
|
79 |
|
80 __uiobject_adopt__ (ca, tmp); |
|
81 |
|
82 xlim = [x(1), x(end)]; |
|
83 ylim = [y(1), y(end)]; |
|
84 |
|
85 set (ca, "view", [0, 90], "xlim", xlim, "ylim", ylim); |
|
86 |
|
87 if (nargout > 0) |
|
88 h = tmp; |
6088
|
89 endif |
559
|
90 |
|
91 endfunction |