[244] | 1 | #include "machdefs.h"
|
---|
[220] | 2 | #include <stdio.h>
|
---|
| 3 | #include <stdlib.h>
|
---|
| 4 |
|
---|
| 5 | #include "simplesort.h"
|
---|
| 6 | #include "nbmath.h"
|
---|
| 7 | #include "histos.h"
|
---|
| 8 | #include "datatypes.h"
|
---|
| 9 | #include "imageop.h"
|
---|
| 10 | #include "nbtri.h"
|
---|
| 11 |
|
---|
| 12 |
|
---|
| 13 | //++
|
---|
| 14 | // Module Operations sur les images (C++)
|
---|
| 15 | // Lib Images++
|
---|
| 16 | // include imageop.h
|
---|
| 17 | //
|
---|
| 18 | // Operations sur les images.
|
---|
| 19 | //--
|
---|
| 20 |
|
---|
| 21 |
|
---|
| 22 | // Outils prives.
|
---|
| 23 | template <class T>
|
---|
| 24 | float RzCmvSigmaCiel(T const * pix,int nx,int ny,int ndata,int bin,
|
---|
| 25 | int taille,float frac,int deg,
|
---|
| 26 | float low,float high,int deb);
|
---|
| 27 |
|
---|
| 28 | #ifdef IMGRGCHECK
|
---|
| 29 | #define CHECKIMG2(_img_,_x_,_y_) \
|
---|
| 30 | if ((_x_ >= (_img_).siz_x) || (_y_ >= (_img_).siz_y) || \
|
---|
| 31 | (_x_ < 0) || (_y_ < 0)) THROW(rangeCheckErr); \
|
---|
| 32 | if (!(_img_).ImagePtr()) THROW(nullPtrErr)
|
---|
| 33 | #else
|
---|
| 34 | #if defined(IMGVOIDCHECK)
|
---|
| 35 | #define CHECKIMG2(_img_,_x_,_y_) \
|
---|
| 36 | if (!(_img_).ImagePtr()) THROW(NullPtrErr)
|
---|
| 37 | #else
|
---|
| 38 | #define CHECKIMG2(_img_,_x_,_y_)
|
---|
| 39 | #endif
|
---|
| 40 | #endif /* IMGRGCHECK */
|
---|
| 41 |
|
---|
| 42 | // Les fonctions
|
---|
| 43 |
|
---|
| 44 | /* Nouvelle-Fonction */
|
---|
| 45 |
|
---|
| 46 | template <class T>
|
---|
| 47 | void CleanImagesOld(int nImg, Image<T>** imgTab, double nSig,
|
---|
| 48 | double lowbad, double highbad)
|
---|
| 49 |
|
---|
| 50 | /* Nettoie une serie d'image a partir de l'histo de la */
|
---|
| 51 | /* serie de valeurs pour chaque pixel (Voir E. Aubourg) */
|
---|
| 52 |
|
---|
| 53 | {
|
---|
| 54 | if (lowbad < MinRange((T)0))
|
---|
| 55 | lowbad = MinRange((T)0);
|
---|
| 56 |
|
---|
| 57 | if (highbad > MaxRange((T)0))
|
---|
| 58 | highbad = MaxRange((T)0);
|
---|
| 59 |
|
---|
| 60 | if (lowbad >= highbad)
|
---|
| 61 | {lowbad = MinRange((T)0); highbad = MaxRange((T)0);}
|
---|
| 62 | Histo h(lowbad, highbad, 500);
|
---|
| 63 |
|
---|
| 64 | for (int i=0; i<imgTab[0]->XSize(); i++)
|
---|
| 65 | for (int j=0; j<imgTab[0]->YSize(); j++) {
|
---|
| 66 | h.Zero();
|
---|
| 67 | for (int k=0; k<nImg; k++)
|
---|
| 68 | h.Add((*imgTab[k])(i,j));
|
---|
| 69 | float x0, s0=0;
|
---|
| 70 | x0 = h.CleanedMean(s0);
|
---|
| 71 | float low = x0 - s0*nSig; if (low < lowbad) low = lowbad;
|
---|
| 72 | float hi = x0 + s0*nSig; // if (hi > highbad) hi = highbad;
|
---|
| 73 | for (k=0; k<nImg; k++)
|
---|
| 74 | if ((*imgTab[k])(i,j) > hi || (*imgTab[k])(i,j) < low)
|
---|
| 75 | (*imgTab[k])(i,j) = 0;
|
---|
| 76 | }
|
---|
| 77 | }
|
---|
| 78 |
|
---|
| 79 | /* Nouvelle-Fonction */
|
---|
| 80 |
|
---|
| 81 | template <class T>
|
---|
| 82 | //++
|
---|
| 83 | void CleanImages(int nImg, Image<T>** imgTab, double nSig,
|
---|
| 84 | double lowbad, double highbad)
|
---|
| 85 | //
|
---|
| 86 | // Nettoie une serie de `nImg' images `imgTab' a partir
|
---|
| 87 | // d'une moyenne tronquee a `nSig' sigma
|
---|
| 88 | // de la serie de valeurs pour chaque pixel.
|
---|
| 89 | // Les valeurs des pixels sont prises entre `lowbad' et `highbad'.
|
---|
| 90 | //--
|
---|
| 91 | {
|
---|
| 92 | if (lowbad < MinRange((T)0))
|
---|
| 93 | lowbad = MinRange((T)0);
|
---|
| 94 |
|
---|
| 95 | if (highbad > MaxRange((T)0))
|
---|
| 96 | highbad = MaxRange((T)0);
|
---|
| 97 |
|
---|
| 98 | if (lowbad >= highbad)
|
---|
| 99 | {lowbad = MinRange((T)0); highbad = MaxRange((T)0);}
|
---|
| 100 |
|
---|
| 101 | double sx, sx2, sig, mean;
|
---|
| 102 | int n;
|
---|
| 103 |
|
---|
| 104 | for (int i=0; i<imgTab[0]->XSize(); i++)
|
---|
| 105 | for (int j=0; j<imgTab[0]->YSize(); j++) {
|
---|
| 106 | sig = 1e20; mean = 0;
|
---|
| 107 | for (int l = 0; l<3; l++) {
|
---|
| 108 | double low = mean - nSig*sig;
|
---|
| 109 | if (low < lowbad) low = lowbad;
|
---|
| 110 | double high = mean + nSig*sig;
|
---|
| 111 | if (high > highbad) high = highbad;
|
---|
| 112 | sx = sx2 = n = 0;
|
---|
| 113 | for (int k=0; k<nImg; k++) {
|
---|
| 114 | double p = (*imgTab[k])(i,j);
|
---|
| 115 | if (p > low && p < high) {
|
---|
| 116 | sx += p;
|
---|
| 117 | sx2 += p*p;
|
---|
| 118 | n++;
|
---|
| 119 | }
|
---|
| 120 | }
|
---|
| 121 | if (n>0) {
|
---|
| 122 | mean = sx / n;
|
---|
| 123 | sig = sqrt( sx2/n - (sx/n)*(sx/n) );
|
---|
| 124 | } // sinon on laisse tel quel, ca sera coupe...
|
---|
| 125 | }
|
---|
| 126 | double low = mean - nSig*sig;
|
---|
| 127 | if (low < lowbad) low = lowbad;
|
---|
| 128 | double high = mean + nSig*sig;
|
---|
| 129 | if (high > highbad) high = highbad;
|
---|
| 130 | for (int k=0; k<nImg; k++)
|
---|
| 131 | if ((*imgTab[k])(i,j) > high || (*imgTab[k])(i,j) < low)
|
---|
| 132 | (*imgTab[k])(i,j) = 0;
|
---|
| 133 | }
|
---|
| 134 | }
|
---|
| 135 |
|
---|
| 136 | /* Nouvelle-Fonction */
|
---|
| 137 |
|
---|
| 138 | template <class T>
|
---|
| 139 | //++
|
---|
| 140 | float ImgFondCielHisto(Image<T> const& img, float binWidth, int degree, float frac,
|
---|
| 141 | float low, float high, int debug)
|
---|
| 142 | //
|
---|
| 143 | // Calcul du fond de ciel par histogrammation. L'histogramme
|
---|
| 144 | // va de `low' a `high' avec une largeur de bin `binWidth'.
|
---|
| 145 | // La valeur la plus probalbe est fittee par un polynome de degre
|
---|
| 146 | // `degree' en utilisant les bins entourant le maximum
|
---|
| 147 | // a `frac' pourcent de sa hauteur.
|
---|
| 148 | //--
|
---|
| 149 | {
|
---|
| 150 | // CHECKIMG2(img,0,0);
|
---|
| 151 |
|
---|
| 152 | if (degree < 2 || degree > 3)
|
---|
| 153 | degree = 3;
|
---|
| 154 |
|
---|
| 155 | if (frac <= 0 || frac >= 1)
|
---|
| 156 | frac = 0.5;
|
---|
| 157 |
|
---|
| 158 | if (low < MinRange((T)0)+2)
|
---|
| 159 | low = MinRange((T)0)+2;
|
---|
| 160 |
|
---|
| 161 | if (high > MaxRange((T)0)-2)
|
---|
| 162 | high = MaxRange((T)0)-2;
|
---|
| 163 |
|
---|
| 164 | if (low >= high)
|
---|
| 165 | {low = MinRange((T)0); high = MaxRange((T)0);}
|
---|
| 166 |
|
---|
| 167 | // verifier binwidth
|
---|
| 168 |
|
---|
| 169 | // if ( binWidth < 65536.0/img.XSize()*img.YSize() )
|
---|
| 170 | // binWidth = 65536.0/img.XSize()*img.YSize();
|
---|
| 171 |
|
---|
| 172 | if (binWidth<0)
|
---|
| 173 | binWidth = 1;
|
---|
| 174 |
|
---|
| 175 | if (debug > 1)
|
---|
| 176 | cout << __FUNCTION__ << " binWidth =" << binWidth <<
|
---|
| 177 | ", degree = " << degree <<
|
---|
| 178 | ", frac = " << frac <<
|
---|
| 179 | ", low = " << low <<
|
---|
| 180 | ", high = " << high << endl;
|
---|
| 181 |
|
---|
| 182 | int nBins = int(((double)high-(double)low)/(double)binWidth + 1);
|
---|
| 183 | Histo hist(low, high, nBins);
|
---|
| 184 |
|
---|
| 185 | int nPix = img.XSize()*img.YSize();
|
---|
| 186 | for (int i=0; i<nPix; i++)
|
---|
| 187 | hist.Add(img[i]);
|
---|
| 188 |
|
---|
| 189 | hist(0) = 0;
|
---|
| 190 |
|
---|
| 191 | float fd = hist.FitMax(degree, frac, debug);
|
---|
| 192 |
|
---|
| 193 | (float&) img.fond = fd;
|
---|
| 194 |
|
---|
| 195 | return fd;
|
---|
| 196 | }
|
---|
| 197 |
|
---|
| 198 |
|
---|
| 199 | /* Nouvelle-Fonction */
|
---|
| 200 |
|
---|
| 201 | template <class T>
|
---|
| 202 | float ImgSigmaCiel(Image<T> const& img, int ndata, int binWidth,
|
---|
| 203 | int taille, float frac, int degree,
|
---|
| 204 | float low, float high, int debug)
|
---|
| 205 | {
|
---|
| 206 | (float&) img.sigmaFond = RzCmvSigmaCiel(img.ImagePtr(), img.XSize(), img.YSize(),
|
---|
| 207 | ndata, binWidth, taille, frac,
|
---|
| 208 | degree, low, high, debug);
|
---|
| 209 | return img.sigmaFond;
|
---|
| 210 | }
|
---|
| 211 |
|
---|
| 212 |
|
---|
| 213 | /* Nouvelle-Fonction */
|
---|
| 214 |
|
---|
| 215 | template <class T>
|
---|
| 216 | //++
|
---|
| 217 | float RzCmvSigmaCiel(T const* pix,int nx,int ny,int ndata,int bin,
|
---|
| 218 | int taille,float frac,int deg,
|
---|
| 219 | float low,float high,int deb)
|
---|
| 220 | //
|
---|
| 221 | // Calcul du fond de ciel par histogrammation
|
---|
| 222 | //
|
---|
| 223 | //| INPUT:
|
---|
| 224 | //| - pix : tableau pix[nx][ny]
|
---|
| 225 | //| - nx,ny : dimensions du tableau pix
|
---|
| 226 | //| - ndata : nombre de donnees a utiliser
|
---|
| 227 | //| - bin : largeur du bin en ADU
|
---|
| 228 | //| - taille: 1/2 dimension de l'histogramme en ADU
|
---|
| 229 | //| - frac : fraction du maximum au dessus de laquelle on fite
|
---|
| 230 | //| - deg : degre fit polynome sous la gaussienne (0 ou 2)
|
---|
| 231 | //| - low : valeur basse limite en ADU
|
---|
| 232 | //| - high : valeur haute limite en ADU
|
---|
| 233 | //| - deb : flag de debug
|
---|
| 234 | //--
|
---|
| 235 | //++
|
---|
| 236 | //| OUTPUT:
|
---|
| 237 | //| - retourne : le sigma du fond de ciel si OK
|
---|
| 238 | //| -1 si probleme definition
|
---|
| 239 | //| -2 si probleme allocation
|
---|
| 240 | //| -3 si probleme remplissage histogramme
|
---|
| 241 | //| -4 si probleme recherche maximum
|
---|
| 242 | //| -5 si probleme calcul fraction du maximum
|
---|
| 243 | //| -6 si probleme nombre de bin
|
---|
| 244 | //| -7 si probleme nombre de fit
|
---|
| 245 | //|
|
---|
| 246 | //--
|
---|
| 247 | // // EA seul changement par rapport a la version C :
|
---|
| 248 | // // pix est un T*, en template. -> C++ necessaire.
|
---|
| 249 | {
|
---|
| 250 | FLOATDOUBLE X,Y,EY;
|
---|
| 251 | double (*Fun) (double ,double *,double *);
|
---|
| 252 | int_4 npar;
|
---|
| 253 | double par[6], epar[6],minpar[6],maxpar[6],stepar[6],stochi2;
|
---|
| 254 | int_4 i,j,i1,j1,j2,n,ip,nbin,inc,ibin0,max,imax,lmax,b1,b2;
|
---|
| 255 | float *histo,*xbin,*ehisto,fwhm,rc;
|
---|
| 256 | double vp,pxv;
|
---|
| 257 |
|
---|
| 258 | /* set reasonable parameters */
|
---|
| 259 | Fun = Gauss1DPolF ;
|
---|
| 260 | if ( deg<=1 ) deg=0; else deg=2;
|
---|
| 261 | low = ( low < 0 ) ? 0 : low;
|
---|
| 262 | high = ( high > 65530 ) ? 65530 : high;
|
---|
| 263 | if ( low >= high ) { low=0; high = 65530;}
|
---|
| 264 | bin = ( bin <= 0 ) ? 1 : bin;
|
---|
| 265 | nbin = int(2.*taille /bin + 1);
|
---|
| 266 | if ( nbin < 20 ) nbin = 20;
|
---|
| 267 | if ( nbin >= 65530 ) nbin = 65530;
|
---|
| 268 | ibin0 = int(-nbin*bin/2.);
|
---|
| 269 | inc = int(nx*ny / ndata); inc = int(sqrt( (double) inc ));
|
---|
| 270 | inc = (inc<1) ? 1 : inc;
|
---|
| 271 | if(deb>1)
|
---|
| 272 | { printf("Sigma_Ciel: pix[%d,%d] ndata=%d bin=%d taille=%d"
|
---|
| 273 | ,nx,ny,ndata,bin,taille);
|
---|
| 274 | printf(" frac=%f low=%g high=%g nbin=%d ibin0=%d inc=%d\n"
|
---|
| 275 | ,frac,low,high,nbin,ibin0,inc); }
|
---|
| 276 | if ( nx < 5 || ny < 5 ) return (-1.);
|
---|
| 277 |
|
---|
| 278 | /* allocate place for histogramme */
|
---|
| 279 | if ( (histo = (float *) calloc(nbin, sizeof(float)) ) == NULL )
|
---|
| 280 | return(-2.);
|
---|
| 281 | if ( (xbin = (float *) calloc(nbin, sizeof(float)) ) == NULL )
|
---|
| 282 | {free(histo); return(-2.);}
|
---|
| 283 | if ( (ehisto = (float *) calloc(nbin, sizeof(float)) ) == NULL )
|
---|
| 284 | {free(histo); free(xbin); return(-2.);}
|
---|
| 285 |
|
---|
| 286 | /* fill histogramme */
|
---|
| 287 | ndata=0;
|
---|
| 288 | for (j=1;j<ny-1;j=j+inc) { for (i=1;i<nx-1;i=i+inc) {
|
---|
| 289 | ip = (int)(*(pix+j*nx+i));
|
---|
| 290 | if ( ip < low || ip > high ) continue;
|
---|
| 291 | vp = (double) ip;
|
---|
| 292 | pxv = 0.; n=0;
|
---|
| 293 | for(j1=j-1;j1<=j+1;j1++) { for(i1=i-1;i1<=i+1;i1++) {
|
---|
| 294 | if ( i1 == i && j1 == j ) continue;
|
---|
| 295 | ip = (int)(*(pix+j1*nx+i1));
|
---|
| 296 | if ( ip < low || ip > high ) continue;
|
---|
| 297 | pxv += (double) ip;
|
---|
| 298 | n++;
|
---|
| 299 | } }
|
---|
| 300 | if ( n != 8 ) continue;
|
---|
| 301 | vp = vp - pxv/n;
|
---|
| 302 | ip = int((vp-ibin0)/bin);
|
---|
| 303 | if( ip<0 || ip >= nbin ) continue;
|
---|
| 304 | histo[ip]++;
|
---|
| 305 | ndata++;
|
---|
| 306 | } }
|
---|
| 307 | for(i=0;i<nbin;i++)
|
---|
| 308 | { xbin[i] = (float) ibin0 + ( (float) i + 0.5 ) * (float) bin;
|
---|
| 309 | ehisto[i] = (histo[i]<1.) ? -1. : sqrt((double) histo[i]);}
|
---|
| 310 |
|
---|
| 311 | if(deb>1) printf(" nombre de data corrects = %d\n",ndata);
|
---|
| 312 | if( ndata < 1 ) {rc= -3.; goto END;}
|
---|
| 313 |
|
---|
| 314 | /* find maximum */
|
---|
| 315 | max = -1; imax = -1;
|
---|
| 316 | for(i=nbin-1;i>=0;i--) if(histo[i]>max) { max=int(histo[i]); imax=i;}
|
---|
| 317 | if(deb>1) printf(" maxi histo = %d (bin=%d)\n",max,imax);
|
---|
| 318 | if ( imax == -1 || imax == 0 || imax == nbin-1 ) {rc= -4.; goto END;}
|
---|
| 319 | if(deb>2) {
|
---|
| 320 | for(i=imax-10;i<=imax+10;i++) if(i>=0 && i<nbin) printf(" %5f",xbin[i]);
|
---|
| 321 | printf("\n");
|
---|
| 322 | for(i=imax-10;i<=imax+10;i++) if(i>=0 && i<nbin) printf(" %5d",(int) histo[i]);
|
---|
| 323 | printf("\n"); }
|
---|
| 324 |
|
---|
| 325 | /* find limites a half maximum */
|
---|
| 326 | lmax = (int) ( (float) max * 0.5 );
|
---|
| 327 | for(b1=imax;b1>0;b1--) if(histo[b1]<=lmax) break;
|
---|
| 328 | for(b2=imax;b2<nbin;b2++) if(histo[b2]<=lmax) break;
|
---|
| 329 | fwhm = (xbin[b2]-xbin[b1]);
|
---|
| 330 | if(deb>1) printf(" fwhm = %f (%d,%d)\n",fwhm,b1,b2);
|
---|
| 331 |
|
---|
| 332 | /* find limites a frac*max */
|
---|
| 333 | lmax = (int) ( (float) max * frac ) + 1;
|
---|
| 334 | if( lmax < 1 )
|
---|
| 335 | {if(deb>1) printf(" lmax=%d\n",lmax); rc= -5.; goto END;}
|
---|
| 336 | for(b1=imax;b1>0;b1--) if(histo[b1]<=lmax) break;
|
---|
| 337 | for(b2=imax;b2<nbin;b2++) if(histo[b2]<=lmax) break;
|
---|
| 338 |
|
---|
| 339 | n=0;
|
---|
| 340 | for(i=b1;i<=b2;i++) if( histo[i] > 0 ) n++;
|
---|
| 341 | if(deb>1) printf(" limites bin %d %d (v=%d) bin non nuls=%d\n"
|
---|
| 342 | ,b1,b2,lmax,n);
|
---|
| 343 | /* pas assez de bin, on en ajoute artificiellement */
|
---|
| 344 | /* 8 est une borne large pour fiter gauss + parab (3+3) */
|
---|
| 345 | if( n < 8 ) {
|
---|
| 346 | j1 = b1; j2 = b2;
|
---|
| 347 | for(i=1;i<nbin;i++) {
|
---|
| 348 | if ( b1-i >= 0 ) j1=b1-i;
|
---|
| 349 | if ( b2+i < nbin ) j2=b2+i;
|
---|
| 350 | if ( histo[j1] > 0 ) n++;
|
---|
| 351 | if ( histo[j2] > 0 ) n++;
|
---|
| 352 | if( n >= 6 ) break;
|
---|
| 353 | }
|
---|
| 354 | b1 = j1; b2 = j2;
|
---|
| 355 | if(deb>1) printf(" Re-update des limites bin %d %d (v=%d) bin non nuls=%d\n"
|
---|
| 356 | ,b1,b2,lmax,n);
|
---|
| 357 | }
|
---|
| 358 | if( n < 4 ) {rc= -6.; goto END;}
|
---|
| 359 | ndata = n;
|
---|
| 360 |
|
---|
| 361 | /* fit dans les limites */
|
---|
| 362 | npar = 3+deg+1; Set_FitFunDPol(deg);
|
---|
| 363 | if(ndata<8) {npar=4; Set_FitFunDPol(0);}
|
---|
| 364 | if(ndata<5) {npar=3; Set_FitFunDPol(-1);}
|
---|
| 365 | X.fx = xbin;
|
---|
| 366 | Y.fx = histo;
|
---|
| 367 | EY.fx = ehisto;
|
---|
| 368 | stochi2 = 0.0001;
|
---|
| 369 | n = nbin;
|
---|
| 370 | par[0] = max;
|
---|
| 371 | par[1] = histo[imax-1]*xbin[imax-1]+histo[imax]*xbin[imax]+histo[imax+1]*xbin[imax+1];
|
---|
| 372 | par[1] = par[1]/(histo[imax-1]+histo[imax]+histo[imax+1]);
|
---|
| 373 | par[2] = (fwhm<1.) ? 1. : fwhm/2.36;
|
---|
| 374 | par[3] = par[4] = par[5] = 0.;
|
---|
| 375 | stepar[0] = par[0]/20.; stepar[1] = 1.; stepar[2] = par[2]/5.;
|
---|
| 376 | stepar[3] = 1.; stepar[5] = 0.1;
|
---|
| 377 | stepar[4] = 0.;
|
---|
| 378 | for(i=0;i<6;i++) {minpar[i] = 1.; maxpar[i] = -1.;}
|
---|
| 379 | minpar[2] = 0.1; maxpar[2] = 65530.;
|
---|
| 380 | if(deb>1) printf(" choix de fit a %d parametres b1=%d,b2=%d,ndata=%d)\n"
|
---|
| 381 | ,npar,b1,b2,ndata);
|
---|
| 382 |
|
---|
| 383 | i = (deb>=3) ? deb-2 : 0 ;
|
---|
| 384 | vp = FitFun(Fun,FITFUN_FLOAT,X,Y,EY,&n,b1,b2,par
|
---|
| 385 | ,epar,stepar,minpar,maxpar,npar,stochi2,50,i);
|
---|
| 386 |
|
---|
| 387 | if( vp<=0. && vp != -4. ) {rc= -7.; goto END;}
|
---|
| 388 | rc = par[2];
|
---|
| 389 | if(deb>1) printf(" sigma=%f (h=%f centrage=%f) xi2=%f (%f pour %d)\n"
|
---|
| 390 | ,rc,par[0],par[1],vp,vp/(n-npar),npar);
|
---|
| 391 |
|
---|
| 392 | END:
|
---|
| 393 | free(histo); free(xbin); free(ehisto);
|
---|
| 394 | return(rc);
|
---|
| 395 | }
|
---|
| 396 |
|
---|
| 397 | /* ................................................................................. */
|
---|
| 398 | /* Filtrage ( Convolution ) d' images */
|
---|
| 399 | /* ................................................................................. */
|
---|
| 400 |
|
---|
| 401 | /* Nouvelle-Fonction */
|
---|
| 402 | template <class T>
|
---|
| 403 | //++
|
---|
| 404 | Image<T> * FilterImage(Image<T> const * pim, Image<T> * pom, ImageR4 *matx)
|
---|
| 405 | //
|
---|
| 406 | // Filtrage ( Convolution ) d'une image `pim' par une matrice carree
|
---|
| 407 | // representee par l'ImageR4 `matx'.
|
---|
| 408 | // Le resultat se retrouve dans `pom'.
|
---|
| 409 | // Si `pom' = NULL, elle est cree.
|
---|
| 410 | // `pim' et `pom' doivent avoir la meme taille.
|
---|
| 411 | //--
|
---|
| 412 | {
|
---|
| 413 |
|
---|
| 414 | float vpix, *mxe;
|
---|
| 415 | bool fgcr;
|
---|
| 416 | int i,j,k,l,m,n;
|
---|
| 417 | int ndim, nd2;
|
---|
| 418 |
|
---|
| 419 | fgcr = false;
|
---|
| 420 |
|
---|
| 421 | if ((pim == NULL) || (matx == NULL))
|
---|
| 422 | { printf(" FilterImage_Erreur : pim ou matx = NULL ! \n");
|
---|
| 423 | return(NULL); }
|
---|
| 424 | if (matx->XSize() != matx->YSize())
|
---|
| 425 | { printf("FilterImage_Erreur: Filtrage par matrice carre uniquement (%d,%d)\n",
|
---|
| 426 | matx->XSize(), matx->YSize()); return(NULL); }
|
---|
| 427 | ndim = matx->XSize();
|
---|
| 428 | if ( (ndim < 3) || ((ndim%2) == 0) || (ndim > 25))
|
---|
| 429 | { printf("FilterImage_Erreur: Pb dimension matrice (%d) (Impair, entre 3 et 25)\n", ndim);
|
---|
| 430 | return(NULL); }
|
---|
| 431 | if (pom == NULL)
|
---|
| 432 | { pom = new Image<T>(pim->XSize(), pim->YSize(), false); fgcr = true; }
|
---|
| 433 |
|
---|
| 434 | if ( (pim->XSize() != pom->XSize()) || (pim->YSize() != pom->YSize()) )
|
---|
| 435 | { printf("FilterImage_Erreur : Taille pim et pom differentes ! \n") ;
|
---|
| 436 | if (fgcr) delete pom; return(NULL) ;}
|
---|
| 437 |
|
---|
| 438 | nd2 = ndim/2;
|
---|
| 439 |
|
---|
| 440 | /* Traitement de la partie centrale */
|
---|
| 441 | for(j=nd2; j<(pom->YSize()-nd2); j++)
|
---|
| 442 | {
|
---|
| 443 | for(i=nd2; i<(pom->XSize()-nd2); i++)
|
---|
| 444 | {
|
---|
| 445 | vpix = 0.; mxe = matx->ImagePtr();
|
---|
| 446 | for(l=-nd2; l<=nd2; l++)
|
---|
| 447 | for(k=-nd2; k<=nd2; k++)
|
---|
| 448 | { vpix += (float)((*pim)((i+k), (j+l))) * (*mxe);
|
---|
| 449 | mxe++; }
|
---|
| 450 | (*pom)(i, j) = (T)vpix;
|
---|
| 451 | }
|
---|
| 452 | }
|
---|
| 453 |
|
---|
| 454 | /* Traitement bord en Y en haut */
|
---|
| 455 | for(j=0; j<nd2; j++)
|
---|
| 456 | {
|
---|
| 457 | for(i=nd2; i<(pom->XSize()-nd2); i++)
|
---|
| 458 | {
|
---|
| 459 | vpix = 0.; mxe = matx->ImagePtr();
|
---|
| 460 | for(l=-nd2; l<=nd2; l++)
|
---|
| 461 |
|
---|
| 462 | for(k=-nd2; k<=nd2; k++)
|
---|
| 463 | {
|
---|
| 464 | m = i+k; n = j+l;
|
---|
| 465 | if (n < 0) n = 0;
|
---|
| 466 | vpix += (float)((*pim)(m, n)) * (*mxe);
|
---|
| 467 | mxe++;
|
---|
| 468 | }
|
---|
| 469 | (*pom)(i, j) = (T)vpix;
|
---|
| 470 | }
|
---|
| 471 | }
|
---|
| 472 |
|
---|
| 473 | /* Traitement bord en Y en bas */
|
---|
| 474 | for(j=(pom->YSize()-nd2); j<pom->YSize(); j++)
|
---|
| 475 | {
|
---|
| 476 | for(i=nd2; i<(pom->XSize()-nd2); i++)
|
---|
| 477 | {
|
---|
| 478 | vpix = 0.; mxe = matx->ImagePtr();
|
---|
| 479 | for(l=-nd2; l<=nd2; l++)
|
---|
| 480 | for(k=-nd2; k<=nd2; k++)
|
---|
| 481 | {
|
---|
| 482 | m = i+k; n = j+l;
|
---|
| 483 | if (n >= pim->YSize()) n = (pim->YSize()-1);
|
---|
| 484 | vpix += (float)((*pim)(m, n)) * (*mxe);
|
---|
| 485 | mxe++;
|
---|
| 486 | }
|
---|
| 487 | (*pom)(i, j) = (T)vpix;
|
---|
| 488 | }
|
---|
| 489 | }
|
---|
| 490 |
|
---|
| 491 | /* traitement bords en X et coins */
|
---|
| 492 | for(j=0; j<pom->YSize(); j++)
|
---|
| 493 | {
|
---|
| 494 | for(i=0; i<nd2; i++)
|
---|
| 495 | {
|
---|
| 496 | vpix = 0.; mxe = matx->ImagePtr();
|
---|
| 497 | for(l=-nd2; l<=nd2; l++)
|
---|
| 498 | for(k=-nd2; k<=nd2; k++)
|
---|
| 499 | {
|
---|
| 500 | m = i+k; n = j+l;
|
---|
| 501 | if (m < 0) m = 0;
|
---|
| 502 | if (n < 0) n = 0;
|
---|
| 503 | if (n >= pim->YSize()) n = (pim->YSize()-1);
|
---|
| 504 | vpix += (float)((*pim)(m, n)) * (*mxe);
|
---|
| 505 | mxe++;
|
---|
| 506 | }
|
---|
| 507 | (*pom)(i, j) = (T)vpix;
|
---|
| 508 | }
|
---|
| 509 | for(i=(pom->XSize()-nd2); i<pom->XSize(); i++)
|
---|
| 510 | {
|
---|
| 511 | vpix = 0.; mxe = matx->ImagePtr();
|
---|
| 512 | for(l=-nd2; l<=nd2; l++)
|
---|
| 513 | for(k=-nd2; k<=nd2; k++)
|
---|
| 514 | {
|
---|
| 515 | m = i+k; n = j+l;
|
---|
| 516 | if (m >= pim->XSize()) m = (pim->XSize()-1);
|
---|
| 517 | if (n < 0) n = 0;
|
---|
| 518 | if (n >= pim->YSize()) n = (pim->YSize()-1);
|
---|
| 519 | vpix += (float)((*pim)(m, n)) * (*mxe);
|
---|
| 520 | mxe++;
|
---|
| 521 | }
|
---|
| 522 | (*pom)(i, j) = (T)vpix;
|
---|
| 523 | }
|
---|
| 524 | }
|
---|
| 525 |
|
---|
| 526 |
|
---|
| 527 | return(pom);
|
---|
| 528 |
|
---|
| 529 | }
|
---|
| 530 |
|
---|
| 531 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 532 | /* Nouvelle-Fonction CMV 14/10/97 */
|
---|
| 533 | template <class T>
|
---|
| 534 | //++
|
---|
| 535 | Image<T> * FilterStat(Image<T> const * pim, Image<T> * pom
|
---|
| 536 | ,int N,int M,float lowbad,float highbad)
|
---|
| 537 | //
|
---|
| 538 | // Filtrage median d'une image `(*pim)'.
|
---|
| 539 | // Le resultat se retrouve dans `(*pom)'.
|
---|
| 540 | // Si pom = NULL l'image de sortie est cree automatiquement.
|
---|
| 541 | // pim et pom doivent avoir la meme taille.
|
---|
| 542 | // Le masque de calcul du filtre median est un rectangle `N'x`M'
|
---|
| 543 | // La dynamique de l'image est `lowbad,highbad'.
|
---|
| 544 | // Si lowbad>=highbad dynamique infinie.
|
---|
| 545 | //--
|
---|
| 546 | {
|
---|
| 547 | if(pim == NULL)
|
---|
| 548 | {printf(" FilterStat_Erreur : pim = NULL ! \n");
|
---|
| 549 | return(NULL);}
|
---|
| 550 | if( N<=0 || M<=0 )
|
---|
| 551 | {printf("FilterStat_Erreur: Filtrage par matrice (%d,%d)\n",N,M);
|
---|
| 552 | return(NULL);}
|
---|
| 553 | bool fgcr = false;
|
---|
| 554 | if(pom == NULL)
|
---|
| 555 | {pom = new Image<T>(pim->XSize(), pim->YSize(), false); fgcr = true;}
|
---|
| 556 | if( (pim->XSize() != pom->XSize()) || (pim->YSize() != pom->YSize()) )
|
---|
| 557 | { printf("FilterImage_Erreur : Taille pim et pom differentes ! \n");
|
---|
| 558 | if(fgcr) delete pom; return(NULL);}
|
---|
| 559 |
|
---|
| 560 | T low = (T) lowbad;
|
---|
| 561 | T high = (T) highbad;
|
---|
| 562 | if(high>low) fgcr = true; else fgcr = false;
|
---|
| 563 |
|
---|
| 564 | N /= 2; M /= 2;
|
---|
| 565 | double * tab = new double[(2*N+1)*(2*M+1)];
|
---|
| 566 |
|
---|
| 567 | for(int j=0;j<pom->YSize();j++) {
|
---|
| 568 | for(int i=0;i<pom->XSize();i++) {
|
---|
| 569 | int n=0;
|
---|
| 570 | for(int jj=j-M;jj<=j+M;jj++) {
|
---|
| 571 | if( jj<0 || jj >= pom->YSize() ) continue;
|
---|
| 572 | for(int ii=i-N;ii<=i+N;ii++) {
|
---|
| 573 | if( ii<0 || ii >= pom->XSize() ) continue;
|
---|
| 574 | if( fgcr && ( (*pim)(ii,jj)<=low || high<=(*pim)(ii,jj) ) ) continue;
|
---|
| 575 | tab[n] = (double) (*pim)(ii,jj);
|
---|
| 576 | n++;
|
---|
| 577 | }
|
---|
| 578 | }
|
---|
| 579 | if(n==0) (*pom)(i,j) = 0;
|
---|
| 580 | else if(n==1) (*pom)(i,j) = (T) tab[0];
|
---|
| 581 | else {
|
---|
| 582 | HeapSort(n,tab);
|
---|
| 583 | if(n%2==1) (*pom)(i,j) = (T) tab[(n-1)/2];
|
---|
| 584 | else (*pom)(i,j) = (T) (tab[n/2]+tab[n/2-1])/2.;
|
---|
| 585 | }
|
---|
| 586 | }
|
---|
| 587 | }
|
---|
| 588 |
|
---|
| 589 | delete [] tab;
|
---|
| 590 | return(pom);
|
---|
| 591 | }
|
---|
| 592 |
|
---|
| 593 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 594 | /* Nouvelle-Fonction CMV 7/8/98 */
|
---|
| 595 | template <class T>
|
---|
| 596 | //++
|
---|
| 597 | Image<T> * CSplineImage(Image<T> const & f1,double pxsz,double x0,double y0,int natural)
|
---|
| 598 | //
|
---|
| 599 | // Fonction retournant un pointeur sur une image qui contient
|
---|
| 600 | // le Spline 3 a 2 dimensions de l'images f1 (NULL est retourne si probleme).
|
---|
| 601 | // `pxsz' est la taille du pixel de l'image retournee en considerant
|
---|
| 602 | // que l'image `f1' en entree a une taille de pixel egale a 1.
|
---|
| 603 | // `x0,y0' est le decalage eventuel a appliquer de l'image origine a
|
---|
| 604 | // l'image retournee, ce decalage etant mesure en unites de pixels
|
---|
| 605 | // de l'image origine (1).
|
---|
| 606 | // `natural' a la signification decrite dans la classe `CSpline2'.
|
---|
| 607 | // Attention, la taille de l'image retournee sera `nx/pxsz' et `ny/pxsz'.
|
---|
| 608 | // Pour eviter les problemes d'extrapolation sur les bords de l'image
|
---|
| 609 | // d'origine, il leurs est assigne la valeur du centre du pixel auquel ils
|
---|
| 610 | // appartiennent.
|
---|
| 611 | //--
|
---|
| 612 | {
|
---|
| 613 | //// open for result
|
---|
| 614 | int nx = f1.XSize();
|
---|
| 615 | int ny = f1.YSize();
|
---|
| 616 | float dum;
|
---|
| 617 | dum = nx/pxsz;
|
---|
| 618 | int dx = (int) (dum+0.5);
|
---|
| 619 | dum = ny/pxsz;
|
---|
| 620 | int dy = (int) (dum+0.5);
|
---|
| 621 | cout<<"Taille image en entree: "<<nx<<" "<<ny<<endl
|
---|
| 622 | <<"Taille image en sortie: "<<dx<<" "<<dy<<" (pix size="<<pxsz<<")"<<endl
|
---|
| 623 | <<"Decalage en x="<<x0<<" en y="<<y0<<endl;
|
---|
| 624 | if(nx<=1 || ny<=1) return NULL;
|
---|
| 625 | if(dx<=0 || dy<=0) return NULL;
|
---|
| 626 |
|
---|
| 627 | Image<T> *f2 = NULL;
|
---|
| 628 | TRY {
|
---|
| 629 | f2 = new Image<T>(dx,dy);
|
---|
| 630 | } CATCHALL {
|
---|
| 631 | cout<<"Impossible d'ouvrir le fichier resultat"<<endl;
|
---|
| 632 | return NULL;
|
---|
| 633 | } ENDTRY
|
---|
| 634 |
|
---|
| 635 | //// Spline 3 2D ... nx+2 pour tenir compte des effets de bords !
|
---|
| 636 | double *x = new double[nx+2];
|
---|
| 637 | double *y = new double[ny+2];
|
---|
| 638 | double *z = new double[(nx+2)*(ny+2)];
|
---|
| 639 | {
|
---|
| 640 | int k;
|
---|
| 641 | // Centre pixel (0,0) en (0.5,0.5) et on ajoute les coordonnees
|
---|
| 642 | // des bords pour extrapolation sur tout l'intervalle.
|
---|
| 643 | // Les coordonnees vont de [0,nx] et [0,ny] (valeurs extremes comprises).
|
---|
| 644 | x[0] = 0.; x[nx+1] = nx;
|
---|
| 645 | y[0] = 0.; y[ny+1] = ny;
|
---|
| 646 | for(k=1;k<=nx;k++) x[k] = k-0.5;
|
---|
| 647 | for(k=1;k<=ny;k++) y[k] = k-0.5;
|
---|
| 648 | // Remplissage des valeurs avec effet de bord [0] et [nx+1],[ny+1].
|
---|
| 649 | k = 0;
|
---|
| 650 | int ii,jj;
|
---|
| 651 | for(int j=0;j<ny+2;j++) {
|
---|
| 652 | jj = j-1;
|
---|
| 653 | if(jj<0) jj=0; else if(jj>=ny) jj=ny-1;
|
---|
| 654 | for(int i=0;i<nx+2;i++) {
|
---|
| 655 | ii = i-1;
|
---|
| 656 | if(ii<0) ii=0; else if(ii>=nx) ii=nx-1;
|
---|
| 657 | z[k] = (double) f1(ii,jj);
|
---|
| 658 | k++;
|
---|
| 659 | }
|
---|
| 660 | }
|
---|
| 661 | }
|
---|
| 662 |
|
---|
| 663 | CSpline2 spl(nx+2,x,ny+2,y,z,natural,true);
|
---|
| 664 | spl.ComputeCSpline();
|
---|
| 665 |
|
---|
| 666 | *f2 = 0.;
|
---|
| 667 | {
|
---|
| 668 | // Attention au decalage possible !
|
---|
| 669 | // Les valeurs vont de [0.5*pxsz,(dx-0.5)*pxsz] idem pour y...
|
---|
| 670 | // a corriger eventuellement du decalage x0,y0.
|
---|
| 671 | double xmin = -pxsz/10000., xmax = nx+pxsz/10000.;
|
---|
| 672 | double ymin = -pxsz/10000., ymax = ny+pxsz/10000.;
|
---|
| 673 | for(int j=0;j<dy;j++) {
|
---|
| 674 | double yy = (j+0.5)*pxsz - y0;
|
---|
| 675 | if( yy<=ymin || yy>=ymax ) continue;
|
---|
| 676 | for(int i=0;i<dx;i++) {
|
---|
| 677 | double xx = (i+0.5)*pxsz - x0;
|
---|
| 678 | if( xx<=xmin || xx>=xmax ) continue;
|
---|
| 679 | (*f2)(i,j) = (T) spl.CSplineInt(xx,yy);
|
---|
| 680 | }}}
|
---|
| 681 |
|
---|
| 682 | //// nettoyage
|
---|
| 683 | delete [] x;
|
---|
| 684 | delete [] y;
|
---|
| 685 | delete [] z;
|
---|
| 686 |
|
---|
| 687 | return f2;
|
---|
| 688 | }
|
---|
| 689 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 690 |
|
---|
| 691 |
|
---|
| 692 |
|
---|
| 693 | /* Nouvelle-Fonction */
|
---|
| 694 | int FondSigmaCiel(RzImage *pim, float low, float high,int pvsz
|
---|
| 695 | ,float nbsig1,float nbsig2,float nbsig3
|
---|
| 696 | ,float binsg,float frac,int modu,int deb)
|
---|
| 697 | {
|
---|
| 698 | int rc;
|
---|
| 699 |
|
---|
| 700 | switch (pim->PixelType())
|
---|
| 701 | {
|
---|
| 702 | case kuint_2:
|
---|
| 703 | {
|
---|
| 704 | ImageU2 imt((RzImage&)(*pim));
|
---|
| 705 | rc = imt.FondSigmaCiel(low, high, pvsz, nbsig1, nbsig2, nbsig3, binsg, frac, modu, deb);
|
---|
| 706 | pim->fond = imt.fond;
|
---|
| 707 | pim->sigmaFond = imt.sigmaFond;
|
---|
| 708 | break;
|
---|
| 709 | }
|
---|
| 710 | case kint_2:
|
---|
| 711 | {
|
---|
| 712 | ImageI2 imt((RzImage&)(*pim));
|
---|
| 713 | rc = imt.FondSigmaCiel(low, high, pvsz, nbsig1, nbsig2, nbsig3, binsg, frac, modu, deb);
|
---|
| 714 | pim->fond = imt.fond;
|
---|
| 715 | pim->sigmaFond = imt.sigmaFond;
|
---|
| 716 | break;
|
---|
| 717 | }
|
---|
| 718 | case kint_4:
|
---|
| 719 | {
|
---|
| 720 | ImageI4 imt((RzImage&)(*pim));
|
---|
| 721 | rc = imt.FondSigmaCiel(low, high, pvsz, nbsig1, nbsig2, nbsig3, binsg, frac, modu, deb);
|
---|
| 722 | pim->fond = imt.fond;
|
---|
| 723 | pim->sigmaFond = imt.sigmaFond;
|
---|
| 724 | break;
|
---|
| 725 | }
|
---|
| 726 | case kr_4:
|
---|
| 727 | {
|
---|
| 728 | ImageR4 imt((RzImage&)(*pim));
|
---|
| 729 | rc = imt.FondSigmaCiel(low, high, pvsz, nbsig1, nbsig2, nbsig3, binsg, frac, modu, deb);
|
---|
| 730 | pim->fond = imt.fond;
|
---|
| 731 | pim->sigmaFond = imt.sigmaFond;
|
---|
| 732 | break;
|
---|
| 733 | }
|
---|
| 734 | default:
|
---|
| 735 | {
|
---|
| 736 | cout<<"FindSigmaCiel: type d'image non-prevu "<<(int) pim->PixelType()<<endl;
|
---|
| 737 | exit(-1);
|
---|
| 738 | }
|
---|
| 739 | }
|
---|
| 740 |
|
---|
| 741 | return(rc);
|
---|
| 742 | }
|
---|
| 743 |
|
---|
| 744 | /* Nouvelle-Fonction */
|
---|
| 745 | int CalFondImage(RzImage *pim, double low, double high, int action)
|
---|
| 746 |
|
---|
| 747 | /* ATTENTION: Adaptation a partir d'une version C */
|
---|
| 748 | /* CalculFond() de imgstat.c */
|
---|
| 749 |
|
---|
| 750 | /* Cette fonction calcule le fond et le sigma du ciel a la CMV */
|
---|
| 751 | /* CMV / E.Aubourg / Reza */
|
---|
| 752 | /* action Bit 0 CheckDyn() */
|
---|
| 753 | /* Bit 1 ImgFondCielHisto() */
|
---|
| 754 | /* Bit 2 ImgSigmaCiel */
|
---|
| 755 | /* Bit 3 FondSig2Ciel() */
|
---|
| 756 | /* Bit 1+2+3 (=14) Fond_Ciel() + Sigma_Ciel() Si OK */
|
---|
| 757 | /* FondSig2Ciel() sinon */
|
---|
| 758 | /* action = 0 ou >= 15 CheckDyn + Bit 1+2+3 (=14) */
|
---|
| 759 | /* Rc=0 OK Erreur Sinon */
|
---|
| 760 | /* Sortie : Mise a jour de la struct RzImage */
|
---|
| 761 |
|
---|
| 762 | {
|
---|
| 763 | int n,ok,rc,fga;
|
---|
| 764 | float fnd, sg;
|
---|
| 765 |
|
---|
| 766 | int nbsig, vitesse, nbin;
|
---|
| 767 | float minaff, maxaff, minpix, maxpix;
|
---|
| 768 | float fracmax,fracnul,fracsat;
|
---|
| 769 | char *meth;
|
---|
| 770 |
|
---|
| 771 | #define DBG 0
|
---|
| 772 |
|
---|
| 773 | if (action >= 15) action = 15;
|
---|
| 774 | if (action <= 0) action = 15;
|
---|
| 775 | fga = action;
|
---|
| 776 | fnd = sg = -1.;
|
---|
| 777 | ok = 1;
|
---|
| 778 |
|
---|
| 779 | if (action & 1)
|
---|
| 780 | { pim->CheckDyn(low, high);
|
---|
| 781 | action--; }
|
---|
| 782 |
|
---|
| 783 | n = pim->XSize()*pim->YSize();
|
---|
| 784 |
|
---|
| 785 | if (action & 6)
|
---|
| 786 | {
|
---|
| 787 | int npu = (n/4 < 5000) ? 5000 : n/4;
|
---|
| 788 | meth = (char *)"Fond/Sig";
|
---|
| 789 | switch (pim->PixelType())
|
---|
| 790 | {
|
---|
| 791 | case kuint_2:
|
---|
| 792 | {
|
---|
| 793 | ImageU2 imt((RzImage&)(*pim));
|
---|
| 794 | if (action & 2)
|
---|
| 795 | fnd = ImgFondCielHisto(imt, 1.0f, 2, 0.5f, (float)low, (float)high, DBG);
|
---|
| 796 | if (action & 4)
|
---|
| 797 | { sg = ImgSigmaCiel(imt, npu, 1, 200, 0.1f, 2,
|
---|
| 798 | (float)low, (float)high, DBG);
|
---|
| 799 | if (sg < -1.e-3 ) ok = 0; }
|
---|
| 800 | break;
|
---|
| 801 | }
|
---|
| 802 | case kint_2:
|
---|
| 803 | {
|
---|
| 804 | ImageI2 imt((RzImage&)(*pim));
|
---|
| 805 | if (action & 2)
|
---|
| 806 | fnd = ImgFondCielHisto(imt, 1.0f, 2, 0.5f, (float)low, (float)high, DBG);
|
---|
| 807 | if (action & 4)
|
---|
| 808 | { sg = ImgSigmaCiel(imt, npu, 1, 200, 0.1f, 2,
|
---|
| 809 | (float)low, (float)high, DBG);
|
---|
| 810 | if (sg < -1.e-3 ) ok = 0; }
|
---|
| 811 | break;
|
---|
| 812 | }
|
---|
| 813 | case kint_4:
|
---|
| 814 | {
|
---|
| 815 | ImageI4 imt((RzImage&)(*pim));
|
---|
| 816 | if (action & 2)
|
---|
| 817 | fnd = ImgFondCielHisto(imt, 1.0f, 2, 0.5f, (float)low, (float)high, DBG);
|
---|
| 818 | if (action & 4)
|
---|
| 819 | { sg = ImgSigmaCiel(imt, npu, 1, 200, 0.1f, 2,
|
---|
| 820 | (float)low, (float)high, DBG);
|
---|
| 821 | if (sg < -1.e-3 ) ok = 0; }
|
---|
| 822 | break;
|
---|
| 823 | }
|
---|
| 824 | case kr_4:
|
---|
| 825 | {
|
---|
| 826 | ImageR4 imt((RzImage&)(*pim));
|
---|
| 827 | if (action & 2)
|
---|
| 828 | fnd = ImgFondCielHisto(imt, 1.0f, 2, 0.5f, (float)low, (float)high, DBG);
|
---|
| 829 | if (action & 4)
|
---|
| 830 | { sg = ImgSigmaCiel(imt, npu, 1, 200, 0.1f, 2,
|
---|
| 831 | (float)low,(float) high, DBG);
|
---|
| 832 | if (sg < -1.e-3 ) ok = 0; }
|
---|
| 833 | break;
|
---|
| 834 | }
|
---|
| 835 |
|
---|
| 836 | case kuint_4:
|
---|
| 837 | case kr_8:
|
---|
| 838 | cerr << "CalFondImage(RzImage *, ...) Unsupported image type (kuint_4/kr_8) "
|
---|
| 839 | << (int) pim->PixelType() << "\n" ;
|
---|
| 840 | break;
|
---|
| 841 | default:
|
---|
| 842 | cerr << "CalFondImage(RzImage *, ...) Unknown image type !! " << (int) pim->PixelType() << "\n" ;
|
---|
| 843 | break;
|
---|
| 844 | }
|
---|
| 845 |
|
---|
| 846 | }
|
---|
| 847 |
|
---|
| 848 | if ( (action == 8) || (!ok && (action & 8)) )
|
---|
| 849 | {
|
---|
| 850 | fracmax = 0.85; nbsig = 1; vitesse = 3;
|
---|
| 851 | minpix = low; maxpix = high; nbin = 10000;
|
---|
| 852 | rc = RzFondSig2Ciel(pim, vitesse, fracmax, nbsig, nbin,
|
---|
| 853 | &minpix, &maxpix, &fnd, &sg,
|
---|
| 854 | &minaff, &maxaff, &fracnul, &fracsat);
|
---|
| 855 | if (rc != 0) ok = 0;
|
---|
| 856 | meth = (char *)"FondSig2";
|
---|
| 857 | }
|
---|
| 858 |
|
---|
| 859 | if (ok > 0) /* Mise a jour */
|
---|
| 860 | {
|
---|
| 861 | if (fnd > -1.) pim->fond = fnd;
|
---|
| 862 | if (sg > -1. ) pim->sigmaFond = sg;
|
---|
| 863 | printf("CalculFond_Info: Meth=%s (%d) Fond/Sig= %5g %4g Nul/Sat=%d %d\n",
|
---|
| 864 | meth, fga, fnd, sg, pim->nbNul, pim->nbSat);
|
---|
| 865 | return(0);
|
---|
| 866 | }
|
---|
| 867 | else
|
---|
| 868 | {
|
---|
| 869 | printf("CalculFond_Erreur: Action=%d NbNul/Sat=%d %d\n",fga,
|
---|
| 870 | pim->nbNul, pim->nbSat);
|
---|
| 871 | return(1);
|
---|
| 872 | }
|
---|
| 873 |
|
---|
| 874 | }
|
---|
| 875 |
|
---|
| 876 |
|
---|
| 877 |
|
---|
| 878 | /* Nouvelle-Fonction */
|
---|
| 879 |
|
---|
| 880 | int RzFondSig2Ciel(RzImage * pim, int vitesse, float FracMax, int NbSigmas, int NBin,
|
---|
| 881 | float *MinPix, float *MaxPix, float *Fond, float *SigFond,
|
---|
| 882 | float *MinAff, float *MaxAff, float *FracNul, float *FracSature)
|
---|
| 883 |
|
---|
| 884 | /* ATTENTION : Cette fonction a ete mis en C++, pour traiter des */
|
---|
| 885 | /* RzImage a partir de la fonction FondSig2Ciel() */
|
---|
| 886 | /* de imgstat.c */
|
---|
| 887 | /* R. Ansari 04/95 */
|
---|
| 888 |
|
---|
| 889 | /* Cette fonction calcule les valeurs suivantes pour une image */
|
---|
| 890 | /* Arguments d'entree : */
|
---|
| 891 | /* - pim : Pointeur RzImage */
|
---|
| 892 | /* - vitesse : 1 pixel / vitesse pris en compte */
|
---|
| 893 | /* - FracMax : Parametre de calcul (voir ci-dessous) */
|
---|
| 894 | /* - NbSigmas: MinAff = Fond + NbSigmas*SigFond */
|
---|
| 895 | /* **Note : Si NbSigmas < 0 , on prend : */
|
---|
| 896 | /* MinAff = Fond + NbSigmas*SigFond */
|
---|
| 897 | /* et MaxAff = Fond - NbSigmas*SigFond */
|
---|
| 898 | /* Dans ce cas la gamme d'affichage fait ressortir le fond. */
|
---|
| 899 | /* - NBin : Nb de bins de l'histo */
|
---|
| 900 | /* - La valeur mini des pixels et la valeur de saturation */
|
---|
| 901 | /* (ValNul et ValSat) doivent etre fournies ds Min/MaxPix */
|
---|
| 902 | /* sorties : */
|
---|
| 903 | /* - MinPix,MaxPix = Valeurs Min et Max des pixels (<ValSat) */
|
---|
| 904 | /* - Fond = Pic de l'histo des pixels */
|
---|
| 905 | /* - SigFond = sigma du fond calcule par la relation */
|
---|
| 906 | /* NbPixel(Fond+SigFond) = Pic histo * 0.606 (=Exp(-0.5)) */
|
---|
| 907 | /* - MinAff = Bruit + NbSigmas * Sigma bruit */
|
---|
| 908 | /* - MaxAff est calcule tel que la relation suivante soit verifie */
|
---|
| 909 | /* NbPixel(MinAff<Pixel<MaxAff) = Nb de pixel entre Min-MaxAff */
|
---|
| 910 | /* = FracMax * NbPixel(MinAff<Pixel<ValSat */
|
---|
| 911 | /* - FracNul = Nb pixel < ValNul / Nb total pixel */
|
---|
| 912 | /* - FracSat = Nb pixel satures (>ValSat) / Nb total pixel */
|
---|
| 913 |
|
---|
| 914 | /* return code : 0 OK , 1 Erreur calloc */
|
---|
| 915 | /* 2 : Pic histos non trouve */
|
---|
| 916 | /* 3,4 : Probleme de Min/MaxAff avec ValSat */
|
---|
| 917 | /* 5 : Gamme dynamique minimale non respectee */
|
---|
| 918 | /* (MaxAff - MinAff > MINDYNAMIC */
|
---|
| 919 |
|
---|
| 920 | {
|
---|
| 921 |
|
---|
| 922 | #define MINNBIN 100
|
---|
| 923 | #define MAXNBIN 32765
|
---|
| 924 |
|
---|
| 925 | int nbin;
|
---|
| 926 |
|
---|
| 927 | float minhis = 0., maxhis = 65530. , binwidth;
|
---|
| 928 | int xdim, ydim;
|
---|
| 929 | int_4 under,over,tothis;
|
---|
| 930 | int_4 *phis;
|
---|
| 931 | float ValNul,ValSat;
|
---|
| 932 | int_4 *q;
|
---|
| 933 |
|
---|
| 934 | float val;
|
---|
| 935 | int i;
|
---|
| 936 | float min, max;
|
---|
| 937 | int_4 nbpix,nbpix2, imin, imax;
|
---|
| 938 | int bin,binmax;
|
---|
| 939 | int sigl,sigr;
|
---|
| 940 | float fracfond,fracsignal;
|
---|
| 941 |
|
---|
| 942 | float MINDYNAMIC = 5; /* Gamme dynamique minimale (MaxAff-MinAff)*/
|
---|
| 943 |
|
---|
| 944 | #define FRACPIC 0.6065 /* Valeur de exp(-0.5) */
|
---|
| 945 |
|
---|
| 946 | xdim = pim->XSize();
|
---|
| 947 | ydim = pim->YSize();
|
---|
| 948 |
|
---|
| 949 | ValNul = *MinPix;
|
---|
| 950 | ValSat = *MaxPix;
|
---|
| 951 | if ((ValSat < ValNul+0.01)) ValSat = ValNul+0.01;
|
---|
| 952 |
|
---|
| 953 | nbin = NBin;
|
---|
| 954 | if (nbin < MINNBIN) nbin = MINNBIN;
|
---|
| 955 | if (nbin > MAXNBIN) nbin = MAXNBIN;
|
---|
| 956 |
|
---|
| 957 | if (vitesse < 1) vitesse = 1;
|
---|
| 958 | if (vitesse > xdim*ydim/100) vitesse = xdim*ydim/100;
|
---|
| 959 |
|
---|
| 960 |
|
---|
| 961 | /* Je modifie min et max histo et nbin en fonction de valnul et valsat */
|
---|
| 962 | /* je garde binwidth constant */
|
---|
| 963 |
|
---|
| 964 | binwidth = (ValSat-ValNul) / nbin;
|
---|
| 965 | minhis = ValNul;
|
---|
| 966 | maxhis = minhis + nbin*binwidth;
|
---|
| 967 |
|
---|
| 968 |
|
---|
| 969 | (*MinAff) = minhis;
|
---|
| 970 | (*MaxAff) = maxhis;
|
---|
| 971 | *MinPix = 0.;
|
---|
| 972 | *MaxPix = -1.;
|
---|
| 973 | *Fond = -1.;
|
---|
| 974 | *SigFond = -1.;
|
---|
| 975 | *FracNul = 0.0;
|
---|
| 976 | *FracSature = 0.0;
|
---|
| 977 |
|
---|
| 978 | /* allocation dynamique de memoire */
|
---|
| 979 | phis = new int_4[nbin];
|
---|
| 980 |
|
---|
| 981 | /* mise a zero de l'histogramme */
|
---|
| 982 | for ( q=phis ; q<phis+nbin ; *q++ = 0 ) ;
|
---|
| 983 | under = over = tothis = 0;
|
---|
| 984 |
|
---|
| 985 |
|
---|
| 986 |
|
---|
| 987 | nbpix2 = nbpix = 0;
|
---|
| 988 | min = ValSat+1.;
|
---|
| 989 | max = ValNul-1;
|
---|
| 990 |
|
---|
| 991 | /* Boucle sur les pixels */
|
---|
| 992 | /* Pour aller plus vite, on prend un pixel sur 7 */
|
---|
| 993 | for ( i = 0 ; i < xdim*ydim ; i += vitesse )
|
---|
| 994 | {
|
---|
| 995 | val = pim->IValue(i);
|
---|
| 996 |
|
---|
| 997 | /* Calcul PixMax/Min et NbPix sature */
|
---|
| 998 | if (val > ValSat) nbpix++;
|
---|
| 999 | else {
|
---|
| 1000 | if(val < ValNul) nbpix2++;
|
---|
| 1001 | else {
|
---|
| 1002 | if (val > max) max = val;
|
---|
| 1003 | else if (val < min) min = val;
|
---|
| 1004 | }
|
---|
| 1005 | }
|
---|
| 1006 |
|
---|
| 1007 | /* remplissage de l'histogramme */
|
---|
| 1008 | bin = (int)((val - minhis) / binwidth) ;
|
---|
| 1009 | if ( bin < 0 ) under++;
|
---|
| 1010 | else
|
---|
| 1011 | {
|
---|
| 1012 | if (bin < nbin) { (*(phis+bin))++; tothis++; }
|
---|
| 1013 | else over++;
|
---|
| 1014 | }
|
---|
| 1015 | } /* Fin de for : Boucle sur les pixels */
|
---|
| 1016 |
|
---|
| 1017 | (*MinPix) = min;
|
---|
| 1018 | (*MaxPix) = max;
|
---|
| 1019 | /* Ne pas oublier le facteur vitesse pour le calcul FracSatue */
|
---|
| 1020 | (*FracNul) = (float)(nbpix2 * vitesse) / (float)(xdim*ydim);
|
---|
| 1021 | (*FracSature) = (float)(nbpix * vitesse) / (float)(xdim*ydim);
|
---|
| 1022 |
|
---|
| 1023 | /* On verifie qu'il y a eu une entree ds l'histo */
|
---|
| 1024 | if (tothis <= 0)
|
---|
| 1025 | { delete[] phis; return(2); }
|
---|
| 1026 |
|
---|
| 1027 | /* recherche du maximum */
|
---|
| 1028 | binmax = -1 ; imax = -1 ; q = phis;
|
---|
| 1029 | for ( i = 0 ; i < nbin ; i++, q++ )
|
---|
| 1030 | if ( *(q) > imax ) {imax = *(q) ; binmax = i ;}
|
---|
| 1031 |
|
---|
| 1032 | if ( (binmax < 0) || (binmax >= nbin) )
|
---|
| 1033 | { delete[] phis; return(2); }
|
---|
| 1034 |
|
---|
| 1035 | *Fond = minhis + binmax * binwidth;
|
---|
| 1036 |
|
---|
| 1037 | /* On va chercher le sigma du fond */
|
---|
| 1038 | imin = (int_4) ( (float)(imax) * FRACPIC ) ;
|
---|
| 1039 |
|
---|
| 1040 | /*
|
---|
| 1041 | printf("StatsDebug : min/maxhis %g %g (nbin= %d) w=%g\n",
|
---|
| 1042 | minhis,maxhis,nbin,binwidth);
|
---|
| 1043 | printf(".binmax= %d imax(=pic) = %d , imin= %d \n ",binmax,imax,imin);
|
---|
| 1044 | */
|
---|
| 1045 |
|
---|
| 1046 | nbpix = 0;
|
---|
| 1047 |
|
---|
| 1048 | sigr = 0;
|
---|
| 1049 | q = phis+binmax;
|
---|
| 1050 | while ( ((*q) > imin) && (sigr < (nbin-binmax)) )
|
---|
| 1051 | { sigr++; nbpix += (*q) ; q++; }
|
---|
| 1052 |
|
---|
| 1053 | sigl = 0;
|
---|
| 1054 | q = phis+binmax;
|
---|
| 1055 | while ( ((*q) > imin) && (sigl < binmax) )
|
---|
| 1056 | { sigl++; nbpix += (*q) ; q--; }
|
---|
| 1057 | nbpix -= (*(phis+binmax));
|
---|
| 1058 |
|
---|
| 1059 | (*SigFond) = (float)(sigl+sigr)*binwidth/2.;
|
---|
| 1060 | fracfond = (float)(nbpix) / (float)(tothis);
|
---|
| 1061 |
|
---|
| 1062 | (*MinAff) = minhis+(binmax-sigl)*binwidth;
|
---|
| 1063 | (*MaxAff) = minhis+(binmax+sigr)*binwidth;
|
---|
| 1064 |
|
---|
| 1065 |
|
---|
| 1066 | /* Check sur NbSigmas : */
|
---|
| 1067 | if (NbSigmas == 0) NbSigmas = 1;
|
---|
| 1068 | if (NbSigmas < 0) /* On considere le cas ou NbSigmas est negatif */
|
---|
| 1069 | {
|
---|
| 1070 | if ( (bin = binmax+NbSigmas*sigr) < 0 ) bin = 0;
|
---|
| 1071 | (*MinAff) = minhis + (float)bin*binwidth;
|
---|
| 1072 | if ( (bin = binmax-NbSigmas*sigr) >= nbin ) bin = nbin-1;
|
---|
| 1073 | (*MaxAff) = minhis + (float)bin*binwidth;
|
---|
| 1074 | goto sortie;
|
---|
| 1075 | }
|
---|
| 1076 |
|
---|
| 1077 | if ( (bin = binmax+NbSigmas*sigl) >= nbin )
|
---|
| 1078 | { delete[] phis; return(4); }
|
---|
| 1079 |
|
---|
| 1080 | (*MinAff) = minhis + bin*binwidth;
|
---|
| 1081 |
|
---|
| 1082 | /* Calcul du nb de pixel entre MinAff et ValSat */
|
---|
| 1083 | nbpix = 0;
|
---|
| 1084 | for( q = phis+bin ; q < phis+nbin ; q++) nbpix += (*q);
|
---|
| 1085 |
|
---|
| 1086 | fracsignal = (float)(nbpix) / (float)(tothis+over+under);
|
---|
| 1087 | nbpix = (int_4)((float)nbpix * FracMax);
|
---|
| 1088 | nbpix2 = 0; q = phis+bin; i = bin;
|
---|
| 1089 | while( (nbpix2 < nbpix) && (i < nbin) )
|
---|
| 1090 | { nbpix2 += (*q); i++; q++; }
|
---|
| 1091 |
|
---|
| 1092 | (*MaxAff) = minhis + (float)i*binwidth;
|
---|
| 1093 |
|
---|
| 1094 |
|
---|
| 1095 | sortie: /* On sort en liberant l'espace */
|
---|
| 1096 |
|
---|
| 1097 | /*
|
---|
| 1098 | printf(" Stats..Debug : Fond,sigl,sigr,SigFond = %g,%d,%d,%g \n",
|
---|
| 1099 | (*Fond),sigl,sigr,(*SigFond));
|
---|
| 1100 | printf(" Min/MaxPix= %g %g , Min/MaxAff= %g %g \n",(*MinPix),
|
---|
| 1101 | (*MaxPix),(*MinAff),(*MaxAff));
|
---|
| 1102 | printf(" FracFond,FracSignal %g %g FracNul,FracSat %g %g\n",
|
---|
| 1103 | fracfond,fracsignal,(*FracNul),(*FracSature));
|
---|
| 1104 | */
|
---|
| 1105 |
|
---|
| 1106 | delete[] phis;
|
---|
| 1107 | if ( (*MaxAff) < ((*MinAff)+MINDYNAMIC) ) return(5);
|
---|
| 1108 | return(0);
|
---|
| 1109 |
|
---|
| 1110 | }
|
---|
| 1111 |
|
---|
| 1112 |
|
---|
| 1113 | // ********** INSTANCES
|
---|
| 1114 |
|
---|
| 1115 | #if defined(__xlC) || defined(__aCC__)
|
---|
| 1116 | void instancetempimageop(int n)
|
---|
| 1117 | {
|
---|
| 1118 | /* Cette fonction sert uniquement a forcer le compilo a instancier les
|
---|
| 1119 | classes/fonctions template */
|
---|
| 1120 |
|
---|
| 1121 | int m = n-50;
|
---|
| 1122 | ImageU2 iu2(n,n), *tiu2[5], xiu2(n,n);
|
---|
| 1123 | ImageI2 ii2(n,n), *tii2[5], xii2(n,n);
|
---|
| 1124 | ImageI4 ii4(n,n), *tii4[5], xii4(n,n);
|
---|
| 1125 | ImageR4 ir4(n,n), *tir4[5], xir4(n,n);
|
---|
| 1126 |
|
---|
| 1127 | ImageR4 matx(5,5);
|
---|
| 1128 |
|
---|
| 1129 | RzCmvSigmaCiel(iu2.ImagePtr(), n, n, 100, 50, 50, (float)0.5, 2, (float)0., (float)65000., 0);
|
---|
| 1130 | RzCmvSigmaCiel(ii2.ImagePtr(), n, n, 100, 50, 50, (float)0.5, 2, (float)0., (float)65000., 0);
|
---|
| 1131 | RzCmvSigmaCiel(ii4.ImagePtr(), n, n, 100, 50, 50, (float)0.5, 2, (float)0., (float)65000., 0);
|
---|
| 1132 | RzCmvSigmaCiel(ir4.ImagePtr(), n, n, 100, 50, 50, (float)0.5, 2, (float)0., (float)65000., 0);
|
---|
| 1133 |
|
---|
| 1134 | ImgFondCielHisto(iu2);
|
---|
| 1135 | ImgFondCielHisto(ii2);
|
---|
| 1136 | ImgFondCielHisto(ii4);
|
---|
| 1137 | ImgFondCielHisto(ir4);
|
---|
| 1138 |
|
---|
| 1139 | ImgSigmaCiel(iu2, 100, 1, 100);
|
---|
| 1140 | ImgSigmaCiel(ii2, 100, 1, 100);
|
---|
| 1141 | ImgSigmaCiel(ii4, 100, 1, 100);
|
---|
| 1142 | ImgSigmaCiel(ir4, 100, 1, 100);
|
---|
| 1143 |
|
---|
| 1144 | CleanImages(5, tiu2);
|
---|
| 1145 | CleanImages(5, tii2);
|
---|
| 1146 | CleanImages(5, tii4);
|
---|
| 1147 | CleanImages(5, tir4);
|
---|
| 1148 |
|
---|
| 1149 |
|
---|
| 1150 | FilterImage(&iu2, &xiu2, &matx);
|
---|
| 1151 | FilterImage(&ii2, &xii2, &matx);
|
---|
| 1152 | FilterImage(&ii4, &xii4, &matx);
|
---|
| 1153 | FilterImage(&ir4, &xir4, &matx);
|
---|
| 1154 |
|
---|
| 1155 | FilterStat(&iu2, &xiu2,(int)3,(int)3,(float)1.,(float)-1.);
|
---|
| 1156 | FilterStat(&ii2, &xii2,(int)3,(int)3,(float)1.,(float)-1.);
|
---|
| 1157 | FilterStat(&ii4, &xii4,(int)3,(int)3,(float)1.,(float)-1.);
|
---|
| 1158 | FilterStat(&ir4, &xir4,(int)3,(int)3,(float)1.,(float)-1.);
|
---|
| 1159 |
|
---|
| 1160 | CSplineImage(iu2,(double)1,(double)0,(double)0,(int)0);
|
---|
| 1161 | CSplineImage(ii2,(double)1,(double)0,(double)0,(int)0);
|
---|
| 1162 | CSplineImage(ii4,(double)1,(double)0,(double)0,(int)0);
|
---|
| 1163 | CSplineImage(ir4,(double)1,(double)0,(double)0,(int)0);
|
---|
| 1164 |
|
---|
| 1165 | return;
|
---|
| 1166 | }
|
---|
| 1167 |
|
---|
| 1168 | #endif
|
---|
| 1169 |
|
---|
| 1170 |
|
---|
| 1171 | #ifdef __CXX_PRAGMA_TEMPLATES__
|
---|
| 1172 |
|
---|
| 1173 | #pragma define_template RzCmvSigmaCiel<uint_2>
|
---|
| 1174 | #pragma define_template RzCmvSigmaCiel<int_2>
|
---|
| 1175 | #pragma define_template RzCmvSigmaCiel<int_4>
|
---|
| 1176 | #pragma define_template RzCmvSigmaCiel<r_4>
|
---|
| 1177 |
|
---|
| 1178 | #pragma define_template ImgFondCielHisto<uint_2>
|
---|
| 1179 | #pragma define_template ImgFondCielHisto<int_2>
|
---|
| 1180 | #pragma define_template ImgFondCielHisto<int_4>
|
---|
| 1181 | #pragma define_template ImgFondCielHisto<r_4>
|
---|
| 1182 |
|
---|
| 1183 | #pragma define_template ImgSigmaCiel<uint_2>
|
---|
| 1184 | #pragma define_template ImgSigmaCiel<int_2>
|
---|
| 1185 | #pragma define_template ImgSigmaCiel<int_4>
|
---|
| 1186 | #pragma define_template ImgSigmaCiel<r_4>
|
---|
| 1187 |
|
---|
| 1188 | #pragma define_template CleanImages<uint_2>
|
---|
| 1189 | #pragma define_template CleanImages<int_2>
|
---|
| 1190 | #pragma define_template CleanImages<int_4>
|
---|
| 1191 | #pragma define_template CleanImages<r_4>
|
---|
| 1192 |
|
---|
| 1193 |
|
---|
| 1194 | #pragma define_template FilterImage<uint_2>
|
---|
| 1195 | #pragma define_template FilterImage<int_2>
|
---|
| 1196 | #pragma define_template FilterImage<int_4>
|
---|
| 1197 | #pragma define_template FilterImage<r_4>
|
---|
| 1198 |
|
---|
| 1199 | #pragma define_template FilterStat<uint_2>
|
---|
| 1200 | #pragma define_template FilterStat<int_2>
|
---|
| 1201 | #pragma define_template FilterStat<int_4>
|
---|
| 1202 | #pragma define_template FilterStat<r_4>
|
---|
| 1203 |
|
---|
| 1204 | #pragma define_template CSplineImage<uint_2>
|
---|
| 1205 | #pragma define_template CSplineImage<int_2>
|
---|
| 1206 | #pragma define_template CSplineImage<int_4>
|
---|
| 1207 | #pragma define_template CSplineImage<r_4>
|
---|
| 1208 |
|
---|
| 1209 | #endif
|
---|
| 1210 |
|
---|
| 1211 |
|
---|
[270] | 1212 | #if ( defined(ANSI_TEMPLATES) && !defined(__aCC__) )
|
---|
[220] | 1213 | template float RzCmvSigmaCiel<uint_2 const>(uint_2 const*, int, int, int, int, int, float, int, float, float, int);
|
---|
| 1214 | template float RzCmvSigmaCiel< int_2 const>( int_2 const*, int, int, int, int, int, float, int, float, float, int);
|
---|
| 1215 | template float RzCmvSigmaCiel< int_4 const>( int_4 const*, int, int, int, int, int, float, int, float, float, int);
|
---|
| 1216 | template float RzCmvSigmaCiel< r_4 const>( r_4 const*, int, int, int, int, int, float, int, float, float, int);
|
---|
| 1217 | template float ImgFondCielHisto<uint_2>(Image<uint_2> const&, float, int, float, float , float , int);
|
---|
| 1218 | template float ImgFondCielHisto< int_2>(Image< int_2> const&, float, int, float, float , float , int);
|
---|
| 1219 | template float ImgFondCielHisto< int_4>(Image< int_4> const&, float, int, float, float , float , int);
|
---|
| 1220 | template float ImgFondCielHisto< r_4>(Image< r_4> const&, float, int, float, float , float , int);
|
---|
| 1221 | template float ImgSigmaCiel<uint_2>(Image<uint_2> const& img, int, int, int, float, int, float , float, int);
|
---|
| 1222 | template float ImgSigmaCiel< int_2>(Image< int_2> const& img, int, int, int, float, int, float , float, int);
|
---|
| 1223 | template float ImgSigmaCiel< int_4>(Image< int_4> const& img, int, int, int, float, int, float , float, int);
|
---|
| 1224 | template float ImgSigmaCiel< r_4>(Image< r_4> const& img, int, int, int, float, int, float , float, int);
|
---|
| 1225 | template void CleanImages<uint_2>(int, Image<uint_2>**, double, double, double);
|
---|
| 1226 | template void CleanImages< int_2>(int, Image< int_2>**, double, double, double);
|
---|
| 1227 | template void CleanImages< int_4>(int, Image< int_4>**, double, double, double);
|
---|
| 1228 | template void CleanImages< r_4>(int, Image< r_4>**, double, double, double);
|
---|
| 1229 |
|
---|
| 1230 |
|
---|
| 1231 | template Image<uint_2>* FilterImage<uint_2>(Image<uint_2> const *, Image<uint_2>*, ImageR4 *);
|
---|
| 1232 | template Image< int_2>* FilterImage< int_2>(Image< int_2> const *, Image< int_2>*, ImageR4 *);
|
---|
| 1233 | template Image< int_4>* FilterImage< int_4>(Image< int_4> const *, Image< int_4>*, ImageR4 *);
|
---|
| 1234 | template Image< r_4>* FilterImage< r_4>(Image< r_4> const *, Image< r_4>*, ImageR4 *);
|
---|
| 1235 |
|
---|
| 1236 | template Image<uint_2>* FilterStat<uint_2>(Image<uint_2> const *, Image<uint_2>*,int,int,float,float);
|
---|
| 1237 | template Image< int_2>* FilterStat< int_2>(Image< int_2> const *, Image< int_2>*,int,int,float,float);
|
---|
| 1238 | template Image< int_4>* FilterStat< int_4>(Image< int_4> const *, Image< int_4>*,int,int,float,float);
|
---|
| 1239 | template Image< r_4>* FilterStat< r_4>(Image< r_4> const *, Image< r_4>*,int,int,float,float);
|
---|
| 1240 |
|
---|
| 1241 | template Image<uint_2>* CSplineImage<uint_2>(Image<uint_2> const &,double,double,double,int);
|
---|
| 1242 | template Image< int_2>* CSplineImage< int_2>(Image< int_2> const &,double,double,double,int);
|
---|
| 1243 | template Image< int_4>* CSplineImage< int_4>(Image< int_4> const &,double,double,double,int);
|
---|
| 1244 | template Image< r_4>* CSplineImage< r_4>(Image< r_4> const &,double,double,double,int);
|
---|
| 1245 |
|
---|
| 1246 | #endif
|
---|
| 1247 |
|
---|
| 1248 |
|
---|
[270] | 1249 | #ifdef GNU_TEMPLATES
|
---|
[220] | 1250 | template float RzCmvSigmaCiel(uint_2 const*, int, int, int, int, int, float, int, float, float, int);
|
---|
| 1251 | template float RzCmvSigmaCiel( int_2 const*, int, int, int, int, int, float, int, float, float, int);
|
---|
| 1252 | template float RzCmvSigmaCiel( int_4 const*, int, int, int, int, int, float, int, float, float, int);
|
---|
| 1253 | template float RzCmvSigmaCiel( r_4 const*, int, int, int, int, int, float, int, float, float, int);
|
---|
| 1254 | template float ImgFondCielHisto(Image<uint_2> const&, float, int, float, float , float , int);
|
---|
| 1255 | template float ImgFondCielHisto(Image< int_2> const&, float, int, float, float , float , int);
|
---|
| 1256 | template float ImgFondCielHisto(Image< int_4> const&, float, int, float, float , float , int);
|
---|
| 1257 | template float ImgFondCielHisto(Image< r_4> const&, float, int, float, float , float , int);
|
---|
| 1258 | template float ImgSigmaCiel(Image<uint_2> const& img, int, int, int, float, int, float , float, int);
|
---|
| 1259 | template float ImgSigmaCiel(Image< int_2> const& img, int, int, int, float, int, float , float, int);
|
---|
| 1260 | template float ImgSigmaCiel(Image< int_4> const& img, int, int, int, float, int, float , float, int);
|
---|
| 1261 | template float ImgSigmaCiel(Image< r_4> const& img, int, int, int, float, int, float , float, int);
|
---|
| 1262 | template void CleanImages(int, Image<uint_2>**, double, double, double);
|
---|
| 1263 | template void CleanImages(int, Image< int_2>**, double, double, double);
|
---|
| 1264 | template void CleanImages(int, Image< int_4>**, double, double, double);
|
---|
| 1265 | template void CleanImages(int, Image< r_4>**, double, double, double);
|
---|
| 1266 |
|
---|
| 1267 |
|
---|
| 1268 | template Image<uint_2>* FilterImage(Image<uint_2> const *, Image<uint_2>*, ImageR4 *);
|
---|
| 1269 | template Image< int_2>* FilterImage(Image< int_2> const *, Image< int_2>*, ImageR4 *);
|
---|
| 1270 | template Image< int_4>* FilterImage(Image< int_4> const *, Image< int_4>*, ImageR4 *);
|
---|
| 1271 | template Image< r_4>* FilterImage(Image< r_4> const *, Image< r_4>*, ImageR4 *);
|
---|
| 1272 |
|
---|
| 1273 | template Image<uint_2>* FilterStat(Image<uint_2> const *, Image<uint_2>*,int,int,float,float);
|
---|
| 1274 | template Image< int_2>* FilterStat(Image< int_2> const *, Image< int_2>*,int,int,float,float);
|
---|
| 1275 | template Image< int_4>* FilterStat(Image< int_4> const *, Image< int_4>*,int,int,float,float);
|
---|
| 1276 | template Image< r_4>* FilterStat(Image< r_4> const *, Image< r_4>*,int,int,float,float);
|
---|
| 1277 |
|
---|
| 1278 | template Image<uint_2>* CSplineImage(Image<uint_2> const &,double,double,double,int);
|
---|
| 1279 | template Image< int_2>* CSplineImage(Image< int_2> const &,double,double,double,int);
|
---|
| 1280 | template Image< int_4>* CSplineImage(Image< int_4> const &,double,double,double,int);
|
---|
| 1281 | template Image< r_4>* CSplineImage(Image< r_4> const &,double,double,double,int);
|
---|
| 1282 |
|
---|
| 1283 | #endif
|
---|