#line 1 "/user/cvsspst/ees1cg/RAVL/RAVL-0.7/Image/Processing/Lines/PCMapping.hh" // This file is part of RAVL, Recognition And Vision Library // Copyright (C) 2001, University of Surrey // This code may be redistributed under the terms of the GNU Lesser // General Public License (LGPL). See the lgpl.licence file for details or // see http://www.gnu.org/copyleft/lesser.html // file-header-ends-here #ifndef RAVLIMAGE_PCMAPPING_HEADER #define RAVLIMAGE_PCMAPPING_HEADER 1 //////////////////////////////////////////////////////////// //! docentry="Ravl.Images.Lines" //! file="Ravl/Image/Processing/Lines/PCMapping.hh" //! lib=RavlImageProc //! author="Charles Galambos" //! rcsid="$Id: PCMapping.hh,v 1.4 2002/06/28 09:24:54 craftit Exp $" //! date="07/01/99" #include "Ravl/Tuple2.hh" #include "Ravl/Image/PCPixelList.hh" #include "Ravl/DLIter.hh" #include "Ravl/SArray1d.hh" #ifndef __sgi__ #include #else #include #endif namespace RavlImageN { //! userlevel=Normal //: Simple mapping between a curve and some pixels. template class PCPixMapC { public: PCPixMapC() {} //: Default constructor. // The curve will be in an undefined state, and the pixel list // will be empty. PCPixMapC(const CurveT &cur,const PCPixelListC &px = PCPixelListC(true),SArray1dC threshData = SArray1dC()) : curve(cur), pixs(px), values(threshData) {} //: Constructor. CurveT &Curve() { return curve; } //: Access curve. const CurveT &Curve() const { return curve; } //: Access curve. PCPixelListC &PixList() { return pixs; } //: Access pixel list. const PCPixelListC &PixList() const { return pixs; } //: Access pixel list. void InsLast(Index2dC pix) { RealT p = curve.Closest(pix); pixs.InsLast(PCIndex2dC(pix,curve.Point(p),p)); } //: Add new pixel to end of list. SArray1dC &Thresh() { return values; } //: Access threshold used in finding this line. SArray1dC Thresh() const { return values; } //: Access threshold used in finding this line. protected: CurveT curve; PCPixelListC pixs; SArray1dC values; }; template ostream &operator<<(ostream &strm,const PCPixMapC &data) { RavlAssert(0); // Not implemented. return strm; } template istream &operator>>(istream &strm,PCPixMapC &data) { RavlAssert(0); // Not implemented. return strm; } //! userlevel=Normal //: Mappings from a curve to a set of pixels. template class PCPixMappingC : public DListC > { public: PCPixMappingC(); //: Default constructor. inline PCPixMappingC(const DListC > &oth); //: Constructor. bool WriteGF(ostream &out) const; //: Write in GF format. }; template ostream &operator<<(ostream &strm,const PCPixMappingC &data) { strm << ((const DListC > &) data); return strm; } template istream &operator>>(istream &strm,PCPixMappingC &data) { strm >> ((DListC > &) data); return strm; } //////////////////////////////////////////// template PCPixMappingC::PCPixMappingC() {} template inline PCPixMappingC::PCPixMappingC(const DListC > &oth) : DListC >(oth) {} template bool PCPixMappingC::WriteGF(ostream &out) const { out << "@Set " << typeid(CurveT).name() << endl; out << "Format idEdgePixels "; CurveT::WriteGFHeader(out); // Write curve header. out << endl; IntT id = 1; DLIterC > it(*this); for(;it;it++) { out << id++ << " "; it.Data().Curve().WriteGF(out); out << endl; } out << "@\n"; out << "@Set EdgePixels\n"; out << "Format "; PCPixelListC::WriteGFHeader(out); out << endl; for(it.First();it;it++) { it.Data().PixList().WriteGFPnts(out); out << endl; } out << "@\n"; return true; } } #endif