comparison scripts/image/image.m @ 18524:bf0d2e51c8f0 stable

axis.m: make 'tight' embrace whole images (bug #36594). * axis.m (__get_tight_lims__): extend image data limits by one pixel. * image.m: remove duplicate code and call "axis image" when there's no other child in the axes.
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Tue, 25 Feb 2014 23:56:49 +0100
parents 4bfd44c15145
children 3283ce934648
comparison
equal deleted inserted replaced
18519:c9ace0567f13 18524:bf0d2e51c8f0
181 181
182 if (do_new && ! ishold (hax)) 182 if (do_new && ! ishold (hax))
183 ## Set axis properties for new images 183 ## Set axis properties for new images
184 184
185 if (! isempty (img)) 185 if (! isempty (img))
186 px = __image_pixel_size__ (h); 186 if (isscalar (get (hax, "children")))
187 187 axis (hax, "image")
188 if (xdata(2) < xdata(1))
189 xdata = fliplr (xdata);
190 elseif (xdata(2) == xdata(1))
191 xdata = xdata(1) + [0, columns(img)-1];
192 endif 188 endif
193 if (ydata(2) < ydata(1))
194 ydata = fliplr (ydata);
195 elseif (ydata(2) == ydata(1))
196 ydata = ydata(1) + [0, rows(img)-1];
197 endif
198 xlim = xdata + [-px(1), px(1)];
199 ylim = ydata + [-px(2), px(2)];
200
201 ## FIXME -- how can we do this and also get the {x,y}limmode
202 ## properties to remain "auto"? I suppose this adjustment should
203 ## happen automatically in axes::update_axis_limits instead of
204 ## explicitly setting the values here. But then what information is
205 ## available to axes::update_axis_limits to determine that the
206 ## adjustment is necessary?
207 set (hax, "xlim", xlim, "ylim", ylim);
208 189
209 if (ndims (img) == 3) 190 if (ndims (img) == 3)
210 if (isinteger (img)) 191 if (isinteger (img))
211 cls = class (img); 192 cls = class (img);
212 mn = intmin (cls); 193 mn = intmin (cls);