Changeset 3292 in Sophya for trunk/SophyaPI
- Timestamp:
- Aug 16, 2007, 6:21:26 PM (18 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/lut.h
r1503 r3292 12 12 // et de 1 a nLevel pour min<=x<max 13 13 14 // Type de lut possibles (Seul Lineaire implemente 05/9514 // Type de lut possibles 15 15 enum {kLutType_Lin=1, kLutType_Log=2, kLutType_Sqrt=3, kLutType_Square=4}; 16 16 -
trunk/SophyaPI/PI/parradapter.cc
r3152 r3292 250 250 251 251 /* --Methode-- */ 252 void P2DArrayAdapter::ComputeLut_PicHisto(double& min, double& max, int nbsig, double fracmax) 252 void 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 253 256 { 254 257 // TIMEF ; … … 258 261 int nbin = sX*sY/10; 259 262 nbin = (nbin < MINNBIN) ? MINNBIN : ((nbin > MAXNBIN) ? MAXNBIN : nbin ); 260 int vitesse = sX*sY / 20000;263 int vitesse = sX*sY / 50000; 261 264 vitesse = (vitesse < 1) ? 1 : ((vitesse > 25) ? 25 : vitesse ); 262 265 … … 331 334 q = phis+binmax; 332 335 while ( ((*q) > hmin) && (sigr < (nbin-binmax)) ) { sigr++; q++; } 336 if (sigr < 1) sigr = 1.; 333 337 int sigl = 0; 334 338 q = phis+binmax; 335 339 while ( ((*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;340 if (sigl < 1) sigl = 1.; 341 342 if (nbsig <= 0.) nbsig = 1.; 343 if (htail == false) { /* On recherche le min/max autour du pic de l'histo */ 344 if ( (bin = binmax-(nbsig*sigl)) < 0 ) bin = 0; 341 345 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; 343 347 max = minhis + (double)bin*binwidth; 344 348 if (max < (min+MINDYNAMIC)) max = min+MINDYNAMIC; … … 346 350 } 347 351 348 // NbSigma positif349 if ( (bin = binmax+ nbsig*sigl) >= nbin ) {352 // On recherche le min/max en supprimant le pic de l'histo (la queue, > pic) 353 if ( (bin = binmax+(nbsig*sigl)) >= nbin ) { 350 354 min = minhis + binmax*binwidth; 351 355 max = maxhis; -
trunk/SophyaPI/PI/parradapter.h
r3152 r3292 83 83 virtual int CheckDyn(double& min, double& max, double& moy, double& sig, int& nbnul, int& nbsat, int vit=10); 84 84 // 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); 86 87 87 88 // Calcul pixmap avec un LUT -
trunk/SophyaPI/PI/piimage.cc
r3152 r3292 55 55 // * <Alt>+ <Cntl>+ : Augmentation du facteur de zoom 56 56 // * <Alt>- <Cntl>- : Diminution du facteur de zoom 57 // * Touches Curseurs : déplace l apavé.57 // * Touches Curseurs : déplace le pavé. 58 58 //-- 59 59 //++ … … 148 148 AddDrawer(mdrw, true, false, false, false); 149 149 150 SetLut( -9.e19, 9.e19, kLutType_Lin, 0, false);150 SetLut(AutoLut_No, -9.e19, 9.e19, kLutType_Lin, 0, false); 151 151 SetColMapId(CMAP_COLRJ32); 152 152 // pour le copier-coller … … 262 262 if (img) { 263 263 // 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 264 266 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); 269 269 aisup = ad; 270 270 } … … 415 415 416 416 //++ 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) 419 419 // Definit la LUT pour l'affichage 420 420 // Si "refr=="true", la fenetre est rafraichie … … 437 437 438 438 /* --Methode-- */ 439 void PIImage::SetLut(double min, double max, int typlut, int lauto, bool refr) 440 { 439 void PIImage::SetLut(AutoLutType alt, double min, double max, int typlut, double nsa, bool refr) 440 { 441 t_al = alt; 442 if (alt != AutoLut_No) { 443 min_al = min; max_al = max; ns_al = nsa; 444 } 441 445 if (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 446 int nbnul, nbsat; 447 double moy, sig, fracmax; 448 double dmx, smin, smax; 449 bool fgtail; 450 451 switch (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 480 if (max <= min) max = min + 0.1*fabs(min); 452 481 lut = new LUT(min, max, NbCol(), typlut); 453 482 … … 461 490 void PIImage::SetLut(LUT *clut, bool refr) 462 491 { 492 t_al = AutoLut_No; 463 493 LUT * olut = lut; 464 494 lut = new LUT(clut->Min(), clut->Max(), NbCol(), clut->Type()); … … 593 623 continue; 594 624 } 595 // lut lineaire625 // Changementr de lut - avec specification type de lut [et min/max] 596 626 if (opts.substr(0,4) == "lut=") { 597 627 double min = Lut()->Min(); … … 605 635 else if (opts.substr(4,4) == "sqrt") typlut=kLutType_Sqrt; 606 636 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); 608 662 continue; 609 663 } … … 627 681 if ( ( optsz1-ndec > 0) && (img) ) { 628 682 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); 629 686 } 630 687 return(ndec+ndec2); -
trunk/SophyaPI/PI/piimage.h
r2652 r3292 20 20 class PIDrwMgrMenu; 21 21 22 enum AutoLutType { AutoLut_No=0, AutoLut_MinMax=1, AutoLut_MeanSigma=2, 23 AutoLut_HistoPeak=3, AutoLut_HistoTail=4}; 24 22 25 class PIImage : public PIPixmap 23 26 { 24 25 27 public: 26 28 enum {ClassId = 5150}; … … 53 55 54 56 // 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); 57 59 void SetLut(LUT *clut, bool refr=true); 58 60 … … 155 157 int xspxm, yspxm; 156 158 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() 157 161 int offx, offy; 158 162 PIElDrawer* mdrw; -
trunk/SophyaPI/PI/piimgtools.cc
r2615 r3292 111 111 cpx += spx+bsx; 112 112 mOpt[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); 113 mOpt[1]->AppendItem("MeanMax", 1206); 114 mOpt[1]->AppendItem("MeanMax90%", 1205); 115 mOpt[1]->AppendItem("MeanMax70%", 1204); 116 mOpt[1]->AppendItem("MeanSig 3", 1203); 117 mOpt[1]->AppendItem("MeanSig 2", 1202); 118 mOpt[1]->AppendItem("MeanSig 1", 1201); 116 119 mOpt[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); 120 mOpt[1]->AppendItem("HistoTail+1s", 1207); 121 mOpt[1]->AppendItem("HistoTail+2s", 1208); 122 mOpt[1]->AppendItem("HistoPeak+1s", 1209); 123 mOpt[1]->AppendItem("HistoPeak+2s", 1210); 124 mOpt[1]->SetValue(1200); 121 125 mOpt[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 122 126 … … 349 353 int lauto, typ; 350 354 int typlut[4] = {kLutType_Lin, kLutType_Log, kLutType_Sqrt, kLutType_Square} ; 351 355 AutoLutType 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 } ; 360 double nsas[11] = {0., 1., 2., 3., 0.70, 0.9, 1., 2., 1., 2.}; 361 352 362 msg = UserMsg(msg); 353 363 … … 388 398 } 389 399 else lauto = mOpt[1]->GetValue() - 1200; 400 if ((lauto < 0) || (lauto > 10)) lauto = 10; 390 401 typ = mOpt[0]->GetValue() - 1100; 391 402 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]); 393 404 if (msg == 2500) { 394 405 min_lut = min; max_lut = max; -
trunk/SophyaPI/PI/piversion.h
r3278 r3292 2 2 #define PIVERSION_H_SEEN 3 3 4 #define PI_VERSIONNUMBER 4.0 24 #define PI_VERSIONNUMBER 4.05 5 5 6 6 #endif
Note:
See TracChangeset
for help on using the changeset viewer.