Isis 3 Programmer Reference
|
Imports JPEG 2000 images as Isis cubes. More...
#include <JP2Importer.h>
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. | |
Cube * | import (FileName outputName) |
Import the image with default output attributes. | |
Cube * | import (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 ImageImporter * | fromFileName (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). | |
Cube * | createOutput (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. | |
Private Attributes | |
JP2Decoder * | m_decoder |
Takes a raw stream of JPEG 2000 data and reads it into a buffer. | |
char ** | m_buffer |
Buffer that stores a line of JPEG 2000 data and all its color bands. | |
Isis::PixelType | m_pixelType |
Pixel type of the input image needed for reading data into the buffer. | |
FileName * | m_inputName |
The filename of the input image. | |
Cube * | m_outCube |
The owned handle on the output cube to be imported to. | |
int | m_samples |
The number of samples to be written to the output. | |
int | m_lines |
The number of lines to be written to the output. | |
int | m_bands |
The number of bands to be written to the output. | |
double | m_nullMin |
The lower bound of the range within which input DNs will be made Null. | |
double | m_nullMax |
The upper bound of the range within which input DNs will be made Null. | |
double | m_lrsMin |
The lower bound of the range within which input DNs will be made LRS. | |
double | m_lrsMax |
The upper bound of the range within which input DNs will be made LRS. | |
double | m_hrsMin |
The lower bound of the range within which input DNs will be made HRS. | |
double | m_hrsMax |
The upper bound of the range within which input DNs will be made HRS. | |
Imports JPEG 2000 images as Isis cubes.
Takes a JPEG 2000 input image and imports it into Isis in the cube format.
Definition at line 30 of file JP2Importer.h.
|
protectedinherited |
Friendly alias for a method used to get a particular color channel.
Definition at line 97 of file ImageImporter.h.
Isis::JP2Importer::JP2Importer | ( | FileName | inputName | ) |
Construct the importer.
inputName | The name of the input image |
Definition at line 23 of file JP2Importer.cpp.
References Isis::ImageImporter::bands(), Isis::ImageImporter::filename(), m_buffer, m_decoder, m_pixelType, Isis::JP2Decoder::OpenFile(), Isis::IException::Programmer, Isis::ImageImporter::samples(), Isis::ImageImporter::setBands(), Isis::ImageImporter::setLines(), Isis::ImageImporter::setSamples(), Isis::SizeOf(), and Isis::IException::User.
|
virtual |
Destruct the importer.
Definition at line 68 of file JP2Importer.cpp.
|
inherited |
The band dimension (depth) of the output image.
Definition at line 298 of file ImageImporter.cpp.
References Isis::ImageImporter::m_bands.
Referenced by Isis::ImageImporter::createOutput(), Isis::ImageImporter::getBandChannel(), Isis::ImageImporter::import(), and JP2Importer().
|
virtualinherited |
Pure virtual method for converting projection information in the file being imported to an ISIS Mapping group.
Reimplemented in Isis::TiffImporter.
Definition at line 66 of file ImageImporter.cpp.
Referenced by Isis::ImageImporter::import().
|
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
pixel | The pixel value to be broken up into RGB components and converted to grayscale |
Definition at line 399 of file ImageImporter.cpp.
References Isis::ImageImporter::getBlue(), Isis::ImageImporter::getGreen(), and Isis::ImageImporter::getRed().
Referenced by getGray(), and Isis::TiffImporter::getGray().
|
protectedinherited |
Create the output cube from the given filename and attributes.
Set its dimensions based on those encapsulated by the importer.
outputName | The filename of the output cube |
att | The attributes for writing the output cube |
Definition at line 179 of file ImageImporter.cpp.
References Isis::ImageImporter::bands(), Isis::Cube::create(), Isis::ImageImporter::lines(), Isis::ImageImporter::m_outCube, Isis::ImageImporter::samples(), and Isis::Cube::setDimensions().
Referenced by Isis::ImageImporter::import().
|
inherited |
The filename of the input image this instance was constructed with.
Definition at line 308 of file ImageImporter.cpp.
References Isis::ImageImporter::m_inputName.
Referenced by JP2Importer().
|
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.
inputName | The filename of the input image to be imported |
Definition at line 420 of file ImageImporter.cpp.
References Isis::IException::Programmer.
|
protectedvirtual |
Retrieves the alpha component of the given pixel from the fourth band of the input buffer.
pixel | Index into the line buffer corresponding to a sample |
Implements Isis::ImageImporter.
Definition at line 210 of file JP2Importer.cpp.
References getFromBuffer().
|
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.
band | The current band of the output image |
Definition at line 354 of file ImageImporter.cpp.
References 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()().
|
protectedvirtual |
Retrieves the blue component of the given pixel from the third band of the input buffer.
pixel | Index into the line buffer corresponding to a sample |
Implements Isis::ImageImporter.
Definition at line 197 of file JP2Importer.cpp.
References getFromBuffer().
|
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.
s | Index into the line buffer corresponding to a sample |
b | Index into the line buffer corresponding to a band |
Definition at line 225 of file JP2Importer.cpp.
References m_buffer, m_pixelType, and Isis::IException::Programmer.
Referenced by getAlpha(), getBlue(), getGray(), getGreen(), and getRed().
|
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.
pixel | Index into the line buffer corresponding to a sample |
Implements Isis::ImageImporter.
Definition at line 158 of file JP2Importer.cpp.
References Isis::ImageImporter::convertRgbToGray(), getFromBuffer(), and isGrayscale().
|
protectedvirtual |
Retrieves the green component of the given pixel from the second band of the input buffer.
pixel | Index into the line buffer corresponding to a sample |
Implements Isis::ImageImporter.
Definition at line 184 of file JP2Importer.cpp.
References getFromBuffer().
|
protectedvirtual |
Returns a representation of a pixel for the input format that can then be broken down into specific gray or RGB/A components.
s | The sample of the desired pixel |
l | The line of the desired pixel |
Implements Isis::ImageImporter.
Definition at line 144 of file JP2Importer.cpp.
|
protectedvirtual |
Retrieves the red component of the given pixel from the first band of the input buffer.
pixel | Index into the line buffer corresponding to a sample |
Implements Isis::ImageImporter.
Definition at line 171 of file JP2Importer.cpp.
References getFromBuffer().
Import the image with default output attributes.
outputName | The filename of the output cube |
Definition at line 108 of file ImageImporter.cpp.
|
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.
outputName | The filename of the output cube |
att | The attributes for writing the output cube |
Definition at line 129 of file ImageImporter.cpp.
References Isis::ImageImporter::bands(), Isis::ImageImporter::convertProjection(), Isis::ImageImporter::createOutput(), Isis::PvlObject::findObject(), Isis::Cube::label(), and Isis::IException::Programmer.
|
virtual |
Tests to see if the input image is quadruple-banded, implying RGBA.
Implements Isis::ImageImporter.
Definition at line 103 of file JP2Importer.cpp.
References m_decoder.
|
virtual |
Tests to see if the input image is single-banded, implying grayscale (no RGB/A).
Implements Isis::ImageImporter.
Definition at line 83 of file JP2Importer.cpp.
References m_decoder.
Referenced by getGray().
|
virtual |
Tests to see if the input image is triple-banded, implying RGB (no alpha).
Implements Isis::ImageImporter.
Definition at line 93 of file JP2Importer.cpp.
References m_decoder.
|
inherited |
The line dimension (height) of the output image.
Definition at line 288 of file ImageImporter.cpp.
References Isis::ImageImporter::m_lines.
Referenced by Isis::ImageImporter::createOutput(), Isis::TiffImporter::getPixel(), and Isis::TiffImporter::TiffImporter().
|
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.
out | A reference to a line of output data to be written to |
Definition at line 84 of file ImageImporter.cpp.
References Isis::ImageImporter::getBandChannel(), Isis::ImageImporter::getPixel(), Isis::ImageImporter::testSpecial(), and Isis::ImageImporter::updateRawBuffer().
|
inherited |
The sample dimension (width) of the output image.
Definition at line 278 of file ImageImporter.cpp.
References Isis::ImageImporter::m_samples.
Referenced by Isis::ImageImporter::createOutput(), Isis::TiffImporter::getPixel(), JP2Importer(), and Isis::TiffImporter::TiffImporter().
|
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.
b | The new band dimension |
Definition at line 263 of file ImageImporter.cpp.
References Isis::ImageImporter::m_bands, and Isis::IException::Programmer.
Referenced by JP2Importer(), and 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.
Definition at line 192 of file ImageImporter.cpp.
References Isis::ImageImporter::isArgb(), Isis::ImageImporter::isGrayscale(), and Isis::ImageImporter::setBands().
Referenced by Isis::QtImporter::QtImporter(), and Isis::TiffImporter::TiffImporter().
|
inherited |
Set the range of DN values within which a pixel from the input image will be set to HRS in the output.
min | Any DN less than this value will not be set to HRS. |
max | Any DN greater than this value will not be set to HRS. |
Definition at line 230 of file ImageImporter.cpp.
References Isis::ImageImporter::m_hrsMax, and Isis::ImageImporter::m_hrsMin.
|
inherited |
Set the line dimension (height) of the output image.
l | The new line dimension |
Definition at line 251 of file ImageImporter.cpp.
References Isis::ImageImporter::m_lines.
Referenced by JP2Importer(), Isis::QtImporter::QtImporter(), and Isis::TiffImporter::TiffImporter().
|
inherited |
Set the range of DN values within which a pixel from the input image will be set to LRS in the output.
min | Any DN less than this value will not be set to LRS. |
max | Any DN greater than this value will not be set to LRS. |
Definition at line 217 of file ImageImporter.cpp.
References Isis::ImageImporter::m_lrsMax, and Isis::ImageImporter::m_lrsMin.
|
inherited |
Set the range of DN values within which a pixel from the input image will be set to Null in the output.
min | Any DN less than this value will not be set to Null. |
max | Any DN greater than this value will not be set to Null. |
Definition at line 204 of file ImageImporter.cpp.
References Isis::ImageImporter::m_nullMax, and Isis::ImageImporter::m_nullMin.
|
inherited |
Set the sample dimension (width) of the output image.
s | The new sample dimension |
Definition at line 241 of file ImageImporter.cpp.
References Isis::ImageImporter::m_samples.
Referenced by JP2Importer(), Isis::QtImporter::QtImporter(), and Isis::TiffImporter::TiffImporter().
|
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.
pixel | The DN value to be tested |
Definition at line 325 of file ImageImporter.cpp.
References Isis::ImageImporter::m_hrsMin, Isis::ImageImporter::m_lrsMin, and Isis::ImageImporter::m_nullMin.
Referenced by Isis::ImageImporter::operator()().
|
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.
line | Current line of the output buffer |
band | Current band of the output buffer |
Implements Isis::ImageImporter.
Definition at line 116 of file JP2Importer.cpp.
References m_buffer, m_decoder, m_pixelType, and Isis::JP2Decoder::Read().
|
privateinherited |
The number of bands to be written to the output.
Definition at line 193 of file ImageImporter.h.
Referenced by Isis::ImageImporter::bands(), and Isis::ImageImporter::setBands().
|
private |
Buffer that stores a line of JPEG 2000 data and all its color bands.
Definition at line 56 of file JP2Importer.h.
Referenced by getFromBuffer(), JP2Importer(), updateRawBuffer(), and ~JP2Importer().
|
private |
Takes a raw stream of JPEG 2000 data and reads it into a buffer.
Definition at line 53 of file JP2Importer.h.
Referenced by isArgb(), isGrayscale(), isRgb(), JP2Importer(), updateRawBuffer(), and ~JP2Importer().
|
privateinherited |
The upper bound of the range within which input DNs will be made HRS.
Definition at line 211 of file ImageImporter.h.
Referenced by Isis::ImageImporter::ImageImporter(), and Isis::ImageImporter::setHrsRange().
|
privateinherited |
The lower bound of the range within which input DNs will be made HRS.
Definition at line 208 of file ImageImporter.h.
Referenced by Isis::ImageImporter::ImageImporter(), Isis::ImageImporter::setHrsRange(), and Isis::ImageImporter::testSpecial().
|
privateinherited |
The filename of the input image.
Definition at line 181 of file ImageImporter.h.
Referenced by Isis::ImageImporter::filename(), Isis::ImageImporter::ImageImporter(), and Isis::ImageImporter::~ImageImporter().
|
privateinherited |
The number of lines to be written to the output.
Definition at line 190 of file ImageImporter.h.
Referenced by Isis::ImageImporter::lines(), and Isis::ImageImporter::setLines().
|
privateinherited |
The upper bound of the range within which input DNs will be made LRS.
Definition at line 205 of file ImageImporter.h.
Referenced by Isis::ImageImporter::ImageImporter(), and Isis::ImageImporter::setLrsRange().
|
privateinherited |
The lower bound of the range within which input DNs will be made LRS.
Definition at line 202 of file ImageImporter.h.
Referenced by Isis::ImageImporter::ImageImporter(), Isis::ImageImporter::setLrsRange(), and Isis::ImageImporter::testSpecial().
|
privateinherited |
The upper bound of the range within which input DNs will be made Null.
Definition at line 199 of file ImageImporter.h.
Referenced by Isis::ImageImporter::ImageImporter(), and Isis::ImageImporter::setNullRange().
|
privateinherited |
The lower bound of the range within which input DNs will be made Null.
Definition at line 196 of file ImageImporter.h.
Referenced by Isis::ImageImporter::ImageImporter(), Isis::ImageImporter::setNullRange(), and Isis::ImageImporter::testSpecial().
|
privateinherited |
The owned handle on the output cube to be imported to.
Definition at line 184 of file ImageImporter.h.
Referenced by Isis::ImageImporter::createOutput(), Isis::ImageImporter::ImageImporter(), and Isis::ImageImporter::~ImageImporter().
|
private |
Pixel type of the input image needed for reading data into the buffer.
Definition at line 59 of file JP2Importer.h.
Referenced by getFromBuffer(), JP2Importer(), and updateRawBuffer().
|
privateinherited |
The number of samples to be written to the output.
Definition at line 187 of file ImageImporter.h.
Referenced by Isis::ImageImporter::samples(), and Isis::ImageImporter::setSamples().