- Timestamp:
- Feb 12, 2008, 6:16:04 PM (18 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/parradapter.cc
r3455 r3458 378 378 379 379 /* --Methode-- */ 380 int P2DArrayAdapter::ComputeLut_Range(double& min, double& max, double fracmin, double fracmax, int vit,int nmax)380 int P2DArrayAdapter::ComputeLut_Range(double& min, double& max, double fracmin, double fracmax,int nmax) 381 381 // Compute min and max by throwing away the "fracmin" lowest values and the "fracmax" greatest values 382 382 // Use 1 value over "vit". Maximum number values to be used is "nmax". 383 383 // Si echec alors min,max restent inchanges. 384 384 { 385 int lp=0; 385 386 if(fracmin<0. || fracmin>=1.) fracmin=0.; 386 if(fracmax<0. || fracmin>=1.) fracmax=0.; 387 if (vit<1) vit = 1; 388 if(nmax<10) nmax = 10000; 389 390 if (sX*sY/vit < 1000) vit = sX*sY/1000; // need enough values 391 if (vit<1) vit = 1; 392 if (sX*sY/vit > nmax) vit = sX*sY/nmax; // but not too much ! 393 if (vit<1) vit = 1; 387 if(fracmax<0. || fracmax>=1.) fracmax=0.; 388 if(nmax<10) nmax = 5000; 389 390 int vit = sX*sY/nmax; // Not too many values, we are using qsort ! 391 if(vit<1) vit = 1; 392 // On recalcule nmax pour bien echantillonner le tableau: 393 // ex: sX*sY=9999, nmax=5000 -> vit=1 394 // - si on ne recalcule pas nmax alors on echantillonne [0,5000[ 395 // et on ne considere pas les 4999 dernieres valeurs! 396 // - si on recalcule nmax=sX*sY/vit=9999 on echantillonne tout le tableau 397 // le prix a payer: l'allocation varie entre nmax et 2*nmax-1 398 nmax = sX*sY/vit; 394 399 395 400 double *buff = new double[nmax]; 396 401 397 int n=0, nfill=0; 402 if(lp) {printf("ComputeLut_Range: sX*sY=%d fracmin=%g fracmax=%g nmax=%d min=%g max=%g\n" 403 ,sX*sY,fracmin,fracmax,nmax,min,max); fflush(stdout);} 404 405 int npix=0, nfill=0; 398 406 for(int j=0;j<sY;j++) for(int i=0;i<sX;i++) { 399 if(nfill>=nmax) continue; 400 if((n++)%vit==0) buff[nfill++] = Value(i,j); 407 if(nfill>=nmax) {j+=sY; break;} // On arrete completement: sortie bouble interne + j>sY 408 if((npix++)%vit!=0) continue; 409 double val = Value(i,j); 410 if( min>=max || (val>=min && val<=max) ) buff[nfill++] = val; 401 411 } 402 412 … … 410 420 if(buff[i1]<buff[i2]) {min=buff[i1]; max=buff[i2];} 411 421 412 //printf("DEBUG (%d,%g,%g,%d,%d)nfill=%d [0]=%g [n]=%g min=[%d]=%g max=[%d]=%g\n"413 // ,sX*sY,fracmin,fracmax,vit,nmax,nfill,buff[0],buff[nfill-1],i1,min,i2,max); fflush(stdout); 422 if(lp) {printf(" ...npix=%d nfill=%d [0]=%g [n]=%g min=[%d]=%g max=[%d]=%g\n" 423 ,npix,nfill,buff[0],buff[nfill-1],i1,min,i2,max); fflush(stdout);} 414 424 415 425 delete [] buff; -
trunk/SophyaPI/PI/parradapter.h
r3455 r3458 86 86 double nbsig=1., double fracmax=0.95); 87 87 // Calcul stable Range 88 virtual int ComputeLut_Range(double& min,double& max,double fracmin=0.,double fracmax=0.,int vit=10,intnmax=10000);88 virtual int ComputeLut_Range(double& min,double& max,double fracmin=0.,double fracmax=0.,int nmax=10000); 89 89 90 90 // Calcul pixmap avec un LUT -
trunk/SophyaPI/PI/piimage.cc
r3455 r3458 458 458 break; 459 459 case AutoLut_Range : 460 img->ComputeLut_Range(min, max, nsa/2., nsa/2., 1, 5000);460 img->ComputeLut_Range(min, max,(1.-nsa)/2.,(1.-nsa)/2., 5000); 461 461 break; 462 462 case AutoLut_MinMax : … … 658 658 else pnsal = atof( suop.c_str() ); 659 659 } 660 AutoLutType palt = AutoLut_No; 660 AutoLutType palt = AutoLut_No; 661 661 if (opts.substr(8,6) == "minmax") palt = AutoLut_MinMax; 662 662 else if (opts.substr(8,7) == "meansig") palt = AutoLut_MeanSigma; 663 663 else if (opts.substr(8,7) == "hispeak") palt = AutoLut_HistoPeak; 664 else if (opts.substr(8,9) == "hispeak") palt = AutoLut_HistoPeak;665 664 else if (opts.substr(8,6) == "hispic") palt = AutoLut_HistoPeak; 666 665 else if (opts.substr(8,7) == "histail") palt = AutoLut_HistoTail; 667 if ( palt != AutoLut_No ) SetLut(palt, min_al, max_al, ctlut, pnsal, false); 666 else if (opts.substr(8,6) == "hisrng") palt = AutoLut_Range; 667 if ( palt != AutoLut_No ) SetLut(palt, min, max, ctlut, pnsal, false); 668 668 continue; 669 669 } -
trunk/SophyaPI/PI/piimgtools.cc
r3455 r3458 122 122 mOpt[1]->AppendItem("HistoPeak+1s", 1209); 123 123 mOpt[1]->AppendItem("HistoPeak+2s", 1210); 124 mOpt[1]->AppendItem("Range -10%", 1211);125 mOpt[1]->AppendItem("Range -30%", 1212);124 mOpt[1]->AppendItem("Range90%", 1211); 125 mOpt[1]->AppendItem("Range70%", 1212); 126 126 mOpt[1]->SetValue(1200); 127 127 mOpt[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); … … 361 361 AutoLut_HistoPeak, AutoLut_HistoPeak, 362 362 AutoLut_Range, AutoLut_Range } ; 363 double nsas[13] = {0., 1., 2., 3., 0.70, 0.9, -1., 1., 2., 1., 2., 0.1, 0.3};363 double nsas[13] = {0., 1., 2., 3., 0.70, 0.9, 1., 1., 2., 1., 2., 0.9, 0.7}; 364 364 365 365 msg = UserMsg(msg);
Note:
See TracChangeset
for help on using the changeset viewer.