help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: printing from octave; loading images


From: Paul Kienzle
Subject: Re: printing from octave; loading images
Date: Sun, 24 Dec 2000 10:24:01 +0000
User-agent: Mutt/1.2.5i

If you check the octave-sources archive for late 1999, you will find a
couple of print commands.  I've included the one by Daniel Heiserer in
matcompat

        http://users.powernet.co.uk/kienzle/octave/matcompat

in scripts/plot/print.m; also requires scripts/plot/gget.m

There are numerous image loading functions available, but I haven't tried
to make sense of them and include them in matcompat.  Start here:

   http://anonimo.isr.ist.utl.pt:8080/Šþetienne/octave/

Paul Kienzle
address@hidden

On Sat, Dec 23, 2000 at 06:56:31PM -0500, Steve Mann wrote:
> I noticed that imread doesn't work right unless the image is a bmp,
> so I wrote the following file "loadpnm.m" that might be of use to
> others.  Please consider this GPL Version 2, if a "license" is needed
> to distribute or use it.
> 
> I left in some lines (commented out) showing how I arrived at the
> current embodiment.
> 
> Also, I noticed that there is no "print" or "gpp" command to print
> the whatever figure is on the screen.
> 
> Although I could do a screen grab of the plot, it would be nicer
> to have a Matlab-like "print" or "gpp" command to make a PostScript file
> of a graph appearing on the screen, rather than using a poor resolution
> bitmap screen capture.
> 
> Is there a print command in octave yet, or should I write that as well?
> 
> % loadpnm.m is based on an earlier cmex program I wrote for Matlab before
> % it was able to deal with images -- address@hidden
> % this crude implementation (quick hack) DOESNT PROPERLY HANDLE COMMENTS
> % feel free to add that feature (fscanf past "#" signs up to "ŠÜn")
> function [R G B]=loadpnm(filename)
> [fp err]=fopen(filename,"r");
> magicnumber=fscanf(fp, "P%d",1); %
> [imagesize]=fscanf(fp, "%d %d",2); % must pass number of arguments wanted or
>                                    % keeps reading and may read into image if
>                                    % pixel values are in range of ascii 
> numbers
> 
> %carriagereturnisagarbagebyte=fscanf(fp, "ŠÜn",1);
> %imagedepth=fscanf(fp, "%dŠÜn",1);
> imagedepth=fscanf(fp, "%d",1);
> newlinegarbage=fread(fp,1,"uchar");
> 
> M=imagesize(2); N=imagesize(1); % reversed convention
> fprintf(stderr,"loadpnm: magic=%d;  M=%d, N=%d;  
> depth=%dŠÜn",magicnumber,M,N,imagedepth);
> 
> if magicnumber == 5 % reading a pgm
>   if nargoutŠþ=1
>     error("magic number of a single output argument must now be P5; P7, P9, 
> etc. not yet supported")
>   end%if
> %%  [r mycount]=fread(fp,M*N,"uchar");
> %  R=reshape(r,M,N);
> %%  R=reshape(r,N,M).';
> %  [R mycount]=fread(fp,[M N],"uchar");
> %  [R mycount]=fread(fp,[N M],"uchar").';% can't transpose list
>   R=fread(fp,[N M],"uchar").'; % must not read mycount!!!
> end%if
> if magicnumber == 6 % reading a ppm
>   if nargoutŠþ=3
>     error("magic number of a single output argument must now be P5; P7, P9, 
> etc. not yet supported")
>   end%if
>   [rgb mycountrgb]=fread(fp,3*M*N,"uchar");
>   RGB=reshape(rgb,3,M*N);
>   R=reshape(RGB(1,:),N,M).';
>   G=reshape(RGB(2,:),N,M).';
>   B=reshape(RGB(3,:),N,M).';
> end%if
> 
> fclose(fp);
> 
> 
> 
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
> 
> Octave's home on the web:  http://www.octave.org
> How to fund new projects:  http://www.octave.org/funding.html
> Subscription information:  http://www.octave.org/archive.html
> -------------------------------------------------------------
> 
> 



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]