changeset 11109:41d18f6342f9

remove image_viewer function
author John W. Eaton <jwe@octave.org>
date Mon, 18 Oct 2010 14:15:06 -0400
parents 78a6016875ed
children 0be2d25700a7
files NEWS doc/ChangeLog doc/interpreter/image.txi scripts/ChangeLog scripts/image/image.m scripts/image/image_viewer.m scripts/image/module.mk scripts/plot/__go_draw_axes__.m
diffstat 8 files changed, 73 insertions(+), 257 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Mon Oct 18 16:53:57 2010 +0200
+++ b/NEWS	Mon Oct 18 14:15:06 2010 -0400
@@ -225,7 +225,6 @@
     from a function using the built-in function `isargout'.
     For more details, consult the manual.
 
-
  ** The list datatype, deprecated since the introduction of cells, has
     been removed.
 
@@ -323,7 +322,11 @@
       cbrt         ifelse       onCleanup    randi        whitebg
       chop         ishermitian  pbaspect     repelems     
       daspect      isindex      powerset     reset
-  
+
+  ** Using the image function to view images with external programs such
+     as display, xv, and xloadimage is no longer supported.  The
+     image_viewer function has also been removed.
+
   ** The behavior of struct assignments to non-struct values has been changed.
      Previously, it was possible to overwrite an arbitrary value:
       
--- a/doc/ChangeLog	Mon Oct 18 16:53:57 2010 +0200
+++ b/doc/ChangeLog	Mon Oct 18 14:15:06 2010 -0400
@@ -1,3 +1,8 @@
+2010-10-18  John W. Eaton  <jwe@octave.org>
+
+	* interpreter/image.txi (Displaying Images):
+	Delete documentation for image_viewer.
+
 2010-10-17  John W. Eaton  <jwe@octave.org>
 
 	* interpreter/strings.txi: Document untabify.
--- a/doc/interpreter/image.txi	Mon Oct 18 16:53:57 2010 +0200
+++ b/doc/interpreter/image.txi	Mon Oct 18 14:15:06 2010 -0400
@@ -82,11 +82,7 @@
 
 A natural part of image processing is visualization of an image.
 The most basic function for this is the @code{imshow} function that
-shows the image given in the first input argument.  This function uses
-an external program to show the image.  If gnuplot 4.2 or later is 
-available it will be used to display the image, otherwise the
-@code{display}, @code{xv}, or @code{xloadimage} program is used.  The
-actual program can be selected with the @code{image_viewer} function.
+shows the image given in the first input argument.
 
 @DOCSTRING(imshow)
 
@@ -94,8 +90,6 @@
 
 @DOCSTRING(imagesc)
 
-@DOCSTRING(image_viewer)
-
 @node Representing Images
 @section Representing Images
 
--- a/scripts/ChangeLog	Mon Oct 18 16:53:57 2010 +0200
+++ b/scripts/ChangeLog	Mon Oct 18 14:15:06 2010 -0400
@@ -1,3 +1,11 @@
+2010-10-18  John W. Eaton  <jwe@octave.org>
+
+	* plot/__go_draw_axes__.m: Always use gnuplot to display images.
+	* image/image.m: Delete references to image_viewer.
+	* image/image_viewer.m: Delete obsolete function.
+	* image/module.mk (image_FCN_FILES): Remove image/image_viewer.m
+	from the list.
+
 2010-10-18  Gunnar Farneback <gunnar@lysator.liu.se>
 
 	* general/interp2.m: Fix input checks for cubic
--- a/scripts/image/image.m	Mon Oct 18 16:53:57 2010 +0200
+++ b/scripts/image/image.m	Mon Oct 18 14:15:06 2010 -0400
@@ -24,11 +24,6 @@
 ## into the current colormap, and the colormap will be scaled so that the
 ## extremes of @var{x} are mapped to the extremes of the colormap.
 ##
-## It first tries to use @code{gnuplot}, then @code{display} from 
-## @code{ImageMagick}, then @code{xv}, and then @code{xloadimage}.
-## The actual program used can be changed using the @code{image_viewer}
-## function.
-##
 ## The axis values corresponding to the matrix elements are specified in
 ## @var{x} and @var{y}.  If you're not using gnuplot 4.2 or later, these
 ## variables are ignored.
@@ -37,11 +32,11 @@
 ## upper left.  For ordinary plots, the origin is located in the lower
 ## left.  Octave handles this inversion by plotting the data normally,
 ## and then reversing the direction of the y-axis by setting the
-## @code{ydir} property to "reverse".  This has implications whenever
+## @code{ydir} property to @code{"reverse"}.  This has implications whenever
 ## an image and an ordinary plot need to be overlaid.  The recommended
 ## solution is to display the image and then plot the reversed ydata
 ## using, for example, @code{flipud (ydata,1)}.
-## @seealso{imshow, imagesc, colormap, image_viewer}
+## @seealso{imshow, imagesc, colormap}
 ## @end deftypefn
 
 ## Author: Tony Richardson <arichard@stark.cc.oh.us>
--- a/scripts/image/image_viewer.m	Mon Oct 18 16:53:57 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,172 +0,0 @@
-## Copyright (C) 2006, 2007, 2008, 2009 S�ren Hauberg
-##
-## This file is part of Octave.
-##
-## Octave is free software; you can redistribute it and/or modify it
-## under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 3 of the License, or (at
-## your option) any later version.
-##
-## Octave is distributed in the hope that it will be useful, but
-## WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-## General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with Octave; see the file COPYING.  If not, see
-## <http://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn {Function File} {[@var{fcn}, @var{default_zoom}] =} image_viewer (@var{fcn}, @var{default_zoom})
-## Change the program or function used for viewing images and return the
-## previous values.
-##
-## When the @code{image} or @code{imshow} function is called it will
-## launch an external program to display the image.  The default behavior
-## is to use gnuplot if the installed version supports image viewing,
-## and otherwise try the programs @code{display}, @code{xv}, and
-## @code{xloadimage}.  Using this function it is possible to change that
-## behavior.
-##
-## When called with one input argument images will be displayed by saving
-## the image to a file and the system command @var{command} will be called
-## to view the image.  The @var{command} must be a string containing
-## @code{%s} and possibly @code{%f}.  The @code{%s} will be replaced by
-## the filename of the image, and the @code{%f} will (if present) be
-## replaced by the zoom factor given to the @code{image} function.
-## For example,
-##
-## @example
-## image_viewer ("eog %s");
-## @end example
-##
-## @noindent
-## changes the image viewer to the @code{eog} program.
-##
-## With two input arguments, images will be displayed by calling
-## the function @var{function_handle}.  For example,
-##
-## @example
-## image_viewer (data, @@my_image_viewer);
-## @end example
-##
-## @noindent
-## sets the image viewer function to @code{my_image_viewer}.  The image
-## viewer function is called with
-##
-## @example
-## my_image_viewer (@var{x}, @var{y}, @var{im}, @var{zoom}, @var{data})
-## @end example
-##
-## @noindent
-## where @var{x} and @var{y} are the axis of the image, @var{im} is the image
-## variable, and @var{data} is extra user-supplied data to be passed to
-## the viewer function.
-##
-## With three input arguments it is possible to change the zooming.
-## Some programs (like @code{xloadimage}) require the zoom factor to be
-## between 0 and 100, and not 0 and 1 like Octave assumes.  This is
-## solved by setting the third argument to 100.
-##
-## @seealso{image, imshow}
-## @end deftypefn
-
-function [ocmd, ofcn, ozoom] = image_viewer (cmd, fcn, zoom)
-
-  persistent view_cmd;
-  persistent view_fcn;
-  persistent view_zoom = 1;
-
-  if (isempty (view_fcn))
-    if (isempty (view_cmd)
-        && compare_versions (__gnuplot_version__ (), "4.0", ">"))
-      view_fcn = "gnuplot_internal";
-    else
-      view_fcn = @__img_via_file__;
-    endif
-  endif
-
-  if (nargin > 3)
-    print_usage ();
-  endif
-
-  if (nargout > 0)
-    ocmd = view_cmd;
-    ofcn = view_fcn;
-    ozoom = view_zoom;
-  endif
-
-  if (nargin > 0)
-
-    if (nargin < 3)
-      zoom = 1;
-      if (nargin < 2)
-        fcn = [];
-      endif
-    endif
-
-    view_cmd = cmd;
-    view_fcn = fcn;
-    view_zoom = zoom;
-
-    if (nargin > 1)
-      if (isa (fcn, "function_handle"))
-        view_fcn = fcn;
-      else
-        error ("image_viewer: expecting second argument to be a function handle");
-      endif
-    endif
-
-    if (nargin > 2)
-      if (isnumeric (zoom) && isscalar (zoom) && isreal (zoom))
-        view_zoom = zoom;
-      else
-        error ("image_viewer: expecting third argument to be a real scalar");
-      endif
-    endif
-
-  endif
-
-endfunction
-
-## Display an image by saving it to a file in PPM format and launching
-## @var{command}.
-##
-## The @var{command} must be a format string containing @code{%s} and
-## possibly @code{%f}.  The @code{%s} will be replaced by the filename
-## of the image, and the @code{%f} will be replaced by @var{zoom}. The
-## @var{x} and @var{y} arguments are ignored.
-
-function __img_via_file__ (x, y, im, zoom, command)
-
-  ppm_name = tmpnam ();
-  saveimage (ppm_name, im, "ppm");
-
-  rm = sprintf ("rm -f \"%s\"", ppm_name);
-
-  if (isempty (command))
-    ## Different image viewer commands.
-    xv = sprintf ("xv -raw -expand %f \"%s\"", zoom, ppm_name);
-    xloadimage = sprintf ("xloadimage -zoom %f \"%s\"", zoom*100, ppm_name);
-    im_display = sprintf ("display -resize %f%% \"%s\"", zoom*100, ppm_name);
-  
-    ## Need to let the shell clean up the tmp file because we are putting
-    ## the viewer in the background.
-    status = system (sprintf ("( %s || %s || %s && %s ) > /dev/null 2>&1 &",
-                              im_display, xv, xloadimage, rm));
-  else
-    ## Does the command support zooming?
-    if (findstr (command, "%f"))
-      command = sprintf (command, zoom, ppm_name);
-    else
-      command = sprintf (command, ppm_name);
-    endif
-    status = system (sprintf ("( %s && %s) > /dev/null 2>&1 &", command, rm));
-  endif
-  
-  ## Did the system call fail?
-  if (status != 0)
-    error ("image_viewer: the image viewing command failed");
-  endif
-
-endfunction
--- a/scripts/image/module.mk	Mon Oct 18 16:53:57 2010 +0200
+++ b/scripts/image/module.mk	Mon Oct 18 14:15:06 2010 -0400
@@ -16,7 +16,6 @@
   image/hsv.m \
   image/hsv2rgb.m \
   image/image.m \
-  image/image_viewer.m \
   image/imagesc.m \
   image/imfinfo.m \
   image/imread.m \
--- a/scripts/plot/__go_draw_axes__.m	Mon Oct 18 16:53:57 2010 +0200
+++ b/scripts/plot/__go_draw_axes__.m	Mon Oct 18 14:15:06 2010 -0400
@@ -405,10 +405,6 @@
     endif
     addedcmap = [];
 
-    [view_cmd, view_fcn, view_zoom] = image_viewer ();
-    use_gnuplot_for_images = (ischar (view_fcn)
-                              && strcmpi (view_fcn, "gnuplot_internal"));
-
     ximg_data = {};
     ximg_data_idx = 0;
 
@@ -440,69 +436,63 @@
           img_xdata = obj.xdata;
           img_ydata = obj.ydata;
 
-          if (use_gnuplot_for_images)
-
-            if (ndims (img_data) == 3)
-              truecolor = true;
-            elseif (strcmpi (obj.cdatamapping, "direct"))
-              cdatadirect = true;
-            endif
-            data_idx++;
-            is_image_data(data_idx) = true;
-            parametric(data_idx) = false;
-            have_cdata(data_idx) = false;
-            have_3d_patch(data_idx) = false;
+          if (ndims (img_data) == 3)
+            truecolor = true;
+          elseif (strcmpi (obj.cdatamapping, "direct"))
+            cdatadirect = true;
+          endif
+          data_idx++;
+          is_image_data(data_idx) = true;
+          parametric(data_idx) = false;
+          have_cdata(data_idx) = false;
+          have_3d_patch(data_idx) = false;
 
-            if (img_xdata(2) < img_xdata(1))
-              img_xdata = img_xdata(2:-1:1);
-              img_data = img_data(:,end:-1:1,:);
-            elseif (img_xdata(1) == img_xdata(2))
-              img_xdata = img_xdata(1) + [0, size(img_data,2)-1];
-            endif
-            if (img_ydata(2) < img_ydata(1))
-              img_ydata = img_ydata(2:-1:1);
-              img_data = img_data(end:-1:1,:,:);
-            elseif (img_ydata(1) == img_ydata(2))
-              img_ydata = img_ydata(1) + [0, size(img_data,1)-1];
-            endif
+          if (img_xdata(2) < img_xdata(1))
+            img_xdata = img_xdata(2:-1:1);
+            img_data = img_data(:,end:-1:1,:);
+          elseif (img_xdata(1) == img_xdata(2))
+            img_xdata = img_xdata(1) + [0, size(img_data,2)-1];
+          endif
+          if (img_ydata(2) < img_ydata(1))
+            img_ydata = img_ydata(2:-1:1);
+            img_data = img_data(end:-1:1,:,:);
+          elseif (img_ydata(1) == img_ydata(2))
+            img_ydata = img_ydata(1) + [0, size(img_data,1)-1];
+          endif
 
-            [y_dim, x_dim] = size (img_data(:,:,1));
-            if (x_dim > 1)
-              dx = abs (img_xdata(2)-img_xdata(1))/(x_dim-1);
-            else
-              x_dim = 2;
-              img_data = [img_data, img_data];
-              dx = abs (img_xdata(2)-img_xdata(1));
-            endif
-            if (y_dim > 1)
-              dy = abs (img_ydata(2)-img_ydata(1))/(y_dim-1);
-            else
-              y_dim = 2;
-              img_data = [img_data; img_data];
-              dy = abs (img_ydata(2)-img_ydata(1));
-            endif
-
-            x_origin = min (img_xdata);
-            y_origin = min (img_ydata);
+          [y_dim, x_dim] = size (img_data(:,:,1));
+          if (x_dim > 1)
+            dx = abs (img_xdata(2)-img_xdata(1))/(x_dim-1);
+          else
+            x_dim = 2;
+            img_data = [img_data, img_data];
+            dx = abs (img_xdata(2)-img_xdata(1));
+          endif
+          if (y_dim > 1)
+            dy = abs (img_ydata(2)-img_ydata(1))/(y_dim-1);
+          else
+            y_dim = 2;
+            img_data = [img_data; img_data];
+            dy = abs (img_ydata(2)-img_ydata(1));
+          endif
 
-            if (ndims (img_data) == 3)
-              data{data_idx} = permute (img_data, [3, 1, 2])(:);
-              format = "1:2:3";
-              imagetype = "rgbimage";
-            else
-              data{data_idx} = img_data(:);
-              format = "1";
-              imagetype = "image";
-            endif
+          x_origin = min (img_xdata);
+          y_origin = min (img_ydata);
 
-            titlespec{data_idx} = "title \"\"";
-            usingclause{data_idx} = sprintf ("binary array=%dx%d scan=yx origin=(%.15g,%.15g) dx=%.15g dy=%.15g using %s",
-                x_dim, y_dim, x_origin, y_origin, dx, dy, format);
-            withclause{data_idx} = sprintf ("with %s;", imagetype);
+          if (ndims (img_data) == 3)
+            data{data_idx} = permute (img_data, [3, 1, 2])(:);
+            format = "1:2:3";
+            imagetype = "rgbimage";
+          else
+            data{data_idx} = img_data(:);
+            format = "1";
+            imagetype = "image";
+          endif
 
-          else
-            ximg_data{++ximg_data_idx} = img_data;
-          endif
+          titlespec{data_idx} = "title \"\"";
+          usingclause{data_idx} = sprintf ("binary array=%dx%d scan=yx origin=(%.15g,%.15g) dx=%.15g dy=%.15g using %s",
+              x_dim, y_dim, x_origin, y_origin, dx, dy, format);
+          withclause{data_idx} = sprintf ("with %s;", imagetype);
 
         case "line"
           if (strncmp (obj.linestyle, "none", 4)
@@ -1480,12 +1470,6 @@
     endif
     fputs (plot_stream, "set style data lines;\n");
 
-    if (! use_gnuplot_for_images)
-      for i = 1:ximg_data_idx
-        view_fcn (xlim, ylim, ximg_data{i}, view_zoom, view_cmd);
-      endfor
-    endif
-
     cmap = [cmap; addedcmap];
     cmap_sz = cmap_sz + rows(addedcmap);
     if (length(cmap) > 0)