[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: imagesc and no image...
From: |
Al Niessner |
Subject: |
Re: imagesc and no image... |
Date: |
Wed, 07 Feb 2001 22:06:58 -0800 |
I attached a quit modification to image.m. I have run it and know that
it works. It is easy to see how to add new viewing utilities, but the
image.m I have only called xv and xloadimage (2.0.16 for linux) so you
will need to add the ImageMagick back in. Also, you may want to handle
the error condition a little better than a printf. I am not an expert
with octave scripts.
Al
"John W. Eaton" wrote:
>
> On 22-Jan-2001, Al Niessner <address@hidden> wrote:
>
> | I installed xv and all works fine now. Octave needs an error message if
> | xv is not found. It was an easy fix though once I got running on another
> | machine and noticed that xv was being used to display the image.
>
> Actually, Octave first tries display from ImageMagick, then xv, then
> xloadimage, so all three have to be missing before it will fail.
>
> If you'd like to try your hand at implementing a better error message,
> please take a look at image.m, and submit a patch.
>
> Thanks,
>
> jwe
## Copyright (C) 1996 John W. Eaton
##
## 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 2, 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, write to the Free
## Software Foundation, 59 Temple Place - Suite 330, Boston, MA
## 02111-1307, USA.
## Display an octave image matrix.
##
## image (x) displays a matrix as a color image. The elements of x are
## indices into the current colormap and should have values between 1
## and the length of the colormap.
##
## image (x, zoom) changes the zoom factor. The default value is 4.
##
## SEE ALSO: imshow, imagesc, colormap.
## Author: Tony Richardson <address@hidden>
## Created: July 1994
## Adapted-By: jwe
function image (x, zoom)
if (nargin == 0)
## Load Bobbie Jo Richardson (Born 3/16/94)
x = loadimage ("default.img");
zoom = 2;
elseif (nargin == 1)
zoom = 4;
elseif (nargin > 2)
usage ("image (matrix, [zoom])");
endif
viewers = [ "xv" ; "xloadimage" ];
foundViewer = 0;
% See if we have a viewer to display the image with.
rv = 0;
for i=1:rows(viewers)
rv = system (["which " viewers(i,:) " 2> /dev/null" ], rv);
if (length(rv) > 1)
foundViewer = i;
break;
endif;
endfor;
% if no viewer was found, throw an error and return
if (foundViewer == 0)
viewerList = " ";
for i=1:rows(viewers)
viewerList = [ viewerList " " viewers(i,:) ];
endfor;
printf (["Could not find any of these viewers to display the image with:\n"
viewerList "\n\n" ]);
return;
endif;
ppm_name = tmpnam ();
saveimage (ppm_name, x, "ppm");
% now that we know which viewer to use, lets fill out the rest of the command
if (foundViewer == 1)
viewer = sprintf ([deblank( viewers(foundViewer,:)) " -expand %f %s"],
zoom, ppm_name);
elseif (foundViewer == 2)
viewer = sprintf ([deblank( viewers(foundViewer,:)) " -zoom %f %s"],
zoom*100, ppm_name);
endif;
rm = sprintf ("rm -f %s", ppm_name);
## Need to let the shell clean up the tmp file because we are putting
## the viewer in the background.
command = sprintf ("( %s && %s ) > /dev/null 2>&1 &",
viewer, rm);
system (command);
endfunction
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: imagesc and no image...,
Al Niessner <=