Isis Developer Reference
Isis::JP2Importer Class Reference

Imports JPEG 2000 images as Isis cubes. More...

#include <JP2Importer.h>

Inheritance diagram for Isis::JP2Importer:
Inheritance graph
Collaboration diagram for Isis::JP2Importer:
Collaboration graph

Public Member Functions

 JP2Importer (FileName inputName)
 Construct the importer.
 
virtual ~JP2Importer ()
 Destruct the importer.
 
virtual bool isGrayscale () const
 Tests to see if the input image is single-banded, implying grayscale (no RGB/A).
 
virtual bool isRgb () const
 Tests to see if the input image is triple-banded, implying RGB (no alpha).
 
virtual bool isArgb () const
 Tests to see if the input image is quadruple-banded, implying RGBA.
 
void operator() (Buffer &out) const
 The method for processing the output cube in place, called for each line of the output image.
 
Cubeimport (FileName outputName)
 Import the image with default output attributes.
 
Cubeimport (FileName outputName, CubeAttributeOutput &att)
 Import the input image this instance was constructed with into the given output Isis cube with the given output attributes.
 
void setNullRange (double min, double max)
 Set the range of DN values within which a pixel from the input image will be set to Null in the output.
 
void setLrsRange (double min, double max)
 Set the range of DN values within which a pixel from the input image will be set to LRS in the output.
 
void setHrsRange (double min, double max)
 Set the range of DN values within which a pixel from the input image will be set to HRS in the output.
 
void setSamples (int s)
 Set the sample dimension (width) of the output image.
 
void setLines (int l)
 Set the line dimension (height) of the output image.
 
void setBands (int b)
 Set the band dimension (depth) of the output image.
 
int samples () const
 The sample dimension (width) of the output image.
 
int lines () const
 The line dimension (height) of the output image.
 
int bands () const
 The band dimension (depth) of the output image.
 
FileName filename () const
 The filename of the input image this instance was constructed with.
 
virtual PvlGroup convertProjection () const
 Pure virtual method for converting projection information in the file being imported to an ISIS Mapping group.
 

Static Public Member Functions

static ImageImporterfromFileName (FileName inputName)
 A static (factory) method for constructing an ImageImporter instance from an input filename.
 

Protected Types

typedef int(ImageImporter::* GetChannelMethod) (int pixel) const
 Friendly alias for a method used to get a particular color channel.
 

Protected Member Functions

virtual void updateRawBuffer (int line, int band) const
 Updates the buffer used to store chunks of the input data at a time.
 
virtual int getPixel (int s, int l) const
 Returns a representation of a pixel for the input format that can then be broken down into specific gray or RGB/A components.
 
virtual int getGray (int pixel) const
 Retrieves the gray component of the given pixel.
 
virtual int getRed (int pixel) const
 Retrieves the red component of the given pixel from the first band of the input buffer.
 
virtual int getGreen (int pixel) const
 Retrieves the green component of the given pixel from the second band of the input buffer.
 
virtual int getBlue (int pixel) const
 Retrieves the blue component of the given pixel from the third band of the input buffer.
 
virtual int getAlpha (int pixel) const
 Retrieves the alpha component of the given pixel from the fourth band of the input buffer.
 
int getFromBuffer (int s, int b) const
 Retrieves the pixel value from the input buffer corresponding to the given sample and band (the buffer contains an entire line).
 
CubecreateOutput (FileName outputName, CubeAttributeOutput &att)
 Create the output cube from the given filename and attributes.
 
void setDefaultBands ()
 Set the number of bands to be created for the output cube based on the number of color channels in the input image.
 
double testSpecial (double pixel) const
 Tests a pixel against the Null, HRS, and LRS ranges defined by the importer's handler.
 
virtual GetChannelMethod getBandChannel (int band) const
 Retrieve the method responsible for fetching the color channel from the input image corresponding to the current band out of output being filled.
 
virtual int convertRgbToGray (int pixel) const
 Convert the current pixel, taken from an RGB/A image, and blend its RGB components into a single grayscale DN.
 

Detailed Description

Imports JPEG 2000 images as Isis cubes.

Takes a JPEG 2000 input image and imports it into Isis in the cube format.

Author
2012-03-16 Travis Addair

Member Typedef Documentation

◆ GetChannelMethod

typedef int(ImageImporter::* Isis::ImageImporter::GetChannelMethod) (int pixel) const
protectedinherited

Friendly alias for a method used to get a particular color channel.

Constructor & Destructor Documentation

◆ JP2Importer()

◆ ~JP2Importer()

Isis::JP2Importer::~JP2Importer ( )
virtual

Destruct the importer.

Member Function Documentation

◆ bands()

int Isis::ImageImporter::bands ( ) const
inherited

The band dimension (depth) of the output image.

Returns
The band dimension

Referenced by Isis::ImageImporter::createOutput(), Isis::ImageImporter::getBandChannel(), Isis::ImageImporter::import(), and JP2Importer().

◆ convertProjection()

PvlGroup Isis::ImageImporter::convertProjection ( ) const
virtualinherited

Pure virtual method for converting projection information in the file being imported to an ISIS Mapping group.

Returns
An ISIS Mapping group

Reimplemented in Isis::TiffImporter.

Referenced by Isis::ImageImporter::import().

◆ convertRgbToGray()

int Isis::ImageImporter::convertRgbToGray ( int pixel) const
protectedvirtualinherited

Convert the current pixel, taken from an RGB/A image, and blend its RGB components into a single grayscale DN.

The three color components are weighted by the following formula:

gray = (red * 11 + green * 16 + blue * 5) / 32

This formula was taken from the Qt documentation on converting an RGB value to grayscale: http://qt-project.org/doc/qt-4.8/qcolor.html#qGray-2

Parameters
pixelThe pixel value to be broken up into RGB components and converted to grayscale
Returns
The grayscale DN value

References Isis::ImageImporter::getBlue(), Isis::ImageImporter::getGreen(), and Isis::ImageImporter::getRed().

Referenced by getGray(), and Isis::TiffImporter::getGray().

◆ createOutput()

Cube * Isis::ImageImporter::createOutput ( FileName outputName,
CubeAttributeOutput & att )
protectedinherited

Create the output cube from the given filename and attributes.

Set its dimensions based on those encapsulated by the importer.

Parameters
outputNameThe filename of the output cube
attThe attributes for writing the output cube
Returns
The newly created cube handle devoid of any data

References Isis::ImageImporter::bands(), Isis::Cube::create(), Isis::ImageImporter::lines(), Isis::ImageImporter::samples(), and Isis::Cube::setDimensions().

Referenced by Isis::ImageImporter::import().

◆ filename()

FileName Isis::ImageImporter::filename ( ) const
inherited

The filename of the input image this instance was constructed with.

Returns
A copy of the input filename

Referenced by JP2Importer().

◆ fromFileName()

ImageImporter * Isis::ImageImporter::fromFileName ( FileName inputName)
staticinherited

A static (factory) method for constructing an ImageImporter instance from an input filename.

The specific subclass of the returned instance is determined from the interpreted image format of the input image. Such tests are done by reading a minimal amount of the input data necessary to determine the format. It is the caller's responsibility to delete the importer instance when they are finished with it. Note that deleting the importer will also delete the cube handle returned by the import() method.

Parameters
inputNameThe filename of the input image to be imported
Returns
A pointer to the instantiated importer owned by the caller

References _FILEINFO_, Isis::JP2Decoder::IsJP2(), and Isis::IException::Programmer.

◆ getAlpha()

int Isis::JP2Importer::getAlpha ( int pixel) const
protectedvirtual

Retrieves the alpha component of the given pixel from the fourth band of the input buffer.

Parameters
pixelIndex into the line buffer corresponding to a sample
Returns
The alpha component

Implements Isis::ImageImporter.

References getFromBuffer().

◆ getBandChannel()

ImageImporter::GetChannelMethod Isis::ImageImporter::getBandChannel ( int band) const
protectedvirtualinherited

Retrieve the method responsible for fetching the color channel from the input image corresponding to the current band out of output being filled.

This will always be the getGray() method for single band output images. For RGB/A images, band 1 will be red, band 2 green, band 3 blue, and band 4 alpha.

Parameters
bandThe current band of the output image
Returns
The method that converts input pixels into the current band's color component

References _FILEINFO_, Isis::ImageImporter::bands(), Isis::ImageImporter::getAlpha(), Isis::ImageImporter::getBlue(), Isis::ImageImporter::getGray(), Isis::ImageImporter::getGreen(), Isis::ImageImporter::getRed(), and Isis::IException::Programmer.

Referenced by Isis::ImageImporter::operator()().

◆ getBlue()

int Isis::JP2Importer::getBlue ( int pixel) const
protectedvirtual

Retrieves the blue component of the given pixel from the third band of the input buffer.

Parameters
pixelIndex into the line buffer corresponding to a sample
Returns
The blue component

Implements Isis::ImageImporter.

References getFromBuffer().

◆ getFromBuffer()

int Isis::JP2Importer::getFromBuffer ( int s,
int b ) const
protected

Retrieves the pixel value from the input buffer corresponding to the given sample and band (the buffer contains an entire line).

Dependent upon the pixel type of the input data.

Parameters
sIndex into the line buffer corresponding to a sample
bIndex into the line buffer corresponding to a band
Returns
The pixel value of the given component

References _FILEINFO_, Isis::IException::Programmer, Isis::SignedWord, Isis::UnsignedByte, and Isis::UnsignedWord.

Referenced by getAlpha(), getBlue(), getGray(), getGreen(), and getRed().

◆ getGray()

int Isis::JP2Importer::getGray ( int pixel) const
protectedvirtual

Retrieves the gray component of the given pixel.

For grayscale images, simply returns the value in the single band. For RGB/A, converts the RGB components into grayscale.

Parameters
pixelIndex into the line buffer corresponding to a sample
Returns
The gray component

Implements Isis::ImageImporter.

References Isis::ImageImporter::convertRgbToGray(), getFromBuffer(), and isGrayscale().

◆ getGreen()

int Isis::JP2Importer::getGreen ( int pixel) const
protectedvirtual

Retrieves the green component of the given pixel from the second band of the input buffer.

Parameters
pixelIndex into the line buffer corresponding to a sample
Returns
The green component

Implements Isis::ImageImporter.

References getFromBuffer().

◆ getPixel()

int Isis::JP2Importer::getPixel ( int s,
int l ) const
protectedvirtual

Returns a representation of a pixel for the input format that can then be broken down into specific gray or RGB/A components.

Parameters
sThe sample of the desired pixel
lThe line of the desired pixel
Returns
The current sample, used as an index into the data buffer

Implements Isis::ImageImporter.

◆ getRed()

int Isis::JP2Importer::getRed ( int pixel) const
protectedvirtual

Retrieves the red component of the given pixel from the first band of the input buffer.

Parameters
pixelIndex into the line buffer corresponding to a sample
Returns
The red component

Implements Isis::ImageImporter.

References getFromBuffer().

◆ import() [1/2]

Cube * Isis::ImageImporter::import ( FileName outputName)
inherited

Import the image with default output attributes.

Parameters
outputNameThe filename of the output cube

◆ import() [2/2]

Cube * Isis::ImageImporter::import ( FileName outputName,
CubeAttributeOutput & att )
inherited

Import the input image this instance was constructed with into the given output Isis cube with the given output attributes.

This will do a black-box import using a ProcessByLine routine. The BandBin group will be updated in the output cube with the names of the color channels included. The output cube will be returned on completion of the import process so the caller can continue to modify the labels. The importer instance will retain ownership of this cube, such that the cube handle will be deallocated upon destruction of the importer.

Parameters
outputNameThe filename of the output cube
attThe attributes for writing the output cube
Returns
A handle on the newly imported Isis cube owned by the importer

References _FILEINFO_, Isis::ImageImporter::bands(), Isis::ProcessByBrick::BandsFirst, Isis::ImageImporter::convertProjection(), Isis::ImageImporter::createOutput(), Isis::PvlObject::findObject(), Isis::Cube::label(), and Isis::IException::Programmer.

◆ isArgb()

bool Isis::JP2Importer::isArgb ( ) const
virtual

Tests to see if the input image is quadruple-banded, implying RGBA.

Returns
True if the image is RGBA, false otherwise

Implements Isis::ImageImporter.

References Isis::JP2Decoder::GetBandDimension().

◆ isGrayscale()

bool Isis::JP2Importer::isGrayscale ( ) const
virtual

Tests to see if the input image is single-banded, implying grayscale (no RGB/A).

Returns
True if the image is grayscale, false otherwise

Implements Isis::ImageImporter.

References Isis::JP2Decoder::GetBandDimension().

Referenced by getGray().

◆ isRgb()

bool Isis::JP2Importer::isRgb ( ) const
virtual

Tests to see if the input image is triple-banded, implying RGB (no alpha).

Returns
True if the image is RGB, false otherwise

Implements Isis::ImageImporter.

References Isis::JP2Decoder::GetBandDimension().

◆ lines()

int Isis::ImageImporter::lines ( ) const
inherited

The line dimension (height) of the output image.

Returns
The line dimension

Referenced by Isis::ImageImporter::createOutput(), Isis::TiffImporter::getPixel(), and Isis::TiffImporter::TiffImporter().

◆ operator()()

void Isis::ImageImporter::operator() ( Buffer & out) const
inherited

The method for processing the output cube in place, called for each line of the output image.

Enables the importer to be used as a functor in a custom ProcessByLine routine, bypassing the black-box import() method entirely. Care should be taken, however, to observe the requirements placed on the structure of such a processing routine by this method. For example, the JP2Importer child requires that the processing proceed in the direction of bands before lines, because its input data is structured in a BIL (band interlaced by line) format.

Parameters
outA reference to a line of output data to be written to

References Isis::ImageImporter::getBandChannel(), Isis::ImageImporter::getPixel(), Isis::ImageImporter::testSpecial(), and Isis::ImageImporter::updateRawBuffer().

◆ samples()

int Isis::ImageImporter::samples ( ) const
inherited

The sample dimension (width) of the output image.

Returns
The sample dimension

Referenced by Isis::ImageImporter::createOutput(), Isis::TiffImporter::getPixel(), JP2Importer(), and Isis::TiffImporter::TiffImporter().

◆ setBands()

void Isis::ImageImporter::setBands ( int b)
inherited

Set the band dimension (depth) of the output image.

Because this importer only works on Grayscale, RGB, and RGBA images, possible values are 1, 3, and 4 for the respective color modes.

Parameters
bThe new band dimension

References _FILEINFO_, and Isis::IException::Programmer.

Referenced by JP2Importer(), and Isis::ImageImporter::setDefaultBands().

◆ setDefaultBands()

void Isis::ImageImporter::setDefaultBands ( )
protectedinherited

Set the number of bands to be created for the output cube based on the number of color channels in the input image.

References Isis::ImageImporter::isArgb(), Isis::ImageImporter::isGrayscale(), and Isis::ImageImporter::setBands().

Referenced by Isis::QtImporter::QtImporter(), and Isis::TiffImporter::TiffImporter().

◆ setHrsRange()

void Isis::ImageImporter::setHrsRange ( double min,
double max )
inherited

Set the range of DN values within which a pixel from the input image will be set to HRS in the output.

Parameters
minAny DN less than this value will not be set to HRS.
maxAny DN greater than this value will not be set to HRS.

◆ setLines()

void Isis::ImageImporter::setLines ( int l)
inherited

Set the line dimension (height) of the output image.

Parameters
lThe new line dimension

Referenced by JP2Importer(), Isis::QtImporter::QtImporter(), and Isis::TiffImporter::TiffImporter().

◆ setLrsRange()

void Isis::ImageImporter::setLrsRange ( double min,
double max )
inherited

Set the range of DN values within which a pixel from the input image will be set to LRS in the output.

Parameters
minAny DN less than this value will not be set to LRS.
maxAny DN greater than this value will not be set to LRS.

◆ setNullRange()

void Isis::ImageImporter::setNullRange ( double min,
double max )
inherited

Set the range of DN values within which a pixel from the input image will be set to Null in the output.

Parameters
minAny DN less than this value will not be set to Null.
maxAny DN greater than this value will not be set to Null.

◆ setSamples()

void Isis::ImageImporter::setSamples ( int s)
inherited

Set the sample dimension (width) of the output image.

Parameters
sThe new sample dimension

Referenced by JP2Importer(), Isis::QtImporter::QtImporter(), and Isis::TiffImporter::TiffImporter().

◆ testSpecial()

double Isis::ImageImporter::testSpecial ( double pixel) const
protectedinherited

Tests a pixel against the Null, HRS, and LRS ranges defined by the importer's handler.

Any pixel value falling within one of these ranges will be converted into the given type of special pixel. In case of overlapping ranges, these tests will be performed in the order mentioned at the start of this description. By default, these ranges are set such that all incoming pixels will retain their original values.

Parameters
pixelThe DN value to be tested
Returns
The valid DN or special pixel if it fell within the special ranges

References Isis::HIGH_REPR_SAT8, Isis::LOW_REPR_SAT8, and Isis::NULL8.

Referenced by Isis::ImageImporter::operator()().

◆ updateRawBuffer()

void Isis::JP2Importer::updateRawBuffer ( int line,
int band ) const
protectedvirtual

Updates the buffer used to store chunks of the input data at a time.

Reads a single line of data from the input with all its color channels. Uses the pixel type to determine the size of each pixel value to read in.

Parameters
lineCurrent line of the output buffer
bandCurrent band of the output buffer

Implements Isis::ImageImporter.

References Isis::JP2Decoder::Read(), and Isis::UnsignedByte.


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