head	1.4;
access
	monica
	thoth;
symbols;
locks; strict;
comment	@// @;


1.4
date	94.11.10.19.40.19;	author monica;	state Exp;
branches;
next	1.3;

1.3
date	94.08.24.00.30.59;	author monica;	state Exp;
branches;
next	1.2;

1.2
date	94.08.18.22.17.06;	author thoth;	state Exp;
branches;
next	1.1;

1.1
date	93.02.20.16.49.24;	author thoth;	state Exp;
branches;
next	;


desc
@test image subtraction.  Heavily mangled logic due to compiler errors.
@


1.4
log
@commented out malloc debug stmts
@
text
@// Emacs: -*- C++ -*-
static char test002rcsid[] = "$Id: test102.c,v 1.3 1994/08/24 00:30:59 monica Exp monica $";

//
// $Log: test102.c,v $
// Revision 1.3  1994/08/24  00:30:59  monica
// int main & exit(0)
//
//Revision 1.2  1994/08/18  22:17:06  thoth
//incomplete updating.
//
// Revision 1.1  93/02/20  16:49:24  thoth
// Initial revision
// 

#include	<fstream.h>
//#include	<malloc.h>

#include	"IntPointSet.h"
#if 0
#include	"IntDI.h"
typedef IA_IntDiscreteImage	IntDI;
#else
#include	"DiscreteImage.h"
typedef IA_DiscreteImage<int>	IntDI;
#endif
#include	"with-ia-pointset.h"

#if 1
void read(const char *fname, IA_DiscreteImage<int>& image);
void write(IA_DiscreteImage<int>& image, const char *fname);
#else
void read(char *fname, IA_DiscreteImage<int>& image)
{
    FILE *fp;

    fp = fopen(fname, "r");
    if (!fp) {
	perror("opening file");
	exit(1);
	}

    int width, height, maxval;
    if (3!=fscanf(fp, "P5 %d %d %d", &width, &height, &maxval)) {
	cerr << "Error: was expecting raw PGM (P5) image in file "
	     << fname << "\n";
	exit(1);
    }

    int size=width*height;

    unsigned char *vec = new unsigned char[size];
    int ch;
    if((ch=getc(fp))!='\n')
	ungetc(ch,fp);
    if(!fread(vec,size,1,fp)) {
	perror("reading");
	exit(1);
    }

    int *ivec = new int[size];
    for(int i=0; i<size; i++){
	ivec[i] = vec[i];
    }

    image = IA_DiscreteImage<int>(ivec,IntPointSet(IntPoint(0,0),
						   IntPoint(height-1,width-1)),
				  size);
    delete ivec;
    delete vec;
}
#endif

#if 1
IA_DiscreteImage<int> calc(const IA_DiscreteImage<int> &lhs,
			      const IA_DiscreteImage<int> &rhs);
#endif

int main(int argc, char **argv)
{
//    malloc_debug(2);

    if (argc!=3) {
	cerr << "requires 2 arguments";
	exit(1);
    }

    IntDI	i1,i2;
#if 1
    read(argv[1],i1);
    read(argv[2],i2);
#else
    {
	ifstream	i(argv[1]);
	i1 = IntDI::read_PGM(i);
    }
    {
	ifstream	i(argv[2]);
	i2 = IntDI::read_PGM(i);
    }
#endif

#if 1
    IA_IntPointSet	common(i1.domain()&i2.domain());
    i1 = i1.restrict(common);
    i2 = i2.restrict(common);

    IntDI	i3 = calc(i1,i2);
#if 1
    write(i3, "shit.pgm");
#else
    i3.write_PGM(cout);
#endif
#endif
    exit(0);
}
@


1.3
log
@int main & exit(0)
@
text
@d2 1
a2 1
static char test002rcsid[] = "$Id: test102.c,v 1.2 1994/08/18 22:17:06 thoth Exp monica $";
d6 3
d17 1
a17 1
#include	<malloc.h>
d81 1
a81 1
    malloc_debug(2);
@


1.2
log
@incomplete updating.
@
text
@d2 1
a2 1
static char test002rcsid[] = "$Id: test102.c,v 1.1 93/02/20 16:49:24 thoth Exp Locker: thoth $";
d5 4
a8 1
// $Log:	test102.c,v $
d112 1
@


1.1
log
@Initial revision
@
text
@d2 1
a2 1
static char test002rcsid[] = "$Id: test100.c,v 1.1 92/11/14 09:45:50 jnw Exp Locker: jnw $";
d5 4
a8 1
// $Log:	test100.c,v $
d98 3
a100 3
    IntPointSet	common(i1.domain()&i2.domain());
    i1 = i1 & common;
    i2 = i2 & common;
@
