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


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

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

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


desc
@magnify and rotate an image.
@


1.3
log
@updated type names
@
text
@// Emacs -*- C++ -*-
static char test112_rcsid[] = "$Id: test112.c,v 1.2 1994/08/24 00:30:59 monica Exp monica $";

//
// magnify and rotate an image
//

//
// $Log: test112.c,v $
// Revision 1.2  1994/08/24  00:30:59  monica
// int main & exit(0)
//
//Revision 1.1  1994/02/18  18:59:11  thoth
//Initial revision
//
//

#include <iostream.h>

#include "Image.h"
#include "IntDI.h"
#include "UcharDI.h"
#include "FloatDI.h"
#include "ClosureI.h"
#include "../test_image/BLinterp.h"

#if 0
class ramp: public IA_OtherCI<int> {
  public:
    ramp(IA_FloatPointSet ps) :IA_OtherCI<int>(ps) { }
    int operator()(const IA_FloatPoint &fp) const {
	return (int) fp[0];
    }
    IA_OtherCI<int> * clone_self() const { return new ramp(*this); }
};

IA_ContinuousImage<int>	barf(ramp(IA_CWhiteHole(2)));
#endif

IA_Point<double>  triple(const IA_Point<double>  &p)
{
    return p/3.0;
}
#if 1
class rot : public IA_Closure<IA_Point<double> , IA_Point<double> > {
    const double	S,C;
  public:
    rot(double	theta)
    :S(sin(theta)), C(cos(theta)) { }
    IA_Closure<IA_Point<double> , IA_Point<double> >* clone_self() const {
	return new rot(*this);
    }
    IA_Point<double>  operator()(const IA_Point<double>  &p) const {
	return IA_Point<double> (p[0]*C + p[1]*S, p[1]*C-p[0]*S);
    }
};
#else
const double	rfact = 20.0/180*M_PI;
const double	srf = sin(rfact);
const double	crf = cos(rfact);
IA_Point<double>  rot20(const IA_Point<double>  &p)
{
  return IA_Point<double> (p[0]*crf+p[1]*srf, -p[0]*srf+p[1]*crf);
}
#endif
int main()
{
    IA_Image<IA_Point<int>, float>	sr71(IA_Image<IA_Point<int>, int>::read_PGM(cin));
    IA_Image<IA_Point<double>,float> sr71i(IA_BLInterp<float>(sr71));
    
    sr71i = compose(sr71i, triple);
#if 1
    sr71i = compose(sr71i, rot(20.0/180*M_PI));
#else
    sr71i = compose(sr71i, rot20);
#endif
    
    IA_Image<IA_Point<int>, u_char>	udi(to_uchar(sr71i.restrict(IA_Set<IA_Point<int> >(IA_Point<int>(0,0), 3*IA_Point<int>(63,63)))));

#if 1
    char	*disp=getenv("DISPLAY");
    if (disp==0) {
	cerr << "No DISPLAY environment variable, hasta.\n";
	exit(1);
    }

    IDP::ClientID	cid;
    cid = IDP::NewClient("iac++ test013");

    IDP::LinkID		lid;
    lid = IDP::CreateDisplay(cid, disp, IDP::READ_WRITE);
    sleep(5);			// avoid race condition

    udi.IDM_display(lid, "scaled and rotated");
#endif
    udi.write_PGM(cout);

    exit(0);
}
@


1.2
log
@int main & exit(0)
@
text
@d2 1
a2 1
static char test112_rcsid[] = "$Id: test112.c,v 1.1 1994/02/18 18:59:11 thoth Exp monica $";
d10 3
d40 1
a40 1
IA_FloatPoint triple(const IA_FloatPoint &p)
d45 1
a45 1
class rot : public IA_Closure<IA_FloatPoint, IA_FloatPoint> {
d50 1
a50 1
    IA_Closure<IA_FloatPoint, IA_FloatPoint>* clone_self() const {
d53 2
a54 2
    IA_FloatPoint operator()(const IA_FloatPoint &p) const {
	return IA_FloatPoint(p[0]*C + p[1]*S, p[1]*C-p[0]*S);
d61 1
a61 1
IA_FloatPoint rot20(const IA_FloatPoint &p)
d63 1
a63 1
  return IA_FloatPoint(p[0]*crf+p[1]*srf, -p[0]*srf+p[1]*crf);
d68 2
a69 2
    IA_FloatDiscreteImage	sr71(IA_IntDiscreteImage::read_PGM(cin));
    IA_Image<IA_FloatPoint,float> sr71i(IA_BLInterp<float>(sr71));
d78 1
a78 1
    IA_UcharDiscreteImage	udi(to_uchar(sr71i.restrict(IA_IntPointSet(IA_IntPoint(0,0), 3*IA_IntPoint(63,63)))));
@


1.1
log
@Initial revision
@
text
@d2 1
a2 1
static char test112_rcsid[] = "$Id: test105.c,v 1.1 93/03/10 13:57:00 thoth Exp $";
d9 3
a11 1
// $Log$
d13 1
d63 1
a63 1
main()
d94 2
@
