[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 |
|
---|
[1390] | 18 | //! Class for handling images
|
---|
[220] | 19 | template <class T>
|
---|
[1104] | 20 | class Image : public TMatrix<T> {
|
---|
[220] | 21 |
|
---|
| 22 | public:
|
---|
| 23 | Image();
|
---|
[1390] | 24 | 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.);
|
---|
[1104] | 25 | Image(const Image<T>& a);
|
---|
| 26 | Image(const Image<T>& a, bool share);
|
---|
| 27 |
|
---|
[220] | 28 | virtual ~Image();
|
---|
| 29 |
|
---|
[1104] | 30 | // Inline element acces methods
|
---|
[1390] | 31 | inline T const& operator()(sa_size_t ix, sa_size_t jy) const;
|
---|
| 32 | inline T& operator()(sa_size_t ix, sa_size_t jy);
|
---|
[220] | 33 |
|
---|
[1390] | 34 | //! Returns the image size along X (corresponding to the number of columns)
|
---|
[2885] | 35 | inline sa_size_t XSize() const {return this->NCols();}
|
---|
[1390] | 36 | //! Returns the image size along Y (corresponding to the number of lines)
|
---|
[2885] | 37 | inline sa_size_t YSize() const {return this->NRows();}
|
---|
[220] | 38 |
|
---|
[1390] | 39 | //! Returns the X position, for pixel(0,0)
|
---|
[1104] | 40 | inline r_8 XOrg() const {return org_x;}
|
---|
[1390] | 41 | //! Returns the Y position, for pixel(0,0)
|
---|
[1104] | 42 | inline r_8 YOrg() const {return org_y;}
|
---|
[220] | 43 |
|
---|
[1390] | 44 | //! Returns pixel size along X
|
---|
[1104] | 45 | inline r_8 XPixSize() const {return pxsz_x;}
|
---|
[1390] | 46 | //! Returns pixel size along Y
|
---|
[1104] | 47 | inline r_8 YPixSize() const {return pxsz_y;}
|
---|
[220] | 48 |
|
---|
[1390] | 49 | //! Returns the pixel position along X, for pixels with X index \b i
|
---|
| 50 | inline r_8 XPos(sa_size_t i) const {return org_x + i*pxsz_x;}
|
---|
| 51 | //! Returns the pixel position along Y, for pixels with Y index \b j
|
---|
| 52 | inline r_8 YPos(sa_size_t j) const {return org_y + j*pxsz_y;}
|
---|
[1204] | 53 |
|
---|
[1390] | 54 | //! Set the position for pixel(0,0)
|
---|
[1104] | 55 | inline void SetOrg(r_8 orgx=0., r_8 orgy=0.)
|
---|
| 56 | { org_x = orgx; org_y = orgy; }
|
---|
[1390] | 57 | //! Set the pixel size
|
---|
[1104] | 58 | inline void SetPixelSize(r_8 szx=1., r_8 szy=1.)
|
---|
| 59 | { pxsz_x = szx; pxsz_y = szy; }
|
---|
[220] | 60 |
|
---|
| 61 | protected:
|
---|
[1104] | 62 | r_8 org_x,org_y; // Coordonnees pixel(0,0)
|
---|
| 63 | r_8 pxsz_x, pxsz_y; // Taille des pixels
|
---|
[220] | 64 | };
|
---|
| 65 |
|
---|
[1390] | 66 | //! () : Return the pixel value (element) for pixel \b ix (column index) and \b jy (line index)
|
---|
[220] | 67 | template <class T>
|
---|
[1390] | 68 | inline T const& Image<T>::operator()(sa_size_t ix, sa_size_t jy) const
|
---|
[220] | 69 | {
|
---|
[1104] | 70 | return (TMatrix<T>::operator() (jy, ix));
|
---|
[220] | 71 | }
|
---|
| 72 |
|
---|
[1390] | 73 | //! () : Return the pixel value (element) for pixel \b ix (column index) and \b jy (line index)
|
---|
[220] | 74 | template <class T>
|
---|
[1390] | 75 | inline T & Image<T>::operator()(sa_size_t ix, sa_size_t jy)
|
---|
[220] | 76 | {
|
---|
[1104] | 77 | return (TMatrix<T>::operator() (jy, ix));
|
---|
[220] | 78 | }
|
---|
| 79 |
|
---|
[1159] | 80 | /////////////////////////////////////////////////////////////////////////
|
---|
| 81 | //! Class for persistent management of Image
|
---|
| 82 | template <class T>
|
---|
| 83 | class FIO_Image : public FIO_TArray<T> {
|
---|
| 84 | public:
|
---|
| 85 | FIO_Image();
|
---|
| 86 | FIO_Image(string const & filename);
|
---|
| 87 | FIO_Image(const Image<T> & obj);
|
---|
| 88 | FIO_Image(Image<T> * obj);
|
---|
| 89 | // virtual ~FIO_Image();
|
---|
| 90 | virtual void SetDataObj(AnyDataObj & o);
|
---|
[2885] | 91 | inline operator Image<T>() { return(*(dynamic_cast<Image<T> * >(this->dobj))); }
|
---|
[1159] | 92 | protected :
|
---|
| 93 | virtual void ReadSelf(PInPersist&);
|
---|
| 94 | virtual void WriteSelf(POutPersist&) const;
|
---|
| 95 | };
|
---|
[220] | 96 |
|
---|
[1390] | 97 | /*! \ingroup NTools \fn operator<<(POutPersist&,Image<T>&)
|
---|
[1159] | 98 | \brief Write Image \b obj into POutPersist stream \b os */
|
---|
| 99 | template <class T>
|
---|
| 100 | inline POutPersist& operator << (POutPersist& os, Image<T> & obj)
|
---|
| 101 | { FIO_Image<T> fio(&obj); fio.Write(os); return(os); }
|
---|
| 102 |
|
---|
[1390] | 103 | /*! \ingroup NTools \fn operator>>(PInPersist&,Image<T>&)
|
---|
[1159] | 104 | \brief Read Image \b obj from PInPersist stream \b os */
|
---|
| 105 | template <class T>
|
---|
| 106 | inline PInPersist& operator >> (PInPersist& is, Image<T> & obj)
|
---|
| 107 | { FIO_Image<T> fio(&obj); fio.Read(is); return(is); }
|
---|
| 108 |
|
---|
| 109 |
|
---|
| 110 |
|
---|
[220] | 111 | typedef Image<uint_2> ImageU2;
|
---|
| 112 | typedef Image<int_4> ImageI4;
|
---|
| 113 | typedef Image<r_4> ImageR4;
|
---|
[1104] | 114 | typedef Image<r_8> ImageR8;
|
---|
[220] | 115 |
|
---|
[1104] | 116 | class GeneralFit;
|
---|
[1390] | 117 | //! OBSOLETE - Should not be used - for compatibility with peida in (s)piapp
|
---|
[1104] | 118 | class RzImage {
|
---|
| 119 | public:
|
---|
| 120 | RzImage() { }
|
---|
| 121 | ~RzImage() { }
|
---|
| 122 | inline uint_4 XSize() const {return 0;}
|
---|
| 123 | inline uint_4 YSize() const {return 0;}
|
---|
[220] | 124 |
|
---|
[1104] | 125 | inline r_8 XOrg() const {return 0;}
|
---|
| 126 | inline r_8 YOrg() const {return 0;}
|
---|
[220] | 127 |
|
---|
[1104] | 128 | inline r_8 XPixSize() const {return 1.;}
|
---|
| 129 | inline r_8 YPixSize() const {return 1.;}
|
---|
| 130 | inline r_8 DValue(int i, int j) const { return 0.; }
|
---|
| 131 | // Resultats d'un GeneralFit
|
---|
| 132 | inline RzImage* FitResidus(GeneralFit& gfit) { return NULL; }
|
---|
| 133 | inline RzImage* FitFunction(GeneralFit& gfit) { return NULL; }
|
---|
[896] | 134 |
|
---|
[1104] | 135 | };
|
---|
| 136 |
|
---|
| 137 | } // End of namespace SOPHYA
|
---|
| 138 |
|
---|
[220] | 139 | #endif
|
---|
| 140 |
|
---|
| 141 |
|
---|