| [220] | 1 | // This may look like C code, but it is really -*- C++ -*- | 
|---|
| [1104] | 2 | //  Classes image heritant de TMatrix<T> | 
|---|
|  | 3 | //                       R.Ansari, C.Magneville 07/2000 | 
|---|
| [220] | 4 | // LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA | 
|---|
|  | 5 |  | 
|---|
|  | 6 | #ifndef CIMAGE_SEEN | 
|---|
|  | 7 | #define CIMAGE_SEEN | 
|---|
|  | 8 |  | 
|---|
| [1104] | 9 | #include "tmatrix.h" | 
|---|
| [1159] | 10 | #include "fioarr.h" | 
|---|
| [220] | 11 |  | 
|---|
|  | 12 |  | 
|---|
|  | 13 | // ********************************************************** | 
|---|
|  | 14 | // Classe Image | 
|---|
|  | 15 |  | 
|---|
| [1104] | 16 | namespace SOPHYA { | 
|---|
| [220] | 17 |  | 
|---|
|  | 18 | template <class T> | 
|---|
| [1104] | 19 | class Image : public TMatrix<T> { | 
|---|
| [220] | 20 |  | 
|---|
|  | 21 | public: | 
|---|
|  | 22 | Image(); | 
|---|
| [1104] | 23 | Image(uint_4 sizx, uint_4 sizy, r_8 szpx=1., r_8 szpy=1., r_8 orgx=0., r_8 orgy=0.); | 
|---|
|  | 24 | Image(const Image<T>& a); | 
|---|
|  | 25 | Image(const Image<T>& a, bool share); | 
|---|
|  | 26 |  | 
|---|
| [220] | 27 | virtual ~Image(); | 
|---|
|  | 28 |  | 
|---|
| [1104] | 29 | // Inline element acces methods | 
|---|
|  | 30 | inline T const& operator()(uint_4 ix,uint_4 jy) const; | 
|---|
|  | 31 | inline T&       operator()(uint_4 ix,uint_4 jy); | 
|---|
| [220] | 32 |  | 
|---|
| [1104] | 33 | inline uint_4  XSize() const {return NCols();} | 
|---|
|  | 34 | inline uint_4  YSize() const {return NRows();} | 
|---|
| [220] | 35 |  | 
|---|
| [1104] | 36 | inline r_8     XOrg() const {return org_x;} | 
|---|
|  | 37 | inline r_8     YOrg() const {return org_y;} | 
|---|
| [220] | 38 |  | 
|---|
| [1104] | 39 | inline r_8     XPixSize() const {return pxsz_x;} | 
|---|
|  | 40 | inline r_8     YPixSize() const {return pxsz_y;} | 
|---|
| [220] | 41 |  | 
|---|
| [1204] | 42 | inline r_8     XPos(uint_4 i) const {return org_x + i*pxsz_x;} | 
|---|
|  | 43 | inline r_8     YPos(uint_4 j) const {return org_y + j*pxsz_y;} | 
|---|
|  | 44 |  | 
|---|
| [1104] | 45 | inline void    SetOrg(r_8 orgx=0., r_8 orgy=0.) | 
|---|
|  | 46 | { org_x = orgx;  org_y = orgy; } | 
|---|
|  | 47 | inline void    SetPixelSize(r_8 szx=1., r_8 szy=1.) | 
|---|
|  | 48 | { pxsz_x = szx;   pxsz_y = szy; } | 
|---|
| [220] | 49 |  | 
|---|
|  | 50 | protected: | 
|---|
| [1104] | 51 | r_8   org_x,org_y;        //  Coordonnees pixel(0,0) | 
|---|
|  | 52 | r_8   pxsz_x, pxsz_y;     //  Taille des pixels | 
|---|
| [220] | 53 | }; | 
|---|
|  | 54 |  | 
|---|
|  | 55 | template <class T> | 
|---|
| [1104] | 56 | inline T const& Image<T>::operator()(uint_4 ix, uint_4 jy) const | 
|---|
| [220] | 57 | { | 
|---|
| [1104] | 58 | return (TMatrix<T>::operator() (jy, ix)); | 
|---|
| [220] | 59 | } | 
|---|
|  | 60 |  | 
|---|
|  | 61 | template <class T> | 
|---|
| [1104] | 62 | inline T & Image<T>::operator()(uint_4 ix, uint_4 jy) | 
|---|
| [220] | 63 | { | 
|---|
| [1104] | 64 | return (TMatrix<T>::operator() (jy, ix)); | 
|---|
| [220] | 65 | } | 
|---|
|  | 66 |  | 
|---|
| [1159] | 67 | ///////////////////////////////////////////////////////////////////////// | 
|---|
|  | 68 | //! Class for persistent management of Image | 
|---|
|  | 69 | template <class T> | 
|---|
|  | 70 | class FIO_Image : public FIO_TArray<T>   { | 
|---|
|  | 71 | public: | 
|---|
|  | 72 | FIO_Image(); | 
|---|
|  | 73 | FIO_Image(string const & filename); | 
|---|
|  | 74 | FIO_Image(const Image<T> & obj); | 
|---|
|  | 75 | FIO_Image(Image<T> * obj); | 
|---|
|  | 76 | //  virtual ~FIO_Image(); | 
|---|
|  | 77 | virtual void        SetDataObj(AnyDataObj & o); | 
|---|
| [1169] | 78 | inline operator Image<T>() { return(*(dynamic_cast<Image<T> * >(dobj))); } | 
|---|
| [1159] | 79 | protected : | 
|---|
|  | 80 | virtual void ReadSelf(PInPersist&); | 
|---|
|  | 81 | virtual void WriteSelf(POutPersist&) const; | 
|---|
|  | 82 | }; | 
|---|
| [220] | 83 |  | 
|---|
| [1159] | 84 | /*! \ingroup Image \fn operator<<(POutPersist&,Image<T>&) | 
|---|
|  | 85 | \brief Write Image \b obj into POutPersist stream \b os */ | 
|---|
|  | 86 | template <class T> | 
|---|
|  | 87 | inline POutPersist& operator << (POutPersist& os, Image<T> & obj) | 
|---|
|  | 88 | { FIO_Image<T> fio(&obj);  fio.Write(os);  return(os); } | 
|---|
|  | 89 |  | 
|---|
|  | 90 | /*! \ingroup Image \fn operator>>(PInPersist&,Image<T>&) | 
|---|
|  | 91 | \brief Read Image \b obj from PInPersist stream \b os */ | 
|---|
|  | 92 | template <class T> | 
|---|
|  | 93 | inline PInPersist& operator >> (PInPersist& is, Image<T> & obj) | 
|---|
|  | 94 | { FIO_Image<T> fio(&obj);  fio.Read(is);  return(is); } | 
|---|
|  | 95 |  | 
|---|
|  | 96 |  | 
|---|
|  | 97 |  | 
|---|
| [220] | 98 | typedef Image<uint_2> ImageU2; | 
|---|
|  | 99 | typedef Image<int_4>  ImageI4; | 
|---|
|  | 100 | typedef Image<r_4>    ImageR4; | 
|---|
| [1104] | 101 | typedef Image<r_8>    ImageR8; | 
|---|
| [220] | 102 |  | 
|---|
| [1104] | 103 | class GeneralFit; | 
|---|
|  | 104 | class RzImage { | 
|---|
|  | 105 | public: | 
|---|
|  | 106 | RzImage() { } | 
|---|
|  | 107 | ~RzImage() { } | 
|---|
|  | 108 | inline uint_4  XSize() const {return 0;} | 
|---|
|  | 109 | inline uint_4  YSize() const {return 0;} | 
|---|
| [220] | 110 |  | 
|---|
| [1104] | 111 | inline r_8     XOrg() const {return 0;} | 
|---|
|  | 112 | inline r_8     YOrg() const {return 0;} | 
|---|
| [220] | 113 |  | 
|---|
| [1104] | 114 | inline r_8     XPixSize() const {return 1.;} | 
|---|
|  | 115 | inline r_8     YPixSize() const {return 1.;} | 
|---|
|  | 116 | inline r_8     DValue(int i, int j) const { return 0.; } | 
|---|
|  | 117 | // Resultats d'un GeneralFit | 
|---|
|  | 118 | inline RzImage*      FitResidus(GeneralFit& gfit) { return NULL; } | 
|---|
|  | 119 | inline RzImage*      FitFunction(GeneralFit& gfit) { return NULL; } | 
|---|
| [896] | 120 |  | 
|---|
| [1104] | 121 | }; | 
|---|
|  | 122 |  | 
|---|
|  | 123 | }  // End of namespace SOPHYA | 
|---|
|  | 124 |  | 
|---|
| [220] | 125 | #endif | 
|---|
|  | 126 |  | 
|---|
|  | 127 |  | 
|---|