void ossimTiledElevationDatabase::getBoundingRect(
   ossimRefPtr<ossimImageGeometry> geom, ossimGrect& boundingRect) const
{
   if ( geom.valid() )
   {
      std::vector<ossimGpt> corner(4);
      if ( geom->getCornerGpts(corner[0], corner[1], corner[2], corner[3]) )
      {
         ossimGpt ulGpt(corner[0]);
         ossimGpt lrGpt(corner[0]);
         for ( ossim_uint32 i = 1; i < 4; ++i )
         {
            if ( corner[i].lon < ulGpt.lon ) ulGpt.lon = corner[i].lon;
            if ( corner[i].lat > ulGpt.lat ) ulGpt.lat = corner[i].lat;
            if ( corner[i].lon > lrGpt.lon ) lrGpt.lon = corner[i].lon;
            if ( corner[i].lat < lrGpt.lat ) lrGpt.lat = corner[i].lat;
         }
         boundingRect = ossimGrect(ulGpt, lrGpt);
      }
      else
      {
         boundingRect.makeNan();
      }
   }
}
Exemplo n.º 2
0
//*****************************************************************************
//  METHOD: ossimHsvGridRemapEngine::computeSourceValue
//  
//*****************************************************************************
void ossimHsvGridRemapEngine::computeSourceValue(
   ossimRefPtr<ossimImageData>& source, void* result)
{
   static const char MODULE[]="ossimHsvGridRemapEngine::computeSourceValue";
   if (traceExec())  CLOG << "entering..." << endl;

   //***
   // This engine defines "value" as the HSV vector corresponding to the mean
   // RGB pixel value of the source data:
   //***
   ossimRgbVector rgb_vector;
   rgb_vector.setR((unsigned char) source->computeAverageBandValue(0));
   rgb_vector.setG((unsigned char) source->computeAverageBandValue(1));
   rgb_vector.setB((unsigned char) source->computeAverageBandValue(2));

   //***
   // Assign the HSV components to the result vector:
   //***
   ossimHsvVector hsv_vector (rgb_vector);
   ((double*)result)[0] = (double) hsv_vector.getH();
   ((double*)result)[1] = (double) hsv_vector.getS();
   ((double*)result)[2] = (double) hsv_vector.getV();
   
   if (traceExec())  CLOG << "returning..." << endl;
   return;
}
Exemplo n.º 3
0
void ossimBandSelector::setProperty(ossimRefPtr<ossimProperty> property)
{
   if(!property) return;

   if(property->getName() == "bandSelection")
   {
     ossimString str = property->valueToString();
     std::vector<ossimString> str_vec;
     std::vector<ossim_uint32> int_vec;
     
     str.split( str_vec, " " );
     
     for ( ossim_uint32 i = 0; i < str_vec.size(); ++i )
     {
        if(!str_vec[i].empty())
        {
           int_vec.push_back( str_vec[i].toUInt32() );
        }
     }
     setOutputBandList( int_vec );
   }
   else
   {
      ossimImageSourceFilter::setProperty(property);
   }
}
Exemplo n.º 4
0
void ossimImageUtil::createHistogram(ossimRefPtr<ossimImageHandler>& ih)
{
   static const char M[] = "ossimImageUtil::createHistogram #1";
   if(traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\n";
   }
   
   if ( ih.valid() )
   {
      // Get the entry list:
      std::vector<ossim_uint32> entryList;
      ih->getEntryList(entryList);
      
      bool useEntryIndex = false;
      if ( entryList.size() )
      {
         if ( (entryList.size() > 1) || (entryList[0] != 0) ) useEntryIndex = true;
      }

      for(ossim_uint32 idx = 0; idx < entryList.size(); ++idx)
      {
         createHistogram(ih, entryList[idx], useEntryIndex);
      }
   }

   if(traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG) << M << " exited...\n";
   }
}
void ossimImageToPlaneNormalFilter::setProperty(ossimRefPtr<ossimProperty> property)
{
   ossimString name = property->getName();
   if(name == "smoothnessFactor")
   {
      theSmoothnessFactor = property->valueToString().toDouble();
      initialize();
   }
   else if(name == "xscale")
   {
      theXScale = property->valueToString().toDouble();
      initialize();
   }
   else if(name == "yscale")
   {
      theYScale = property->valueToString().toDouble();
      initialize();
   }
   else if(name == "autoTrackScaleFlag")
   {
      theTrackScaleFlag = property->valueToString().toDouble();
      initialize();
   }
   else
   {
      ossimImageSourceFilter::setProperty(property);
   }
}
Exemplo n.º 6
0
void ossimLasReader::setProperty(ossimRefPtr<ossimProperty> property)
{
   if ( property.valid() )
   {
      if ( property->getName() == SCALE_KW )
      {
         ossimString s;
         property->valueToString(s);
         ossim_float64 d = s.toFloat64();
         if ( ossim::isnan(d) == false )
         {
            setScale( d );
         }
      }
      else if ( property->getName() == SCAN_KW )
      {
         ossimString s;
         property->valueToString(s);
         m_scan = s.toBool();
      }
      else
      {
         ossimImageHandler::setProperty(property);
      }
   }
}
Exemplo n.º 7
0
// Create overview for image:
void ossimImageUtil::createOverview(ossimRefPtr<ossimImageHandler>& ih,
                                    bool& consumedHistogramOptions,
                                    bool& /* consumedCmmOptions */)
{
   static const char M[] = "ossimImageUtil::createOverview #1";
   if(traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\n";
   }
    
   if ( ih.valid() )
   {
      // Get the entry list:
      std::vector<ossim_uint32> entryList;
      ih->getEntryList(entryList);
      
      bool useEntryIndex = false;
      if ( entryList.size() )
      {
         if ( (entryList.size() > 1) || (entryList[0] != 0) ) useEntryIndex = true;
      }

      // Create the overview builder:
      ossimString overviewType;
      getOverviewType( overviewType.string() );
      ossimRefPtr<ossimOverviewBuilderBase> ob =
         ossimOverviewBuilderFactoryRegistry::instance()->createBuilder(overviewType);
      if ( ob.valid() )
      {
         // Set up any overview builder options that don't involve histograms.
         ossimPropertyInterface* pi = dynamic_cast<ossimPropertyInterface*>( ob.get() );
         if ( pi ) setProps(pi);
         
         ossim_uint32 stopDimension = getOverviewStopDimension();
         if ( stopDimension ) ob->setOverviewStopDimension(stopDimension);

         ob->setScanForMinMax( scanForMinMax() );
         
         ob->setScanForMinMaxNull( scanForMinMaxNull() );
         
         for(ossim_uint32 idx = 0; idx < entryList.size(); ++idx)
         {
            createOverview(ih, ob, entryList[idx], useEntryIndex, consumedHistogramOptions);
         }
      }
      else
      {
        ossimNotify(ossimNotifyLevel_WARN)
           << "ERROR:\nCould not create builder for:  "<< overviewType << std::endl;
        outputOverviewWriterTypes();
      }
   }

   if(traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG) << M << " exited...\n";
   }
}
Exemplo n.º 8
0
//---
// For std::sort of ElevationDatabaseListType
// e.g.: std::sort( dbList.begin(), dbList.end(), dbSort );
//---
bool dbSort(ossimRefPtr<ossimElevationDatabase> a, ossimRefPtr<ossimElevationDatabase> b)
{
   bool result = false;
   if ( a.valid() && b.valid() )
   {
      result = ( a->getMeanSpacingMeters() < b->getMeanSpacingMeters() );
   }
   return result;
}
Exemplo n.º 9
0
void ossimEdgeFilter::setProperty(ossimRefPtr<ossimProperty> property)
{
   if(!property) return;
   
   if(property->getName() == PROP_EDGE_FILTER)
   {
      theFilterType = property->valueToString();
   }
}
Exemplo n.º 10
0
void ossimEdgeFilter::runLocalMax8Filter(T /* dummyVariable */,
                                         ossimRefPtr<ossimImageData> inputData)
{
   ossim_uint32 bandIdx = 0;
   ossim_uint32 numberOfBands = inputData->getNumberOfBands();
  
   ossim_uint32 x = 0;
   ossim_uint32 y = 0;
   ossim_uint32 width  = theTile->getWidth();
   ossim_uint32 height = theTile->getHeight();
   ossim_int32 rowIncrement  = inputData->getWidth();
   ossim_int32 rowIncrement2 = 2*inputData->getWidth(); 
         
   for(bandIdx = 0; bandIdx < numberOfBands; ++bandIdx)
   {
      //inputBuf has a 1 pixel edge compared to outputBuf
      T* inputBuf  = static_cast<T*>(inputData->getBuf(bandIdx));
      T* outputBuf = static_cast<T*>(theTile->getBuf(bandIdx));
      T np         = static_cast<T>(inputData->getNullPix(bandIdx)); //changed to input Null            

      if(inputBuf&&outputBuf)
      {
         //one pass: maybe faster if changed to two passes
         T* outB;
         T* inB;
         
      	outB = outputBuf;         
         inB  = inputBuf;         
         for(y = 0; y < height; ++y)
         {
            for(x = 0; x < width; ++x)
            {
               if (inB[1+rowIncrement] != np)
               {
                  *outB = max<T>(
                           max<T>(
                            max<T>(inB[0],inB[1]),
                            max<T>(inB[2],inB[rowIncrement])),
                           max<T>(
                            max<T>(inB[rowIncrement+2],inB[rowIncrement2]),
                            max<T>(inB[rowIncrement2+1],inB[rowIncrement2+2])
                            ));
               }
               else
               {
                  *outB = np;
               }
               ++outB;
               ++inB;
            }
            inB+=2; //go to next line, jump due to edge
         }       
      }      
   }
   theTile->validate();
}
ossim_uint32 ossimMultiResLevelHistogram::getNumberOfBands(ossim_uint32 resLevel) const
{
   const ossimRefPtr<ossimMultiBandHistogram> h = getMultiBandHistogram(resLevel);
   if (h.valid())
   {
      return h->getNumberOfBands();
   }

   return 0;
}  
Exemplo n.º 12
0
bool ossimOpjCompressor::setProperty(ossimRefPtr<ossimProperty> property)
{
   bool consumed = false;
   
   if ( property.valid() )
   {
      ossimString key = property->getName();

      if ( traceDebug() )
      {
         ossimNotify(ossimNotifyLevel_DEBUG)
            << "ossimOpjCompressor::setProperty DEBUG:"
            << "\nkey: " << key
            << " values: " << property->valueToString() << std::endl;
      }
      
      if (key == ossimKeywordNames::COMPRESSION_QUALITY_KW)
      {
         setQualityTypeString(property->valueToString());
         consumed = true;
      }
      else if ( (key == LEVELS_KW) || (key ==  "Clevels") )
      {
         m_levels = property->valueToString().toInt32();
         consumed = true;
      }
      else if( (key == REVERSIBLE_KW) || (key == "Creversible") )
      {
         setReversibleFlag(property->valueToString().toBool());
         consumed = true;
      }
      else if (key == ADD_ALPHA_CHANNEL_KW)
      {
         m_alpha = property->valueToString().toBool();
         consumed = true;
      }
      else if ( key == THREADS_KW)
      {
         m_threads = property->valueToString().toInt32();
         consumed = true;
      }
      else if ( (key == "Clayers") ||
                (key == "Cprecincts") )
      {
         // Generic options passed through kdu_params::parse_string.

         // Make in the form of "key=value" for kdu_params::parse_string.
         ossimString option = key;
         option += "=";
         option += property->valueToString();
         
         // Add to list.
         m_options.push_back(option);
         
         consumed = true;
      } 
   }

   return consumed;
}
Exemplo n.º 13
0
void ossimRgbImage::setCurrentImageData(ossimRefPtr<ossimImageData>& imageData)
{
   if(imageData.valid())
   {
      if((imageData->getScalarType() == OSSIM_UCHAR)&&
         (imageData->getDataObjectStatus()!=OSSIM_NULL))
      {
         theImageData = imageData;
         initialize();
      }
   }
}
const ossimRefPtr<ossimHistogram> ossimMultiResLevelHistogram::getHistogram(ossim_uint32 band,
                                                                            ossim_uint32 resLevel)const
{
   const ossimRefPtr<ossimMultiBandHistogram> temp = getMultiBandHistogram(resLevel);

   if(temp.valid())
   {
      return temp->getHistogram(band);
   }
   
   return (ossimHistogram*)0;
}
Exemplo n.º 15
0
void ossimMaskFilter::setProperty(ossimRefPtr<ossimProperty> property)
{
   if( property.valid() )
   {
      if(property->getName() == MASK_FILTER_MASK_TYPE_KW)
      {
         setMaskType(property->valueToString());
      }
      else
      {
         ossimImageCombiner::setProperty(property);
      }
   }
}
void ossimPlanetQtLegendAnimationPathItem::loadXml(ossimRefPtr<ossimXmlNode> node,
                                             std::vector<ossimPlanetOperation*>& activityList)
{
   if(!node.valid()) return;
   ossimString tempValue;

   if(node->getChildTextValue(tempValue, "name"))
   {
      setText(0, tempValue.c_str());
   }
   if(node->getChildTextValue(tempValue, "path"))
   {   
      setAnimationPathFromString(tempValue);
   }  
}
// Private method:
bool ossimTiledElevationDatabase::isDirectoryBasedImage(ossimRefPtr<ossimImageHandler> ih)
{
   bool result = false;
   if ( ih.valid() )
   {
      // Get the image handler name.
      ossimString imageHandlerName = ih->getClassName();
      if ( (imageHandlerName == "ossimAdrgTileSource") ||
           (imageHandlerName == "ossimCibCadrgTileSource") )  
      {
         result = true;
      }
   }
   return result;
}
void ossimPlanetCacheTextureLayer::getMetadata(ossimRefPtr<ossimXmlNode> metadata)const
{
  if(m_textureLayer.valid())
  {
    m_textureLayer->getMetadata(metadata.get());
  }
}
Exemplo n.º 19
0
void ossimCFARFilter::setProperty(ossimRefPtr<ossimProperty> property)

{

    if(!property) return;

    ossimString name = property->getName();



    if(name == "aperture_size")

    {


    }

    else

    {

        ossimImageSourceFilter::setProperty(property);

    }

}
Exemplo n.º 20
0
void ossimBumpShadeTileSource::setProperty(ossimRefPtr<ossimProperty> property)
{
   ossimString name = property->getName();
   if(name == "lightSourceElevationAngle")
   {
      m_lightSourceElevationAngle = property->valueToString().toDouble();
   }
   else if(name == "lightSourceAzimuthAngle")
   {
      m_lightSourceAzimuthAngle = property->valueToString().toDouble();
   }
   else
   {
      ossimImageCombiner::setProperty(property);
   }
}
Exemplo n.º 21
0
void ossimPngReader::setProperty(ossimRefPtr<ossimProperty> property)
{
   if ( property.valid() )
   {
      if ( property->getName().string() == USE_ALPHA_KW )
      {
         ossimString s;
         property->valueToString(s);
         m_useAlphaChannelFlag = s.toBool();
      }
      else
      {
         ossimImageHandler::setProperty(property);
      }
   }
}
Exemplo n.º 22
0
void ossimTableRemapper::remapFromNormalizedTable(
   ossimRefPtr<ossimImageData>& inputTile)
{
   if (!theNormBuf) // First time...
   {
      theNormBuf = new ossim_float64[theTile->getSize()];
   }
   
   // Normalize and copy the source tile to a buffer.
   inputTile->copyTileToNormalizedBuffer(theNormBuf);

   const ossim_uint32 BANDS = theTile->getNumberOfBands();
   const ossim_uint32 PPB   = theTile->getSizePerBand(); // pixels per band

   //---
   // NOTE:
   // If (theTableBandCount == one) that means we only have one band; or,
   // the user wanted to remap all bands using the same table...
   //---
   const ossim_uint32 BAND_OFFSET = (theTableBandCount == 1) ? 0 : PPB;

   // remap table (rt)
   ossim_float64* rt = reinterpret_cast<ossim_float64*>(&theTable.front()); 

   ossim_float64* buf = theNormBuf;
   ossim_float64 p = 0.0;
   for (ossim_uint32 band = 0; band < BANDS; ++band)
   {
      for (ossim_uint32 pixel = 0; pixel < PPB; ++pixel)
      {
         // Get the source pixel...
         ossim_uint32 idx
            = static_cast<ossim_uint32>(buf[pixel]*theTableBinCount+0.5);

         if((idx < theTableBinCount))
         {
            // If within range use to index the remap table; else, null.
            p = (idx < theTableBinCount) ? rt[idx] : 0.0;
         }
//         else if(idx < 0)
//         {
//            p = 0.0;
//         }
         else 
         {
            p = 1.0;
         }
         // Range check (in case table bad) and assign to destination pixel.
         buf[pixel] = (p >= 0.0) ? ( (p <=1.0) ? p : 1) : 0.0;
      }

      // Go to next band.
      rt += BAND_OFFSET;
      buf += PPB;
   }
   
   // Un-normalize and copy the buffer to the destination tile.
   theTile->copyNormalizedBufferToTile(theNormBuf);
}
Exemplo n.º 23
0
void ossimIndexToRgbLutFilter::setProperty(ossimRefPtr<ossimProperty> property)
{
   if(property.valid())
   {
      ossimString value = property->valueToString();
      value = value.trim();

      if(property->getName() == "LUT file")
      {
         setLut(ossimFilename(property->valueToString()));
      }
      else
      {
         ossimImageSourceFilter::setProperty(property);
      }
   }
}
Exemplo n.º 24
0
void ossimFftFilter::setProperty(ossimRefPtr<ossimProperty> property)
{
   if(!property) return;
   
   if(property->getName() == "FFT Direction")
   {
      if(theTile.valid())
      {
         theTile = NULL;
      }
      setDirectionType(property->valueToString());
   }
   else
   {
      ossimImageSourceFilter::setProperty(property);
   }
}
template <class T> void ossimTiledElevationDatabase::fillGrid(T /* dummyTemplate */,
                                                              ossimRefPtr<ossimImageData> data)
{
   if ( data.valid() )
   {
      // Copy to grid reversing the lines as the ossimDblGrid's origin is the SW corner.
      const ossim_float64 NP  = data->getNullPix(0);
      const T* buf = static_cast<T*>(data->getBuf(0));
      if ( buf )
      {
         const ossimIpt SIZE( data->getWidth(), data->getHeight() );
         ossim_int32 bufIdx = (SIZE.y-1) * data->getWidth();
         ossim_int32 grdY = 0;
         for (ossim_int32 y = SIZE.y-1; y >= 0; --y)
         {
            for (ossim_int32 x = 0; x < SIZE.x; ++ x)
            {
               ossim_float64 v = static_cast<ossim_float64>(buf[bufIdx+x]);
               m_grid->setNode(x, grdY, (v!=NP?v:ossim::nan()) );
            }
            bufIdx -= data->getWidth();
            ++grdY;
         }
      }
   }
}
Exemplo n.º 26
0
ossimRefPtr<ossimImageData> ossimMaskFilter::executeMaskFilter(ossimRefPtr<ossimImageData> imageSourceData,
                                                               ossimRefPtr<ossimImageData> maskSourceData)
{
   if(!theTile)
   {
      theTile = (ossimImageData*)imageSourceData->dup();
      if(!theTile->getBuf())
      {
         theTile->initialize();
      }
   }
   else
   {
      ossim_uint32 tw = theTile->getWidth();
      ossim_uint32 th = theTile->getHeight();
      ossim_uint32 dw = imageSourceData->getWidth();
      ossim_uint32 dh = imageSourceData->getHeight();
      
      theTile->setWidthHeight(imageSourceData->getWidth(),
			      imageSourceData->getHeight());
      theTile->setOrigin(imageSourceData->getOrigin());
      if((tw*th) != (dw*dh))
      {
         theTile->initialize();
      }
     theTile->setDataObjectStatus(imageSourceData->getDataObjectStatus());
   }
   theTile->loadTile(imageSourceData.get());
   theTile->setDataObjectStatus(imageSourceData->getDataObjectStatus());
  switch(theMaskType)
  {
  case OSSIM_MASK_TYPE_SELECT:
  {
     return executeMaskFilterSelect(theTile,
                                    maskSourceData);
  }
  case OSSIM_MASK_TYPE_INVERT:
  {
     return executeMaskFilterInvertSelect(theTile,
                                          maskSourceData);
  }
  case OSSIM_MASK_TYPE_WEIGHTED:
  {
     return executeMaskFilterWeighted(theTile,
                                      maskSourceData);
  }
  }
  
  return imageSourceData;
}
Exemplo n.º 27
0
ossimRefPtr<ossimImageData> ossimFixedTileCache::addTile(ossimRefPtr<ossimImageData> imageData,
                                                         bool duplicateData)
{
   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
   ossimRefPtr<ossimImageData> result = NULL;
   if(!imageData.valid())
   {
      return result;
   }
   if(!imageData->getBuf())
   {
      return result;
   }
   
   ossim_int32 id = computeId(imageData->getOrigin());
   if(id < 0)
   {
      return result;
   }
   
   std::map<ossim_int32, ossimFixedTileCacheInfo>::iterator tileIter =
      theTileMap.find(id);

   if(tileIter==theTileMap.end())
   {
      if(duplicateData)
      {
         result = (ossimImageData*)imageData->dup();
      }
      else
      {
         result = imageData;
      }
      ossimFixedTileCacheInfo cacheInfo(result, id);
       
      theCacheSize += imageData->getDataSizeInBytes();
      theTileMap.insert(make_pair(id, cacheInfo));
      if(theUseLruFlag)
      {
         theLruQueue.push_back(id);
      }
   }
   
   return result;
}
Exemplo n.º 28
0
void oms::SingleImageChain::setImageViewTransform(ossimRefPtr<ossimImageViewTransform> imageViewTransform)
{
   theViewCutter->setEnableFlag(false);
   theViewImageCutter->setEnableFlag(false);
   theRenderer->setImageViewTransform(imageViewTransform.get());
   theRenderer->setEnableFlag(true);
   ossimRefreshEvent evt(theRenderer);
   theRenderer->propagateEventToOutputs(evt);
}
Exemplo n.º 29
0
void ossimXmlNode::addChildNode(ossimRefPtr<ossimXmlNode> node)
{
    if(node->theParentNode)
    {
        node->theParentNode->removeChild(node);
    }
    node->theParentNode = this;
    theChildNodes.push_back(node.get());
}
void ossimCFARFilter::setProperty(ossimRefPtr<ossimProperty> property)
{
   if(!property) return;
   ossimString name = property->getName();

	if(name == "threshold")
	{
		theThreshold = property->valueToString().toDouble();
	}
   else if(name == "Kernel")
   {
      ossimMatrixProperty* matrixProperty = PTR_CAST(ossimMatrixProperty,
                                                     property.get());
      if(matrixProperty)
      {
      	for(ossim_int32 r = 0; r < 5; r++)
   		{
      		for(ossim_int32 c = 0; c < 5; c++)
      		{
      			theKernel[r][c] = (*matrixProperty)(r,c);
      		}
   		}
   		/*
         theKernel[0][0] = (*matrixProperty)(0,0);
         theKernel[1][0] = (*matrixProperty)(1,0);
         theKernel[2][0] = (*matrixProperty)(2,0);
         theKernel[0][1] = (*matrixProperty)(0,1);
         theKernel[1][1] = (*matrixProperty)(1,1);
         theKernel[2][1] = (*matrixProperty)(2,1);
         theKernel[0][2] = (*matrixProperty)(0,2);
         theKernel[1][2] = (*matrixProperty)(1,2);
         theKernel[2][2] = (*matrixProperty)(2,2);
			*/
      }
      else
      {
         ossimImageSourceFilter::setProperty(property);
      }
   }
   else
   {
      ossimImageSourceFilter::setProperty(property);
   }
}