void ossimHistogramEqualization::setHistogram(ossimRefPtr<ossimMultiResLevelHistogram> histogram)
{
   ossimImageSourceHistogramFilter::setHistogram(histogram);
   computeAccumulationHistogram();
   initializeLuts();
}
ossimRefPtr<ossimImageData> ossimHistogramEqualization::getTile(
   const ossimIrect& tileRect,
   ossim_uint32 resLevel)
{
   if(!theInputConnection)
   {
      return NULL;
   }
   
   ossimRefPtr<ossimImageData> inputTile = theInputConnection->getTile(tileRect,
                                                                       resLevel);

   if(!inputTile.valid()) return inputTile;
   
   if (!isSourceEnabled())
   {
      return inputTile;
   }
   
   if(!theTile.valid())
   {
      allocate(); // First time through...
   }
   
   // if (!theTile) throw exception!
   
   // Set the origin, resize if needed of the output tile.
   theTile->setImageRectangleAndBands(inputTile->getImageRectangle(),
				      inputTile->getNumberOfBands());
   
   if( !inputTile.valid() ||
       inputTile->getDataObjectStatus() == OSSIM_NULL ||
       inputTile->getDataObjectStatus() == OSSIM_EMPTY )
   {
      return theTile;
   }

   if(!theAccumulationHistogram)
   {
      computeAccumulationHistogram();
   }
   if(theForwardLut.size() == 0 ||
      theInverseLut.size() == 0)
   {
      initializeLuts();
   }
   if((theForwardLut.size() == 0) ||
      (theInverseLut.size() == 0))
   {
      return inputTile;
   }
   
   switch(inputTile->getScalarType())
   {
      case OSSIM_UCHAR:
      {
         return runEqualizationAlgorithm(static_cast<ossim_uint8>(0),
                                         inputTile);
      }
      case OSSIM_USHORT11:
      case OSSIM_UINT16:
      {
         return runEqualizationAlgorithm(static_cast<ossim_uint16>(0),
                                         inputTile);
      }
      case OSSIM_SINT16:
      {
         return runEqualizationAlgorithm(static_cast<ossim_sint16>(0),
                                         inputTile);
      }
      case OSSIM_UINT32:
      {
         return runEqualizationAlgorithm(static_cast<ossim_uint32>(0),
                                         inputTile);
      }
      case OSSIM_SINT32:
      {
         return runEqualizationAlgorithm(static_cast<ossim_sint32>(0),
                                         inputTile);
      }
      case OSSIM_FLOAT32:
      {
         return runEqualizationAlgorithm(static_cast<ossim_float32>(0),
                                         inputTile);
      }
      case OSSIM_FLOAT64:
      {
         return runEqualizationAlgorithm(static_cast<ossim_float64>(0),
                                         inputTile);
      }
      default:
      {
         ossimNotify(ossimNotifyLevel_WARN)
            << "ossimHistogramEqualization::getTile WARNING: Unsupported scalar type."
            << endl;
         break;
      }
   }
   
   return inputTile;
}
void rspfHistogramEqualization::setHistogram(rspfRefPtr<rspfMultiResLevelHistogram> histogram)
{
   rspfImageSourceHistogramFilter::setHistogram(histogram);
   computeAccumulationHistogram();
   initializeLuts();
}