Changeset 3458 in Sophya for trunk/SophyaPI


Ignore:
Timestamp:
Feb 12, 2008, 6:16:04 PM (18 years ago)
Author:
cmv
Message:

add ComputeLut_Range and autolut=hisrng cmv 12/02/2008

Location:
trunk/SophyaPI/PI
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/parradapter.cc

    r3455 r3458  
    378378
    379379/* --Methode-- */
    380 int P2DArrayAdapter::ComputeLut_Range(double& min, double& max, double fracmin, double fracmax, int vit,int nmax)
     380int P2DArrayAdapter::ComputeLut_Range(double& min, double& max, double fracmin, double fracmax,int nmax)
    381381// Compute min and max by throwing away the "fracmin" lowest values and the "fracmax" greatest values
    382382// Use 1 value over "vit". Maximum number values to be used is "nmax".
    383383// Si echec alors min,max restent inchanges.
    384384{
     385  int lp=0;
    385386 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;
    394399
    395400 double *buff = new double[nmax];
    396401
    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;
    398406 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;
    401411 }
    402412
     
    410420 if(buff[i1]<buff[i2]) {min=buff[i1]; max=buff[i2];}
    411421
    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);}
    414424
    415425 delete [] buff;
  • trunk/SophyaPI/PI/parradapter.h

    r3455 r3458  
    8686                                      double nbsig=1., double fracmax=0.95);
    8787//    Calcul stable Range
    88   virtual int     ComputeLut_Range(double& min,double& max,double fracmin=0.,double fracmax=0.,int vit=10,int nmax=10000);
     88  virtual int     ComputeLut_Range(double& min,double& max,double fracmin=0.,double fracmax=0.,int nmax=10000);
    8989
    9090//    Calcul pixmap avec un LUT
  • trunk/SophyaPI/PI/piimage.cc

    r3455 r3458  
    458458   break;
    459459 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);
    461461   break;
    462462 case AutoLut_MinMax :
     
    658658        else pnsal = atof( suop.c_str() );
    659659      }
    660       AutoLutType palt = AutoLut_No;     
     660      AutoLutType palt = AutoLut_No;
    661661      if (opts.substr(8,6) == "minmax")  palt = AutoLut_MinMax;
    662662      else if (opts.substr(8,7) == "meansig")  palt = AutoLut_MeanSigma;
    663663      else if (opts.substr(8,7) == "hispeak")  palt = AutoLut_HistoPeak;
    664       else if (opts.substr(8,9) == "hispeak")  palt = AutoLut_HistoPeak;
    665664      else if (opts.substr(8,6) == "hispic")   palt = AutoLut_HistoPeak;
    666665      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);
    668668      continue;
    669669    }
  • trunk/SophyaPI/PI/piimgtools.cc

    r3455 r3458  
    122122mOpt[1]->AppendItem("HistoPeak+1s", 1209);
    123123mOpt[1]->AppendItem("HistoPeak+2s", 1210);
    124 mOpt[1]->AppendItem("Range-10%", 1211);
    125 mOpt[1]->AppendItem("Range-30%", 1212);
     124mOpt[1]->AppendItem("Range90%", 1211);
     125mOpt[1]->AppendItem("Range70%", 1212);
    126126mOpt[1]->SetValue(1200);
    127127mOpt[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
     
    361361                         AutoLut_HistoPeak, AutoLut_HistoPeak,
    362362                         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};
     363double nsas[13] = {0., 1., 2., 3., 0.70, 0.9, 1., 1., 2., 1., 2., 0.9, 0.7};
    364364 
    365365msg = UserMsg(msg);
Note: See TracChangeset for help on using the changeset viewer.