Mercurial > octave
annotate scripts/image/image.m @ 15064:489736962e80
image.m: Don't accept complex image data (bug #36866)
* image.m: Add input test for complex data. Add %!error validation
tests.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 31 Jul 2012 11:11:05 -0700 |
parents | c2dbdeaa25df |
children | 7a3957ca99c3 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14001
diff
changeset
|
1 ## Copyright (C) 1994-2012 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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
2313 | 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 | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
1024 | 18 |
3381 | 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 | 21 ## @deftypefnx {Function File} {} image (@var{x}, @var{y}, @var{img}) |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13993
diff
changeset
|
22 ## @deftypefnx {Function File} {@var{h} =} image (@dots{}) |
14260
1f911333ed3d
doc: Update docstrings for functions in image/ directory
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
23 ## Display a matrix as a color image. |
3651 | 24 ## |
14260
1f911333ed3d
doc: Update docstrings for functions in image/ directory
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
25 ## The elements of @var{img} are indices into the current colormap. |
3651 | 26 ## The axis values corresponding to the matrix elements are specified in |
14260
1f911333ed3d
doc: Update docstrings for functions in image/ directory
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
27 ## @var{x} and @var{y}. If you are using gnuplot 4.1 or earlier, these |
6164 | 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 ## |
14260
1f911333ed3d
doc: Update docstrings for functions in image/ directory
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
30 ## The optional return value @var{h} is a graphics handle to the image. |
1f911333ed3d
doc: Update docstrings for functions in image/ directory
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
31 ## |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
32 ## 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
|
33 ## 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
|
34 ## 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
|
35 ## and then reversing the direction of the y-axis by setting the |
14260
1f911333ed3d
doc: Update docstrings for functions in image/ directory
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
36 ## @code{ydir} property to "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
|
37 ## 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
|
38 ## 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
|
39 ## using, for example, @code{flipud (ydata,1)}. |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13993
diff
changeset
|
40 ## |
11109
41d18f6342f9
remove image_viewer function
John W. Eaton <jwe@octave.org>
parents:
11090
diff
changeset
|
41 ## @seealso{imshow, imagesc, colormap} |
3373 | 42 ## @end deftypefn |
559 | 43 |
3202 | 44 ## Author: Tony Richardson <arichard@stark.cc.oh.us> |
2312 | 45 ## Created: July 1994 |
46 ## Adapted-By: jwe | |
904 | 47 |
7189 | 48 function retval = image (varargin) |
49 | |
7276 | 50 [ax, varargin, nargin] = __plt_get_axis_arg__ ("image", varargin{:}); |
51 | |
52 firstnonnumeric = Inf; | |
53 for i = 1 : nargin | |
54 if (! isnumeric (varargin{i})) | |
55 firstnonnumeric = i; | |
56 break; | |
7189 | 57 endif |
7276 | 58 endfor |
59 | |
60 if (nargin == 0 || firstnonnumeric == 1) | |
10650
f0dc41c824ce
Replace calls to deprecated functions.
Rik <octave@nomad.inbox5.com>
parents:
10433
diff
changeset
|
61 img = imread ("default.img"); |
7276 | 62 x = y = []; |
63 elseif (nargin == 1 || firstnonnumeric == 2) | |
64 img = varargin{1}; | |
65 x = y = []; | |
66 elseif (nargin == 2 || firstnonnumeric == 3) | |
67 print_usage (); | |
7189 | 68 else |
7276 | 69 x = varargin{1}; |
70 y = varargin{2}; | |
71 img = varargin{3}; | |
72 firstnonnumeric = 4; | |
7189 | 73 endif |
74 | |
15064
489736962e80
image.m: Don't accept complex image data (bug #36866)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
75 if (iscomplex (img)) |
489736962e80
image.m: Don't accept complex image data (bug #36866)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
76 error ("image: data can not be complex"); |
489736962e80
image.m: Don't accept complex image data (bug #36866)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
77 endif |
489736962e80
image.m: Don't accept complex image data (bug #36866)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
78 |
7276 | 79 oldax = gca (); |
80 unwind_protect | |
81 axes (ax); | |
82 h = __img__ (x, y, img, varargin {firstnonnumeric:end}); | |
7315 | 83 set (ax, "layer", "top"); |
7276 | 84 unwind_protect_cleanup |
85 axes (oldax); | |
86 end_unwind_protect | |
87 | |
7189 | 88 if (nargout > 0) |
7276 | 89 retval = h; |
7189 | 90 endif |
91 | |
92 endfunction | |
9899
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
93 |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
94 ## Generic image creation. |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
95 ## |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
96 ## The axis values corresponding to the matrix elements are specified in |
14260
1f911333ed3d
doc: Update docstrings for functions in image/ directory
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
97 ## @var{x} and @var{y}. If you're not using gnuplot 4.2 or later, these |
9899
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
98 ## variables are ignored. |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
99 |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
100 ## 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
|
101 ## Created: July 1994 |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
102 ## Adapted-By: jwe |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
103 |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
104 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
|
105 |
9899
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
106 newplot (); |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
107 |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
108 if (isempty (img)) |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
109 error ("__img__: matrix is empty"); |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
110 endif |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
111 |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
112 if (isempty (x)) |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
113 x = [1, columns(img)]; |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
114 endif |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
115 |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
116 if (isempty (y)) |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
117 y = [1, rows(img)]; |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
118 endif |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
119 |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
120 xdata = [x(1), x(end)]; |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
121 ydata = [y(1), y(end)]; |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
122 |
13993
e58963b5c0b1
image.m: Fix test for non-linearly spaced coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
13980
diff
changeset
|
123 dx = diff (x); |
e58963b5c0b1
image.m: Fix test for non-linearly spaced coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
13980
diff
changeset
|
124 dy = diff (y); |
e58963b5c0b1
image.m: Fix test for non-linearly spaced coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
13980
diff
changeset
|
125 dx = std (dx) / mean (abs (dx)); |
e58963b5c0b1
image.m: Fix test for non-linearly spaced coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
13980
diff
changeset
|
126 dy = std (dy) / mean (abs (dy)); |
e58963b5c0b1
image.m: Fix test for non-linearly spaced coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
13980
diff
changeset
|
127 tol = 100*eps; |
e58963b5c0b1
image.m: Fix test for non-linearly spaced coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
13980
diff
changeset
|
128 if (any (dx > tol) || any (dy > tol)) |
13980
bd2be36fd949
image.m: Warn if input coordinates are not linearly spaced.
Ben Abbott <bpabbott@mac.com>
parents:
13173
diff
changeset
|
129 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
|
130 endif |
bd2be36fd949
image.m: Warn if input coordinates are not linearly spaced.
Ben Abbott <bpabbott@mac.com>
parents:
13173
diff
changeset
|
131 |
9899
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
132 ca = gca (); |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
133 |
10817
d9147775da54
image.m: Always reverse 'ydir' property when displaying images.
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
134 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
|
135 "cdatamapping", "direct", varargin {:}); |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10952
diff
changeset
|
136 |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10952
diff
changeset
|
137 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
|
138 |
2adf4736dafa
Do not store flipped image property values when x/ydata descends.
Ben Abbott <bpabbott@mac.com>
parents:
11080
diff
changeset
|
139 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
|
140 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
|
141 elseif (xdata(2) == xdata(1)) |
14872
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14260
diff
changeset
|
142 xdata = xdata(1) + [0, columns(img)-1]; |
11090
2adf4736dafa
Do not store flipped image property values when x/ydata descends.
Ben Abbott <bpabbott@mac.com>
parents:
11080
diff
changeset
|
143 endif |
2adf4736dafa
Do not store flipped image property values when x/ydata descends.
Ben Abbott <bpabbott@mac.com>
parents:
11080
diff
changeset
|
144 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
|
145 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
|
146 elseif (ydata(2) == ydata(1)) |
14872
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14260
diff
changeset
|
147 ydata = ydata(1) + [0, rows(img)-1]; |
11090
2adf4736dafa
Do not store flipped image property values when x/ydata descends.
Ben Abbott <bpabbott@mac.com>
parents:
11080
diff
changeset
|
148 endif |
11076
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10952
diff
changeset
|
149 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
|
150 ylim = ydata + [-px(2), px(2)]; |
9899
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
151 |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
152 ## 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
|
153 ## 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
|
154 ## 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
|
155 ## 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
|
156 ## 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
|
157 ## adjustment is necessary? |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
158 set (ca, "xlim", xlim, "ylim", ylim); |
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 if (ndims (img) == 3) |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
161 if (isinteger (img)) |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
162 c = class (img); |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
163 mn = intmin (c); |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
164 mx = intmax (c); |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
165 set (ca, "clim", double ([mn, mx])); |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
166 endif |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
167 endif |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
168 |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
169 set (ca, "view", [0, 90]); |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
170 |
11308
9a08fa5b33bd
image.m: Only flip y-axis if nextplot property equal "replace".
Ben Abbott <bpabbott@mac.com>
parents:
11109
diff
changeset
|
171 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
|
172 # 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
|
173 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
|
174 endif |
10817
d9147775da54
image.m: Always reverse 'ydir' property when displaying images.
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
175 |
9899
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
176 if (nargout > 0) |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
177 h = tmp; |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
178 endif |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
179 |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
180 endfunction |
10942
48a1812fcc3a
image.m: Matlab compatible axis limits, add demo.
Ben Abbott <bpabbott@mac.com>
parents:
10818
diff
changeset
|
181 |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
182 |
10942
48a1812fcc3a
image.m: Matlab compatible axis limits, add demo.
Ben Abbott <bpabbott@mac.com>
parents:
10818
diff
changeset
|
183 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
184 %! clf; |
14247
c4fa5e0b6193
test: Make surface demos reproducible by setting colormap to default at start of demo.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
185 %! colormap ("default"); |
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 %! 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
|
187 %! 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
|
188 %! y = x; |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
189 %! subplot (2,2,1); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
190 %! h = image (abs(x), abs(y), img); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
191 %! set (h, "cdatamapping", "scaled"); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
192 %! ylabel ("limits = [4.5, 15.5]"); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
193 %! title ("image (abs(x), abs(y), img)"); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
194 %! subplot (2,2,2); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
195 %! h = image (-x, y, img); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
196 %! set (h, "cdatamapping", "scaled"); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
197 %! title ("image (-x, y, img)"); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
198 %! subplot (2,2,3); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
199 %! h = image (x, -y, img); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
200 %! set (h, "cdatamapping", "scaled"); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
201 %! title ("image (x, -y, img)"); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
202 %! ylabel ("limits = [-5.5, 5.5]"); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
203 %! subplot (2,2,4); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
204 %! h = image (-x, -y, img); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
205 %! set (h, "cdatamapping", "scaled"); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
206 %! title ("image (-x, -y, img)"); |
10942
48a1812fcc3a
image.m: Matlab compatible axis limits, add demo.
Ben Abbott <bpabbott@mac.com>
parents:
10818
diff
changeset
|
207 |
13165
9efb676b34ac
Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents:
11587
diff
changeset
|
208 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
209 %! clf; |
14247
c4fa5e0b6193
test: Make surface demos reproducible by setting colormap to default at start of demo.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
210 %! colormap ("default"); |
13165
9efb676b34ac
Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents:
11587
diff
changeset
|
211 %! g = 0.1:0.1:10; |
9efb676b34ac
Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents:
11587
diff
changeset
|
212 %! h = g'*g; |
9efb676b34ac
Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents:
11587
diff
changeset
|
213 %! imagesc (g, g, sin (h)); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
214 %! hold on; |
13165
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)); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
216 %! axis ([0 10 0 22]); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
217 %! hold off; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
218 %! 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
|
219 |
13165
9efb676b34ac
Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents:
11587
diff
changeset
|
220 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
221 %! clf; |
14247
c4fa5e0b6193
test: Make surface demos reproducible by setting colormap to default at start of demo.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
222 %! colormap ("default"); |
13165
9efb676b34ac
Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents:
11587
diff
changeset
|
223 %! g = 0.1:0.1:10; |
9efb676b34ac
Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents:
11587
diff
changeset
|
224 %! h = g'*g; |
9efb676b34ac
Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents:
11587
diff
changeset
|
225 %! imagesc (g, g, sin (h)); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
226 %! hold all; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
227 %! plot (g, 11.0 * ones (size (g))); |
13165
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)); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
229 %! axis ([0 10 0 22]); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
230 %! hold off; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
231 %! title ("image, line, image"); |
13165
9efb676b34ac
Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents:
11587
diff
changeset
|
232 |
9efb676b34ac
Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents:
11587
diff
changeset
|
233 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
234 %! clf; |
14247
c4fa5e0b6193
test: Make surface demos reproducible by setting colormap to default at start of demo.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
235 %! colormap ("default"); |
13165
9efb676b34ac
Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents:
11587
diff
changeset
|
236 %! g = 0.1:0.1:10; |
9efb676b34ac
Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents:
11587
diff
changeset
|
237 %! h = g'*g; |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
238 %! plot (g, 10.5 * ones (size (g))); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
239 %! hold all; |
13165
9efb676b34ac
Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents:
11587
diff
changeset
|
240 %! imagesc (g, g, sin (h)); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
241 %! plot (g, 11.0 * ones (size (g))); |
13165
9efb676b34ac
Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents:
11587
diff
changeset
|
242 %! imagesc (g, g+12, cos (h/2)); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
243 %! plot (g, 11.5 * ones (size (g))); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
244 %! axis ([0 10 0 22]); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
245 %! hold off; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
246 %! title ("line, image, line, image, line"); |
13165
9efb676b34ac
Fix bug #34015. Allow for sequential images.
Ben Abbott <bpabbott@mac.com>
parents:
11587
diff
changeset
|
247 |
15064
489736962e80
image.m: Don't accept complex image data (bug #36866)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
248 ## Test input validation |
489736962e80
image.m: Don't accept complex image data (bug #36866)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
249 %!error <can not be complex> image (1+i) |
489736962e80
image.m: Don't accept complex image data (bug #36866)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
250 %!error <matrix is empty> image ([]) |