Mercurial > octave
comparison scripts/image/image.m @ 10942:48a1812fcc3a
image.m: Matlab compatible axis limits, add demo.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Fri, 03 Sep 2010 08:04:10 -0400 |
parents | 947adebb1336 |
children | 18b0af0bbd6b |
comparison
equal
deleted
inserted
replaced
10941:97294dd3ccd4 | 10942:48a1812fcc3a |
---|---|
117 endif | 117 endif |
118 | 118 |
119 xdata = [x(1), x(end)]; | 119 xdata = [x(1), x(end)]; |
120 ydata = [y(1), y(end)]; | 120 ydata = [y(1), y(end)]; |
121 | 121 |
122 xlim = [x(1)-0.5, x(end)+0.5]; | 122 c = size (img, 2); |
123 ylim = [y(1)-0.5, y(end)+0.5]; | 123 xlim = 0.5 * ((x(end) - x(1)) * c / (c - 1) * [-1, 1] + (x(1) + x(end))); |
124 | 124 |
125 r = size (img, 1); | |
126 ylim = 0.5 * ((y(end) - y(1)) * r / (r - 1) * [-1, 1] + (y(1) + y(end))); | |
127 | |
125 ca = gca (); | 128 ca = gca (); |
126 | 129 |
127 tmp = __go_image__ (ca, "cdata", img, "xdata", xdata, "ydata", ydata, | 130 tmp = __go_image__ (ca, "cdata", img, "xdata", xdata, "ydata", ydata, |
128 "cdatamapping", "direct", varargin {:}); | 131 "cdatamapping", "direct", varargin {:}); |
129 | 132 |
152 if (nargout > 0) | 155 if (nargout > 0) |
153 h = tmp; | 156 h = tmp; |
154 endif | 157 endif |
155 | 158 |
156 endfunction | 159 endfunction |
160 | |
161 %!demo | |
162 %! img = 1 ./ hilb (10); | |
163 %! x = 20 * rand (1, 41) - 20; | |
164 %! y = -1:1; | |
165 %! h = image (x, y, img); | |
166 %! set (h, "cdatamapping", "scaled") | |
167 |