Beispiel #1
0
bool ossim::copyOpjImage( opj_image* image, ossimImageData* tile )
{
   bool status = false;
   
   if ( image && tile )
   {
      if ( image->color_space == OPJ_CLRSPC_SRGB )
      {
         const ossimScalarType SCALAR = tile->getScalarType();
         if ( SCALAR == OSSIM_UINT8 )
         {
            status = ossim::copyOpjSrgbImage( ossim_uint8(0), image, tile );
         }
         else
         {
            ossimNotify(ossimNotifyLevel_WARN)
               << "ossim::copyOpjImage WARNING!\nUnhandle scalar: "
               << SCALAR << "\n";
         }
      }
      else
      {
         ossimNotify(ossimNotifyLevel_WARN)
            << "ossim::copyOpjImage WARNING!\nUnhandle color space: "
            << image->color_space << "\n";
      }
   }

   return status;
}
Beispiel #2
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)"
}
Beispiel #3
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)"
}
Beispiel #4
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;
}
Beispiel #5
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;
}
Beispiel #6
0
void ossimPngReader::fillTile(const ossimIrect& clip_rect,
                              ossimImageData* tile)
{
   if (!tile || !m_str) return;

   ossimIrect buffer_rect = clip_rect;
   buffer_rect.stretchToTileBoundary(m_cacheSize);
   buffer_rect.set_ulx(0);
   buffer_rect.set_lrx(getImageRectangle(0).lr().x);

   ossim_int32 number_of_cache_tiles = buffer_rect.height()/m_cacheSize.y;

#if 0
   if (traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG)
         << "tiles high:  " << number_of_cache_tiles
         << endl;
   }
#endif

   ossimIpt origin = buffer_rect.ul();
   
   for (int tileIdx = 0; tileIdx < number_of_cache_tiles; ++tileIdx)
   {
      // See if it's in the cache already.
      ossimRefPtr<ossimImageData> tempTile;
      tempTile = ossimAppFixedTileCache::instance()->
         getTile(m_cacheId, origin);
      if (tempTile.valid())
      {
         tile->loadTile(tempTile.get());
      }
      else
      {
         // Have to read from the png file.
         ossim_uint32 startLine = static_cast<ossim_uint32>(origin.y);
         ossim_uint32 stopLine  = 
            static_cast<ossim_uint32>( min(origin.y+m_cacheSize.y-1,
                                           getImageRectangle().lr().y) );
         ossimIrect cache_rect(origin.x,
                               origin.y,
                               origin.x+m_cacheSize.x-1,
                               origin.y+m_cacheSize.y-1);
         
         m_cacheTile->setImageRectangle(cache_rect);

         if ( !m_cacheTile->getImageRectangle().
              completely_within(getImageRectangle()) )
         {
            m_cacheTile->makeBlank();
         }

         if (startLine < m_currentRow)
         {
            // Must restart the compression process again.
            restart();
         }

         // Gobble any not needed lines.
         while(m_currentRow < startLine)
         {
            png_read_row(m_pngReadPtr, m_lineBuffer, NULL);
            ++m_currentRow;
         }
            
         switch (m_readMode)
         {
            case ossimPngRead8:
            {
               copyLines(ossim_uint8(0), stopLine);
               break;
            }
            case ossimPngRead16:
            {
               copyLines(ossim_uint16(0), stopLine);
               break;
            }
            case ossimPngRead8a:
            {
               if (m_useAlphaChannelFlag)
               {
                  copyLines(ossim_uint8(0), stopLine);
               }
               else
               {
                  // Will burn alpha value into the other bands.
                  copyLinesWithAlpha(ossim_uint8(0), stopLine);
               }
               break;
            }
            case ossimPngRead16a:
            {
               if (m_useAlphaChannelFlag)
               {
                  copyLines(ossim_uint16(0), stopLine); 
               }
               else
               {
                  // Will burn alpha value into the other bands.
                  copyLinesWithAlpha(ossim_uint16(0), stopLine);
               }
               break;
            }
            case ossimPngReadUnknown:
            default:
            {
               break; // should never happen.
            }
         }

         m_cacheTile->validate();
         
         tile->loadTile(m_cacheTile.get());
         
         // Add it to the cache for the next time.
         ossimAppFixedTileCache::instance()->addTile(m_cacheId,
                                                     m_cacheTile);
         
      } // End of reading for png file.
      
      origin.y += m_cacheSize.y;
      
   } // for (int tile = 0; tile < number_of_cache_tiles; ++tile)
   
   tile->validate();
}
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;
}