USGS

Isis 3.0 Object Programmers' Reference

Home

Isis::ImageImporter Class Referenceabstract

Imports images with standard formats into Isis as cubes. More...

#include <ImageImporter.h>

Inheritance diagram for Isis::ImageImporter:
Inheritance graph
Collaboration diagram for Isis::ImageImporter:
Collaboration graph

Public Member Functions

 ImageImporter (FileName inputName)
 Construct the importer.
 
virtual ~ImageImporter ()
 Destruct the importer.
 
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.
 
virtual bool isGrayscale () const =0
 Pure virtual method for returning true if the image is grayscale.
 
virtual bool isRgb () const =0
 Pure virtual method for returning true if the image is RGB (no alpha).
 
virtual bool isArgb () const =0
 Pure virtual method for returning true if the image is RGBA.
 

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

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.
 
virtual void updateRawBuffer (int line, int band) const =0
 Pure virtual method that updates the buffer used to store chunks of the input data at a time.
 
virtual int getPixel (int s, int l) const =0
 Pure virtual method that 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 =0
 Pure virtual method for retrieving the gray component of the given pixel.
 
virtual int getRed (int pixel) const =0
 Pure virtual method for retrieving the red component of the given pixel.
 
virtual int getGreen (int pixel) const =0
 Pure virtual method for retrieving the green component of the given pixel.
 
virtual int getBlue (int pixel) const =0
 Pure virtual method for retrieving the blue component of the given pixel.
 
virtual int getAlpha (int pixel) const =0
 Pure virtual method for retrieving the alpha component of the given pixel.
 

Private Attributes

FileNamem_inputName
 The filename of the input image.
 
Cubem_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.
 

Detailed Description

Imports images with standard formats into Isis as cubes.

Abstract base class for a series of image importers. Each importer handles a specialized suite of standard image formats, and can be used as a black-box with the import() method, or for finer control, the importer can act as a functor in a ProcessByLine routine.

Author
2012-03-16 Travis Addair
History:

2012-03-28 Travis Addair - Added documentation.

2014-01-17 Kimberly Oyama - Added the history label to the output cube. Fixes #1894.

2014-01-27 Kimberly Oyama - Changed the method of adding the history to the cube from adding it in the import method to using Process' WriteHistory method. References #1894.

Definition at line 55 of file ImageImporter.h.

Member Typedef Documentation

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

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

Definition at line 113 of file ImageImporter.h.

Constructor & Destructor Documentation

Isis::ImageImporter::ImageImporter ( FileName  inputName)

Construct the importer.

Parameters
inputNameThe name of the input image

Definition at line 26 of file ImageImporter.cpp.

Isis::ImageImporter::~ImageImporter ( )
virtual

Destruct the importer.

Also deletes the output cube handle.

Definition at line 45 of file ImageImporter.cpp.

Member Function Documentation

int Isis::ImageImporter::bands ( ) const

The band dimension (depth) of the output image.

Returns
The band dimension

Definition at line 292 of file ImageImporter.cpp.

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

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

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.

Definition at line 60 of file ImageImporter.cpp.

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

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

Definition at line 393 of file ImageImporter.cpp.

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

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

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

Definition at line 173 of file ImageImporter.cpp.

References Isis::Cube::setDimensions().

FileName Isis::ImageImporter::filename ( ) const

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

Returns
A copy of the input filename

Definition at line 302 of file ImageImporter.cpp.

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

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

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

Definition at line 414 of file ImageImporter.cpp.

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

virtual int Isis::ImageImporter::getAlpha ( int  pixel) const
protectedpure virtual

Pure virtual method for retrieving the alpha component of the given pixel.

Parameters
pixelRepresentation of a pixel for the input format
Returns
The alpha component

Implemented in Isis::TiffImporter, Isis::QtImporter, and Isis::JP2Importer.

Referenced by getBandChannel().

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

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

Definition at line 348 of file ImageImporter.cpp.

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

virtual int Isis::ImageImporter::getBlue ( int  pixel) const
protectedpure virtual

Pure virtual method for retrieving the blue component of the given pixel.

Parameters
pixelRepresentation of a pixel for the input format
Returns
The blue component

Implemented in Isis::TiffImporter, Isis::QtImporter, and Isis::JP2Importer.

Referenced by getBandChannel().

virtual int Isis::ImageImporter::getGray ( int  pixel) const
protectedpure virtual

Pure virtual method for retrieving the gray component of the given pixel.

Parameters
pixelRepresentation of a pixel for the input format
Returns
The gray component

Implemented in Isis::TiffImporter, Isis::QtImporter, and Isis::JP2Importer.

Referenced by getBandChannel().

virtual int Isis::ImageImporter::getGreen ( int  pixel) const
protectedpure virtual

Pure virtual method for retrieving the green component of the given pixel.

Parameters
pixelRepresentation of a pixel for the input format
Returns
The green component

Implemented in Isis::TiffImporter, Isis::QtImporter, and Isis::JP2Importer.

Referenced by getBandChannel().

virtual int Isis::ImageImporter::getPixel ( int  s,
int  l 
) const
protectedpure virtual

Pure virtual method that 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 format-specific pixel representation

Implemented in Isis::TiffImporter, Isis::QtImporter, and Isis::JP2Importer.

virtual int Isis::ImageImporter::getRed ( int  pixel) const
protectedpure virtual

Pure virtual method for retrieving the red component of the given pixel.

Parameters
pixelRepresentation of a pixel for the input format
Returns
The red component

Implemented in Isis::TiffImporter, Isis::QtImporter, and Isis::JP2Importer.

Referenced by getBandChannel().

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

Import the image with default output attributes.

Parameters
outputNameThe filename of the output cube

Definition at line 102 of file ImageImporter.cpp.

Cube * Isis::ImageImporter::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.

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

Definition at line 123 of file ImageImporter.cpp.

References _FILEINFO_, Isis::PvlObject::addGroup(), Isis::ProcessByBrick::EndProcess(), Isis::PvlObject::findObject(), Isis::PvlContainer::keywords(), Isis::Cube::label(), Isis::ProcessByLine::ProcessCubeInPlace(), Isis::IException::Programmer, Isis::ProcessByLine::SetInputCube(), Isis::ProcessByBrick::SetProcessingDirection(), and Isis::Process::WriteHistory().

virtual bool Isis::ImageImporter::isArgb ( ) const
pure virtual

Pure virtual method for returning true if the image is RGBA.

Returns
True if the image is RGBA, false otherwise

Implemented in Isis::TiffImporter, Isis::QtImporter, and Isis::JP2Importer.

virtual bool Isis::ImageImporter::isGrayscale ( ) const
pure virtual

Pure virtual method for returning true if the image is grayscale.

Returns
True if the image is grayscale, false otherwise

Implemented in Isis::TiffImporter, Isis::QtImporter, and Isis::JP2Importer.

virtual bool Isis::ImageImporter::isRgb ( ) const
pure virtual

Pure virtual method for returning true if the image is RGB (no alpha).

Returns
True if the image is RGB, false otherwise

Implemented in Isis::TiffImporter, Isis::QtImporter, and Isis::JP2Importer.

int Isis::ImageImporter::lines ( ) const

The line dimension (height) of the output image.

Returns
The line dimension

Definition at line 282 of file ImageImporter.cpp.

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

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

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

Definition at line 78 of file ImageImporter.cpp.

References Isis::Buffer::Band(), Isis::Buffer::Line(), and Isis::Buffer::SampleDimension().

int Isis::ImageImporter::samples ( ) const

The sample dimension (width) of the output image.

Returns
The sample dimension

Definition at line 272 of file ImageImporter.cpp.

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

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

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

Definition at line 257 of file ImageImporter.cpp.

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

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

void Isis::ImageImporter::setDefaultBands ( )
protected

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 186 of file ImageImporter.cpp.

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

void Isis::ImageImporter::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.

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.

Definition at line 224 of file ImageImporter.cpp.

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

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

Parameters
lThe new line dimension

Definition at line 245 of file ImageImporter.cpp.

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

void Isis::ImageImporter::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.

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.

Definition at line 211 of file ImageImporter.cpp.

void Isis::ImageImporter::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.

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.

Definition at line 198 of file ImageImporter.cpp.

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

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

Parameters
sThe new sample dimension

Definition at line 235 of file ImageImporter.cpp.

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

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

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

Definition at line 319 of file ImageImporter.cpp.

virtual void Isis::ImageImporter::updateRawBuffer ( int  line,
int  band 
) const
protectedpure virtual

Pure virtual method that updates the buffer used to store chunks of the input data at a time.

Does nothing for classes that read the entire input image into memory.

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

Implemented in Isis::TiffImporter, Isis::QtImporter, and Isis::JP2Importer.

Member Data Documentation

int Isis::ImageImporter::m_bands
private

The number of bands to be written to the output.

Definition at line 209 of file ImageImporter.h.

double Isis::ImageImporter::m_hrsMax
private

The upper bound of the range within which input DNs will be made HRS.

Definition at line 227 of file ImageImporter.h.

double Isis::ImageImporter::m_hrsMin
private

The lower bound of the range within which input DNs will be made HRS.

Definition at line 224 of file ImageImporter.h.

FileName* Isis::ImageImporter::m_inputName
private

The filename of the input image.

Definition at line 197 of file ImageImporter.h.

int Isis::ImageImporter::m_lines
private

The number of lines to be written to the output.

Definition at line 206 of file ImageImporter.h.

double Isis::ImageImporter::m_lrsMax
private

The upper bound of the range within which input DNs will be made LRS.

Definition at line 221 of file ImageImporter.h.

double Isis::ImageImporter::m_lrsMin
private

The lower bound of the range within which input DNs will be made LRS.

Definition at line 218 of file ImageImporter.h.

double Isis::ImageImporter::m_nullMax
private

The upper bound of the range within which input DNs will be made Null.

Definition at line 215 of file ImageImporter.h.

double Isis::ImageImporter::m_nullMin
private

The lower bound of the range within which input DNs will be made Null.

Definition at line 212 of file ImageImporter.h.

Cube* Isis::ImageImporter::m_outCube
private

The owned handle on the output cube to be imported to.

Definition at line 200 of file ImageImporter.h.

int Isis::ImageImporter::m_samples
private

The number of samples to be written to the output.

Definition at line 203 of file ImageImporter.h.


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