Exemplo n.º 1
0
void ossimTableRemapper::remapFromNativeTable(
   ossimRefPtr<ossimImageData>& inputTile)
{
   switch (theOutputScalarType)
   {
      case OSSIM_UINT8:
      {
         remapFromNativeTable(ossim_uint8(0), inputTile);
         break;
      }
      
      case OSSIM_USHORT11:
      case OSSIM_USHORT16:
      {
         remapFromNativeTable(ossim_uint16(0), inputTile);
         break;
      }
      
      case OSSIM_SSHORT16:
      {
         remapFromNativeTable(ossim_sint16(0), inputTile);
         break;
      }
      
      case OSSIM_NORMALIZED_FLOAT:
      case OSSIM_FLOAT:
      {
         remapFromNativeTable(ossim_float32(0), inputTile);
         break;
      }
      
      case OSSIM_NORMALIZED_DOUBLE:
      case OSSIM_DOUBLE:
      {
         remapFromNativeTable(ossim_float64(0), inputTile);
         break;
      }
      
      case OSSIM_SCALAR_UNKNOWN:
      default:
      {
         if(traceDebug())
         {
         // Shouldn't hit this.
            ossimNotify(ossimNotifyLevel_WARN)
            << "ossimTableRemapper::remapFromNativeTable"
            << "\nOutput scalar type is OSSIM_SCALAR_UNKNOWN!\n";
         }
         break;
      }

   } // End of "switch (theTableType)"
}
Exemplo n.º 2
0
void ossimHistogramRemapper::buildAutoLinearMinMaxTable()
{
   switch (getOutputScalarType())
   {
      case OSSIM_UINT8:
      {
         buildAutoLinearMinMaxTableTemplate(ossim_uint8(0));
         break;
      }
			
      case OSSIM_USHORT11:
      case OSSIM_UINT16:
      {
         buildAutoLinearMinMaxTableTemplate(ossim_uint16(0));
         break;
      }
			
      case OSSIM_SINT16:
      {
         buildAutoLinearMinMaxTableTemplate(ossim_sint16(0));
         break;
      }
			
      case OSSIM_NORMALIZED_FLOAT:      
      case OSSIM_FLOAT:
      {
         buildAutoLinearMinMaxTableTemplate(ossim_float32(0));
         break;
      }
			
      case OSSIM_NORMALIZED_DOUBLE:
      case OSSIM_DOUBLE:
      {
         buildAutoLinearMinMaxTableTemplate(ossim_float64(0));
         break;
      }
			
      case OSSIM_SCALAR_UNKNOWN:
      default:
      {
         if(traceDebug())
         {
         // Shouldn't hit this.
            ossimNotify(ossimNotifyLevel_WARN)
               << "ossimTableRemapper::buildTable OSSIM_SCALAR_UNKNOWN!"
               << endl;
         }
         break;
      }
			
   } // End of "switch (theTableType)"
}
Exemplo n.º 3
0
ossimRefPtr<ossimImageData> ossimShiftFilter::getTile(
   const ossimIrect& tileRect,
   ossim_uint32 resLevel)
{
   ossimRefPtr<ossimImageData> result = 0;
   
   if ( theInputConnection )
   {
      ossimRefPtr<ossimImageData> inputTile = theInputConnection->getTile( tileRect, resLevel );
      
      if ( inputTile.get() && isSourceEnabled() &&
           !ossim::isnan(m_null) && !ossim::isnan(m_min) && !ossim::isnan(m_max) )
      {
         // Get its status of the input tile.
         ossimDataObjectStatus tile_status = inputTile->getDataObjectStatus();
         
         if ( tile_status != OSSIM_NULL )
         {
            if ( !m_tile )
            {
               allocate(); // First time through.
            }
            
            if ( tile_status != OSSIM_EMPTY )
            {
               // Set the origin,bands of the output tile.
               m_tile->setImageRectangle(tileRect);

               switch(inputTile->getScalarType())
               {
                  case OSSIM_UINT8:
                  {
                     fillTile( ossim_uint8(0), inputTile.get(), m_tile.get() );
                     break;
                  }
                  case OSSIM_SINT8:
                  {
                     fillTile( ossim_sint8(0), inputTile.get(), m_tile.get() );
                     break;
                  }
                  case OSSIM_UINT16:
                  case OSSIM_USHORT11:
                  {
                     fillTile( ossim_uint16(0), inputTile.get(), m_tile.get() );
                     break;
                  }
                  case OSSIM_SINT16:
                  {
                     fillTile( ossim_sint16(0), inputTile.get(), m_tile.get() ); 
                     break;
                  }
                  case OSSIM_SINT32:
                  {
                     fillTile( ossim_sint32(0), inputTile.get(), m_tile.get() );
                     break;
                  }
                  case OSSIM_UINT32:
                  {
                     fillTile( ossim_uint32(0), inputTile.get(), m_tile.get() );
                     break;
                  }
                  case OSSIM_FLOAT32: 
                  case OSSIM_NORMALIZED_FLOAT:
                  {
                     fillTile( ossim_float32(0), inputTile.get(), m_tile.get() );
                     break;
                  }
                  case OSSIM_FLOAT64:
                  case OSSIM_NORMALIZED_DOUBLE:
                  {
                     fillTile( ossim_float64(0), inputTile.get(), m_tile.get() );
                     break;
                  }
                  case OSSIM_SCALAR_UNKNOWN:
                  default:
                  {
                     ossimNotify(ossimNotifyLevel_WARN)
                        << "ossimShiftFilter::getTile ERROR Unhandled scalar!" << endl;
                        break;
                  }
            
               } // Matches: switch(inputTile->getScalarType())

               m_tile->validate();
            }
            else
            {
               m_tile->makeBlank();
            }

            result = m_tile;
            
         } // Matches: if ( tile_status != OSSIM_NULL )
            
      } // Matches: if ( inputTile.get() ... )

      if ( !result && inputTile.get() )
      {
         result = inputTile;
      }
           
   } // Matches: if ( theInputConnection ) 
   
   return result;
}
Exemplo n.º 4
0
ostream& ossimTableRemapper::print(ostream& os) const
{
   ossimScalarTypeLut* sl = ossimScalarTypeLut::instance();

   os << "\nossimTableRemapper::print:"
      << "\ntheTableBinCount:    " << theTableBinCount
      << "\ntheTableBandCount:   " << theTableBandCount
      << "\ntheTableType:        " << TABLE_TYPE[theTableType]
      << "\ntheInputScalarType:  " << (*sl)[theInputScalarType]
      << "\ntheOutputScalarType: " << (*sl)[theOutputScalarType]
      << endl;
   
   if (theTile.valid())
   {
      os << "theTile:\n" << *theTile << endl;
   }
   if (theTmpTile.valid())
   {
      os << "theTmpTile:\n" << *theTmpTile << endl;
   }

   switch (theOutputScalarType)
   {
      case OSSIM_UCHAR:
      {
         dumpTable(ossim_uint8(0), os);
         break;
      }
      
      case OSSIM_USHORT11:
      case OSSIM_USHORT16:
      {
         dumpTable(ossim_uint16(0), os);
         break;
      }
      
      case OSSIM_SSHORT16:
      {
         dumpTable(ossim_sint16(0), os);
         break;
      }
      
      case OSSIM_NORMALIZED_FLOAT:
      case OSSIM_FLOAT:
      {
         dumpTable(ossim_float32(0), os);
         break;
      }
      
      case OSSIM_NORMALIZED_DOUBLE:
      case OSSIM_DOUBLE:
      {
         dumpTable(ossim_float64(0), os);
         break;
      }
      
      case OSSIM_SCALAR_UNKNOWN:
      default:
      {
         if(traceDebug())
         {
         // Shouldn't hit this.
            ossimNotify(ossimNotifyLevel_WARN)
               << "ossimTableRemapper::print OSSIM_SCALAR_UNKNOWN!\n";
         }
         break;
      }

   } // End of "switch (theTableType)"

   return os;
}
void ossimTiledElevationDatabase::mapRegion()
{
   static const char M[] = "ossimTiledElevationDatabase::mapRegion";
   
   if ( m_entries.size() && ( m_requestedRect.isLonLatNan() == false ) )
   {
      ossimRefPtr<ossimOrthoImageMosaic> mosaic = new ossimOrthoImageMosaic();
      std::vector<ossimTiledElevationEntry>::iterator i = m_entries.begin();
      while ( i != m_entries.end() )
      {
         mosaic->connectMyInputTo( (*i).m_sic.get() );
         ++i;
      }

      // Compute the requested rectangle in view space.
      ossimRefPtr<ossimImageGeometry> geom = mosaic->getImageGeometry();
      if ( geom.valid() )
      {
         ossimDpt ulDpt;
         ossimDpt lrDpt;
         geom->worldToLocal(m_requestedRect.ul(), ulDpt);
         geom->worldToLocal(m_requestedRect.lr(), lrDpt);

         // Expand out to fall on even view coordinates.
         ulDpt.x = std::floor(ulDpt.x);
         ulDpt.y = std::floor(ulDpt.y);
         lrDpt.x = std::ceil(lrDpt.x);
         lrDpt.y = std::floor(lrDpt.y);

         // Get new(expanded) corners in ground space.
         ossimGpt ulGpt;
         ossimGpt lrGpt;
         geom->localToWorld(ulDpt, ulGpt);
         geom->localToWorld(lrDpt, lrGpt);
         theGroundRect = ossimGrect(ulGpt, lrGpt);
            
         // Expanded requested rect in view space.
         ossimIpt ulIpt = ulDpt;
         ossimIpt lrIpt = lrDpt;
         const ossimIrect VIEW_RECT(ulIpt, lrIpt);

         // Get the data.
         ossimRefPtr<ossimImageData> data = mosaic->getTile(VIEW_RECT, 0);
         if ( data.valid() )
         {
            // Initialize the grid:
            const ossimIpt SIZE( data->getWidth(), data->getHeight() );
            const ossimDpt ORIGIN(ulGpt.lon, lrGpt.lat); // SouthWest corner
            const ossimDpt SPACING( (lrGpt.lon-ulGpt.lon)/(SIZE.x-1),
                                    (ulGpt.lat-lrGpt.lat)/(SIZE.y-1) );
            if ( !m_grid ) m_grid = new ossimDblGrid();
            m_grid->initialize(SIZE, ORIGIN, SPACING, ossim::nan());

            if ( traceDebug() )
            {
               ossimNotify(ossimNotifyLevel_DEBUG)
                  << M
                  << "\nrequested view rect: " << VIEW_RECT
                  << "\nexpanded ground rect: " << theGroundRect
                  << "\norigin:  " << ORIGIN
                  << "\nsize:    " << SIZE
                  << "\nspacing: " << SPACING << std::endl;
            }

            // Fill the grid:
            switch( data->getScalarType() )
            {
               case OSSIM_SINT16:
               {
                  fillGrid(ossim_sint16(0), data);
                  break;
               }
               case OSSIM_SINT32:
               {
                  fillGrid(ossim_sint32(0), data);
                  break;
               }
               case OSSIM_FLOAT32:
               {
                  fillGrid(ossim_float32(0), data);
                  break;
               }
               case OSSIM_FLOAT64:
               {
                  fillGrid(ossim_float64(0), data);
                  break;
               }
               case OSSIM_UINT8:
               case OSSIM_SINT8:
               case OSSIM_USHORT11:
               case OSSIM_UINT16:
               case OSSIM_UINT32:
               case OSSIM_NORMALIZED_DOUBLE:
               case OSSIM_NORMALIZED_FLOAT:
               case OSSIM_SCALAR_UNKNOWN:
               default:
               {
                  std::string errMsg = M;
                  errMsg += " ERROR:\nUnhandled scalar type: ";
                  errMsg += data->getScalarTypeAsString().string();
                  throw ossimException(errMsg);
               }
            }
            
         } // if ( data.valid() )

      } // if ( geom.valid() )

   } // if ( m_entries.size() && ...
}
Exemplo n.º 6
0
ossimRefPtr<ossimImageData> ossimWatermarkFilter::getTile(
   const ossimIrect& tile_rect, ossim_uint32 resLevel)
{
   // Lock for the length of this method.
   // Check for input.
   if (!theInputConnection)
   {
      if (theTile.valid())
      {
         theTile->setImageRectangle(tile_rect);
         theTile->makeBlank();
      }
      return theTile;
   }

   // Fetch a tile from from the input source.
   ossimRefPtr<ossimImageData> inputTile =
      theInputConnection->getTile(tile_rect, resLevel);

   // Check for bypass.
   if (theEnableFlag == false) return inputTile;

   // Check for weight being 0.0.
   if (theWatermarkWeight == 0.0) return inputTile;

   //---
   // Check for dirty state.
   // Note: This is set in initialize if something changes.
   //---
   if (theDirtyFlag == true)
   {
      if (allocate() == false) // Something not right if false.
      {
         return inputTile;
      }
   }   
   
   // We will only watermark (process) within the input bounding rectangle.
   if (tile_rect.intersects(theInputBoundingRect) == false)
   {
      return inputTile;
   }

   // Capture the rectangle and blank out theTile.
   theTile->setImageRectangle(tile_rect);

   if (inputTile.valid() &&
       (inputTile->getDataObjectStatus() != OSSIM_NULL))
   {
      // Copy the inputTile to theTile.
      theTile->loadTile(inputTile.get());
   }
   else 
   {
      theTile->makeBlank();
   }

   // Write the watermarks...
   switch(theTile->getScalarType())
   {
      case OSSIM_UINT8:
      {
         fill(ossim_uint8(0));
         break;
      }
      case OSSIM_SINT8:
      {
         fill(ossim_sint8(0));
         break;
      }
      case OSSIM_USHORT11:
      case OSSIM_UINT16:
      {
         fill(ossim_uint16(0));
         break;
      }
      case OSSIM_SINT16:
      {
         fill(ossim_sint16(0));
         break;
      }
      case OSSIM_UINT32:
      {
         fill(ossim_uint32(0));
         break;
      }
      case OSSIM_SINT32:
      {
         fill(ossim_sint32(0));
         break;
      }
      case OSSIM_FLOAT32: 
      case OSSIM_NORMALIZED_FLOAT:
      {
         fill(ossim_float32(0));
         break;
      }
      case OSSIM_FLOAT64: 
      case OSSIM_NORMALIZED_DOUBLE:
      {
         fill(ossim_float32(0));
         break;
      }
      case OSSIM_SCALAR_UNKNOWN:
      default:
      {
         ossimNotify(ossimNotifyLevel_WARN)
            << "Scalar type = " << theTile->getScalarType()
            << " Not supported by ossimWatermarkFilter" << std::endl;
         return inputTile;
      }
   }

   return theTile;
}