Last change
on this file since 3559 was 3520, checked in by ansari, 17 years ago |
Ajout/codage methode P2DArrayAdapter::MeanVal() pour les classes adapter heritant de P2DArrayAdapter, Reza 11/09/2008
|
File size:
1.5 KB
|
Rev | Line | |
---|
[165] | 1 | #ifndef PIMGADAPTER_SEEN
|
---|
| 2 | #define PIMGADAPTER_SEEN
|
---|
| 3 |
|
---|
| 4 | #include "cimage.h"
|
---|
| 5 | #include "parradapter.h"
|
---|
| 6 |
|
---|
[493] | 7 | #ifdef SANS_EVOLPLANCK
|
---|
[165] | 8 | class RzImageAdapter : public P2DArrayAdapter {
|
---|
| 9 | public:
|
---|
| 10 | RzImageAdapter(RzImage* rzi, bool ad=false) :
|
---|
| 11 | P2DArrayAdapter(rzi->XSize(), rzi->YSize())
|
---|
[338] | 12 | { aDel = ad; mImg = rzi;
|
---|
| 13 | DefineXYCoordinates(rzi->XOrg(), rzi->YOrg(), 1., 1. ); }
|
---|
[165] | 14 |
|
---|
| 15 | virtual ~RzImageAdapter() { if (aDel) delete mImg; }
|
---|
[205] | 16 | virtual double Value(int ix, int iy) { return mImg->FValue(ix, iy); }
|
---|
[165] | 17 |
|
---|
| 18 | protected :
|
---|
| 19 | bool aDel;
|
---|
| 20 | RzImage* mImg;
|
---|
| 21 | };
|
---|
[493] | 22 | #endif
|
---|
[165] | 23 |
|
---|
| 24 | template <class T>
|
---|
| 25 | class ImageAdapter : public P2DArrayAdapter {
|
---|
| 26 | public:
|
---|
| 27 | ImageAdapter(Image<T>* img, bool ad=false) :
|
---|
| 28 | P2DArrayAdapter(img->XSize(), img->YSize())
|
---|
[338] | 29 | { aDel = ad; mImg = img;
|
---|
| 30 | DefineXYCoordinates(img->XOrg(), img->YOrg(), 1., 1. ); }
|
---|
[165] | 31 |
|
---|
| 32 | virtual ~ImageAdapter() { if (aDel) delete mImg; }
|
---|
[205] | 33 | virtual double Value(int ix, int iy) { return((*mImg)(ix, iy)); }
|
---|
[3520] | 34 | virtual double MeanVal(int ix1, int ix2, int jy1, int jy2)
|
---|
| 35 | {
|
---|
| 36 | int ec;
|
---|
| 37 | if (ix1>ix2) { ec=ix1; ix1=ix2; ix2=ec; }
|
---|
| 38 | if (jy1>jy2) { ec=jy1; jy1=jy2; jy2=ec; }
|
---|
| 39 | double ss = 0.;
|
---|
| 40 | for(int j=jy1; j<=jy2; j++)
|
---|
| 41 | for(int i=ix1; i<=ix2; i++) ss += (double)((*mImg)(i, j));
|
---|
| 42 | ss /= (double)((jy2-jy1+1)*(ix2-ix1+1));
|
---|
| 43 | return ss;
|
---|
| 44 | }
|
---|
[165] | 45 |
|
---|
| 46 | protected :
|
---|
| 47 | bool aDel;
|
---|
| 48 | Image<T>* mImg;
|
---|
| 49 | };
|
---|
| 50 |
|
---|
| 51 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.