Changeset 3527 in Sophya for trunk/SophyaPI


Ignore:
Timestamp:
Oct 12, 2008, 6:57:14 PM (17 years ago)
Author:
ansari
Message:

Suite codage+debug RGB-Colormaps et affichage d'image en couleurs RGB, Reza 12/10/2008

Location:
trunk/SophyaPI/PI
Files:
6 edited

Legend:

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

    r3519 r3527  
    2323if (bornes == NULL)  return;
    2424type = typ;  nLevel = nlev;
     25int qqq = 1;
     26quantum = 1;
     27for(quantum=2; quantum<=42; quantum++) {
     28  qqq = quantum*quantum*quantum;
     29  if (qqq > NCol())  break;
     30}
     31quantum--;
     32
    2533table = NULL; 
    2634tablenbin = 0;
     
    4755bornes = new double[nlev+1];
    4856nLevel = nlev;
     57int qqq = 1;
     58quantum = 1;
     59for(quantum=2; quantum<=42; quantum++) {
     60  qqq = quantum*quantum*quantum;
     61  if (qqq > NCol())  break;
     62}
     63quantum--;
     64// printf("*DBG*LUT* quantum= %d \n", (int)quantum);
    4965SetLut(min, max, Type());
    5066}
     
    5975type = typ;
    6076if (max <= min)  max = min+1.;
     77mMin = min;  mMax = max;
     78mMinI = (int)(min+0.1);  mMaxI = (int)(max+0.1);
    6179if (nLevel > 0)
    6280  {
     
    125143{
    126144  long lv = x+0.3;
    127   double r = (lv%256);
     145  int r = (lv%256);
    128146  lv /= 256;
    129   double g = (lv%256);
     147  int g = (lv%256);
    130148  lv /= 256;
    131   double b = (lv%256);
    132   int qqq = 1;
    133   int quantum = 1;
    134   for(quantum=2; quantum<=42; quantum++) {
    135         qqq = quantum*quantum*quantum;
    136         if (qqq > NCol())  break;
    137   }
    138   quantum--;
    139   int ir = AppFast(r)*quantum/(NCol());
    140   int ig = AppFast(g)*quantum/(NCol());
    141   int ib = AppFast(b)*quantum/(NCol());
    142   return ((unsigned short)((ib*quantum+ig)*quantum+ir));
     149  int b = (lv%256);
     150  return (unsigned short)((Contraste(b)*quantum+Contraste(g))*quantum+Contraste(r));
    143151}
    144152
  • trunk/SophyaPI/PI/lut.h

    r3519 r3527  
    4949    return(table[k]);
    5050    }
    51          
     51  inline int  Contraste(int ii)   /* for ApplyRGB */
     52    {
     53    if (ii >= mMaxI) return quantum-1;
     54    if (ii <= mMinI) return 0;
     55    else return ((ii-mMinI)*(quantum-1)/mMaxI);
     56    }     
    5257  int type;
    5358  int nLevel;
     59  int quantum;
    5460  double * bornes;
     61  double mMin, mMax;
     62  int mMinI, mMaxI;
    5563  int tablenbin;
    5664  unsigned short * table;
  • trunk/SophyaPI/PI/parradapter.cc

    r3519 r3527  
    562562  if (zm == 1)  {  // Pas de zoom 
    563563    for(j=ofy; j<ofy+npy; j++)
    564       for(i=ofx; i<ofx+npx; i++)
    565         { *pp = (unsigned char) lut->ApplyFast(
    566                 this->Value(j*sgnX+offX, i*sgnY+offY)); 
    567            pp++; }
     564      for(i=ofx; i<ofx+npx; i++) {
     565        *pp = lut->ApplyFast(this->Value(j*sgnX+offX, i*sgnY+offY));  pp++;
     566      }
    568567    }
    569568  else if (zm < -1) {       // Compression
     
    578577    for(j=ofy; j<ofy+npy; j++)
    579578      for(i=ofx; i<ofx+npx; i++)  {
    580         ucp = (unsigned char) lut->ApplyFast(this->Value(j*sgnX+offX, i*sgnY+offY));
     579        ucp = lut->ApplyFast(this->Value(j*sgnX+offX, i*sgnY+offY));
    581580        for(l=0; l<zm; l++)  {
    582581          pp = pixc.ShortPointer()+((j-ofy)*zm+l)*nppx+((i-ofx)*zm);
     
    589588  if (zm == 1)  {  // Pas de zoom 
    590589    for(j=ofy; j<ofy+npy; j++)
    591       for(i=ofx; i<ofx+npx; i++)
    592         { *pp = (unsigned char) lut->ApplyFast(
    593                 this->Value(i*sgnX+offX, j*sgnY+offY)); 
    594            pp++; }
     590      for(i=ofx; i<ofx+npx; i++) {
     591        *pp = lut->ApplyFast(this->Value(i*sgnX+offX, j*sgnY+offY));  pp++;
     592      }
    595593    }
    596594  else if (zm < -1) {       // Compression
     
    605603    for(j=ofy; j<ofy+npy; j++)
    606604      for(i=ofx; i<ofx+npx; i++)  {
    607         ucp = (unsigned char) lut->ApplyFast(this->Value(i*sgnX+offX, j*sgnY+offY));
     605        ucp = lut->ApplyFast(this->Value(i*sgnX+offX, j*sgnY+offY));
    608606        for(l=0; l<zm; l++)  {
    609607          pp = pixc.ShortPointer()+((j-ofy)*zm+l)*nppx+((i-ofx)*zm);
  • trunk/SophyaPI/PI/picmap.cc

    r3519 r3527  
    597597      int drgb = 65535/(nlev-1);
    598598      i = 0;
    599       for(int kb=0; kb<8; kb++) {
     599      for(int kb=0; kb<nlev; kb++) {
    600600        mycol.blue = (unsigned short)(kb*drgb);
    601         for(int jg=0; jg<8; jg++) {
     601        for(int jg=0; jg<nlev; jg++) {
    602602          mycol.green = (unsigned short)(jg*drgb);
    603           for(int ir=0; ir<8; ir++) {
     603          for(int ir=0; ir<nlev; ir++) {
    604604            mycol.red = (unsigned short)(ir*drgb);
    605605            AllocColor(mycol, i);   i++;
  • trunk/SophyaPI/PI/piimage.cc

    r3519 r3527  
    625625      double min = Lut()->Min();
    626626      double max = Lut()->Max();
    627       size_t q = opts.find(',');
    628       if (q < opts.length()-1)
    629         sscanf(opts.substr(q+1).c_str(),"%lg,%lg",&min, &max);
    630627      int typlut=kLutType_Lin;      ;
    631628      if (opts.substr(4,3) == "lin")  typlut=kLutType_Lin;
     
    633630      else if (opts.substr(4,4) == "sqrt")  typlut=kLutType_Sqrt;
    634631      else if (opts.substr(4,6) == "square")  typlut=kLutType_Square;
    635       else if (opts.substr(4,6) == "rgb")  typlut=kLutType_RGB;
     632      else if (opts.substr(4,3) == "rgb")  {
     633        typlut=kLutType_RGB;
     634        min = 0;  max = 255;
     635      }
     636      size_t q = opts.find(',');
     637      if (q < opts.length()-1)
     638        sscanf(opts.substr(q+1).c_str(),"%lg,%lg",&min, &max);
     639
    636640      SetLut(AutoLut_No, min, max, typlut, 0, false);
    637641      continue;
  • trunk/SophyaPI/PI/piimgtools.cc

    r3519 r3527  
    448448    if ((lauto < 0) || (lauto > 12))  lauto = 12;
    449449    typ = mOpt[0]->GetValue() - 1100;
    450     if ( (typ < 0) || (typ > 3) )  typ = 0;
     450    if ( (typ < 0) || (typ > 4) )  typ = 0;
    451451    (PIImage::CurrentPIImage())->SetLut(alts[lauto], min, max, typlut[typ], nsas[lauto]);
    452452    if (msg == 2500) {
Note: See TracChangeset for help on using the changeset viewer.