annotate scripts/image/image.m @ 13980:bd2be36fd949

image.m: Warn if input coordinates are not linearly spaced.
author Ben Abbott <bpabbott@mac.com>
date Fri, 02 Dec 2011 20:33:42 -0500
parents 536c6a5ab705
children e58963b5c0b1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 11308
diff changeset
1 ## Copyright (C) 1994-2011 John W. Eaton
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
2 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
3 ## This file is part of Octave.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
4 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6368
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6368
diff changeset
8 ## your option) any later version.
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
9 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
13 ## General Public License for more details.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
14 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6368
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6368
diff changeset
17 ## <http://www.gnu.org/licenses/>.
1024
56520a75b5b3 [project @ 1995-01-11 20:30:04 by jwe]
jwe
parents: 904
diff changeset
18
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3373
diff changeset
19 ## -*- texinfo -*-
10793
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 10704
diff changeset
20 ## @deftypefn {Function File} {} image (@var{img})
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6164
diff changeset
21 ## @deftypefnx {Function File} {} image (@var{x}, @var{y}, @var{img})
12617
fb2e14a276d2 Fixed naming of variables in texinfo
Paul Boven <p.boven@xs4all.nl>
parents: 11587
diff changeset
22 ## Display a matrix as a color image. The elements of @var{img} are indices
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7074
diff changeset
23 ## into the current colormap, and the colormap will be scaled so that the
12617
fb2e14a276d2 Fixed naming of variables in texinfo
Paul Boven <p.boven@xs4all.nl>
parents: 11587
diff changeset
24 ## extremes of @var{img} are mapped to the extremes of the colormap.
3651
c2305b99fbd7 [project @ 2000-03-31 07:12:29 by jwe]
jwe
parents: 3457
diff changeset
25 ##
c2305b99fbd7 [project @ 2000-03-31 07:12:29 by jwe]
jwe
parents: 3457
diff changeset
26 ## The axis values corresponding to the matrix elements are specified in
9051
1bf0ce0930be Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
27 ## @var{x} and @var{y}. If you're not using gnuplot 4.2 or later, these
6164
d90b16110095 [project @ 2006-11-14 21:08:00 by jwe]
jwe
parents: 6088
diff changeset
28 ## variables are ignored.
10817
d9147775da54 image.m: Always reverse 'ydir' property when displaying images.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
29 ##
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
30 ## Implementation Note: The origin (0, 0) for images is located in the
10817
d9147775da54 image.m: Always reverse 'ydir' property when displaying images.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
31 ## upper left. For ordinary plots, the origin is located in the lower
d9147775da54 image.m: Always reverse 'ydir' property when displaying images.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
32 ## left. Octave handles this inversion by plotting the data normally,
d9147775da54 image.m: Always reverse 'ydir' property when displaying images.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
33 ## and then reversing the direction of the y-axis by setting the
11109
41d18f6342f9 remove image_viewer function
John W. Eaton <jwe@octave.org>
parents: 11090
diff changeset
34 ## @code{ydir} property to @code{"reverse"}. This has implications whenever
10817
d9147775da54 image.m: Always reverse 'ydir' property when displaying images.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
35 ## an image and an ordinary plot need to be overlaid. The recommended
d9147775da54 image.m: Always reverse 'ydir' property when displaying images.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
36 ## solution is to display the image and then plot the reversed ydata
d9147775da54 image.m: Always reverse 'ydir' property when displaying images.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
37 ## using, for example, @code{flipud (ydata,1)}.
11109
41d18f6342f9 remove image_viewer function
John W. Eaton <jwe@octave.org>
parents: 11090
diff changeset
38 ## @seealso{imshow, imagesc, colormap}
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3202
diff changeset
39 ## @end deftypefn
559
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
40
3202
44d82b369c78 [project @ 1998-10-29 20:27:57 by jwe]
jwe
parents: 2847
diff changeset
41 ## Author: Tony Richardson <arichard@stark.cc.oh.us>
2312
204cc7db6f4a [project @ 1996-07-11 21:20:36 by jwe]
jwe
parents: 2311
diff changeset
42 ## Created: July 1994
204cc7db6f4a [project @ 1996-07-11 21:20:36 by jwe]
jwe
parents: 2311
diff changeset
43 ## Adapted-By: jwe
904
3470f1e25a79 [project @ 1994-11-09 21:22:15 by jwe]
jwe
parents: 686
diff changeset
44
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7074
diff changeset
45 function retval = image (varargin)
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7074
diff changeset
46
7276
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
47 [ax, varargin, nargin] = __plt_get_axis_arg__ ("image", varargin{:});
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
48
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
49 firstnonnumeric = Inf;
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
50 for i = 1 : nargin
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
51 if (! isnumeric (varargin{i}))
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
52 firstnonnumeric = i;
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
53 break;
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7074
diff changeset
54 endif
7276
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
55 endfor
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
56
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
57 if (nargin == 0 || firstnonnumeric == 1)
10650
f0dc41c824ce Replace calls to deprecated functions.
Rik <octave@nomad.inbox5.com>
parents: 10433
diff changeset
58 img = imread ("default.img");
7276
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
59 x = y = [];
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
60 elseif (nargin == 1 || firstnonnumeric == 2)
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
61 img = varargin{1};
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
62 x = y = [];
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
63 elseif (nargin == 2 || firstnonnumeric == 3)
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
64 print_usage ();
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7074
diff changeset
65 else
7276
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
66 x = varargin{1};
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
67 y = varargin{2};
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
68 img = varargin{3};
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
69 firstnonnumeric = 4;
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7074
diff changeset
70 endif
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7074
diff changeset
71
7276
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
72 oldax = gca ();
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
73 unwind_protect
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
74 axes (ax);
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
75 h = __img__ (x, y, img, varargin {firstnonnumeric:end});
7315
3ceb12c499e9 [project @ 2007-12-13 21:35:36 by jwe]
jwe
parents: 7276
diff changeset
76 set (ax, "layer", "top");
7276
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
77 unwind_protect_cleanup
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
78 axes (oldax);
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
79 end_unwind_protect
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
80
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7074
diff changeset
81 if (nargout > 0)
7276
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
82 retval = h;
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7074
diff changeset
83 endif
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7074
diff changeset
84
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7074
diff changeset
85 endfunction
9899
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
86
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
87 ## Generic image creation.
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
88 ##
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
89 ## The axis values corresponding to the matrix elements are specified in
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
90 ## @var{x} and @var{y}. If you're not using gnuplot 4.2 or later, these
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
91 ## variables are ignored.
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
92
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
93 ## Author: Tony Richardson <arichard@stark.cc.oh.us>
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
94 ## Created: July 1994
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
95 ## Adapted-By: jwe
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
96
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
97 function h = __img__ (x, y, img, varargin)
13980
bd2be36fd949 image.m: Warn if input coordinates are not linearly spaced.
Ben Abbott <bpabbott@mac.com>
parents: 13173
diff changeset
98
bd2be36fd949 image.m: Warn if input coordinates are not linearly spaced.
Ben Abbott <bpabbott@mac.com>
parents: 13173
diff changeset
99 persistent warn = true
9899
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
100
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
101 newplot ();
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
102
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
103 if (isempty (img))
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
104 error ("__img__: matrix is empty");
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
105 endif
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
106
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
107 if (isempty (x))
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
108 x = [1, columns(img)];
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
109 endif
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
110
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
111 if (isempty (y))
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
112 y = [1, rows(img)];
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
113 endif
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
114
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
115 xdata = [x(1), x(end)];
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
116 ydata = [y(1), y(end)];
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
117
13980
bd2be36fd949 image.m: Warn if input coordinates are not linearly spaced.
Ben Abbott <bpabbott@mac.com>
parents: 13173
diff changeset
118 if ((numel (unique (diff (x))) > 1 || numel (unique (diff (y))) > 1) && warn)
bd2be36fd949 image.m: Warn if input coordinates are not linearly spaced.
Ben Abbott <bpabbott@mac.com>
parents: 13173
diff changeset
119 warning ("Image does not map to non-linearly spaced coordinates")
bd2be36fd949 image.m: Warn if input coordinates are not linearly spaced.
Ben Abbott <bpabbott@mac.com>
parents: 13173
diff changeset
120 warn = false;
bd2be36fd949 image.m: Warn if input coordinates are not linearly spaced.
Ben Abbott <bpabbott@mac.com>
parents: 13173
diff changeset
121 endif
bd2be36fd949 image.m: Warn if input coordinates are not linearly spaced.
Ben Abbott <bpabbott@mac.com>
parents: 13173
diff changeset
122
9899
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
123 ca = gca ();
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
124
10817
d9147775da54 image.m: Always reverse 'ydir' property when displaying images.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
125 tmp = __go_image__ (ca, "cdata", img, "xdata", xdata, "ydata", ydata,
11076
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10952
diff changeset
126 "cdatamapping", "direct", varargin {:});
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10952
diff changeset
127
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10952
diff changeset
128 px = __image_pixel_size__ (tmp);
11090
2adf4736dafa Do not store flipped image property values when x/ydata descends.
Ben Abbott <bpabbott@mac.com>
parents: 11080
diff changeset
129
2adf4736dafa Do not store flipped image property values when x/ydata descends.
Ben Abbott <bpabbott@mac.com>
parents: 11080
diff changeset
130 if (xdata(2) < xdata(1))
2adf4736dafa Do not store flipped image property values when x/ydata descends.
Ben Abbott <bpabbott@mac.com>
parents: 11080
diff changeset
131 xdata = xdata(2:-1:1);
2adf4736dafa Do not store flipped image property values when x/ydata descends.
Ben Abbott <bpabbott@mac.com>
parents: 11080
diff changeset
132 elseif (xdata(2) == xdata(1))
2adf4736dafa Do not store flipped image property values when x/ydata descends.
Ben Abbott <bpabbott@mac.com>
parents: 11080
diff changeset
133 xdata = xdata(1) + [0, size(img,2)-1];
2adf4736dafa Do not store flipped image property values when x/ydata descends.
Ben Abbott <bpabbott@mac.com>
parents: 11080
diff changeset
134 endif
2adf4736dafa Do not store flipped image property values when x/ydata descends.
Ben Abbott <bpabbott@mac.com>
parents: 11080
diff changeset
135 if (ydata(2) < ydata(1))
2adf4736dafa Do not store flipped image property values when x/ydata descends.
Ben Abbott <bpabbott@mac.com>
parents: 11080
diff changeset
136 ydata = ydata(2:-1:1);
2adf4736dafa Do not store flipped image property values when x/ydata descends.
Ben Abbott <bpabbott@mac.com>
parents: 11080
diff changeset
137 elseif (ydata(2) == ydata(1))
2adf4736dafa Do not store flipped image property values when x/ydata descends.
Ben Abbott <bpabbott@mac.com>
parents: 11080
diff changeset
138 ydata = ydata(1) + [0, size(img,1)-1];
2adf4736dafa Do not store flipped image property values when x/ydata descends.
Ben Abbott <bpabbott@mac.com>
parents: 11080
diff changeset
139 endif
11076
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10952
diff changeset
140 xlim = xdata + [-px(1), px(1)];
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10952
diff changeset
141 ylim = ydata + [-px(2), px(2)];
9899
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
142
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
143 ## FIXME -- how can we do this and also get the {x,y}limmode
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
144 ## properties to remain "auto"? I suppose this adjustment should
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
145 ## happen automatically in axes::update_axis_limits instead of
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
146 ## explicitly setting the values here. But then what information is
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
147 ## available to axes::update_axis_limits to determine that the
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
148 ## adjustment is necessary?
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
149 set (ca, "xlim", xlim, "ylim", ylim);
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
150
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
151 if (ndims (img) == 3)
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
152 if (isinteger (img))
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
153 c = class (img);
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
154 mn = intmin (c);
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
155 mx = intmax (c);
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
156 set (ca, "clim", double ([mn, mx]));
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
157 endif
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
158 endif
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
159
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
160 set (ca, "view", [0, 90]);
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
161
11308
9a08fa5b33bd image.m: Only flip y-axis if nextplot property equal "replace".
Ben Abbott <bpabbott@mac.com>
parents: 11109
diff changeset
162 if (strcmp (get (ca, "nextplot"), "replace"))
9a08fa5b33bd image.m: Only flip y-axis if nextplot property equal "replace".
Ben Abbott <bpabbott@mac.com>
parents: 11109
diff changeset
163 # Always reverse y-axis for images, unless hold is on
9a08fa5b33bd image.m: Only flip y-axis if nextplot property equal "replace".
Ben Abbott <bpabbott@mac.com>
parents: 11109
diff changeset
164 set (ca, "ydir", "reverse");
9a08fa5b33bd image.m: Only flip y-axis if nextplot property equal "replace".
Ben Abbott <bpabbott@mac.com>
parents: 11109
diff changeset
165 endif
10817
d9147775da54 image.m: Always reverse 'ydir' property when displaying images.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
166
9899
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
167 if (nargout > 0)
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
168 h = tmp;
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
169 endif
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
170
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
171 endfunction
10942
48a1812fcc3a image.m: Matlab compatible axis limits, add demo.
Ben Abbott <bpabbott@mac.com>
parents: 10818
diff changeset
172
48a1812fcc3a image.m: Matlab compatible axis limits, add demo.
Ben Abbott <bpabbott@mac.com>
parents: 10818
diff changeset
173 %!demo
13165
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
174 %! clf
11080
36ceff79607b image.m: Allow x/ydata to imply a flip of the image. Modify demos.
Ben Abbott <bpabbott@mac.com>
parents: 11076
diff changeset
175 %! img = 1 ./ hilb (11);
36ceff79607b image.m: Allow x/ydata to imply a flip of the image. Modify demos.
Ben Abbott <bpabbott@mac.com>
parents: 11076
diff changeset
176 %! x = -5:5;
36ceff79607b image.m: Allow x/ydata to imply a flip of the image. Modify demos.
Ben Abbott <bpabbott@mac.com>
parents: 11076
diff changeset
177 %! y = x;
36ceff79607b image.m: Allow x/ydata to imply a flip of the image. Modify demos.
Ben Abbott <bpabbott@mac.com>
parents: 11076
diff changeset
178 %! subplot (2,2,1)
36ceff79607b image.m: Allow x/ydata to imply a flip of the image. Modify demos.
Ben Abbott <bpabbott@mac.com>
parents: 11076
diff changeset
179 %! h = image (abs(x), abs(y), img);
36ceff79607b image.m: Allow x/ydata to imply a flip of the image. Modify demos.
Ben Abbott <bpabbott@mac.com>
parents: 11076
diff changeset
180 %! set (h, "cdatamapping", "scaled")
36ceff79607b image.m: Allow x/ydata to imply a flip of the image. Modify demos.
Ben Abbott <bpabbott@mac.com>
parents: 11076
diff changeset
181 %! ylabel ("limits = [4.5, 15.5]")
36ceff79607b image.m: Allow x/ydata to imply a flip of the image. Modify demos.
Ben Abbott <bpabbott@mac.com>
parents: 11076
diff changeset
182 %! title ('image (abs(x), abs(y), img)')
36ceff79607b image.m: Allow x/ydata to imply a flip of the image. Modify demos.
Ben Abbott <bpabbott@mac.com>
parents: 11076
diff changeset
183 %! subplot (2,2,2)
36ceff79607b image.m: Allow x/ydata to imply a flip of the image. Modify demos.
Ben Abbott <bpabbott@mac.com>
parents: 11076
diff changeset
184 %! h = image (-x, y, img);
10942
48a1812fcc3a image.m: Matlab compatible axis limits, add demo.
Ben Abbott <bpabbott@mac.com>
parents: 10818
diff changeset
185 %! set (h, "cdatamapping", "scaled")
11080
36ceff79607b image.m: Allow x/ydata to imply a flip of the image. Modify demos.
Ben Abbott <bpabbott@mac.com>
parents: 11076
diff changeset
186 %! title ('image (-x, y, img)')
36ceff79607b image.m: Allow x/ydata to imply a flip of the image. Modify demos.
Ben Abbott <bpabbott@mac.com>
parents: 11076
diff changeset
187 %! subplot (2,2,3)
36ceff79607b image.m: Allow x/ydata to imply a flip of the image. Modify demos.
Ben Abbott <bpabbott@mac.com>
parents: 11076
diff changeset
188 %! h = image (x, -y, img);
36ceff79607b image.m: Allow x/ydata to imply a flip of the image. Modify demos.
Ben Abbott <bpabbott@mac.com>
parents: 11076
diff changeset
189 %! set (h, "cdatamapping", "scaled")
36ceff79607b image.m: Allow x/ydata to imply a flip of the image. Modify demos.
Ben Abbott <bpabbott@mac.com>
parents: 11076
diff changeset
190 %! title ('image (x, -y, img)')
36ceff79607b image.m: Allow x/ydata to imply a flip of the image. Modify demos.
Ben Abbott <bpabbott@mac.com>
parents: 11076
diff changeset
191 %! ylabel ("limits = [-5.5, 5.5]")
36ceff79607b image.m: Allow x/ydata to imply a flip of the image. Modify demos.
Ben Abbott <bpabbott@mac.com>
parents: 11076
diff changeset
192 %! subplot (2,2,4)
36ceff79607b image.m: Allow x/ydata to imply a flip of the image. Modify demos.
Ben Abbott <bpabbott@mac.com>
parents: 11076
diff changeset
193 %! h = image (-x, -y, img);
36ceff79607b image.m: Allow x/ydata to imply a flip of the image. Modify demos.
Ben Abbott <bpabbott@mac.com>
parents: 11076
diff changeset
194 %! set (h, "cdatamapping", "scaled")
36ceff79607b image.m: Allow x/ydata to imply a flip of the image. Modify demos.
Ben Abbott <bpabbott@mac.com>
parents: 11076
diff changeset
195 %! title ('image (-x, -y, img)')
10942
48a1812fcc3a image.m: Matlab compatible axis limits, add demo.
Ben Abbott <bpabbott@mac.com>
parents: 10818
diff changeset
196
13165
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
197 %!demo
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
198 %! clf
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
199 %! g = 0.1:0.1:10;
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
200 %! h = g'*g;
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
201 %! imagesc (g, g, sin (h));
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
202 %! hold on
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
203 %! imagesc (g, g+12, cos (h/2));
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
204 %! axis ([0 10 0 22])
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
205 %! hold off
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
206 %! title ("two consecutive images")
10952
18b0af0bbd6b image.m: Fix axis limits for single dimension images, add demo.
Ben Abbott <bpabbott@mac.com>
parents: 10942
diff changeset
207
13165
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
208 %!demo
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
209 %! clf
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
210 %! g = 0.1:0.1:10;
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
211 %! h = g'*g;
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
212 %! imagesc (g, g, sin (h));
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
213 %! hold all
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
214 %! plot (g, 11.0 * ones (size (g)))
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
215 %! imagesc (g, g+12, cos (h/2));
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
216 %! axis ([0 10 0 22])
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
217 %! hold off
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
218 %! title ("image, line, image")
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
219
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
220 %!demo
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
221 %! clf
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
222 %! g = 0.1:0.1:10;
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
223 %! h = g'*g;
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
224 %! plot (g, 10.5 * ones (size (g)))
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
225 %! hold all
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
226 %! imagesc (g, g, sin (h));
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
227 %! plot (g, 11.0 * ones (size (g)))
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
228 %! imagesc (g, g+12, cos (h/2));
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
229 %! plot (g, 11.5 * ones (size (g)))
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
230 %! axis ([0 10 0 22])
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
231 %! hold off
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
232 %! title ("line, image, line, image, line")
9efb676b34ac Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents: 11587
diff changeset
233