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 = []; |
1024
|
50 elseif (nargin == 1) |
6257
|
51 img = x; |
3651
|
52 x = y = []; |
6257
|
53 elseif (nargin > 3) |
|
54 print_usage (); |
|
55 endif |
|
56 |
|
57 if (isempty (img)) |
|
58 error ("image: matrix is empty"); |
|
59 endif |
|
60 |
|
61 ## Use the newly added mode of "plot" called "with image". |
|
62 if (isempty (x)) |
|
63 x = [1, columns(img)]; |
|
64 endif |
|
65 |
|
66 if (isempty (y)) |
|
67 y = [1, rows(img)]; |
559
|
68 endif |
|
69 |
6257
|
70 ca = gca (); |
|
71 |
|
72 s = __uiobject_image_ctor__ (ca); |
|
73 |
|
74 s.cdata = img; |
|
75 |
|
76 tmp = __uiobject_make_handle__ (s); |
|
77 |
|
78 __uiobject_adopt__ (ca, tmp); |
|
79 |
|
80 xlim = [x(1), x(end)]; |
|
81 ylim = [y(1), y(end)]; |
|
82 |
|
83 set (ca, "view", [0, 90], "xlim", xlim, "ylim", ylim); |
|
84 |
|
85 if (nargout > 0) |
|
86 h = tmp; |
6088
|
87 endif |
559
|
88 |
6257
|
89 drawnow (); |
6164
|
90 |
559
|
91 endfunction |