comparison scripts/image/image.m @ 11076:b748b86cb8c1

fix images with width or height of 1
author Shai Ayal <shaiay@users.sourceforge.net>
date Mon, 04 Oct 2010 21:35:02 +0200
parents 18b0af0bbd6b
children 36ceff79607b
comparison
equal deleted inserted replaced
11075:4e31d44a9763 11076:b748b86cb8c1
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 c = size (img, 2);
123 if (c > 1)
124 xlim = 0.5 * (diff (xdata) * c / (c - 1) * [-1, 1] + sum (xdata));
125 elseif (numel (unique (x)) > 1)
126 xlim = xdata;
127 elseif (x(1) != 0)
128 xlim = [0, x];
129 else
130 xlim = [0, 1];
131 endif
132
133 r = size (img, 1);
134 if (r > 1)
135 ylim = 0.5 * (diff (ydata) * r / (r - 1) * [-1, 1] + sum (ydata));
136 elseif (numel (unique (y)) > 1)
137 ylim = ydata;
138 elseif (y(1) != 0)
139 ylim = [0, y];
140 else
141 ylim = [0, 1];
142 endif
143
144 ca = gca (); 122 ca = gca ();
145 123
146 tmp = __go_image__ (ca, "cdata", img, "xdata", xdata, "ydata", ydata, 124 tmp = __go_image__ (ca, "cdata", img, "xdata", xdata, "ydata", ydata,
147 "cdatamapping", "direct", varargin {:}); 125 "cdatamapping", "direct", varargin {:});
126
127 px = __image_pixel_size__ (tmp);
128 xlim = xdata + [-px(1), px(1)];
129 ylim = ydata + [-px(2), px(2)];
148 130
149 ## FIXME -- how can we do this and also get the {x,y}limmode 131 ## FIXME -- how can we do this and also get the {x,y}limmode
150 ## properties to remain "auto"? I suppose this adjustment should 132 ## properties to remain "auto"? I suppose this adjustment should
151 ## happen automatically in axes::update_axis_limits instead of 133 ## happen automatically in axes::update_axis_limits instead of
152 ## explicitly setting the values here. But then what information is 134 ## explicitly setting the values here. But then what information is