JPEG 2000

Long name JPEG 2000
Short name JP2
File extension(s) .jp2, . jpc, .jpx, .j2k, .j2c

Most common forms of JPEG2000 and GeoJP2 (tm) files can be read and written by the GDB library. JPEG 2000 (JP2) is a wavelet-based successor format to the popular JPEG format. It includes several features that make it attractive for geospatial applications. These include the support for fast overview extraction, 8-bit and 16-bit data types, the ability to extract subregions, and support for embedding extra metadata within the container file.

The JP2 format is the most common form of JPEG 2000 data; however, some other forms exist. One form is the "JPC" format, a raw JPEG 2000 data stream. This format is supported for read and write, but may not have associated georeferencing or coordinate system data. It must have the extension .jpc.

For reading, GDB supports grayscale, RGB, color encoded as YCbCr (automatically converted to RGB while reading), and multispectral. Eight-bit unsigned, 16-bit signed and 16-bit unsigned data types are supported. All metadata entries are stored inside the JP2 file. When creating a JP2 file, a different number of overview levels will be created depending on the raster dimensions.

Export to JPC and JP2 format is supported with the format type "JP2". To generate a JPC instead of a JP2 format file, use the extension .jpc for the file. All files generated with extensions other than JPC will be JP2 files. On export any number of 8U, 16U or 16S bands may be exported. All metadata tags in the original file are copied over automatically upon export. The export of PCTs and GCPs is supported. It is currently not possible to generate YCbCr encoded files; however, RGB color files can still be generated in the RGB color space, by exporting three or more channels. JPEG 2000 export does not support vector data.

QualityPercent and Lossless

For export, the QualityPercent option may be set to control the degree of compression in the generated file. The argument is a number from 1 to 100 indicating the size the compressed file should be relative to the uncompressed size of the image being written. The default is 20, indicating the output file should be approximately 20 percent of the size it would be if uncompressed. Depending on the data, a QualityPercent value of 5 or less may still produce a useful output. The syntax for this typically would be FOPTIONS="QualityPercent=5"; however, FOPTIONS="5" is also acceptable.

If a value of 100 is selected for QualityPercent or the Lossless option is used, then a lossless compression mechanism is used. The resulting image can be read back without any alteration to the image values, though typically the degree of compression achieved will range from 30 through 50 percent.

OneTile

The OneTile option allows the image to be exported as one full tile no matter what size the image is. In normal circumstances, a tile size of 1K x 1K is a typical tile size for optimal performance. A maximum tile size of 8K x 8K is enforced. Some JPEG 2000 reader software only allows single tiles. In order to create JPEG 2000 files compatible with this type of software, use the OneTile option.

GEOREFTYPE

Use the GEOREFTYPE option to specify the georeferencing method you want to apply when exporting to JPEG 2000. See JPEG 2000 georeferencing.

Reading the DEM data

When GDB reads a JP2 file, some special behavior can occur for very specific files. In particular, if the file stores a digital elevation model (DEM) in a certain way, GDB will massage the data automatically. If the JP2 file has a metadata tag of "ELEVATION_FACTOR" and contains only one 16-bit channel, then a 32-bit real channel will be synthesized on the fly. The ELEVATION_FACTOR metadata can store two numbers which will be interpreted as <offset> and <scale> respectively. The 32R channel will then be calculated by this formula:
32R_DEM = <scale> * (16S_DEM + <offset>)

In GDB, the 32R channel will be presented as channel 1 and the original data, as it exists in the JP2 file on disk, will be presented as channel 2. This can be useful for storing 16S elevation values in a highly compressed JP2 file and then being able to get a more appropriate range of elevation values in the 32R channel. Of course, when the JP2 file is accessed by non-PCI software, only the 16S channel will be found.

Because of the nature of the JP2 compression, some special attention is needed for NoData. In the synthesized 32R channel, a pixel will be defined to be NoData if in the 16S channel the pixel is within 300 of the defined NoData value. This is done because when the JP2 file is created, NoData pixels are treated as regular numbers, so you can end up with values near, but not quite the same as, the original NoData value. For this reason, when creating a JP2 it is best to use a NoData value that is far from actual data values. With a DEM, using -32767 as the NoData value is recommended.

More about JPEG 2000

Explore the following links for more information about the JPEG 2000 format:

© PCI Geomatics Enterprises, Inc.®, 2023. All rights reserved.