sources-request@mirror.TMC.COM (11/11/86)
Submitted by: David Sher <seismo!rochester!sher> Mod.sources: Volume 7, Issue 64 Archive-name: image/Part01 [ The Makefiles had ESCAPE and \r characters in their comment lines; I changed them to their printable representation, the two-character sequences ^[ and ^M, respectively. Also, the file ascii2var/uu.test.var had some non-ASCII characters in it; I used uuencode; the resultant file is really ascii2var/test.var. Also, I do not have C++ nor any images, so I have not tested this package. --r$ ] #!/bin/sh # This is a shell archive. Remove anything before this line, # then unpack it by saving it in a file and typing "sh file". # If all goes well, you will see the message "No problems found." # Wrapped by mirror!rs on Mon Nov 10 13:38:43 EST 1986 # Exit status; set to 1 on "wc" errors or if would overwrite. STATUS=0 # Contents: ascii2var correlate lowerbound man scale truncate # upperbound var2ascii varc++ vartools README copywrite # ascii2var/main.c++ ascii2var/makefile ascii2var/uu.test.var # correlate/main.c++ correlate/makefile lowerbound/main.c++ # lowerbound/makefile man/image.5 man/iff2var.1 man/var2iff.1 # man/ascii2var.1 for I in ascii2var correlate lowerbound man scale truncate upperbound \ var2ascii varc++ vartools ; do if test -d $I ; then echo Directory $I exists, changing mode just in case else echo mkdir - $I mkdir $I fi chmod 777 $I done echo x - README if test -f README ; then echo README exists, putting output in $$README OUT=$$README STATUS=1 else OUT=README fi sed 's/^X//' > $OUT <<'@//E*O*F README//' XThis directory contains a set of files that constitute a package of routines Xfor manipulating images in C++. These routines are designed to be Xfile format independent. The interface to your local image file Xformat will have to be written on site. At this time there are Xinterfaces written for the Maryland U image file format (mv) and the U XBritish Columbia image file form (iff) which can be supplied at Xrequest to the author. The routines supplied are interfaced to the Xlocally produced vision archive format (var) which is an extension of Xiff to handle a more varied type of image. The makefiles in this Xpackage assume a program called c++ which takes a file with c++ Xsource and terminates in .c++ and returns a file that ends in .o. XNote that some modification of the makefiles are probably necessary Xfor your system. This software isn't and isn't meant to be self installing. XI tolerate this because it will probably have to be modified in any Xcase to run with the local image file format. X-David Sher Xsher@rochester X{seismo,allegra}!rochester!sher X/* XCopyright (C) 1986, David Sher in the University of Rochester XPermission is granted to any individual or institution to use, copy, or Xredistribute this software so long as it is not sold for profit, provided Xthis copyright notice is retained. X*/ @//E*O*F README// chmod u=rw,g=r,o=r $OUT echo x - copywrite if test -f copywrite ; then echo copywrite exists, putting output in $$copywrite OUT=$$copywrite STATUS=1 else OUT=copywrite fi sed 's/^X//' > $OUT <<'@//E*O*F copywrite//' X/* XCopyright (C) 1986, David Sher in the University of Rochester XPermission is granted to any individual or institution to use, copy, or Xredistribute this software so long as it is not sold for profit, provided Xthis copyright notice is retained. X*/ @//E*O*F copywrite// chmod u=rw,g=r,o=r $OUT echo x - ascii2var/main.c++ if test -f ascii2var/main.c++ ; then echo ascii2var/main.c++ exists, putting output in $$ascii2var/main.c++ OUT=$$ascii2var/main.c++ STATUS=1 else OUT=ascii2var/main.c++ fi sed 's/^X//' > $OUT <<'@//E*O*F ascii2var/main.c++//' X/* X This is the main routine for translating X ascii to floating point images X*/ X#include <stream.h> X#include <stdio.h> X#include <vartools.h++> Xint Xmain(int argc,char *argv[]) X { X switch ( argc ) X { X // with 0 arguments it is a pipe X case 1: X ascii2var(stdin,stdout); X break; X // with 1 arguments it takes from named file to stdout X case 2: X { X FILE *input; // pointer to the input file X if ( NULL == ( input = fopen(argv[1],"r") ) ) X { X perror("ascii2var"); X return 2; X } X ascii2var(input,stdout); X } X break; X // with 2 arguments it takes from named file to named file X case 3: X { X FILE *input; // pointer to the input file X FILE *output; // pointer to the output file X if ( NULL == ( input = fopen(argv[1],"r") ) ) X { X perror("ascii2var"); X return 2; X } X if ( NULL == ( output = fopen(argv[2],"w") ) ) X { X perror("ascii2var"); X return 2; X } X ascii2var(input,output); X } X break; X // otherwise something is wrong X default: X cerr << "Syntax is: ascii2var [input [output]]\n"; X return 1; X } X return 0; X } X/* XCopyright (C) 1986, David Sher in the University of Rochester XPermission is granted to any individual or institution to use, copy, or Xredistribute this software so long as it is not sold for profit, provided Xthis copyright notice is retained. X*/ @//E*O*F ascii2var/main.c++// chmod u=rw,g=r,o=r $OUT echo x - ascii2var/makefile if test -f ascii2var/makefile ; then echo ascii2var/makefile exists, putting output in $$ascii2var/makefile OUT=$$ascii2var/makefile STATUS=1 else OUT=ascii2var/makefile fi sed 's/^X//' > $OUT <<'@//E*O*F ascii2var/makefile//' X# this is the makefile for iff2var X.SUFFIXES: .c++ X# This line constructs the program name (equal to the directory name) X# jccpwd^[!!sh^M:s/.*\///g^MIPROGRAM = ^[ XPROGRAM = ascii2var XCFLAGS = -O -I/usr/grads/include -DVAX -Ddebug XC++FLAGS = +i $(CFLAGS) XLIBS = -lvartools -lvarc++ -lvar -liff X# This line constructs the list of possible objects X# 2jc}ls *[A-Za-z0-9].c *.c++^[!!sh^M>}>}:g/\.c\+*$/ s//.o \\/^M XOBJS = \ X main.o X.c++.o: X c++ -c $(C++FLAGS) $*.c++ X# the program is linked by this line X$(PROGRAM) : $(OBJS) X CC -o $(PROGRAM) $(CFLAGS) $(OBJS) $(LIBS) X# the program is linted by this line X$(PROGRAM).lint : *.c X lint -hb *.c -lm > lint.out @//E*O*F ascii2var/makefile// chmod u=rw,g=r,o=r $OUT echo x - ascii2var/uu.test.var if test -f ascii2var/uu.test.var ; then echo ascii2var/uu.test.var exists, putting output in $$ascii2var/uu.test.var OUT=$$ascii2var/uu.test.var STATUS=1 else OUT=ascii2var/uu.test.var fi sed 's/^X//' > $OUT <<'@//E*O*F ascii2var/uu.test.var//' Xbegin 644 test.tar XM(3QA<F-H/@I?+DA%041%4B`@("`@("`@+3$@("`@("`@("`@.3@@("`@,3`@ XM("`@-C0T("`@("`Y.2`@("`@("`@8`I&:6QE(%1Y<&4@/2!V87AD;W5B;&4* XM0GET97,@<&5R(%!I>&5L(#T@.`I.=6UB97(@0F%N9',@/2`R"C`@/2!L;W=? XM<&EX96QS(&EF9@HS,B`](&AI9VA?<&EX96QS(&EF9@H*7RY#3TU-14Y44R`@ XM("`@("TQ("`@("`@("`@(#DX("`@(#$P("`@(#8T-"`@("`@,34@("`@("`@ XM(&`*5&AI<R!I<R!A('1E<W0*"FQO=U]P:7AE;',@("`@("`M,2`@("`@("`@ XM("`Y."`@("`Q,"`@("`V-#0@("`@(#$P-#@@("`@("!@"DEM86=E9FEL92!V XM97)S:6]N+3(Z(&YR;W=S(#T@,B!N8V]L<R`](#,@8G!P(#T@,S(@<VEG;F5D XM(#T@,"!P;W-I=&EV92`](#$*```````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM`````````````````````````````````/`_`%JE0%EV8<(``#'`'W[0O0`` XM`$!H:6=H7W!I>&5L<R`@("`@+3$@("`@("`@("`@.3@@("`@,3`@("`@-C0T XM("`@("`Q,#0X("`@("`@8`I);6%G969I;&4@=F5R<VEO;BTR.B!N<F]W<R`] XM(#(@;F-O;',@/2`S(&)P<"`](#,R('-I9VYE9"`](#`@<&]S:71I=F4@/2`Q XM"@`````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` XM```````````````````````````````````````````````````````````` X>``````````#P/P!:I4!9=F'"```QP!]^T+T```!` X` Xend @//E*O*F ascii2var/uu.test.var// chmod u=rw,g=rw,o=rw $OUT echo x - correlate/main.c++ if test -f correlate/main.c++ ; then echo correlate/main.c++ exists, putting output in $$correlate/main.c++ OUT=$$correlate/main.c++ STATUS=1 else OUT=correlate/main.c++ fi sed 's/^X//' > $OUT <<'@//E*O*F correlate/main.c++//' X/* X This is the main routine for the correlation program X Syntax is: X correlation template.var [input.var [output.var]] X*/ X#include <stream.h> X#include <stdio.h> X#include <double_image.h++> X#include <vartools.h++> Xint Xmain ( int argc , char *argv[] ) X { X switch(argc) X { X // if only 1 argument act as a pipe X case 2: X { X FILE *template_file; X // open the template file X if ( NULL == (template_file = fopen(argv[1],"r"))) X { X perror(form("Problem with opening %s mode r:",argv[1])); X return 2; X } X // do the correlation X correlate(template_file,stdin,stdout,""); X } X break; X // if two arguments use the second for input file X case 3: X { X FILE *template_file; X // open the template file X if ( NULL == (template_file = fopen(argv[1],"r"))) X { X perror(form("Problem with opening %s mode r:",argv[1])); X return 2; X } X FILE *input_file; X // open the input file X if ( NULL == (input_file = fopen(argv[2],"r"))) X { X perror(form("correlate: Problem with opening %s mode r:",argv[2])); X return 3; X } X // do the correlation X correlate(template_file,input_file,stdout,""); X } X break; X // if 3 arguments use the second for input and the 3rd for output X case 4: X { X FILE *template_file; X // open the template file X if ( NULL == (template_file = fopen(argv[1],"r"))) X { X perror(form("correlate: Problem with opening %s mode r:",argv[1])); X return 2; X } X FILE *input_file; X // open the input file X if ( NULL == (input_file = fopen(argv[2],"r"))) X { X perror(form("correlate: Problem with opening %s mode r:",argv[2])); X return 3; X } X FILE *output_file; X // open the output file X if ( NULL == (output_file = fopen(argv[3],"w"))) X { X perror(form("correlate: Problem with opening %s mode w:",argv[3])); X return 4; X } X // do the correlation X correlate(template_file,input_file,output_file,""); X } X break; X // if wrong number of arguments print error message and exit X default: X cerr << "Syntax is: correlation template.var [input.var [output.var]]\n"; X return 1; X break; X } X return 0; X } X/* XCopyright (C) 1986, David Sher in the University of Rochester XPermission is granted to any individual or institution to use, copy, or Xredistribute this software so long as it is not sold for profit, provided Xthis copyright notice is retained. X*/ @//E*O*F correlate/main.c++// chmod u=rw,g=r,o=r $OUT echo x - correlate/makefile if test -f correlate/makefile ; then echo correlate/makefile exists, putting output in $$correlate/makefile OUT=$$correlate/makefile STATUS=1 else OUT=correlate/makefile fi sed 's/^X//' > $OUT <<'@//E*O*F correlate/makefile//' X# this is the makefile for iff2var X.SUFFIXES: .c++ X# This line constructs the program name (equal to the directory name) X# jccpwd^[!!sh^M:s/.*\///g^MIPROGRAM = ^[ XPROGRAM = correlate XCFLAGS = -O -I/usr/grads/include -DVAX -Ddebug XC++FLAGS = +i $(CFLAGS) XLIBS = -lvartools -lvarc++ -lvar -liff X# This line constructs the list of possible objects X# 2jc}ls *[A-Za-z0-9].c *.c++^[!!sh^M>}>}:g/\.c\+*$/ s//.o \\/^M XOBJS = \ X main.o X.c++.o: X c++ -c $(C++FLAGS) $*.c++ X# the program is linked by this line X$(PROGRAM) : $(OBJS) X c++ -o $(PROGRAM) $(CFLAGS) $(OBJS) $(LIBS) X# the program is linted by this line X$(PROGRAM).lint : *.c X lint -hb *.c -lm > lint.out @//E*O*F correlate/makefile// chmod u=rw,g=r,o=r $OUT echo x - lowerbound/main.c++ if test -f lowerbound/main.c++ ; then echo lowerbound/main.c++ exists, putting output in $$lowerbound/main.c++ OUT=$$lowerbound/main.c++ STATUS=1 else OUT=lowerbound/main.c++ fi sed 's/^X//' > $OUT <<'@//E*O*F lowerbound/main.c++//' X/* X This applies an lower bound to a var file X The syntax is: X lowerbound bound [input.var [output.var]] X*/ X#include <stream.h> X#include <stdio.h> X#include <vartools.h++> Xint Xmain ( int argc , char *argv[] ) X { X switch(argc) X { X // with 1 argument it acts as a pipe X case 2: X lower_bound(atof(argv[1]),stdin,stdout,"Bounding file from stdin\n"); X break; X // with 2 arguments it reads from specified file and writes to stdout X case 3: X FILE *input; X if(NULL == (input = fopen(argv[2],"r"))) X { X perror(form("lowerbound problem with openning %s:",argv[2])); X return 5; X } X lower_bound(atof(argv[1]),input,stdout,form("bounding file %s\n",argv[2])); X break; X // with 3 arguments it reads from specified file and writes to X // specified file X case 4: X FILE *input; X FILE *output; X if(NULL == (input = fopen(argv[2],"r"))) X { X perror(form("lowerbound problem with openning %s:",argv[2])); X return 5; X } X if(NULL == (output = fopen(argv[3],"w"))) X { X perror(form("lowerbound problem with openning %s:",argv[3])); X return 6; X } X lower_bound(atof(argv[1]),input,output,form("bounding file %s to file %s\n",argv[2],argv[3])); X break; X // otherwise wrong number of arguments failure! X default: X cerr << "Syntax is: lowerbound bound [input.var [output.var]]"; X return 1; X break; X } X return 0; X } X/* XCopyright (C) 1986, David Sher in the University of Rochester XPermission is granted to any individual or institution to use, copy, or Xredistribute this software so long as it is not sold for profit, provided Xthis copyright notice is retained. X*/ @//E*O*F lowerbound/main.c++// chmod u=rw,g=r,o=r $OUT echo x - lowerbound/makefile if test -f lowerbound/makefile ; then echo lowerbound/makefile exists, putting output in $$lowerbound/makefile OUT=$$lowerbound/makefile STATUS=1 else OUT=lowerbound/makefile fi sed 's/^X//' > $OUT <<'@//E*O*F lowerbound/makefile//' X# this is the makefile for iff2var X.SUFFIXES: .c++ X# This line constructs the program name (equal to the directory name) X# jccpwd^[!!sh^M:s/.*\///g^MIPROGRAM = ^[ XPROGRAM = lowerbound XCFLAGS = -O -I/usr/grads/include -DVAX -Ddebug XC++FLAGS = +i $(CFLAGS) XLIBS = -lvartools -lvarc++ -lvar -liff X# This line constructs the list of possible objects X# 2jc}ls *[A-Za-z0-9].c *.c++^[!!sh^M>}>}:g/\.c\+*$/ s//.o \\/^M XOBJS = \ X main.o X.c++.o: X c++ -c $(C++FLAGS) $*.c++ X# the program is linked by this line X$(PROGRAM) : $(OBJS) X c++ -o $(PROGRAM) $(CFLAGS) $(OBJS) $(LIBS) X# the program is linted by this line X$(PROGRAM).lint : *.c X lint -hb *.c -lm > lint.out @//E*O*F lowerbound/makefile// chmod u=rw,g=r,o=r $OUT echo x - man/image.5 if test -f man/image.5 ; then echo man/image.5 exists, putting output in $$man/image.5 OUT=$$man/image.5 STATUS=1 else OUT=man/image.5 fi sed 's/^X//' > $OUT <<'@//E*O*F man/image.5//' X.TH IMAGE 5 8/19/86 X.CM 1 X.SH "NAME" Ximage \- double_image long_image X.SH "SYNOPSIS" X.nf X// for a long image X#include <long_image.h++> X// for a double image X#include <double_image.h++> X// to create your own image type X#include <image.h++> X.sp X// this is the base data structure for images: X.sp X.sp X/* X The operations that can be applied when creating the window. X one can read in an image or create one. X*/ Xenum create_image_type { CREATE = 7 }; Xenum read_image_type { READ = 4 }; X.sp X.sp X/* protection for images */ Xenum image_prot X { X CAN_READ = 1 , X CAN_WRITE = 2 , X CAN_READ_AND_WRITE = 3 , X CAN_NOT_DO_ANYTHING = 4 X }; X.sp X/* X useful for determining the status of data structures X*/ Xenum status { INITIALIZED = 8 , UNINITIALIZED = 16 }; X.sp X/* X This is the abstract data type for any image X Actually objects of this type are not useful X it is meant to have derived types X*/ Xclass image_class X { Xpublic: X card number_rows; // number rows in image X card number_cols; // number of collumns in image X void * header_info ; // any further header information required by implementation X image_prot prot; // the protection of the image X card comment_length; // the length of the comments X char * comments ; // comments about the image X status image_status; // determines when image data is initialized X.sp X /* position in image */ X status window_status; // determines when the window has been initialized X card collumn; // the collumn X card row; // the row X card window_width; // width of possible window in image X card window_length; // length of possible window in image X FILE * file; // file associated with image X.sp X /* constructors for images */ X /* constructor when reading an image from a file */ X image_class X ( X const read_image_type rit , // marker that the image is being read X const FILE * image_file , // file for image X const card w_width , // window width X const card w_length // window length X ); X.sp X /* constructor for creating a new image */ X image_class X ( X const create_image_type cit, // maker that the image is being created X const FILE * image_file , // the file for the image X const card n_rows , // the number of rows in the image X const card n_cols , // the number of collumns in the image X const card w_width , // the width of the window X const card w_length // the length of the window X ); X.sp X /* destructor for images */ X ~image_class () { ; } X.sp X /* comment manipulation */ X.sp X /* sets the comments */ X void set_comments( char * string , const card length ); X.sp X /* adds a string to the comments */ X void add_comment( char * string , const card length ); X.sp X /* for moving around in an image */ X.sp X.sp X /* X move in row n steps X returns 1 when that motion is legal 0 otherwise X */ X virtual int move_collumn ( const int n ) ; X.sp X /* X move in collumn n steps X returns 1 when that motion is legal 0 otherwise X */ X virtual int move_row ( const int n ) ; X.sp X /* X move to specified row X */ X virtual void move_to_row ( const card n ) ; X.sp X /* X move to specified collumn X */ X virtual void move_to_collumn ( const card n ) ; X.sp X /* routine to write out the image to a file */ X virtual void write ( ) ; X.sp X /* change the protection from CAN_WRITE to CAN_READ_AND_WRITE */ X virtual void read_and_write ( ); X.sp X }; X.sp X/* returns a null terminated string for comments */ Xconst char * comment_string ( image_class& i ); X.sp X.sp X// This is the derived type for images of doubles. X// The derived type for longs is the same with long replacing double X.sp X.sp X/* X the definition of the class to manage image structures X*/ Xclass double_image : image_class X { X double *image_buffer; // buffer to hold image X double **image_rows; // pointers to the rows of the image X double **window_rows; // pointers to the rows of the window X /* functions for function pointers */ X ... X.sp Xpublic: X /* constructors */ X /* the constructor when the image is being read from a file */ X double_image X ( X const read_image_type rit , // marker that the image is being read X const FILE * image_file , // file for image X const card w_width = 1 , // window width X const card w_length = 1 // window length X ); X.sp X /* the constructor when the image is built */ X double_image X ( X const create_image_type cit , // marker that the image is being created X const card n_rows , // the number of rows in the image X const card n_cols , // the number of collumns in the image X const FILE * image_file , // file for image X const card w_width = 1 , // window width X const card w_length = 1 // window length X ); X.sp X /* destructor (who would want to destroy an image?) */ X ~double_image ( ) { ; } X.sp X /* access routines for parts of data structure */ X const card n_rows() { return number_rows ; } X const card n_cols() { return number_cols ; } X const image_prot the_prot() { return prot; } X const card c_length() { return comment_length ; } X const char *the_comments() { return comments ; } X const card the_collumn() { return collumn ; } X const card the_row() { return row ; } X const card the_width() { return window_width ; } X const card the_length() { return window_length ; } X const FILE * the_file() { return file ; } X const status image_init() { return image_status ; } X const status window_init() { return window_status ; } X.sp X /* access a pointer to a particular row */ X const double * get_row( card row ); X.sp X /* sets the comments */ X void set_comments( char * string , const card length ) X { X this->image_class::set_comments ( string , length ); X } X.sp X /* adds a string to the comments */ X void add_comment( char * string , const card length ) X { X this->image_class::add_comment ( string , length ); X } X.sp X.sp X /* real versions of virtual functions */ X /* routine to write out the image to a file */ X void write ( ) ; X.sp X /* X move in row n steps X returns 1 when that motion is legal 0 otherwise X */ X int move_collumn ( const int n ) ; X.sp X /* X move in collumn n steps X returns 1 when that motion is legal 0 otherwise X */ X int move_row ( const int n ) ; X.sp X /* X move to specified row X */ X void move_to_row ( const card n ) ; X.sp X /* X move to specified collumn X */ X void move_to_collumn ( const card n ) ; X.sp X X /* X the function to get the specified element of a window X it is a function pointer so that unitialized windows X or protected images don't get read from X this accesses the function pointer X */ X double get_w_e ( const card i , const card j ) X { return (( double (*) (...) )(* get_w_e_pointer)) ( this , i , j ); } X.sp X /* X the fast function without checking for initialization X of a function pointer for getting elements of a window X Also no bounds checking! X ( Not recommended!) X */ X double fast_g_w_e ( const card i , const card j ) X { return window_rows[i][j]; } X X /* X the function to write to the specified element of a window. X it is a function pointer so that unitialized windows X or protected images don't get read from X this accesses the function pointer X */ X void write_w_e ( const card i , const card j , const double value ) X { ((void (*) (...) )(* write_w_e_pointer)) ( this , i , j , value ); } X.sp X /* X the fast function without checking for initialization X of a function pointer for writing elements to a window X Also no bounds checking! X ( Not recommended!) X */ X void fast_w_w_e ( const card i , const card j , const double value ) X { window_rows[i][j] = value; } X.sp X /* X the function call on the image gets the upper left hand X of the image window and returns a reference so it can be X used as a lvalue or rvalue X optimized so does not check that the window is initialized X if the window is not initialized then odd things may happen X */ X double& operator() () X { return **window_rows; } X X /* X move to next legal position in image X returns 1 when there is a next legal position 0 otherwise X if the window is not initialized then it initializes it. X with the window in the position 0,0 (if possible) X */ X int (* next) (...); /* this will point to member functions! */ X.sp X /* X move to previous legal position in image X returns 1 when there is a previous legal position 0 otherwise X if the window is not initialized then it initializes it. X with the window in the farthest position (if possible) X */ X int (* prev) (...); /* this will point to member functions! */ X.sp X /* X Access for next and previous elements of images X */ X int operator++ ( ) X { return (* next) ( this /* because points to member*/ ); } X int operator-- ( ) X { return (* prev) ( this /* because points to member*/ ); } X.sp X /* X Change the size of a window X causes the window to become uninitialized X */ X void resize_window ( card width , card length ); X.sp X /* X Causes the window to cover the entire image. X Allows one to access any part of the image with window operations X */ X void window_entire_image ( ); X.sp X }; X.sp X.fi XCompile with -lvarc++ -lvar -liff X.SH "DESCRIPTION" XThis is a description of a C++ class to access images. XIt handles the concept of a 2d array of longs or doubles Xwith a window of a specified size. XThe routines are designed Xto check in so far as possible for illegal values given to them Xsuch as points outside the window to the window routines. XThe current implementation is designed to work with the var Ximage package ( X.B "var(3)" X). X.IP "CONSTRUCTORS" XThere are two constructors for double or long images. The first Xreads in the image and constructs the correct image data structure Xfor it. It should be called as: X.nf X{double,long}_image input(READ,file_pointer) Xor X{double,long}_image input(READ,file_pointer,window_width,window_length) X.fi XThe last two arguments are optional and control the size of the Xwindow. If they are omitted then the window is 1 by 1. X.br XThe other constructor is used to create an image for output which is Xnot read in from a file. It should be called as: X.nf X{double,long}_image output X ( X CREATE, X number_rows, X number_collumns, X file_pointer X ) Xor X{double,long}_image output X ( X CREATE, X number_rows, X number_collumns, X file_pointer, X window_width, X window_length X ) X.fi XAs before the last two arguments are optional and when left out are Xinitialized to 1. X.PP XThe destructor for images is currently null. X.IP "Access Routines" XThese routines retrieve interesting private parts of the data Xstructure that can be useful. This allows parts of an image to be Xread only. This also one to pass parts of the data structure to C Xroutines. The first few retrieve information about the image as a Xwhole. X.br X.B "n_rows:" X retrieves the number of rows in the image. X.br X.B "n_cols:" X retrieves the number of collumns in the image. X.br X.B "the_prot:" X retrieves the protection status of the image. This way one can tell Xwhether the image is read or write protected. X.br X.B "c_length:" X returns the number of chars in the comments X.br X.B "the_comments:" X returns a X.I "not necessarily" Xnull terminated string containing the comments. X.br X.B "the_file:" X returns the file pointer which is the file for the image. X.br X.B "image_init:" X returns whether the image has been initialized. X.br X.br XThe next few access functions control the window to the image. X.br X.B "window_init:" X returns whether the image window has been initialized. X.br X.B "the_collumn:" X the collumn of the upper left hand corner of the window. X.br X.B "the_row:" X the row of the upper left hand corner of the window. X.br X.B "the_width:" X the width of the window. X.br X.B "the_length:" X the length of the window. X.br X.br XAnother access function mostly for C routines is X.B get_row Xthat retrieves a pointer to a specified row in an image. X.br X.br XA command that is not part of the access routines but functions in Xmuch the same way is X.B "comment_string" Xthat takes an image and returns a null terminated string for the Xcomment. X.IP "Comment Management" XThere are two routines that are used to construct comments for an Ximage. X.B "set_comments" Xsets the comments to a specified string of a specified length. X.B "add_comments" Xadds to the already existing comments a specified string of a Xspecified length. X.IP "Output" X.B "write" Xwrites the image out to its specified file. X.IP "Moving the Window" X.B "move_collumn" Xand X.B "move_row" Xincrementally move the window to a specified number of rows or Xcollumns. They both return a boolean to indicate whether the Xmove is possible. X.B "move_to_row" Xand X.B "move_to_collumn" Xare used to move the window on the image to a specified position in Xthe image. They will print an error message and dump core if an Xillegal position is specified. X.IP "Iterating through an Image" XFor iterating through an entire image there are two function X.I "pointers" X.B "*next" and X.B "*prev." XWhen X.B "*next" Xis called on an initialized image it initializes the window and Xsends it to the upper left hand corner of the image. Successive calls Xmove the window along the row until it doesn't fit any more and then Xto the beginning of the next collumn. X.B "*prev" Xstarts on the bottom right of the the image and moves backwards. X.B "++" Xis overloaded to be X.B "*next" Xon images and X.B "--" Xis overloaded to be X.B "*prev" Xon images. XBoth functions return true when they are legal and false when Xthey fall off the image. If they fall off the image they do nothing. XOne can iterate through an image using these this way: X.nf Xwhile(++image) Xor Xwhile(++input,++output) X.fi XWhen the second technique is used one must be careful to make sure Xthat the size of output is (input.n_rows() - input.the_length() + 1 , Xinput.n_cols() - input.the_width() + 1). X.IP "Accessing Window Elements" XThere are several functions for reading or writing to elements of a Xwindow. For reading X.B "get_w_e" Xreturns a window element. A version of this exists without any Xchecking that the numbers given make sense. It is called X.B "fast_get_w_e." XUse of this code is not recomended. XSimilarly X.B "write_w_e" Xand X.B "fast_write_w_e" Xwrite a value to a particular point in a window. Once again I do not Xrecomend using X.B "fast_write_w_e." XIf you only want to access the (0,0) element of a window (especially Xuseful if your window is default size). You can use the overloaded Xfunction call operator X.B "()" Xto access or write to this element. Xas an example: X.nf Xoutput() = 7; Xwrites 7 to the upper left hand corner of the window on the image Xoutput. Xcout << input(); Xwrites the upper left hand corner of the window to the stdout. X.fi X.IP "Changing the Size of the Window" XTwo member functions are supplied to retrieve the size of an existing Xwindow: X.B "resize_window" Xand X.B "window_entire_image." X.B "resize_window" Xchanges the size of a window to a specified size. X.b "window_entire_image" Xmakes the window size the same as the image size and makes the entire Ximage inside the window. This allows one to access any part of the Ximage array as a point in the window. X.SH "FILES" X/usr/local/include/image.h++ X/usr/local/include/double_image.h++ X/usr/local/include/long_image.h++ X.SH "SEE ALSO" Xvar(3) X.SH "DIAGNOSTICS" XUsually crashes out with an error message and a core dump Xif something suspicious is tried. X.SH "BUGS" XEither my code has absolutely and completely no bugs or I am Xa bare faced liar. X.SH HISTORY X.TP X19-Aug-86 David Sher (sher) at University of Rochester XCreated. @//E*O*F man/image.5// chmod u=rw,g=r,o=r $OUT echo x - man/iff2var.1 if test -f man/iff2var.1 ; then echo man/iff2var.1 exists, putting output in $$man/iff2var.1 OUT=$$man/iff2var.1 STATUS=1 else OUT=man/iff2var.1 fi sed 's/^X//' > $OUT <<'@//E*O*F man/iff2var.1//' X.TH IFF2VAR 1 8/21/86 X.CM 1 X.SH "NAME" Xiff2var \- Program to convert iff files to var format. X.SH "SYNOPSIS" Xiff2var [input.iff [output.var]] X.SH "DESCRIPTION" XThis is the routine to convert iff files to var files. XIt also Xdemonstrates how the var(3) routines can be called from C. XIf given no arguments it acts as a pipe. XIf you give it Xone argument it takes it as the input file and sends the output Xto stdout. XWith two arguments it uses the first for input and Xthe second for output. X.SH "SEE ALSO" Xvar(3) var(5) iff2var(3) X.SH "DIAGNOSTICS" XSome errors cause core dumps others not. X.SH "BUGS" XNo doubt. X.SH HISTORY X.TP X21-Aug-86 David Sher (sher) at University of Rochester XCreated. @//E*O*F man/iff2var.1// chmod u=rw,g=r,o=r $OUT echo x - man/var2iff.1 if test -f man/var2iff.1 ; then echo man/var2iff.1 exists, putting output in $$man/var2iff.1 OUT=$$man/var2iff.1 STATUS=1 else OUT=man/var2iff.1 fi sed 's/^X//' > $OUT <<'@//E*O*F man/var2iff.1//' X.TH VAR2IFF 1 8/21/86 X.CM 1 X.SH "NAME" Xvar2iff \- a conversion program from var format to iff X.SH "SYNOPSIS" Xvar2iff [input.var [output.iff]] X.SH "DESCRIPTION" XThis takes files in the var(5) image format and generates files Xin the iff(5) image format. XIf no arguments this is a pipe, Xwith one argument uses it to find input with two arguments Xuses them for input and output. X.SH "SEE ALSO" Xvar(3) var(5) iff(5) var2iff(3) iff2var(1) X.SH "DIAGNOSTICS" XDumps core at times when given spurious input. XShould always print error messages though! X.SH "BUGS" XNone so far. X.SH HISTORY X.TP X21-Aug-86 David Sher (sher) at University of Rochester XCreated. @//E*O*F man/var2iff.1// chmod u=rw,g=r,o=r $OUT echo x - man/ascii2var.1 if test -f man/ascii2var.1 ; then echo man/ascii2var.1 exists, putting output in $$man/ascii2var.1 OUT=$$man/ascii2var.1 STATUS=1 else OUT=man/ascii2var.1 fi sed 's/^X//' > $OUT <<'@//E*O*F man/ascii2var.1//' X.TH ASCII2VAR 1 8/25/86 X.CM 1 X.SH "NAME" Xascii2var \- A program to translate an ascii file to a floating point image X.SH "SYNOPSIS" Xascii2var [input.ascii [output.var]] X.SH "DESCRIPTION" XThis is the program that takes a file in ascii format and returns a Xvar(5) file. XThe ascii format is a pair of dimensions (length followed Xby width) and then the pixels followed by comments. XIf no arguments Xit is a pipe. XOtherwise it can take an input file and send to stdout Xor it can take both an input and an output file. XThis program can facilitate passing floating point images Xbetween machines with incompatible floating point formats. X.SH "SEE ALSO" Xvar(5) var(3) vartools(3) Xvar2ascii(1) X.SH "DIAGNOSTICS" XIf something major goes wrong it prints an error message and dumps Xcore. X.SH "BUGS" XHmmm... @//E*O*F man/ascii2var.1// chmod u=rw,g=r,o=r $OUT echo Inspecting for damage in transit... temp=/tmp/sharin$$; dtemp=/tmp/sharout$$ trap "rm -f $temp $dtemp; exit" 0 1 2 3 15 cat > $temp <<\!!! 24 222 1311 README 6 42 249 copywrite 61 207 1344 main.c++ 31 102 671 makefile 58 60 3415 uu.test.var 93 317 2359 main.c++ 31 102 672 makefile 60 208 1630 main.c++ 31 102 673 makefile 534 2655 15637 image.5 26 121 688 iff2var.1 23 106 647 var2iff.1 25 133 793 ascii2var.1 1003 4377 30089 total !!! wc README copywrite ascii2var/main.c++ ascii2var/makefile ascii2var/uu.test.var correlate/main.c++ correlate/makefile lowerbound/main.c++ lowerbound/makefile man/image.5 man/iff2var.1 man/var2iff.1 man/ascii2var.1 | sed 's=[^ ]*/==' | diff -b $temp - >$dtemp if test -s $dtemp ; then echo "Ouch [diff of wc output]:" cat $dtemp STATUS=1 elif test $STATUS = 0 ; then echo "No problems found." else echo "WARNING -- PROBLEMS WERE FOUND..." fi exit $STATUS