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


1.3
date	94.10.26.00.10.54;	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.46.36;	author thoth;	state Exp;
branches;
next	;


desc
@compute the histogram of an image.
@


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

//
// compute the histogram of an image
//

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

#include "IntDI.h"
//#include "OtherI.h"
#include "FloatDI.h"
#include "ImageIter.h"

typedef IA_Image<IA_Point<int>,int>	IntDI;

class HistImage: public IA_Image<IA_Point<int> ,int> {
    IntDI	hist;
  public:
    HistImage(IntDI hist_)
    :IA_Image<IA_Point<int> ,int>(IA_Set<IA_Point<int> >(concat(0, hist_.domain().inf()),
				    concat(255, hist_.domain().sup()))),
    hist(hist_) {
	domain().output(cout);
    }
    int operator()(const IA_Point<int>  &p) const {
	return p[0]+hist(cdr(p)) > 255;
    }
    IA_Image<IA_Point<int> ,int> *clone_self() const { return new HistImage(*this); }
};

int main()
{
  IntDI	im(IntDI::read_PGM(cin));

  IA_IVIter<IA_Point<int> ,int>	iter(im);
  int	v, maxv;
  IntDI	hist(IA_Set<IA_Point<int> >(IA_Point<int> (min(im)),
			    IA_Point<int> (max(im))),0);

  while (iter(v)) {
    hist[IA_Point<int> (v)] ++;
  }
  hist[hist.domain().sup()] = hist[hist.domain().inf()] = 0;

  maxv = max(hist);
  if (maxv>255) {
      (hist *= 255) /= maxv;
      maxv = 255;
  }

  IntDI(HistImage(hist)).write_PGM(cout);

  exit(0);
}


@


1.2
log
@int main & exit(0)
@
text
@d2 1
a2 1
static char test109_rcsid[] = "$Id: test109.c,v 1.1 1994/02/18 18:46:36 thoth Exp monica $";
d10 3
d18 1
a18 1
#include "OtherI.h"
d22 1
a22 1
typedef IA_IntDiscreteImage	IntDI;
d24 1
a24 1
class HistImage: public IA_OtherI<IA_IntPoint,int> {
d28 1
a28 1
    :IA_OtherI<IA_IntPoint,int>(IA_IntPointSet(concat(0, hist_.domain().inf()),
d33 1
a33 1
    int operator()(const IA_IntPoint &p) const {
d36 1
a36 1
    IA_OtherI<IA_IntPoint,int> *clone_self() const { return new HistImage(*this); }
d43 1
a43 1
  IA_IVIter<IA_IntPoint,int>	iter(im);
d45 2
a46 2
  IntDI	hist(IA_IntPointSet(IA_IntPoint(min(im)),
			    IA_IntPoint(max(im))),0);
d49 1
a49 1
    hist[IA_IntPoint(v)] ++;
d63 2
@


1.1
log
@Initial revision
@
text
@d2 1
a2 1
static char test109_rcsid[] = "$Id: test105.c,v 1.1 93/03/10 13:57:00 thoth Exp $";
d9 4
a12 1
// $Log:	test105.c,v $
d57 2
@
