source: Sophya/trunk/SophyaLib/NTools/imageop.cc@ 262

Last change on this file since 262 was 244, checked in by ansari, 26 years ago

beaucoup modifs rz+cmv 22/4/99

File size: 40.1 KB
Line 
1#include "machdefs.h"
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.
23template <class T>
24float 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
46template <class T>
47void 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
81template <class T>
82//++
83void 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
138template <class T>
139//++
140float 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
201template <class T>
202float 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
215template <class T>
216//++
217float 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{
250FLOATDOUBLE X,Y,EY;
251double (*Fun) (double ,double *,double *);
252int_4 npar;
253double par[6], epar[6],minpar[6],maxpar[6],stepar[6],stochi2;
254int_4 i,j,i1,j1,j2,n,ip,nbin,inc,ibin0,max,imax,lmax,b1,b2;
255float *histo,*xbin,*ehisto,fwhm,rc;
256double vp,pxv;
257
258/* set reasonable parameters */
259Fun = Gauss1DPolF ;
260if ( deg<=1 ) deg=0; else deg=2;
261low = ( low < 0 ) ? 0 : low;
262high = ( high > 65530 ) ? 65530 : high;
263if ( low >= high ) { low=0; high = 65530;}
264bin = ( bin <= 0 ) ? 1 : bin;
265nbin = int(2.*taille /bin + 1);
266if ( nbin < 20 ) nbin = 20;
267if ( nbin >= 65530 ) nbin = 65530;
268ibin0 = int(-nbin*bin/2.);
269inc = int(nx*ny / ndata); inc = int(sqrt( (double) inc ));
270inc = (inc<1) ? 1 : inc;
271if(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); }
276if ( nx < 5 || ny < 5 ) return (-1.);
277
278/* allocate place for histogramme */
279if ( (histo = (float *) calloc(nbin, sizeof(float)) ) == NULL )
280 return(-2.);
281if ( (xbin = (float *) calloc(nbin, sizeof(float)) ) == NULL )
282 {free(histo); return(-2.);}
283if ( (ehisto = (float *) calloc(nbin, sizeof(float)) ) == NULL )
284 {free(histo); free(xbin); return(-2.);}
285
286/* fill histogramme */
287ndata=0;
288for (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} }
307for(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
311if(deb>1) printf(" nombre de data corrects = %d\n",ndata);
312if( ndata < 1 ) {rc= -3.; goto END;}
313
314/* find maximum */
315max = -1; imax = -1;
316for(i=nbin-1;i>=0;i--) if(histo[i]>max) { max=int(histo[i]); imax=i;}
317if(deb>1) printf(" maxi histo = %d (bin=%d)\n",max,imax);
318if ( imax == -1 || imax == 0 || imax == nbin-1 ) {rc= -4.; goto END;}
319if(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 */
326lmax = (int) ( (float) max * 0.5 );
327for(b1=imax;b1>0;b1--) if(histo[b1]<=lmax) break;
328for(b2=imax;b2<nbin;b2++) if(histo[b2]<=lmax) break;
329fwhm = (xbin[b2]-xbin[b1]);
330if(deb>1) printf(" fwhm = %f (%d,%d)\n",fwhm,b1,b2);
331
332/* find limites a frac*max */
333lmax = (int) ( (float) max * frac ) + 1;
334if( lmax < 1 )
335 {if(deb>1) printf(" lmax=%d\n",lmax); rc= -5.; goto END;}
336for(b1=imax;b1>0;b1--) if(histo[b1]<=lmax) break;
337for(b2=imax;b2<nbin;b2++) if(histo[b2]<=lmax) break;
338
339n=0;
340for(i=b1;i<=b2;i++) if( histo[i] > 0 ) n++;
341if(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) */
345if( 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}
358if( n < 4 ) {rc= -6.; goto END;}
359ndata = n;
360
361/* fit dans les limites */
362npar = 3+deg+1; Set_FitFunDPol(deg);
363if(ndata<8) {npar=4; Set_FitFunDPol(0);}
364if(ndata<5) {npar=3; Set_FitFunDPol(-1);}
365X.fx = xbin;
366Y.fx = histo;
367EY.fx = ehisto;
368stochi2 = 0.0001;
369n = nbin;
370par[0] = max;
371par[1] = histo[imax-1]*xbin[imax-1]+histo[imax]*xbin[imax]+histo[imax+1]*xbin[imax+1];
372par[1] = par[1]/(histo[imax-1]+histo[imax]+histo[imax+1]);
373par[2] = (fwhm<1.) ? 1. : fwhm/2.36;
374par[3] = par[4] = par[5] = 0.;
375stepar[0] = par[0]/20.; stepar[1] = 1.; stepar[2] = par[2]/5.;
376stepar[3] = 1.; stepar[5] = 0.1;
377stepar[4] = 0.;
378for(i=0;i<6;i++) {minpar[i] = 1.; maxpar[i] = -1.;}
379minpar[2] = 0.1; maxpar[2] = 65530.;
380if(deb>1) printf(" choix de fit a %d parametres b1=%d,b2=%d,ndata=%d)\n"
381 ,npar,b1,b2,ndata);
382
383i = (deb>=3) ? deb-2 : 0 ;
384vp = FitFun(Fun,FITFUN_FLOAT,X,Y,EY,&n,b1,b2,par
385 ,epar,stepar,minpar,maxpar,npar,stochi2,50,i);
386
387if( vp<=0. && vp != -4. ) {rc= -7.; goto END;}
388rc = par[2];
389if(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
392END:
393free(histo); free(xbin); free(ehisto);
394return(rc);
395}
396
397/* ................................................................................. */
398/* Filtrage ( Convolution ) d' images */
399/* ................................................................................. */
400
401/* Nouvelle-Fonction */
402template <class T>
403//++
404Image<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
414float vpix, *mxe;
415bool fgcr;
416int i,j,k,l,m,n;
417int ndim, nd2;
418
419fgcr = false;
420
421if ((pim == NULL) || (matx == NULL))
422 { printf(" FilterImage_Erreur : pim ou matx = NULL ! \n");
423 return(NULL); }
424if (matx->XSize() != matx->YSize())
425 { printf("FilterImage_Erreur: Filtrage par matrice carre uniquement (%d,%d)\n",
426 matx->XSize(), matx->YSize()); return(NULL); }
427ndim = matx->XSize();
428if ( (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); }
431if (pom == NULL)
432 { pom = new Image<T>(pim->XSize(), pim->YSize(), false); fgcr = true; }
433
434if ( (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
438nd2 = ndim/2;
439
440/* Traitement de la partie centrale */
441for(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 */
455for(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 */
474for(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 */
492for(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
527return(pom);
528
529}
530
531//////////////////////////////////////////////////////////////////////////////
532/* Nouvelle-Fonction CMV 14/10/97 */
533template <class T>
534//++
535Image<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{
547if(pim == NULL)
548 {printf(" FilterStat_Erreur : pim = NULL ! \n");
549 return(NULL);}
550if( N<=0 || M<=0 )
551 {printf("FilterStat_Erreur: Filtrage par matrice (%d,%d)\n",N,M);
552 return(NULL);}
553bool fgcr = false;
554if(pom == NULL)
555 {pom = new Image<T>(pim->XSize(), pim->YSize(), false); fgcr = true;}
556if( (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
560T low = (T) lowbad;
561T high = (T) highbad;
562if(high>low) fgcr = true; else fgcr = false;
563
564N /= 2; M /= 2;
565double * tab = new double[(2*N+1)*(2*M+1)];
566
567for(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
589delete [] tab;
590return(pom);
591}
592
593//////////////////////////////////////////////////////////////////////////////
594/* Nouvelle-Fonction CMV 7/8/98 */
595template <class T>
596//++
597Image<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
614int nx = f1.XSize();
615int ny = f1.YSize();
616float dum;
617dum = nx/pxsz;
618int dx = (int) (dum+0.5);
619dum = ny/pxsz;
620int dy = (int) (dum+0.5);
621cout<<"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;
624if(nx<=1 || ny<=1) return NULL;
625if(dx<=0 || dy<=0) return NULL;
626
627Image<T> *f2 = NULL;
628TRY {
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 !
636double *x = new double[nx+2];
637double *y = new double[ny+2];
638double *z = new double[(nx+2)*(ny+2)];
639{
640int 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).
644x[0] = 0.; x[nx+1] = nx;
645y[0] = 0.; y[ny+1] = ny;
646for(k=1;k<=nx;k++) x[k] = k-0.5;
647for(k=1;k<=ny;k++) y[k] = k-0.5;
648// Remplissage des valeurs avec effet de bord [0] et [nx+1],[ny+1].
649k = 0;
650int ii,jj;
651for(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
663CSpline2 spl(nx+2,x,ny+2,y,z,natural,true);
664spl.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.
671double xmin = -pxsz/10000., xmax = nx+pxsz/10000.;
672double ymin = -pxsz/10000., ymax = ny+pxsz/10000.;
673for(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
683delete [] x;
684delete [] y;
685delete [] z;
686
687return f2;
688}
689//////////////////////////////////////////////////////////////////////////////
690
691
692
693/* Nouvelle-Fonction */
694int 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{
698int 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
741return(rc);
742}
743
744/* Nouvelle-Fonction */
745int 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{
763int n,ok,rc,fga;
764float fnd, sg;
765
766int nbsig, vitesse, nbin;
767float minaff, maxaff, minpix, maxpix;
768float fracmax,fracnul,fracsat;
769char *meth;
770
771#define DBG 0
772
773if (action >= 15) action = 15;
774if (action <= 0) action = 15;
775fga = action;
776fnd = sg = -1.;
777ok = 1;
778
779if (action & 1)
780 { pim->CheckDyn(low, high);
781 action--; }
782
783n = pim->XSize()*pim->YSize();
784
785if (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
848if ( (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
859if (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 }
867else
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
880int 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
925int nbin;
926
927float minhis = 0., maxhis = 65530. , binwidth;
928int xdim, ydim;
929int_4 under,over,tothis;
930int_4 *phis;
931float ValNul,ValSat;
932int_4 *q;
933
934float val;
935int i;
936float min, max;
937int_4 nbpix,nbpix2, imin, imax;
938int bin,binmax;
939int sigl,sigr;
940float fracfond,fracsignal;
941
942float MINDYNAMIC = 5; /* Gamme dynamique minimale (MaxAff-MinAff)*/
943
944#define FRACPIC 0.6065 /* Valeur de exp(-0.5) */
945
946xdim = pim->XSize();
947ydim = pim->YSize();
948
949ValNul = *MinPix;
950ValSat = *MaxPix;
951if ((ValSat < ValNul+0.01)) ValSat = ValNul+0.01;
952
953nbin = NBin;
954if (nbin < MINNBIN) nbin = MINNBIN;
955if (nbin > MAXNBIN) nbin = MAXNBIN;
956
957if (vitesse < 1) vitesse = 1;
958if (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
964binwidth = (ValSat-ValNul) / nbin;
965minhis = ValNul;
966maxhis = 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 */
979phis = new int_4[nbin];
980
981/* mise a zero de l'histogramme */
982for ( q=phis ; q<phis+nbin ; *q++ = 0 ) ;
983under = over = tothis = 0;
984
985
986
987nbpix2 = nbpix = 0;
988min = ValSat+1.;
989max = ValNul-1;
990
991/* Boucle sur les pixels */
992/* Pour aller plus vite, on prend un pixel sur 7 */
993for ( 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 */
1024if (tothis <= 0)
1025 { delete[] phis; return(2); }
1026
1027/* recherche du maximum */
1028binmax = -1 ; imax = -1 ; q = phis;
1029for ( i = 0 ; i < nbin ; i++, q++ )
1030 if ( *(q) > imax ) {imax = *(q) ; binmax = i ;}
1031
1032if ( (binmax < 0) || (binmax >= nbin) )
1033 { delete[] phis; return(2); }
1034
1035*Fond = minhis + binmax * binwidth;
1036
1037/* On va chercher le sigma du fond */
1038imin = (int_4) ( (float)(imax) * FRACPIC ) ;
1039
1040/*
1041printf("StatsDebug : min/maxhis %g %g (nbin= %d) w=%g\n",
1042 minhis,maxhis,nbin,binwidth);
1043printf(".binmax= %d imax(=pic) = %d , imin= %d \n ",binmax,imax,imin);
1044*/
1045
1046nbpix = 0;
1047
1048sigr = 0;
1049q = phis+binmax;
1050while ( ((*q) > imin) && (sigr < (nbin-binmax)) )
1051 { sigr++; nbpix += (*q) ; q++; }
1052
1053sigl = 0;
1054q = phis+binmax;
1055while ( ((*q) > imin) && (sigl < binmax) )
1056 { sigl++; nbpix += (*q) ; q--; }
1057nbpix -= (*(phis+binmax));
1058
1059(*SigFond) = (float)(sigl+sigr)*binwidth/2.;
1060fracfond = (float)(nbpix) / (float)(tothis);
1061
1062(*MinAff) = minhis+(binmax-sigl)*binwidth;
1063(*MaxAff) = minhis+(binmax+sigr)*binwidth;
1064
1065
1066/* Check sur NbSigmas : */
1067if (NbSigmas == 0) NbSigmas = 1;
1068if (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
1077if ( (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 */
1083nbpix = 0;
1084for( q = phis+bin ; q < phis+nbin ; q++) nbpix += (*q);
1085
1086fracsignal = (float)(nbpix) / (float)(tothis+over+under);
1087nbpix = (int_4)((float)nbpix * FracMax);
1088nbpix2 = 0; q = phis+bin; i = bin;
1089while( (nbpix2 < nbpix) && (i < nbin) )
1090 { nbpix2 += (*q); i++; q++; }
1091
1092(*MaxAff) = minhis + (float)i*binwidth;
1093
1094
1095sortie: /* On sort en liberant l'espace */
1096
1097/*
1098printf(" 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));
1102printf(" FracFond,FracSignal %g %g FracNul,FracSat %g %g\n",
1103 fracfond,fracsignal,(*FracNul),(*FracSature));
1104*/
1105
1106delete[] phis;
1107if ( (*MaxAff) < ((*MinAff)+MINDYNAMIC) ) return(5);
1108return(0);
1109
1110}
1111
1112
1113// ********** INSTANCES
1114
1115#if defined(__xlC) || defined(__aCC__)
1116void instancetempimageop(int n)
1117{
1118/* Cette fonction sert uniquement a forcer le compilo a instancier les
1119 classes/fonctions template */
1120
1121int m = n-50;
1122ImageU2 iu2(n,n), *tiu2[5], xiu2(n,n);
1123ImageI2 ii2(n,n), *tii2[5], xii2(n,n);
1124ImageI4 ii4(n,n), *tii4[5], xii4(n,n);
1125ImageR4 ir4(n,n), *tir4[5], xir4(n,n);
1126
1127ImageR4 matx(5,5);
1128
1129RzCmvSigmaCiel(iu2.ImagePtr(), n, n, 100, 50, 50, (float)0.5, 2, (float)0., (float)65000., 0);
1130RzCmvSigmaCiel(ii2.ImagePtr(), n, n, 100, 50, 50, (float)0.5, 2, (float)0., (float)65000., 0);
1131RzCmvSigmaCiel(ii4.ImagePtr(), n, n, 100, 50, 50, (float)0.5, 2, (float)0., (float)65000., 0);
1132RzCmvSigmaCiel(ir4.ImagePtr(), n, n, 100, 50, 50, (float)0.5, 2, (float)0., (float)65000., 0);
1133
1134ImgFondCielHisto(iu2);
1135ImgFondCielHisto(ii2);
1136ImgFondCielHisto(ii4);
1137ImgFondCielHisto(ir4);
1138
1139ImgSigmaCiel(iu2, 100, 1, 100);
1140ImgSigmaCiel(ii2, 100, 1, 100);
1141ImgSigmaCiel(ii4, 100, 1, 100);
1142ImgSigmaCiel(ir4, 100, 1, 100);
1143
1144CleanImages(5, tiu2);
1145CleanImages(5, tii2);
1146CleanImages(5, tii4);
1147CleanImages(5, tir4);
1148
1149
1150FilterImage(&iu2, &xiu2, &matx);
1151FilterImage(&ii2, &xii2, &matx);
1152FilterImage(&ii4, &xii4, &matx);
1153FilterImage(&ir4, &xir4, &matx);
1154
1155FilterStat(&iu2, &xiu2,(int)3,(int)3,(float)1.,(float)-1.);
1156FilterStat(&ii2, &xii2,(int)3,(int)3,(float)1.,(float)-1.);
1157FilterStat(&ii4, &xii4,(int)3,(int)3,(float)1.,(float)-1.);
1158FilterStat(&ir4, &xir4,(int)3,(int)3,(float)1.,(float)-1.);
1159
1160CSplineImage(iu2,(double)1,(double)0,(double)0,(int)0);
1161CSplineImage(ii2,(double)1,(double)0,(double)0,(int)0);
1162CSplineImage(ii4,(double)1,(double)0,(double)0,(int)0);
1163CSplineImage(ir4,(double)1,(double)0,(double)0,(int)0);
1164
1165return;
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
1212#if ( defined(__ANSI_TEMPLATES__) && !defined(__aCC__) )
1213template float RzCmvSigmaCiel<uint_2 const>(uint_2 const*, int, int, int, int, int, float, int, float, float, int);
1214template float RzCmvSigmaCiel< int_2 const>( int_2 const*, int, int, int, int, int, float, int, float, float, int);
1215template float RzCmvSigmaCiel< int_4 const>( int_4 const*, int, int, int, int, int, float, int, float, float, int);
1216template float RzCmvSigmaCiel< r_4 const>( r_4 const*, int, int, int, int, int, float, int, float, float, int);
1217template float ImgFondCielHisto<uint_2>(Image<uint_2> const&, float, int, float, float , float , int);
1218template float ImgFondCielHisto< int_2>(Image< int_2> const&, float, int, float, float , float , int);
1219template float ImgFondCielHisto< int_4>(Image< int_4> const&, float, int, float, float , float , int);
1220template float ImgFondCielHisto< r_4>(Image< r_4> const&, float, int, float, float , float , int);
1221template float ImgSigmaCiel<uint_2>(Image<uint_2> const& img, int, int, int, float, int, float , float, int);
1222template float ImgSigmaCiel< int_2>(Image< int_2> const& img, int, int, int, float, int, float , float, int);
1223template float ImgSigmaCiel< int_4>(Image< int_4> const& img, int, int, int, float, int, float , float, int);
1224template float ImgSigmaCiel< r_4>(Image< r_4> const& img, int, int, int, float, int, float , float, int);
1225template void CleanImages<uint_2>(int, Image<uint_2>**, double, double, double);
1226template void CleanImages< int_2>(int, Image< int_2>**, double, double, double);
1227template void CleanImages< int_4>(int, Image< int_4>**, double, double, double);
1228template void CleanImages< r_4>(int, Image< r_4>**, double, double, double);
1229
1230
1231template Image<uint_2>* FilterImage<uint_2>(Image<uint_2> const *, Image<uint_2>*, ImageR4 *);
1232template Image< int_2>* FilterImage< int_2>(Image< int_2> const *, Image< int_2>*, ImageR4 *);
1233template Image< int_4>* FilterImage< int_4>(Image< int_4> const *, Image< int_4>*, ImageR4 *);
1234template Image< r_4>* FilterImage< r_4>(Image< r_4> const *, Image< r_4>*, ImageR4 *);
1235
1236template Image<uint_2>* FilterStat<uint_2>(Image<uint_2> const *, Image<uint_2>*,int,int,float,float);
1237template Image< int_2>* FilterStat< int_2>(Image< int_2> const *, Image< int_2>*,int,int,float,float);
1238template Image< int_4>* FilterStat< int_4>(Image< int_4> const *, Image< int_4>*,int,int,float,float);
1239template Image< r_4>* FilterStat< r_4>(Image< r_4> const *, Image< r_4>*,int,int,float,float);
1240
1241template Image<uint_2>* CSplineImage<uint_2>(Image<uint_2> const &,double,double,double,int);
1242template Image< int_2>* CSplineImage< int_2>(Image< int_2> const &,double,double,double,int);
1243template Image< int_4>* CSplineImage< int_4>(Image< int_4> const &,double,double,double,int);
1244template Image< r_4>* CSplineImage< r_4>(Image< r_4> const &,double,double,double,int);
1245
1246#endif
1247
1248
1249#ifdef __GNU_TEMPLATES__
1250template float RzCmvSigmaCiel(uint_2 const*, int, int, int, int, int, float, int, float, float, int);
1251template float RzCmvSigmaCiel( int_2 const*, int, int, int, int, int, float, int, float, float, int);
1252template float RzCmvSigmaCiel( int_4 const*, int, int, int, int, int, float, int, float, float, int);
1253template float RzCmvSigmaCiel( r_4 const*, int, int, int, int, int, float, int, float, float, int);
1254template float ImgFondCielHisto(Image<uint_2> const&, float, int, float, float , float , int);
1255template float ImgFondCielHisto(Image< int_2> const&, float, int, float, float , float , int);
1256template float ImgFondCielHisto(Image< int_4> const&, float, int, float, float , float , int);
1257template float ImgFondCielHisto(Image< r_4> const&, float, int, float, float , float , int);
1258template float ImgSigmaCiel(Image<uint_2> const& img, int, int, int, float, int, float , float, int);
1259template float ImgSigmaCiel(Image< int_2> const& img, int, int, int, float, int, float , float, int);
1260template float ImgSigmaCiel(Image< int_4> const& img, int, int, int, float, int, float , float, int);
1261template float ImgSigmaCiel(Image< r_4> const& img, int, int, int, float, int, float , float, int);
1262template void CleanImages(int, Image<uint_2>**, double, double, double);
1263template void CleanImages(int, Image< int_2>**, double, double, double);
1264template void CleanImages(int, Image< int_4>**, double, double, double);
1265template void CleanImages(int, Image< r_4>**, double, double, double);
1266
1267
1268template Image<uint_2>* FilterImage(Image<uint_2> const *, Image<uint_2>*, ImageR4 *);
1269template Image< int_2>* FilterImage(Image< int_2> const *, Image< int_2>*, ImageR4 *);
1270template Image< int_4>* FilterImage(Image< int_4> const *, Image< int_4>*, ImageR4 *);
1271template Image< r_4>* FilterImage(Image< r_4> const *, Image< r_4>*, ImageR4 *);
1272
1273template Image<uint_2>* FilterStat(Image<uint_2> const *, Image<uint_2>*,int,int,float,float);
1274template Image< int_2>* FilterStat(Image< int_2> const *, Image< int_2>*,int,int,float,float);
1275template Image< int_4>* FilterStat(Image< int_4> const *, Image< int_4>*,int,int,float,float);
1276template Image< r_4>* FilterStat(Image< r_4> const *, Image< r_4>*,int,int,float,float);
1277
1278template Image<uint_2>* CSplineImage(Image<uint_2> const &,double,double,double,int);
1279template Image< int_2>* CSplineImage(Image< int_2> const &,double,double,double,int);
1280template Image< int_4>* CSplineImage(Image< int_4> const &,double,double,double,int);
1281template Image< r_4>* CSplineImage(Image< r_4> const &,double,double,double,int);
1282
1283#endif
Note: See TracBrowser for help on using the repository browser.