Home > RPSstuff > ppmwrite.m

ppmwrite

PURPOSE ^

PPMWRITE writes the current figure in PPM format.

SYNOPSIS ^

function [X,map]=ppmwrite(ppmfile,style)

DESCRIPTION ^

  PPMWRITE writes the current figure in PPM format.

    Usage:  ppmwrite(file)
       or   ppmwrite(file,style)
       or   [X,map]=ppmwrite(file)

     file  = string containing name of output file (e.g. 'out.ppm')
     style = index controling B/W swapping and transparent color

                Swap Black and White   
                --------------------   
       style=1        no               
       style=2        yes              

  Rich Signell (rsignell@usgs.gov)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [X,map]=ppmwrite(ppmfile,style)
0002 
0003 %  PPMWRITE writes the current figure in PPM format.
0004 %
0005 %    Usage:  ppmwrite(file)
0006 %       or   ppmwrite(file,style)
0007 %       or   [X,map]=ppmwrite(file)
0008 %
0009 %     file  = string containing name of output file (e.g. 'out.ppm')
0010 %     style = index controling B/W swapping and transparent color
0011 %
0012 %                Swap Black and White
0013 %                --------------------
0014 %       style=1        no
0015 %       style=2        yes
0016 %
0017 %  Rich Signell (rsignell@usgs.gov)
0018 
0019 % this module attempts to correct for strange behavior of "capture",
0020 % therefore it assumes:
0021 % - X is returned with an extra column and row.
0022 % - the last row of X has a strange color index
0023 % - the background color is the 2nd row in the colormap
0024 % - the opposite color of background is in the 3rd row of the colormap
0025 %
0026 %
0027 %  Rich Signell rsignell@usgs.gov
0028 %
0029 [X,map]=capture;
0030 [m,n]=size(X);
0031 X(:,1)=[];      % delete extra column
0032 X(m,:)=[];      % delete extra row
0033 X(m-1,:)=X(m-2,:);  %copy last row from next to last row
0034 if(exist('style')~=1),
0035    style=1;
0036 end
0037 if(style==2),
0038  map([2 3],:)=map([3 2],:);  % swap black and white
0039 end
0040 writeppm(X,map,ppmfile)

Generated on Wed 30-Nov-2005 14:45:02 by m2html © 2003