Isis 3 Programmer Reference
Isis::JP2Decoder Class Reference

JPEG2000 decoder class. More...

#include <JP2Decoder.h>

Collaboration diagram for Isis::JP2Decoder:
Collaboration graph

Public Member Functions

 JP2Decoder (const QString &jp2file)
 Constructs a JPEG2000 decoder object.
 
 ~JP2Decoder ()
 JP2Decoder destructor.
 
JP2Errorkakadu_error () const
 
void OpenFile ()
 Open the JPEG2000 file.
 
int GetSampleDimension () const
 
int GetLineDimension () const
 
int GetBandDimension () const
 
int GetPixelBytes () const
 
bool GetSignedData () const
 
void Read (unsigned char **inbuf)
 Read data from JP2 file containing 8-bit data.
 
void Read (short int **inbuf)
 Read data from JP2 file containing 16-bit data.
 

Static Public Member Functions

static bool IsJP2 (QString filename)
 

Private Member Functions

void SetResolutionAndRegion ()
 Sets resolution of data that will be decompressed. Also determines the image dimensions at the requested resolution.
 

Private Attributes

QString p_jp2File
 Input file name.
 
unsigned int p_numSamples
 Number of samples in JP2 file.
 
unsigned int p_numLines
 Number of lines in JP2 file.
 
unsigned int p_numBands
 Number of bands in JP2 file.
 
unsigned int p_pixelBytes
 Number of bytes per pixel in JP2 file.
 
bool p_signedData
 Set to true if data in JP2 file is signed.
 
JP2ErrorKakadu_Error
 JP2 Error handling facility.
 

Detailed Description

JPEG2000 decoder class.

This class is used to decode a JPEG2000 image.

Here is an example of how to use JP2Decoder

JP2Decoder *JP2_decoder;
JP2_decoder = new JP2Decoder(QString(ui.GetFileName("FROM")));
JP2_decoder->OpenFile();
int nsamps = JP2_decoder->GetSampleDimension();
int nlines = JP2_decoder->GetLineDimension();
int nbands = JP2_decoder->GetBandDimension();
int pixelbytes = JP2_decoder->GetPixelBytes();
bool is_signed = JP2_decoder->GetSignedData();
delete JP2_decoder;
jp.SetDimensions(nsamps,nlines,nbands);
if (pixelbytes == 1) {
jp.SetPixelType(Isis::UnsignedByte);
} else if (pixelbytes == 2) {
if (is_signed) {
jp.SetPixelType(Isis::SignedWord);
} else {
jp.SetPixelType(Isis::UnsignedWord);
}
} else {
throw iException::Message(iException::User,
"The file [" + ui.GetFileName("FROM") + "] contains unsupported data type.",
_FILEINFO_);
}
jp.SetInputFile(QString(ui.GetFileName("FROM")));
jp.SetOutputCube("TO");
jp.SetOrganization(ProcessImport::JP2);
jp.StartProcess();
jp.EndProcess();
JPEG2000 decoder class.
Definition JP2Decoder.h:83
JP2Decoder(const QString &jp2file)
Constructs a JPEG2000 decoder object.
@ JP2
Jpeg 2000 Format (always band sequential).
void SetDimensions(const int ns, const int nl, const int nb)
Sets the physical size of the input cube.

If you would like to see JP2Decoder being used in implementation, see std2isis.cpp or for a class that implements JP2Decoder, see ProcessImport

Author
2009-12-18 Janet Barrett
History

2009-12-18 Janet Barrett - Original version.

2012-04-06 Kris Becker - Fixed condition compilation where support for JP2K is disabled

2016-08-28 Kelvin Rodriguez - Moved member variables to be placed properly within the if ENABLEJP2K preprocessor block in order to stop unused member variable warnings in clang. Part of porting to OS X 10.11.

2017-08-21 Tyler Wilson, Ian Humphrey, Summer Stapleton - Added support for new kakadu libraries. References #4809.

2017-09-15 Ian Humphrey - Modified destructor to call finish() on the decompressor before destroying the kdu_codestream. Caused segfault on OSX 10.11 for the JP2Importer test, and isis2std and std2isis jpeg2000 tests. References #4809.

Definition at line 83 of file JP2Decoder.h.

Constructor & Destructor Documentation

◆ JP2Decoder()

Isis::JP2Decoder::JP2Decoder ( const QString & jp2file)

Constructs a JPEG2000 decoder object.

Parameters
jp2fileThe name of the JP2 file that needs to be decoded.

Definition at line 32 of file JP2Decoder.cpp.

References Kakadu_Error, p_jp2File, and Isis::IException::Programmer.

◆ ~JP2Decoder()

Isis::JP2Decoder::~JP2Decoder ( )

JP2Decoder destructor.

Definition at line 196 of file JP2Decoder.cpp.

References Kakadu_Error.

Member Function Documentation

◆ GetBandDimension()

int Isis::JP2Decoder::GetBandDimension ( ) const
inline

Definition at line 107 of file JP2Decoder.h.

◆ GetLineDimension()

int Isis::JP2Decoder::GetLineDimension ( ) const
inline

Definition at line 102 of file JP2Decoder.h.

◆ GetPixelBytes()

int Isis::JP2Decoder::GetPixelBytes ( ) const
inline

Definition at line 112 of file JP2Decoder.h.

◆ GetSampleDimension()

int Isis::JP2Decoder::GetSampleDimension ( ) const
inline

Definition at line 97 of file JP2Decoder.h.

◆ GetSignedData()

bool Isis::JP2Decoder::GetSignedData ( ) const
inline

Definition at line 117 of file JP2Decoder.h.

◆ IsJP2()

bool Isis::JP2Decoder::IsJP2 ( QString filename)
static

Definition at line 228 of file JP2Decoder.cpp.

◆ kakadu_error()

JP2Error * Isis::JP2Decoder::kakadu_error ( ) const
inline

Definition at line 89 of file JP2Decoder.h.

◆ OpenFile()

void Isis::JP2Decoder::OpenFile ( )

Open the JPEG2000 file.

Definition at line 52 of file JP2Decoder.cpp.

References p_jp2File, p_numBands, p_pixelBytes, p_signedData, SetResolutionAndRegion(), and Isis::IException::User.

Referenced by Isis::JP2Importer::JP2Importer().

◆ Read() [1/2]

void Isis::JP2Decoder::Read ( short int ** inbuf)

Read data from JP2 file containing 16-bit data.

Parameters
inbufThe array of pointers to byte buffers that will be used to read in the image data. One byte buffer is required for each band in the image. Kakadu reads in a BIL manner. It is up to the calling routine to do the casting necessary to convert the byte data to the actual pixel type (UnsignedByte, UnsignedWord, SignedWord).

Definition at line 185 of file JP2Decoder.cpp.

◆ Read() [2/2]

void Isis::JP2Decoder::Read ( unsigned char ** inbuf)

Read data from JP2 file containing 8-bit data.

Parameters
inbufThe array of pointers to byte buffers that will be used to read in the image data. One byte buffer is required for each band in the image. Kakadu reads in a BIL manner. It is up to the calling routine to do the casting necessary to convert the byte data to the actual pixel type (UnsignedByte, UnsignedWord, SignedWord).

Definition at line 168 of file JP2Decoder.cpp.

Referenced by Isis::JP2Importer::updateRawBuffer().

◆ SetResolutionAndRegion()

void Isis::JP2Decoder::SetResolutionAndRegion ( )
private

Sets resolution of data that will be decompressed. Also determines the image dimensions at the requested resolution.

Set resolution level of the JPEG2000 file.

This class is currently set up to only read a file at full resolution.

Definition at line 145 of file JP2Decoder.cpp.

References p_numLines, and p_numSamples.

Referenced by OpenFile().

Member Data Documentation

◆ Kakadu_Error

JP2Error* Isis::JP2Decoder::Kakadu_Error
private

JP2 Error handling facility.

Definition at line 162 of file JP2Decoder.h.

Referenced by JP2Decoder(), and ~JP2Decoder().

◆ p_jp2File

QString Isis::JP2Decoder::p_jp2File
private

Input file name.

Definition at line 130 of file JP2Decoder.h.

Referenced by JP2Decoder(), and OpenFile().

◆ p_numBands

unsigned int Isis::JP2Decoder::p_numBands
private

Number of bands in JP2 file.

Definition at line 133 of file JP2Decoder.h.

Referenced by OpenFile().

◆ p_numLines

unsigned int Isis::JP2Decoder::p_numLines
private

Number of lines in JP2 file.

Definition at line 132 of file JP2Decoder.h.

Referenced by SetResolutionAndRegion().

◆ p_numSamples

unsigned int Isis::JP2Decoder::p_numSamples
private

Number of samples in JP2 file.

Definition at line 131 of file JP2Decoder.h.

Referenced by SetResolutionAndRegion().

◆ p_pixelBytes

unsigned int Isis::JP2Decoder::p_pixelBytes
private

Number of bytes per pixel in JP2 file.

Definition at line 134 of file JP2Decoder.h.

Referenced by OpenFile().

◆ p_signedData

bool Isis::JP2Decoder::p_signedData
private

Set to true if data in JP2 file is signed.

Definition at line 135 of file JP2Decoder.h.

Referenced by OpenFile().


The documentation for this class was generated from the following files: