1.11 Compression and Decompression
GeoRaster provides the following types of native compression to reduce storage space requirements for GeoRaster objects: JPEG (JPEG-F), JPEG 2000, and DEFLATE.
-
With JPEG (JPEG-F) and DEFLATE compression, each block of a GeoRaster object is compressed individually, as a distinct raster representation; and when a compressed GeoRaster object is decompressed, each block is decompressed individually
-
With JPEG 2000 compression, each GeoRaster object is stored in a single BLOB as a JP2 file, in which the raster can be internally blocked.
For JPEG (JPEG-F) and DEFLATE compression, any GeoRaster operation that can be performed on a decompressed (uncompressed) GeoRaster object can also be performed on a compressed GeoRaster object. When GeoRaster performs an operation, if the source GeoRaster object is compressed, GeoRaster internally decompresses blocks of the source object as needed, performs the specified operation, and then compresses the resulting object in the format specified by the compression
keyword or, if the compression
keyword is not specified, in the source object's compression format. Therefore, you do not need to decompress compressed GeoRaster objects before performing certain operations, but you might gain some overall performance benefit if you decompress the objects before performing other operations.
For JPEG 2000 compression, most GeoRaster operations can internally decompress the JP2 compressed GeoRaster object while performing the operation.
Before a database user compresses or decompresses a GeoRaster object, ensure that the database has been created with a default temporary tablespace or that the user has been assigned a temporary tablespace or tablespace group. Otherwise, by default the SYSTEM
tablespace is used for the temporary tablespace, and large temporary LOB data generated during GeoRaster operations are put in the SYSTEM
tablespace, possibly affecting overall database performance. For information about managing temporary tablespaces, see Oracle Database Administrator's Guide.
To specify compression or decompression of a GeoRaster object, use the compression
keyword in the storageParam
parameter, which is described in Storage Parameters. You can use the compression
keyword in the storageParam
parameter with all GeoRaster procedures. (For JPEG (JPEG-F) and DEFLATE compression, there are no separate procedures for compressing and decompressing a GeoRaster object.)
If the source GeoRaster object is blank, the compression
keyword is ignored, except for the SDO_GEOR.getRasterSubset and SDO_GEOR.getRasterData functions. That is, a blank GeoRaster object is never compressed, and the compression type in the metadata is always NONE
. (Blank GeoRaster objects are explained in Blank and Empty GeoRaster Objects.)
This section covers the following topics.
- JPEG (JPEG-F) Compression of GeoRaster Objects
- JPEG 2000 Compression of GeoRaster Objects
- DEFLATE Compression of GeoRaster Objects
- Decompression of GeoRaster Objects
- Third-Party Plug-ins for Compression
- Advanced LOB Compression
Parent topic: GeoRaster Overview and Concepts
1.11.1 JPEG (JPEG-F) Compression of GeoRaster Objects
JPEG (JPEG-F) compression is supported only for GeoRaster objects with a
cellDepth
value of 8BIT_U
and no more than 3 bands
per block, and each block must have 1 band or 3 bands. (2 bands per block is not
supported for JPEG compression.) You can JPEG compress GeoRaster objects of more than 3
bands by reblocking the GeoRaster object with a band block size of 1 or 3 bands. JPEG
compression is not supported for GeoRaster objects with a colormap.
Although JPEG compression is supported for GeoRaster objects of any size, the total size (columnsPerBlock * rowsPerBlock * bandsPerBlock * cellDepth / 8
) of each block of the GeoRaster object must not exceed 50 megabytes (MB). For large GeoRaster objects, you can call the SDO_GEOR.changeFormatCopy procedure to block the GeoRaster object into blocks smaller than 50 MB, and then compress the GeoRaster object; or you can perform the blocking and compression in the same call to the SDO_GEOR.changeFormatCopy procedure.
GeoRaster supports the JPEG-F compression mode, which compresses objects in the full-format baseline JPEG format.
JPEG-F compression is described in the CCITT Rec. T.81 JPEG specification (or ICO/IEC IS 10918-1). GeoRaster uses the quantization table in Table K.2 of the CCITT Rec. T.81 JPEG specification and (for the Huffman tables) standard chrominance tables in Tables K.4 and K.6 of that specification. The quantization table is scaled by the compression quality before the table is applied to data during the compression process.
JPEG-F is a lossy compression format. You can control the degree of loss with the quality
keyword to the storageParam
parameter. The quality
keyword takes an integer value from 0 to 100. A value of 0 (zero) provides maximum compression, but causes substantial loss of data. A value of 75 (the GeoRaster default) provides an image that most people perceive as having no loss of quality, but that provides significant compression. A value of 100 provides the least compression, but the best quality.
Parent topic: Compression and Decompression
1.11.1.1 JPEG-B Support Deprecated
GeoRaster support for JPEG-B compression, which compresses objects in the abbreviated baseline JPEG format, is deprecated, and will be desupported in a future release. If JPEG-B is specified in a parameter to a GeoRaster subprogram, JPEG-F compression is used instead. You are encouraged to use the JPEG-F support.
Parent topic: JPEG (JPEG-F) Compression of GeoRaster Objects
1.11.2 JPEG 2000 Compression of GeoRaster Objects
GeoRaster supports JPEG 2000 (JP2) compression on cell depth 8BIT_U
and 16BIT_U
raster images following the standard ISO/IEC 15444-1. A JPEG 2000 compressed GeoRaster object is stored in one raster block. The data in this raster block is in JP2 file format as described in standard ISO/IEC 15444-1 Annex I. The image contained in the JPEG 2000 compressed GeoRaster object can be internally tiled.
With JPEG 2000 compression, the pyramids are implicitly embedded in the JP2 compressed data, and thus there is no separate, explicit pyramid storage in the JP2 compressed GeoRaster object. The maximum level of pyramids that can be retrieved from a JP2 compressed GeoRaster object is log2(min(tile_width, tile_height))
, where tile_width
and tile_height
are the width and height of the internal tiles, respectively. Both lossy and lossless compressions are supported.
The SDO_GEOR.compressJP2 procedure is used to compress a GeoRaster object into JP2 compressed GeoRaster object. The SDO_GEOR.decompressJP2 procedure can be used to explicitly decompress a JP2 compressed GeoRaster object into another GeoRaster object. Other GeoRaster operations, such as rectification, mosaicking, and raster algebra – but not SDO_GEOR.changeCellValue, SDO_GEOR.reproject, SDO_GEOR.scaleScopy, and SDO_GEOR.mosaic – can internally decompress the JP2 compressed GeoRaster object while performing the operation.
Large images can be compressed, but the size is limited by memory and max number of tiles (max_mem_size / 20 * 65535). To improve scalability and performance, always apply internal tiling. The tile size can be specified using the tileSize
keyword in the compressParam
parameter of the SDO_GEOR.compressJP2 procedure. The maximum number of tiles supported is 65535.
Parent topic: Compression and Decompression
1.11.3 DEFLATE Compression of GeoRaster Objects
DEFLATE compression compresses objects according to the Deflate Compressed Data Format Specification (Network Working Group RFC 1951), and it stores the compressed data in ZLIB format, as described in the ZLIB Compressed Data Format Specification (Network Working Group RFC 1950). The ZLIB header and checksum fields are included in the compressed GeoRaster object.
Although DEFLATE compression is supported for GeoRaster objects of any size, the total size (columnsPerBlock * rowsPerBlock * bandsPerBlock * cellDepth / 8
) of each block of the GeoRaster object must not exceed 1 gigabyte (GB). For large GeoRaster objects, you can call the SDO_GEOR.changeFormatCopy procedure to block the GeoRaster object into blocks smaller than1 GB, and then compress the GeoRaster object; or you can perform the blocking and compression in the same call to the SDO_GEOR.changeFormatCopy procedure.
Because DEFLATE compression is lossless, compression quality does not apply, and is ignored if it is specified.
Parent topic: Compression and Decompression
1.11.4 Decompression of GeoRaster Objects
You can decompress a compressed GeoRaster object in the database by specifying compression=NONE
in the storageParam
parameter. For JPEG-F compression, you should not specify compression quality as a storage parameter.
You can decompress a compressed GeoRaster object outside the database (that is, on the client side) by using an existing application programming interface (API), such as PL/SQL or the Oracle Call Interface (OCI), to retrieve the BLOB objects corresponding to the GeoRaster object's blocks, and decoding each compressed block individually according to the specifications of the relevant compression format. For example, if a GeoRaster object is compressed in JPEG-F mode, the decoding process should first parse the JPEG headers to retrieve the tables and block dimensions, and then apply Huffman decoding and dequantization to the image data.
Implementing JPEG decompression completely on your own is a complex, detail-oriented process. Depending on the application, it may be better to use an existing implementation. Libraries such as jpeglib
in C and several imaging APIs in Java (for example, Oracle J2SE and JAI) already implement JPEG decompression, and you can adapt them to perform the decoding process on JPEG-compressed GeoRaster objects. You can apply essentially the same approach for DEFLATE compression using a ZLIB C library or Java API.
Parent topic: Compression and Decompression
1.11.5 Third-Party Plug-ins for Compression
GeoRaster provides a plug-in architecture for third-party compression solutions. LizardTech Corporation provides a plug-in that enables users to compress and store raster imagery, in MrSID and JPEG 2000 compression types, natively in Oracle Spatial GeoRaster.
Before you install the LizardTech plug-in, you must follow these steps:
-
Go to the
$ORACLE_HOME/md/admin
directory. -
Connect to the database as
SYS AS SYSDBA
. -
Enter the following SQL statement:
SQL> @prvtgrlt.plb
To get the LizardTech plug-in and related information, contact LizardTech Corporation.
Parent topic: Compression and Decompression
1.11.6 Advanced LOB Compression
You can use Oracle Database Advanced LOB Compression (described briefly in Oracle Database SecureFiles and Large Objects Developer's Guide) to achieve lossless compression of GeoRaster raster data tables (RDTs), thus compressing the GeoRaster objects. If you specify Advanced LOB Compression for LOB storage when you create a table (such as the rasterBlock column of an RDT), then the SecureFiles LOBs in all rows of that table are compressed using Advanced LOB Compression. The compression is transparent to GeoRaster, and thus no application changes are required. However, you should avoid using Advanced LOB Compression on the RDT raster blocks if you are also using any GeoRaster-specific compression types (such as JPEG, DEFLATE, or a third-party plug-in) on these blocks.
The use of Advanced LOB Compression requires licensing for the Oracle Database Advanced Compression Option, which is described in Oracle Database Licensing Information. Note that the Oracle Database Advanced Compression Option is not required for GeoRaster compression operations that do not involve Advanced LOB Compression.
Parent topic: Compression and Decompression