void rspfScalarRemapper::allocate()
{
   destroy();

   if(!theInputConnection) // Nothing to do here.
   {
      setInitializedFlag(false);
      theByPassFlag = true;
      return;
   }
   
   if (theOutputScalarType == RSPF_SCALAR_UNKNOWN)
   {
      // default to RSPF_UINT8
      theOutputScalarType = RSPF_UINT8;
   }
   
   if(theInputConnection &&
      (getOutputScalarType() != theInputConnection->getOutputScalarType())&&
      (theInputConnection->getOutputScalarType() != RSPF_SCALAR_UNKNOWN)&&
      (getOutputScalarType() != RSPF_SCALAR_UNKNOWN))
   {
      theByPassFlag = false;
      
      theTile = rspfImageDataFactory::instance()->create(this, this);

      // Initialize the tile.
      theTile->initialize();
      
      // Set the base class flags to be initialized and enabled.
      setInitializedFlag(true);
      
   } // End of "if(theInputConnection->isConnected()..."
   else
   {
      // Set to not initialized and disabled.
      setInitializedFlag(false);
      theByPassFlag = true;
   }

   if (traceDebug())
   {
      rspfNotify(rspfNotifyLevel_DEBUG)
         << "rspfScalarRemapper::allocate() DEBUG"
         << "\ninput scalar:  " << theInputConnection->getOutputScalarType()
         << "\noutput scalar: " << getOutputScalarType()
         << "\nenabled:  " << (isSourceEnabled()?"true":"false")
         << std::endl;
   }
}
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;
   }

}