|
Last change
on this file since 3981 was 3572, checked in by cmv, 17 years ago |
|
char* -> const char* pour regler les problemes de deprecated string const... + comparaison unsigned signed + suppression EVOL_PLANCK rz+cmv 07/02/2009
|
|
File size:
972 bytes
|
| Line | |
|---|
| 1 | #ifndef PIMGADAPTER_SEEN
|
|---|
| 2 | #define PIMGADAPTER_SEEN
|
|---|
| 3 |
|
|---|
| 4 | #include "cimage.h"
|
|---|
| 5 | #include "parradapter.h"
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 | template <class T>
|
|---|
| 9 | class ImageAdapter : public P2DArrayAdapter {
|
|---|
| 10 | public:
|
|---|
| 11 | ImageAdapter(Image<T>* img, bool ad=false) :
|
|---|
| 12 | P2DArrayAdapter(img->XSize(), img->YSize())
|
|---|
| 13 | { aDel = ad; mImg = img;
|
|---|
| 14 | DefineXYCoordinates(img->XOrg(), img->YOrg(), 1., 1. ); }
|
|---|
| 15 |
|
|---|
| 16 | virtual ~ImageAdapter() { if (aDel) delete mImg; }
|
|---|
| 17 | virtual double Value(int ix, int iy) { return((*mImg)(ix, iy)); }
|
|---|
| 18 | virtual double MeanVal(int ix1, int ix2, int jy1, int jy2)
|
|---|
| 19 | {
|
|---|
| 20 | int ec;
|
|---|
| 21 | if (ix1>ix2) { ec=ix1; ix1=ix2; ix2=ec; }
|
|---|
| 22 | if (jy1>jy2) { ec=jy1; jy1=jy2; jy2=ec; }
|
|---|
| 23 | double ss = 0.;
|
|---|
| 24 | for(int j=jy1; j<=jy2; j++)
|
|---|
| 25 | for(int i=ix1; i<=ix2; i++) ss += (double)((*mImg)(i, j));
|
|---|
| 26 | ss /= (double)((jy2-jy1+1)*(ix2-ix1+1));
|
|---|
| 27 | return ss;
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | protected :
|
|---|
| 31 | bool aDel;
|
|---|
| 32 | Image<T>* mImg;
|
|---|
| 33 | };
|
|---|
| 34 |
|
|---|
| 35 | #endif
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.