void ossimAtCorrRemapper::initialize()
{
   if(theInputConnection)
   {
      theTile = ossimImageDataFactory::instance()->create(this,
                                                          theInputConnection);
      theTile->initialize();

      if(theSurfaceReflectance)
      {
         delete []theSurfaceReflectance;
         theSurfaceReflectance = NULL;
      }
      
      ossim_uint32 tw    = theTile->getWidth();
      ossim_uint32 th    = theTile->getHeight();
      ossim_uint32 bands = theTile->getNumberOfBands();
      ossim_uint32 size  = tw*th*bands;
      if (traceDebug())
      {
         cout << "ossimAtCorrRemapper::initialize DEBUG:"
              << "\ntile width:   " << tw
              << "\ntile height:  " << th
              << "\nbands:        " << bands
              << "\nBuffer size:  " << size << endl;
      }
      
      theSurfaceReflectance = new double[size];

      setInitializedFlag(true);
      clearErrorStatus();
   }
   else
   {
      setInitializedFlag(false);
      setErrorStatus();
   };

   verifyEnabled();

   if (traceDebug())
   {
      cout << "ossimAtCorrRemapper::initialize DEBUG:"
           << *this
           << endl;
   }

}
Exemple #2
0
void ossimHistogramRemapper::setStretchMode(StretchMode mode,
                                            bool rebuildTable)
{
   if (theStretchMode != mode)
   {
      theStretchMode = mode;

      if (rebuildTable)
      {
         buildTable();

         // Check for internal bypass.
         verifyEnabled();

         // Clear the dirty flag.
         theDirtyFlag = false;
      }
      else
      {
         theDirtyFlag = true;
      }
   }
}
Exemple #3
0
ossimRefPtr<ossimImageData> ossimHistogramRemapper::getTile(
   const ossimIrect& tile_rect,
   ossim_uint32 resLevel)
{
   
#if 0 /* Please leave for serious debug. (drb) */
   cout << "\ntheEnableFlag: " << theEnableFlag
        << "\ntheBypassFlag: " << theBypassFlag
        << "\ntheDirtyFlag:  " << theDirtyFlag
        << endl;
#endif
   ossimRefPtr<ossimImageData> result = 0;

   if (theEnableFlag && theDirtyFlag) // Enabled and dirty.
   {
      // Always rebuild table if dirty.
      buildTable();
      
      // Check for internal bypass.
      verifyEnabled();

      // Always clear the dirty flag.
      theDirtyFlag = false;
   }
   
   if (!theBypassFlag) // Not bypassed...
   {
      // Base handles the rest...
      result = ossimTableRemapper::getTile(tile_rect, resLevel);
   }
   else if (theInputConnection)
   {
      // Fetch tile from pointer from the input source.
      result = theInputConnection->getTile(tile_rect, resLevel);
   }
   return result;
}
bool ossimAtCorrRemapper::loadState(const ossimKeywordlist& kwl,
                                    const char* prefix)
{
   static const char MODULE[] = "ossimAtCorrRemapper::loadState()";

   if (traceDebug())  CLOG << "entering..." << endl;

   if (!theTile || !theSurfaceReflectance)
   {
      cerr << MODULE << " ERROR:"
           << "Not initialized..." << endl;
      return false;
   }

   ossim_uint32 bands = theTile->getNumberOfBands();

   // Clear out the old values.
   theMinPixelValue.clear();
   theMaxPixelValue.clear();   
   theXaArray.clear();
   theXbArray.clear();
   theXcArray.clear();
   theBiasArray.clear();
   theGainArray.clear();
   theCalCoefArray.clear();
   theBandWidthArray.clear();
 
   
   // Now resize them.

   // Start with arbitrary big number.
   theMinPixelValue.resize(bands, 1.0);

   // Start with arbitrary small number.
   theMaxPixelValue.resize(bands, 0.0);

   
   theXaArray.resize(bands, 1.0);
   theXbArray.resize(bands, 1.0);
   theXcArray.resize(bands, 1.0);
   
   theBiasArray.resize(bands, 0.0);
   theGainArray.resize(bands, 1.0);
   theCalCoefArray.resize(bands);
   theBandWidthArray.resize(bands);
   
   for(ossim_uint32 band = 0; band < bands; ++band)
   {
      const char* lookup = NULL;
      ossimString band_string = ".band";
      band_string += ossimString::toString(band+1);
      
      ossimString kw = AT_CORR_XA_KW;
      kw += band_string;
      lookup = kwl.find(prefix, kw.c_str());
      if (lookup)
      {
         theXaArray[band] = atof(lookup);
      }
      else
      {
         if (traceDebug())
         {
            CLOG << "DEBUG:"
                 << "\nlookup failed for keyword:  " << kw.c_str() << endl;
         }
      }
      
      kw = AT_CORR_XB_KW;
      kw += band_string;
      lookup = kwl.find(prefix, kw.c_str());
      if (lookup)
      {
         theXbArray[band] = atof(lookup);
      }
      else
      {
         if (traceDebug())
         {
            CLOG << "DEBUG:"
                 << "\nlookup failed for keyword:  " << kw.c_str()
                 << endl;
         }
      }
      
      kw = AT_CORR_XC_KW;
      kw += band_string;
      lookup = kwl.find(prefix, kw.c_str());
      if (lookup)
      {
         theXcArray[band] = atof(lookup);
      }
      else
      {
         if (traceDebug())
         {
            CLOG << "DEBUG:"
                 << "\nlookup failed for keyword:  " << kw.c_str()
                 << endl;
         }
      }
      
      if(theSensorType == "ls7ms")
      {
         kw = AT_CORR_BIAS_KW;
         kw += band_string;
         lookup = kwl.find(prefix, kw.c_str());
         if (lookup)
         {
            theBiasArray[band] = atof(lookup);
         }
         else
         {
            if (traceDebug())
            {
               CLOG << "DEBUG:"
                    << "\nlookup failed for keyword:  " << kw.c_str()
                    << endl;
            }
         }
         
         kw = AT_CORR_GAIN_KW;
         kw += band_string;
         lookup = kwl.find(prefix, kw.c_str());
         if (lookup)
         {
            theGainArray[band] = atof(lookup);
         }
         else
         {
            if (traceDebug())
            {
               CLOG << "DEBUG:"
                    << "\nlookup failed for keyword:  " << kw.c_str()
                    << endl;
            }
         }
      }
      
      if(theSensorType == "qbms")
      {
         kw = AT_CORR_CALCOEF_KW;
         kw += band_string;
         lookup = kwl.find(prefix, kw.c_str());
         if (lookup)
         {
            theCalCoefArray[band] = atof(lookup);
         }
         else
         {
            if (traceDebug())
            {
               CLOG << "DEBUG:"
                    << "\nlookup failed for keyword:  " << kw.c_str()
                    << endl;
            }
         }
         
         kw = AT_CORR_BANDWIDTH_KW;
         kw += band_string;
         lookup = kwl.find(prefix, kw.c_str());
         if (lookup)
         {
            theBandWidthArray[band] = atof(lookup);
         }
         else
         {
            if (traceDebug())
            {
               CLOG << "DEBUG:"
                    << "\nlookup failed for keyword:  " << kw.c_str()
                    << endl;
            }
         }
      }
      if(theSensorType == "ikms")
      {
         kw = AT_CORR_CALCOEF_KW;
         kw += band_string;
         lookup = kwl.find(prefix, kw.c_str());
         if (lookup)
         {
            theCalCoefArray[band] = atof(lookup);
         }
         else
         {
            if (traceDebug())
            {
               CLOG << "DEBUG:"
                    << "\nlookup failed for keyword:  " << kw.c_str()
                    << endl;
            }
         }
         
         kw = AT_CORR_BANDWIDTH_KW;
         kw += band_string;
         lookup = kwl.find(prefix, kw.c_str());
         if (lookup)
         {
            theBandWidthArray[band] = atof(lookup);
         }
         else
         {
            if (traceDebug())
            {
               CLOG << "DEBUG:"
                    << "\nlookup failed for keyword:  " << kw.c_str()
                    << endl;
            }
         }
      }
   }
   
   verifyEnabled();

   if (theEnableFlag)
   {
      //***
      // Call the base class to pick up the enable flag.  Note that this
      // can override the state set from verifyEnabled() method.
      //***
      ossimString pref;
      if (prefix) pref += prefix;
      pref += "atmospheric_correction.";

   }
   
   if (traceDebug())
   {
      CLOG << "DEBUG:"
           << *this
           << "returning..."
           << endl;
   }
   
   return true;
}