Mercurial > hg > octave-nkf
changeset 6368:ec2a523713b5
[project @ 2007-02-28 22:07:24 by jwe]
author | jwe |
---|---|
date | Wed, 28 Feb 2007 22:07:24 +0000 |
parents | 268bfc8a2755 |
children | 16901a3e5416 |
files | scripts/ChangeLog scripts/image/image.m scripts/image/imagesc.m scripts/image/imshow.m scripts/plot/__uiobject_draw_axes__.m |
diffstat | 5 files changed, 80 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,10 @@ +2007-02-28 Daniel J Sebald <daniel.sebald@ieee.org> + + * plot/__uiobject_draw_axes__.m: Improve calculation of limits for + plots with images. + * image/image.m, image/imagesc.m, image/imshow.m: + Deprecate zoom argument. + 2007-02-28 John W. Eaton <jwe@octave.org> * plot/__uiobject_draw_axes__.m: Use fullfile to generate
--- a/scripts/image/image.m +++ b/scripts/image/image.m @@ -41,18 +41,26 @@ function image (x, y, img) - newplot (); + ## Deprecated zoom. Remove this hunk of code if old zoom argument + ## is outmoded. + if ((nargin == 2 && isscalar (y)) || nargin == 4) + warning ("image: zoom argument ignored -- use GUI features"); + endif + if (nargin == 4) + nargin = 3; + endif + if (nargin == 2 && isscalar (y)) + nargin = 1; + endif if (nargin == 0) ## Load Bobbie Jo Richardson (Born 3/16/94) img = loadimage ("default.img"); x = y = []; - elseif (nargin == 1 || nargin == 2) - ## FIXME -- should we handle the old zoom argument? How? What - ## figure property should we be setting? + elseif (nargin == 1) img = x; x = y = []; - elseif (nargin > 3) + elseif (nargin == 2 || nargin > 3) print_usage (); endif
--- a/scripts/image/imagesc.m +++ b/scripts/image/imagesc.m @@ -20,20 +20,18 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} imagesc (@var{A}) ## @deftypefnx {Function File} {} imagesc (@var{x}, @var{y}, @var{A}) -## @deftypefnx {Function File} {} imagesc (@dots{}, @var{zoom}) ## @deftypefnx {Function File} {} imagesc (@dots{}, @var{limits}) ## @deftypefnx {Function File} { @var{B} = } imagesc (@dots{}) ## Display a scaled version of the matrix @var{A} as a color image. The ## matrix is scaled so that its entries are indices into the current -## colormap. The scaled matrix is returned. If @var{zoom} is omitted, a -## comfortable size is chosen. If @var{limits} = [@var{lo}, @var{hi}] are +## colormap. The scaled matrix is returned. If @var{limits} = [@var{lo}, @var{hi}] are ## given, then that range maps into the full range of the colormap rather ## than the minimum and maximum values of @var{A}. ## ## The axis values corresponding to the matrix elements are specified in ## @var{x} and @var{y}, either as pairs giving the minimum and maximum ## values for the respective axes, or as values for each row and column -## of the matrix @var{A}. At present they are ignored. +## of the matrix @var{A}. ## @seealso{image, imshow} ## @end deftypefn @@ -41,34 +39,48 @@ ## Created: July 1994 ## Adapted-By: jwe -function ret = imagesc (x, y, A, zoom, limits) +function ret = imagesc (x, y, A, limits, DEPRECATEDZOOM) - if (nargin < 1 || nargin > 5) + ## Deprecated zoom. Remove this hunk of code if old zoom argument + ## is outmoded. + if ((nargin == 2 && isscalar (y)) + || (nargin == 3 && (isscalar (y) || isscalar (A))) + || (nargin == 4 && isscalar (limits)) + || nargin == 5) + warning ("image: zoom argument ignored -- use GUI features"); + endif + if (nargin == 5) + if (isscalar (limits)) + limits = DEPRECATEDZOOM; + endif + nargin = 4; + endif + if (nargin == 4 && isscalar (limits)) + nargin = 3; + endif + if (nargin == 3 && (isscalar (y) || isscalar (A))) + if (isscalar (y)) + y = A; + endif + nargin = 2; + endif + if (nargin == 2 && isscalar (y)) + nargin = 1; + endif + + if (nargin < 1 || nargin > 4) print_usage (); elseif (nargin == 1) A = x; - zoom = x = y = limits = []; + x = y = limits = []; elseif (nargin == 2) A = x; - zoom = y; - x = y = limits = []; - elseif (nargin == 3) - ## Assume imagesc(x,y,A) for compatibility. It - ## could also be imagesc(A,limits,zoom), but if A is - ## a 1x2 vector, this is equivalent to imagesc(x,y,A) - ## for scalar A so we won't try to guess. - zoom = limits = []; - elseif (nargin == 4) + limits = y; + x = y = []; + elseif (nargin == 3 && !isscalar (x) && !isscalar (y) && !isscalar (A)) limits = []; endif - ## correct for zoom, limits parameter order - if (length (zoom) == 2) - swap = limits; - limits = zoom; - zoom = swap; - endif - ## use given limits or guess them from the matrix if (length (limits) == 2 && limits(2) >= limits(1)) minval = limits(1); @@ -92,7 +104,7 @@ ## display or return the image if (nargout == 0) - image (x, y, B, zoom); + image (x, y, B); else ret = B; endif
--- a/scripts/image/imshow.m +++ b/scripts/image/imshow.m @@ -24,7 +24,7 @@ ## @deftypefnx {Function File} {} imshow (@var{R}, @var{G}, @var{B}, @dots{}) ## @deftypefnx {Function File} {} imshow (@var{filename}) ## @deftypefnx {Function File} {} imshow (@dots{}, @var{string_param1}, @var{value1}, @dots{}) -## Display the image @var{im}, where @var{im} can a 2-dimensional +## Display the image @var{im}, where @var{im} can be a 2-dimensional ## (gray-scale image) or a 3-dimensional (RGB image) matrix. If three matrices ## of the same size are given as arguments, they will be concatenated into ## a 3-dimensional (RGB image) matrix. @@ -44,12 +44,8 @@ ## If given, the parameter @var{string_param1} has value ## @var{value1}. @var{string_param1} can be any of the following: ## @table @samp -## @item "display_range" +## @item "displayrange" ## @var{value1} is the display range as described above. -## -## @item "InitialMagnification" -## @var{value1} sets the zoom level in percent. -## If @var{value1} is 100 the image is showed unscaled. ## @end table ## @seealso{image, imagesc, colormap, gray2ind, rgb2ind} ## @end deftypefn @@ -110,14 +106,14 @@ elseif (ismatrix (arg) && size (arg, 2) == 3) color_map = arg; isindexed = true; - elseif (ischar (arg) && strcmpi (arg, "truesize")) - initial_magnification = 100; elseif (ischar (arg) && strcmpi (arg, "displayrange")) narg++; display_range = varargin{narg}; - elseif (ischar (arg) && strcmpi (arg, "initialmagnification")) + elseif (ischar (arg) && + (strcmpi (arg, "truesize") || + strcmpi (arg, "initialmagnification"))) narg++; - initial_magnification = varargin{narg}; + warning ("image: zoom argument ignored -- use GUI features"); else warning ("imshow: input argument number %d is unsupported", narg) endif @@ -145,11 +141,11 @@ im(im < 0) = 0; im(im > 1) = 1; endif - + dim = ndims (im); if (dim == 2) im = round ((size (color_map, 1) - 1) * im); - image (im, initial_magnification/100); + image (im); colormap (color_map); elseif (dim == 3 && size (im, 3) == 3) __img__ ([] , [], im); @@ -171,10 +167,6 @@ %! imshow (loadimage ("default.img")); %!demo -%! I = loadimage ("default.img"); -%! imshow (I, "truesize") - -%!demo %! [I, M] = loadimage ("default.img"); %! imshow (I, M);
--- a/scripts/plot/__uiobject_draw_axes__.m +++ b/scripts/plot/__uiobject_draw_axes__.m @@ -272,6 +272,22 @@ x_origin = min (img_xdata); y_origin = min (img_ydata); + if (nd == 2) + if (xautoscale) + xmin = min (xmin, min (img_xdata) - dx/2); + xmax = max (xmax, max (img_xdata) + dx/2); + xminp = min (xminp, min (img_xdata((img_xdata - dx/2)>0)) - dx/2); + endif + if (yautoscale) + ymin = min (ymin, min (img_ydata) - dy/2); + ymax = max (ymax, max (img_ydata) + dy/2); + yminp = min (yminp, min (img_ydata((img_ydata - dy/2)>0)) - dy/2); + endif + else + ## Can have images in 3D, but the image routines don't seem + ## to have a means of arbitrary projection. + endif + ## Let the file be deleted when Octave exits or `purge_tmp_files' ## is called. [img_fid, img_fname] = mkstemp (fullfile (P_tmpdir, "gpimageXXXXXX"), 1);