# HG changeset patch # User jwe # Date 1155846674 0 # Node ID 8702f00329bf158abb07de4f45615385cdbdbf81 # Parent 1bcd9dd629c3456e74adca9cc3f40cbc7bf01641 [project @ 2006-08-17 20:29:51 by jwe] diff -r 1bcd9dd629c3 -r 8702f00329bf ChangeLog --- a/ChangeLog Thu Aug 17 08:01:14 2006 +0000 +++ b/ChangeLog Thu Aug 17 20:31:14 2006 +0000 @@ -1,3 +1,9 @@ +2006-08-17 John W. Eaton + + * aclocal.m4 (OCTAVE_PROG_GHOSTSCRIPT, OCTAVE_PROG_MAKEINFO, + OCTAVE_PROG_TEXI2DVI, OCTAVE_PROG_TEXI2PDF): New macros. + * configure.in: Use them. Maybe print warnings in summary. + 2006-07-27 John W. Eaton * Makeconf.in (localapiarchlibdir): Substitute it here. diff -r 1bcd9dd629c3 -r 8702f00329bf Makeconf.in --- a/Makeconf.in Thu Aug 17 08:01:14 2006 +0000 +++ b/Makeconf.in Thu Aug 17 20:31:14 2006 +0000 @@ -59,9 +59,11 @@ RUNTEST = @RUNTEST@ -MAKEINFO = makeinfo -TEXI2DVI = texi2dvi -TEXI2PDF = texi2pdf +MAKEINFO = @MAKEINFO@ +TEXI2DVI = @TEXI2DVI@ +TEXI2PDF = @TEXI2PDF@ + +GHOSTSCRIPT = @GHOSTSCRIPT@ DEFAULT_PAGER = @DEFAULT_PAGER@ diff -r 1bcd9dd629c3 -r 8702f00329bf aclocal.m4 --- a/aclocal.m4 Thu Aug 17 08:01:14 2006 +0000 +++ b/aclocal.m4 Thu Aug 17 20:31:14 2006 +0000 @@ -560,6 +560,58 @@ AC_SUBST(GPERF) ]) dnl +dnl Is ghostscript installed? +dnl +dnl OCTAVE_PROG_GHOSTSCRIPT +AC_DEFUN(OCTAVE_PROG_GHOSTSCRIPT, [ + AC_CHECK_PROG(GHOSTSCRIPT, gs, gs, []) + if test -z "$GHOSTSCRIPT"; then + GHOSTSCRIPT='$(top_srcdir)/missing gs' + warn_ghostscript="I didn't find ghostscript, but it's only a problem if you need to reconstruct figures for the manual" + AC_MSG_WARN($warn_ghostscript) + fi + AC_SUBST(GHOSTSCRIPT) +]) +dnl +dnl Is makeinfo installed? +dnl +dnl OCTAVE_PROG_MAKEINFO +AC_DEFUN(OCTAVE_PROG_MAKEINFO, [ + AC_CHECK_PROG(MAKEINFO, makeinfo, makeinfo, []) + if test -z "$MAKEINFO"; then + MAKEINFO='$(top_srcdir)/missing makeinfo' + warn_makeinfo="I didn't find makeinfo, but it's only a problem if you need to reconstruct the Info version of the manual" + AC_MSG_WARN($warn_makeinfo) + fi + AC_SUBST(MAKEINFO) +]) +dnl +dnl Is texi2dvi installed? +dnl +dnl OCTAVE_PROG_TEXI2DVI +AC_DEFUN(OCTAVE_PROG_TEXI2DVI, [ + AC_CHECK_PROG(TEXI2DVI, texi2dvi, texi2dvi, []) + if test -z "$TEXI2DVI"; then + TEXI2DVI='$(top_srcdir)/missing texi2dvi' + warn_texi2dvi="I didn't find texi2dvi, but it's only a problem if you need to reconstruct the DVI version of the manual" + AC_MSG_WARN($warn_texi2dvi) + fi + AC_SUBST(TEXI2DVI) +]) +dnl +dnl Is texi2pdf installed? +dnl +dnl OCTAVE_PROG_TEXI2PDF +AC_DEFUN(OCTAVE_PROG_TEXI2PDF, [ + AC_CHECK_PROG(TEXI2PDF, texi2pdf, texi2pdf, []) + if test -z "$TEXI2PDF"; then + TEXI2PDF='$(top_srcdir)/missing texi2pdf' + warn_texi2pdf="I didn't find texi2pdf, but it's only a problem if you need to reconstruct the PDF version of the manual" + AC_MSG_WARN($warn_texi2pdf) + fi + AC_SUBST(TEXI2PDF) +]) +dnl dnl Find nm. dnl dnl OCTAVE_PROG_NM diff -r 1bcd9dd629c3 -r 8702f00329bf configure.in --- a/configure.in Thu Aug 17 08:01:14 2006 +0000 +++ b/configure.in Thu Aug 17 20:31:14 2006 +0000 @@ -29,7 +29,7 @@ EXTERN_CXXFLAGS="$CXXFLAGS" AC_INIT -AC_REVISION($Revision: 1.518 $) +AC_REVISION($Revision: 1.519 $) AC_PREREQ(2.57) AC_CONFIG_SRCDIR([src/octave.cc]) AC_CONFIG_HEADER(config.h) @@ -1531,6 +1531,11 @@ OCTAVE_PROG_PAGER OCTAVE_PROG_GPERF +OCTAVE_PROG_GHOSTSCRIPT +OCTAVE_PROG_MAKEINFO +OCTAVE_PROG_TEXI2DVI +OCTAVE_PROG_TEXI2PDF + ### Even though we include config.h, we need to have the preprocessor ### defines available in a variable for the octave-bug script. Use ### UGLY_DEFS for that. @@ -1898,6 +1903,26 @@ warn_msg_printed=true fi +if test -n "$warn_ghostscript"; then + AC_MSG_WARN($warn_ghostscript) + warn_msg_printed=true +fi + +if test -n "$warn_makeinfo"; then + AC_MSG_WARN($warn_makeinfo) + warn_msg_printed=true +fi + +if test -n "$warn_texi2dvi"; then + AC_MSG_WARN($warn_texi2dvi) + warn_msg_printed=true +fi + +if test -n "$warn_texi2pdf"; then + AC_MSG_WARN($warn_texi2pdf) + warn_msg_printed=true +fi + if test -n "$warn_64_bit"; then AC_MSG_WARN($warn_64_bit) warn_msg_printed=true diff -r 1bcd9dd629c3 -r 8702f00329bf doc/ChangeLog --- a/doc/ChangeLog Thu Aug 17 08:01:14 2006 +0000 +++ b/doc/ChangeLog Thu Aug 17 20:31:14 2006 +0000 @@ -1,3 +1,8 @@ +2006-08-17 John W. Eaton + + * interpreter/images/Makefile.in (%.pdf : %eps): + Use $(GHOSTSCRIPT) instead of gs. + 2006-08-14 Dmitri A. Sergatskov * interpreter/images/sparseimages.m: Adapt to new automatic_replot diff -r 1bcd9dd629c3 -r 8702f00329bf doc/interpreter/images/Makefile.in --- a/doc/interpreter/images/Makefile.in Thu Aug 17 08:01:14 2006 +0000 +++ b/doc/interpreter/images/Makefile.in Thu Aug 17 20:31:14 2006 +0000 @@ -12,8 +12,10 @@ SPARSEIMAGES = \ $(addsuffix .eps, $(SPARSEIMAGES_1)) \ $(addsuffix .png, $(SPARSEIMAGES_1)) \ - $(addsuffix .txt, $(SPARSEIMAGES_1)) -IMAGES += $(SPARSEIMAGES) $(addsuffix .pdf, $(SPARSEIMAGES_1)) + $(addsuffix .txt, $(SPARSEIMAGES_1)) \ + $(addsuffix .pdf, $(SPARSEIMAGES_1)) + +IMAGES = $(SPARSEIMAGES) DISTFILES = Makefile.in $(SOURCES) $(IMAGES) @@ -29,7 +31,7 @@ $(run-octave) %.pdf : %.eps - if [ -f $< ] ; then gs -dBATCH -dEPSCrop -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=$@ $< ; fi + if [ -f $< ] ; then $(GHOSTSCRIPT) -dBATCH -dEPSCrop -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=$@ $< ; fi install install-strip: .PHONY: install install-strip diff -r 1bcd9dd629c3 -r 8702f00329bf scripts/ChangeLog --- a/scripts/ChangeLog Thu Aug 17 08:01:14 2006 +0000 +++ b/scripts/ChangeLog Thu Aug 17 20:31:14 2006 +0000 @@ -1,3 +1,7 @@ +2006-08-14 Søren Hauberg + + * image/imshow.m: New Matlab-compatible version. + 2006-08-15 John W. Eaton * deprecated/is_global.m: Delete. diff -r 1bcd9dd629c3 -r 8702f00329bf scripts/image/imshow.m --- a/scripts/image/imshow.m Thu Aug 17 08:01:14 2006 +0000 +++ b/scripts/image/imshow.m Thu Aug 17 20:31:14 2006 +0000 @@ -1,5 +1,5 @@ -## Copyright (C) 1996, 1997 John W. Eaton -## +## Copyright (C) 2005 Soren Hauberg +## ## This file is part of Octave. ## ## Octave is free software; you can redistribute it and/or modify it @@ -18,172 +18,149 @@ ## 02110-1301, USA. ## -*- texinfo -*- -## @deftypefn {Function File} {} imshow (@var{i}) -## @deftypefnx {Function File} {} imshow (@var{x}, @var{map}) -## @deftypefnx {Function File} {} imshow (@var{i}, @var{n}) -## @deftypefnx {Function File} {} imshow (@var{r}, @var{g}, @var{b}) -## Display an image. +## @deftypefn {Function File} {} imshow (@var{im}) +## @deftypefnx {Function File} {} imshow (@var{im}, @var{limits}) +## @deftypefnx {Function File} {} imshow (@var{im}, @var{map}) +## @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}, ...) +## Display the image @var{im}, where @var{im} can 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. +## +## If @var{limits} is a 2-element vector @code{[@var{low}, @var{high}]}, +## the image is shown using a display range between @var{low} and +## @var{high}. If an empty matrix is passed for @var{limits}, the +## display range is computed as the range between the minimal and the +## maximal value in the image. ## -## @code{imshow (@var{x})} displays an image @var{x}. -## The numerical class of the image determines its bit-depth: 1 for -## @code{logical}, 8 for @code{uint8} and @code{logical}, and 16 for -## @code{double} or @code{uint16}. If @var{x} has dimensions MxNx3, the -## three matrices represent the red, green and blue components of the -## image. +## If @var{map} is a valid color map, the image will be shown as an indexed +## image using the supplied color map. +## +## If a file name is given instead of an image, the file will be read and +## shown. ## -## @code{imshow (@var{x}, @var{map})} displays an indexed image using the -## specified colormap. +## 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" +## @var{value1} is the display range as described above. ## -## @code{imshow (@var{i}, @var{n})} displays a gray scale intensity image of -## N levels. -## -## @code{imshow (@var{r}, @var{g}, @var{b})} displays an RGB image. -## -## The character string @code{"truesize"} can always be used as an -## optional final argument to prevent automatic zooming of the image. +## @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 -## Author: Tony Richardson -## Created: July 1994 +## Author: Soren Hauberg ## Adapted-By: jwe -function imshow (varargin) - - usage_str = "imshow (x) or imshow (x, map) or imshow (i, N) or imshow (r, g, b)"; +function imshow (im, varargin) - if (nargin == 0 || nargin > 4) - usage (usage_str); - endif - - ## Count nr of matrix arguments. - mvars = 0; - while (mvars < nargin && ismatrix (varargin{mvars+1})) - mvars++; - endwhile - - if (mvars < 1 || mvars > 3) - usage (usage_str); - endif - - ## Determine image depth - imclass = class (varargin{1}); - s = __im_numeric_limits__ (imclass); - if (!isfield (s, "max")) - error ("imshow: cannot handle image class '%s'", imclass); + if (nargin == 0) + print_usage (); endif - ## Maximum bit-depth is 16 - if (s.max > 65535) - s.max = 65535; - endif - - imdepth = log (s.max+1) / log (2); - if (imdepth - floor (imdepth) != 0) - error ("imshow: cannot determine image colour depth"); + ## Get the image + if (ischar (im)) + im = loadimage (im); # It would be better to use imread from octave-forge + elseif (! ismatrix (im)) + error ("imshow: first argument must be an image or the filename of an image"); endif - ## Remove complex parts of arguments - realwarning = false; - for i = 1:mvars - if (iscomplex (varargin{i})) - if (!realwarning) - warning ("imshow: displaying real part of complex image"); - realwarning = true; - endif - varargin{i} = real (varargin{i}); - endif - endfor - - ## Pack r,g,b image into ND-matrix if necessary - if (mvars == 3) - I = []; - try - I = cat (3, varargin{1:3}); - catch - error ("imshow: r, g and b matrix dimensions must agree"); - end_try_catch - else - I = varargin{1}; - endif - I = double (I); - - ## Is the image specified as MxNx3 colour? - iscolour = false; - if (size (I,3) == 3) - iscolour = true; + ## Is the function called with 3 matrices (i.e., imshow (R, G, B))? + if (nargin >= 3 + && ndims (im) == 2 + && ndims (varargin{1}) == 2 + && ndims (varargin{2}) == 2 + && size (im) == size (varargin{1}) + && size (im) == size (varargin{2})) + im(:,:,3) = varargin{2}; + im(:,:,2) = varargin{1}; + varargin(1:2) = []; endif - ## Is the image indexed? + ## Set default display range. + switch class (im) + case {"uint8"} + display_range = [0, 255]; + case {"uint16"} + display_range = [0, 65535]; + case {"double", "single", "logical"} + display_range = [0, 1]; + otherwise + error ("imshow: currently only images whos class is uint8, uint16, logical, or double are supported"); + endswitch + + ## Set other default parameters. isindexed = false; - if (mvars == 2) - isindexed = true; - if (iscolour) - error ("imshow: cannot provide colour image and colourmap"); - endif - endif + initial_magnification = 100; + old_colormap = color_map = colormap (); - ## Scale images of class "double" appropriately - if (!isindexed) - if (strcmp (imclass, "double") == 1) - if (max (I(:)) <= 1) - ## image in [0-1]; scale to [0 - 2^imdepth] - I = I * 2^imdepth; - else - ## image outside [0-1]; this is unexpected: scale to [0 - 2^imdepth] - I = I / max (I(:)) * 2^imdepth; - endif + ## Handle the rest of the arguments. + narg = 1; + while (narg <= length (varargin)) + arg = varargin{narg}; + if (ismatrix (arg) && ndims (arg) == 2) + display_range = arg; + elseif (isempty (arg)) + display_range = [min(im(:)), max(im(:))]; + 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")) + narg++; + initial_magnification = varargin{narg}; + else + warning ("imshow: input argument number %d is unsupported", narg) endif + narg++; + endwhile + + ## Check for complex images + if (iscomplex (im)) + warning ("imshow: only showing real part of complex image"); + im = real (im); endif - ## Generate colour map - if (isindexed) - M = varargin{2}; - if (isscalar (M)) - M = gray (M); - endif - elseif (iscolour) - I = I / 2^imdepth; - [I, M] = rgb2ind (I(:,:,1), I(:,:,2), I(:,:,3)); - else - I = I+1; ## index into colourmap - M = gray (2^imdepth); + ## Scale the image to the interval [0, 1] according to display_range. + if (! isindexed) + low = display_range(1); + high = display_range(2); + im = (double (im) - low)/(high-low); + im(im < 0) = 0; + im(im > 1) = 1; endif - ## Check for "truesize". - zoom = []; - for i = mvars+1:nargin - if (ischar (varargin{i}) && strcmp (varargin{i}, "truesize")) - zoom = 1; - endif - endfor - - colormap (M); - image (I, zoom); + ## Convert to indexed image + dim = ndims (im); + if (dim == 2) + im = round ((size (color_map, 1) - 1) * im); + elseif (dim == 3 && size (im, 3) == 3) + [im, color_map] = rgb2ind (im(:,:,1), im(:,:,2), im(:,:,3)); + #[im, color_map] = rgb2ind (im); # Change rgb2ind to support ND-arrays and then use this line + else + error ("imshow: input image must be a 2D or 3D matrix"); + endif + + ## And now, we show the image + colormap (color_map); + image (im, initial_magnification/100); + colormap (old_colormap); endfunction -function s = __im_numeric_limits__ (cname) - s = struct (); - switch (cname) - case ("double") - s.max = realmax; - case ("char") - s.max = 255; - case ("logical") - s.max = 1; - otherwise - try - s.max = double (intmax (cname)); - catch - end_try_catch - endswitch -endfunction - %!error imshow () # no arguments -%!error imshow (1, 2, 3, 4, 5) # too many arguments -%!error imshow ([1,2], [2,3], [3,4], [4,5]) # too many matrix arguments -%!error imshow ("image.png") # filename not accepted as argument +%!error imshow ({"cell"}) # No image or filename given +%!error imshow (int8(1)) # Unsupported image class +%!error imshow (ones(4,4,4)) # Too many dimensions in image %!demo %! imshow (loadimage ("default.img")); @@ -198,13 +175,8 @@ %!demo %! [I, M] = loadimage ("default.img"); -%! imshow (I, I*0.5, I*0.8); +%! imshow (cat(3, I, I*0.5, I*0.8)); %!demo -%! [I, M] = loadimage ("default.img"); -%! X = []; -%! X = cat (3, X, I*0.8); -%! X = cat (3, X, I*0.8); -%! X = cat (3, X, I); -%! imshow (X); - +%! I = loadimage("default.img"); +%! imshow(I, I, I);