Changeset 3292 in Sophya


Ignore:
Timestamp:
Aug 16, 2007, 6:21:26 PM (18 years ago)
Author:
ansari
Message:

Introduction de nouveaux algorithmes de calcul d'auto-lut pour affichage d'image - Reza 16/08/2007

Location:
trunk/SophyaPI/PI
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/lut.h

    r1503 r3292  
    1212// et de 1 a nLevel pour min<=x<max
    1313
    14 // Type de lut possibles (Seul Lineaire implemente 05/95
     14// Type de lut possibles
    1515enum {kLutType_Lin=1, kLutType_Log=2, kLutType_Sqrt=3, kLutType_Square=4};
    1616
  • trunk/SophyaPI/PI/parradapter.cc

    r3152 r3292  
    250250
    251251/* --Methode-- */
    252 void P2DArrayAdapter::ComputeLut_PicHisto(double& min, double& max, int nbsig, double fracmax)
     252void P2DArrayAdapter::ComputeLut_PicHisto(double& min, double& max, bool htail,
     253                                          double nbsig, double fracmax)
     254// htail = true --> on vire le pic et on garde la queue de l'histo
     255// htail = false --> on garde le pic le l'histo
    253256{
    254257// TIMEF ;
     
    258261int nbin = sX*sY/10;
    259262nbin = (nbin < MINNBIN) ? MINNBIN : ((nbin > MAXNBIN) ? MAXNBIN : nbin );
    260 int vitesse = sX*sY / 20000;
     263int vitesse = sX*sY / 50000;
    261264vitesse = (vitesse < 1) ? 1 : ((vitesse > 25) ? 25 : vitesse );
    262265
     
    331334q = phis+binmax;
    332335while ( ((*q) > hmin) && (sigr < (nbin-binmax)) )  { sigr++;  q++; }
     336if (sigr < 1) sigr = 1.;
    333337int sigl = 0;
    334338q = phis+binmax;
    335339while ( ((*q) > hmin) && (sigl < binmax) )  { sigl++; q--; }
    336 
    337 
    338 if (nbsig == 0) nbsig = 1;
    339 if (nbsig < 0)  {  /*   On considere le cas ou NbSigmas est negatif   */
    340   if ( (bin = binmax+nbsig*sigl) < 0 )  bin = 0;
     340if (sigl < 1) sigl = 1.;
     341
     342if (nbsig <= 0.) nbsig = 1.;
     343if (htail == false)  {  /*   On recherche le min/max autour du pic de l'histo  */
     344  if ( (bin = binmax-(nbsig*sigl)) < 0 )  bin = 0;
    341345  min = minhis + (double)bin*binwidth;
    342   if ( (bin = binmax-nbsig*sigr) >= nbin ) bin = nbin-1;
     346  if ( (bin = binmax+(nbsig*sigr)) >= nbin ) bin = nbin-1;
    343347  max = minhis + (double)bin*binwidth;
    344348  if (max < (min+MINDYNAMIC))  max = min+MINDYNAMIC;
     
    346350  }
    347351
    348 // NbSigma positif
    349 if ( (bin = binmax+nbsig*sigl) >= nbin ) {
     352//  On recherche le min/max en supprimant le pic de l'histo  (la queue, > pic)
     353if ( (bin = binmax+(nbsig*sigl)) >= nbin ) {
    350354  min = minhis + binmax*binwidth;
    351355  max = maxhis;
  • trunk/SophyaPI/PI/parradapter.h

    r3152 r3292  
    8383  virtual int     CheckDyn(double& min, double& max, double& moy, double& sig, int& nbnul, int& nbsat, int vit=10);
    8484//    Calcul AutoLut
    85   virtual void    ComputeLut_PicHisto(double& min, double& max, int nbsig=1, double fracmax=0.95);
     85  virtual void    ComputeLut_PicHisto(double& min, double& max, bool htail,
     86                                      double nbsig=1., double fracmax=0.95);
    8687
    8788//    Calcul pixmap avec un LUT
  • trunk/SophyaPI/PI/piimage.cc

    r3152 r3292  
    5555//      * <Alt>+ <Cntl>+ : Augmentation du facteur de zoom
    5656//      * <Alt>- <Cntl>- : Diminution du facteur de zoom
    57 //      * Touches Curseurs : déplace la pavé.
     57//      * Touches Curseurs : déplace le pavé.
    5858//--
    5959//++
     
    148148AddDrawer(mdrw, true, false, false, false);
    149149
    150 SetLut(-9.e19, 9.e19, kLutType_Lin, 0, false);
     150SetLut(AutoLut_No, -9.e19, 9.e19, kLutType_Lin, 0, false);
    151151SetColMapId(CMAP_COLRJ32);
    152152// pour le copier-coller
     
    262262if (img)  {
    263263//  SetSize(img->XSize(), img->YSize());
     264// Reza, Aout 2007 : SetLut par defaut passe a AutoLut MeanSigma a 2 sigmas
     265// a l'occasion des corrections et nouveaux types de calculs d'autolut
    264266  CenterPave();
    265   double min=1., max=-1., moy, sig;
    266   int nbnul, nbsat;
    267   img->CheckDyn(min, max, moy, sig, nbnul, nbsat);
    268   SetLut(min, max, kLutType_Lin, 1, refr);
     267  double min=1., max=-1.;
     268  SetLut(AutoLut_MeanSigma, min, max, kLutType_Lin, 2., refr);
    269269  aisup = ad;
    270270  }
     
    415415
    416416//++
    417 // SetLut(double min, double max, int typlut=kLutType_Lin, \
    418 //        int lauto=0, bool refr=true)
     417// SetLut(AutoLutType alt, double min, double max, int typlut=kLutType_Lin, \
     418//        double nsa=1., bool refr=true)
    419419//      Definit la LUT pour l'affichage
    420420//      Si "refr=="true", la fenetre est rafraichie
     
    437437
    438438/* --Methode-- */
    439 void PIImage::SetLut(double min, double max, int typlut, int lauto, bool refr)
    440 {
     439void PIImage::SetLut(AutoLutType alt, double min, double max, int typlut, double nsa, bool refr)
     440{
     441t_al = alt;
     442if (alt != AutoLut_No) {
     443  min_al = min; max_al = max; ns_al = nsa;
     444}
    441445if (lut) delete(lut);
    442 if (lauto && img)
    443   {
    444   int nbsig = lauto; 
    445   double fracmax = 1. - 0.05*nbsig;
    446   int nbnul, nbsat;
    447   double moy, sig;
    448   img->CheckDyn(min, max, moy, sig, nbnul, nbsat);
    449   img->ComputeLut_PicHisto(min, max, nbsig, fracmax);
    450   }
    451 
     446int nbnul, nbsat;
     447double moy, sig, fracmax;
     448double dmx, smin, smax;
     449bool fgtail;
     450
     451switch (alt)
     452{
     453 case AutoLut_No :
     454   if (min >= max)  img->CheckDyn(min, max, moy, sig, nbnul, nbsat);
     455   break;
     456 case AutoLut_MinMax :
     457   min = 1.; max = -1.; 
     458   img->CheckDyn(min, max, moy, sig, nbnul, nbsat);
     459   if (max <= min) max = min+0.1*fabs(min);
     460   if ((nsa <= 0.)||(nsa > 1.))  nsa = 1.;
     461   dmx = (nsa-1.)*(max-min);
     462   min = min+dmx;  max = max-dmx;
     463   break;
     464 case AutoLut_MeanSigma :
     465   img->CheckDyn(min, max, moy, sig, nbnul, nbsat);
     466   smin = min, smax = max;
     467   min = moy - nsa*sig;   max = moy + nsa*sig;
     468   if (min < smin) min = smin;
     469   if (max > smax) max = smax;
     470   break;
     471 case AutoLut_HistoPeak :
     472 case AutoLut_HistoTail :
     473   fracmax = 1.-0.05*nsa;
     474   if (min >= max)  img->CheckDyn(min, max, moy, sig, nbnul, nbsat);
     475   fgtail = (alt == AutoLut_HistoTail) ? true : false;
     476   img->ComputeLut_PicHisto(min, max, fgtail, nsa, fracmax);
     477   break;
     478}
     479
     480if (max <= min) max = min + 0.1*fabs(min);
    452481lut = new LUT(min, max, NbCol(), typlut);
    453482
     
    461490void PIImage::SetLut(LUT *clut, bool refr)
    462491{
     492t_al = AutoLut_No;
    463493LUT * olut = lut;
    464494lut = new LUT(clut->Min(), clut->Max(), NbCol(), clut->Type());
     
    593623      continue;
    594624    }
    595     // lut lineaire
     625    // Changementr de lut - avec specification type de lut [et min/max]
    596626    if (opts.substr(0,4) == "lut=") {
    597627      double min = Lut()->Min();
     
    605635      else if (opts.substr(4,4) == "sqrt")  typlut=kLutType_Sqrt;
    606636      else if (opts.substr(4,6) == "square")  typlut=kLutType_Square;
    607       SetLut(min, max, typlut, 0, false);
     637      SetLut(AutoLut_No, min, max, typlut, 0, false);
     638      continue;
     639    }
     640    // Auto lut avec specification type auto-lut [et nb-sigmas] (Aout2007)
     641    if (opts.substr(0,8) == "autolut=") {
     642      double min = min_al;
     643      double max = max_al;
     644      int ctlut = Lut()->Type();
     645      double pnsal = ns_al;
     646      size_t q = opts.find(',');
     647      if (q < opts.length()-1) {
     648        string suop = opts.substr(q+1);
     649        size_t q2 = suop.find(',');
     650        if (q2 < suop.length()-1)
     651          sscanf(suop.c_str(),"%lg,%lg,%lg",&pnsal,&min, &max);
     652        else pnsal = atof( suop.c_str() );
     653      }
     654      AutoLutType palt = AutoLut_No;     
     655      if (opts.substr(8,6) == "minmax")  palt = AutoLut_MinMax;
     656      else if (opts.substr(8,7) == "meansig")  palt = AutoLut_MeanSigma;
     657      else if (opts.substr(8,7) == "hispeak")  palt = AutoLut_HistoPeak;
     658      else if (opts.substr(8,9) == "hispeak")  palt = AutoLut_HistoPeak;
     659      else if (opts.substr(8,6) == "hispic")   palt = AutoLut_HistoPeak;
     660      else if (opts.substr(8,7) == "histail")  palt = AutoLut_HistoTail;
     661      if ( palt != AutoLut_No )  SetLut(palt, min_al, max_al, ctlut, pnsal, false);
    608662      continue;
    609663    }
     
    627681  if ( ( optsz1-ndec > 0) && (img) ) {
    628682    ndec2 = img->DecodeOptionString(opt, rmdecopt);
     683    // On recalcule la LUT si on est en auto-lut, le contenu de l'image peut avoir change (Aout2007)
     684    if ((ndec2 > 0) && (t_al != AutoLut_No)) 
     685      SetLut(t_al, min_al, max_al, Lut()->Type(), ns_al, false);
    629686  }
    630687  return(ndec+ndec2);
  • trunk/SophyaPI/PI/piimage.h

    r2652 r3292  
    2020class PIDrwMgrMenu;
    2121
     22enum AutoLutType { AutoLut_No=0, AutoLut_MinMax=1, AutoLut_MeanSigma=2,
     23                   AutoLut_HistoPeak=3, AutoLut_HistoTail=4};
     24
    2225class PIImage : public PIPixmap
    2326{
    24 
    2527public:
    2628  enum {ClassId = 5150};
     
    5355
    5456//  Gestion du choix de LUT, facteur d agrandissement, table de couleur
    55   void SetLut(double min, double max, int typlut=kLutType_Lin,
    56               int lauto=0, bool refr=true);
     57  void SetLut(AutoLutType alt, double min, double max, int typlut=kLutType_Lin,
     58              double nsa=1., bool refr=true);
    5759  void SetLut(LUT *clut, bool refr=true);
    5860
     
    155157  int xspxm, yspxm;
    156158  LUT * lut;
     159  AutoLutType t_al;   // Si AutoLut et le type lors du dernier appel a SetLut()
     160  double min_al, max_al, ns_al; // Parametres nsa, min et max lors  du dernier appel a SetLut()
    157161  int offx, offy;
    158162  PIElDrawer* mdrw;
  • trunk/SophyaPI/PI/piimgtools.cc

    r2615 r3292  
    111111cpx += spx+bsx;
    112112mOpt[1] = new PIOptMenu(this, "imglut-opt-2", 1.5*bsx, bsy, cpx, cpy);
    113 mOpt[1]->AppendItem("+3 Sig", 1203);
    114 mOpt[1]->AppendItem("+2 Sig", 1202);
    115 mOpt[1]->AppendItem("+1 Sig", 1201);
     113mOpt[1]->AppendItem("MeanMax", 1206);
     114mOpt[1]->AppendItem("MeanMax90%", 1205);
     115mOpt[1]->AppendItem("MeanMax70%", 1204);
     116mOpt[1]->AppendItem("MeanSig 3", 1203);
     117mOpt[1]->AppendItem("MeanSig 2", 1202);
     118mOpt[1]->AppendItem("MeanSig 1", 1201);
    116119mOpt[1]->AppendItem("NoAuto", 1200);
    117 mOpt[1]->AppendItem("-1 Sig", 1199);
    118 mOpt[1]->AppendItem("-2 Sig", 1198);
    119 mOpt[1]->AppendItem("-3 Sig", 1197);
    120 mOpt[1]->SetValue(1202);
     120mOpt[1]->AppendItem("HistoTail+1s", 1207);
     121mOpt[1]->AppendItem("HistoTail+2s", 1208);
     122mOpt[1]->AppendItem("HistoPeak+1s", 1209);
     123mOpt[1]->AppendItem("HistoPeak+2s", 1210);
     124mOpt[1]->SetValue(1200);
    121125mOpt[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
    122126
     
    349353int lauto, typ;
    350354int typlut[4] = {kLutType_Lin, kLutType_Log, kLutType_Sqrt, kLutType_Square} ;
    351 
     355AutoLutType alts[11] = { AutoLut_No,
     356                         AutoLut_MeanSigma, AutoLut_MeanSigma, AutoLut_MeanSigma,
     357                         AutoLut_MinMax, AutoLut_MinMax, AutoLut_MinMax,
     358                         AutoLut_HistoTail, AutoLut_HistoTail,
     359                         AutoLut_HistoPeak, AutoLut_HistoPeak } ;
     360double nsas[11] = {0., 1., 2., 3., 0.70, 0.9, 1., 2., 1., 2.};
     361 
    352362msg = UserMsg(msg);
    353363
     
    388398    }
    389399    else lauto = mOpt[1]->GetValue() - 1200;
     400    if ((lauto < 0) || (lauto > 10))  lauto = 10;
    390401    typ = mOpt[0]->GetValue() - 1100;
    391402    if ( (typ < 0) || (typ > 3) )  typ = 0;
    392     (PIImage::CurrentPIImage())->SetLut(min, max, typlut[typ], lauto);
     403    (PIImage::CurrentPIImage())->SetLut(alts[lauto], min, max, typlut[typ], nsas[lauto]);
    393404    if (msg == 2500) {
    394405      min_lut = min;   max_lut = max;
  • trunk/SophyaPI/PI/piversion.h

    r3278 r3292  
    22#define PIVERSION_H_SEEN
    33
    4 #define PI_VERSIONNUMBER  4.02
     4#define PI_VERSIONNUMBER  4.05
    55
    66#endif
Note: See TracChangeset for help on using the changeset viewer.