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