// This may look like C code, but it is really -*- C++ -*- // Classes image heritant de TMatrix // R.Ansari, C.Magneville 07/2000 // LAL (Orsay) / IN2P3-CNRS DAPNIA/SPP (Saclay) / CEA #ifndef CIMAGE_SEEN #define CIMAGE_SEEN #include "tmatrix.h" #include "fioarr.h" // ********************************************************** // Classe Image namespace SOPHYA { //! Class for handling images template class Image : public TMatrix { public: Image(); Image(sa_size_t sizx, sa_size_t sizy, r_8 szpx=1., r_8 szpy=1., r_8 orgx=0., r_8 orgy=0.); Image(const Image& a); Image(const Image& a, bool share); virtual ~Image(); // Inline element acces methods inline T const& operator()(sa_size_t ix, sa_size_t jy) const; inline T& operator()(sa_size_t ix, sa_size_t jy); //! Returns the image size along X (corresponding to the number of columns) inline sa_size_t XSize() const {return this->NCols();} //! Returns the image size along Y (corresponding to the number of lines) inline sa_size_t YSize() const {return this->NRows();} //! Returns the X position, for pixel(0,0) inline r_8 XOrg() const {return org_x;} //! Returns the Y position, for pixel(0,0) inline r_8 YOrg() const {return org_y;} //! Returns pixel size along X inline r_8 XPixSize() const {return pxsz_x;} //! Returns pixel size along Y inline r_8 YPixSize() const {return pxsz_y;} //! Returns the pixel position along X, for pixels with X index \b i inline r_8 XPos(sa_size_t i) const {return org_x + i*pxsz_x;} //! Returns the pixel position along Y, for pixels with Y index \b j inline r_8 YPos(sa_size_t j) const {return org_y + j*pxsz_y;} //! Set the position for pixel(0,0) inline void SetOrg(r_8 orgx=0., r_8 orgy=0.) { org_x = orgx; org_y = orgy; } //! Set the pixel size inline void SetPixelSize(r_8 szx=1., r_8 szy=1.) { pxsz_x = szx; pxsz_y = szy; } protected: r_8 org_x,org_y; // Coordonnees pixel(0,0) r_8 pxsz_x, pxsz_y; // Taille des pixels }; //! () : Return the pixel value (element) for pixel \b ix (column index) and \b jy (line index) template inline T const& Image::operator()(sa_size_t ix, sa_size_t jy) const { return (TMatrix::operator() (jy, ix)); } //! () : Return the pixel value (element) for pixel \b ix (column index) and \b jy (line index) template inline T & Image::operator()(sa_size_t ix, sa_size_t jy) { return (TMatrix::operator() (jy, ix)); } ///////////////////////////////////////////////////////////////////////// //! Class for persistent management of Image template class FIO_Image : public FIO_TArray { public: FIO_Image(); FIO_Image(string const & filename); FIO_Image(const Image & obj); FIO_Image(Image * obj); // virtual ~FIO_Image(); virtual void SetDataObj(AnyDataObj & o); inline operator Image() { return(*(dynamic_cast * >(this->dobj))); } protected : virtual void ReadSelf(PInPersist&); virtual void WriteSelf(POutPersist&) const; }; /*! \ingroup NTools \fn operator<<(POutPersist&,Image&) \brief Write Image \b obj into POutPersist stream \b os */ template inline POutPersist& operator << (POutPersist& os, Image & obj) { FIO_Image fio(&obj); fio.Write(os); return(os); } /*! \ingroup NTools \fn operator>>(PInPersist&,Image&) \brief Read Image \b obj from PInPersist stream \b os */ template inline PInPersist& operator >> (PInPersist& is, Image & obj) { FIO_Image fio(&obj); fio.Read(is); return(is); } typedef Image ImageU2; typedef Image ImageI4; typedef Image ImageR4; typedef Image ImageR8; class GeneralFit; //! OBSOLETE - Should not be used - for compatibility with peida in (s)piapp class RzImage { public: RzImage() { } ~RzImage() { } inline uint_4 XSize() const {return 0;} inline uint_4 YSize() const {return 0;} inline r_8 XOrg() const {return 0;} inline r_8 YOrg() const {return 0;} inline r_8 XPixSize() const {return 1.;} inline r_8 YPixSize() const {return 1.;} inline r_8 DValue(int i, int j) const { return 0.; } // Resultats d'un GeneralFit inline RzImage* FitResidus(GeneralFit& gfit) { return NULL; } inline RzImage* FitFunction(GeneralFit& gfit) { return NULL; } }; } // End of namespace SOPHYA #endif