Isis 3 Programmer Reference
Isis::TiffExporter Class Reference

Exports cubes into TIFF images. More...

#include <TiffExporter.h>

Inheritance diagram for Isis::TiffExporter:
Inheritance graph
Collaboration diagram for Isis::TiffExporter:
Collaboration graph

Public Member Functions

 TiffExporter ()
 Construct the TIFF exporter. More...
 
virtual ~TiffExporter ()
 Destruct the exporter. More...
 
virtual void write (FileName outputName, int quality=100, QString compression="none")
 Open the output file for writing, initialize its fields, then let the base ImageExporter handle the generic black-box writing routine. More...
 
virtual void setGrayscale (ExportDescription &desc)
 Generic initialization with the export description. More...
 
virtual void setRgb (ExportDescription &desc)
 Generic initialization with the export description. More...
 
virtual void setRgba (ExportDescription &desc)
 Generic initialization with the export description. More...
 
void operator() (vector< Buffer * > &in) const
 The method for writing a line of input image data (with potentially several bands representing color channels) to the output image. More...
 
int samples () const
 Number of samples (columns) in the output image. More...
 
int lines () const
 Number of lines (rows) in the output image. More...
 
int bands () const
 Number of bands (channels) in the output image. More...
 
double inputMinimum (int channel) const
 Returns the input minimum for the given channel. More...
 
double inputMaximum (int channel) const
 Returns the input maximum for the given channel. More...
 
void setOutputPixelRange (double outputPixelMinimum, double outputPixelMaximum)
 Set the DN floor and ceiling for the exported image. More...
 

Static Public Member Functions

static bool canWriteFormat (QString format)
 Returns true if the format is "tiff". More...
 
static ImageExporterfromFormat (QString format)
 A static (factory) method for constructing an ImageExporter instance from an output format. More...
 

Protected Types

typedef void(ImageExporter::* WriteChannels) (vector< Buffer * > &in) const
 Friendly alias for a method used to write a particular color channel. More...
 

Protected Member Functions

virtual void createBuffer ()
 Creates the buffer to store a chunk of streamed line data with one or more bands. More...
 
virtual void setBuffer (int s, int b, int dn) const
 Set the DN value at the given sample and band, resolved to a single index, of the line buffer. More...
 
virtual void writeLine (int l) const
 Writes a line of buffered data to the output image on disk. More...
 
virtual void initialize (ExportDescription &desc)
 Generic initialization with the export description. More...
 
virtual void writeGrayscale (vector< Buffer * > &in) const
 Write a line of grayscale data to the output image. More...
 
virtual void writeRgb (vector< Buffer * > &in) const
 Write a line of RGB data to the output image. More...
 
virtual void writeRgba (vector< Buffer * > &in) const
 Write a line of RGBA data to the output image. More...
 
void setExtension (QString extension)
 Sets the extension for the output image and generates the extension for the world file from it. More...
 
void setExportDescription (ExportDescription &desc)
 Sets the description for the output image. More...
 
CubeinitializeProcess ()
 Sets up the export process with the parameters described within the given description. More...
 
QString extension () const
 Gets the extension for the output image. More...
 
ExportDescriptionexportDescription () const
 Gets the description for the output image. More...
 
ProcessExportprocess () const
 Get a reference to the process object, useful for subclasses to access and manipulate the process. More...
 
PixelType pixelType () const
 Returns the pixel type. More...
 
virtual int outputPixelValue (double dn) const
 Return the output clamped integer pixel value from the input double-precision DN. More...
 

Private Member Functions

CubeaddChannel (int i)
 Add a channel of input data to the process from the export description at the given index. More...
 
void createWorldFile (FileName outputName)
 Creates a world file is the input has a map projection. More...
 

Private Attributes

TIFF * m_image
 Object responsible for writing data to the output image. More...
 
unsigned char * m_raster
 Array containing all color channels for a line. More...
 
ProcessExportm_process
 The object that feeds lines to this instance and handles stretching. More...
 
WriteChannels m_writeMethod
 Method pointer to one of the pure virtual write methods. More...
 
QString m_extension
 Extension to append to the output image if not already provided. More...
 
QString m_worldExtension
 Extension to append to the output world file. More...
 
int m_samples
 Number of samples (columns) in the output image. More...
 
int m_lines
 Number of lines (rows) in the output image. More...
 
int m_bands
 Number of bands (channels) in the output image. More...
 
double m_outputPixelMinimum
 ! The absolute minimum value for the output pixels. More...
 
double m_outputPixelMaximum
 ! The absolute maximum value for the output pixels. More...
 
ExportDescriptionm_exportDescription
 ! The description for the export. More...
 

Detailed Description

Exports cubes into TIFF images.

A streamed exporter for TIFF images. Can write an arbitrarily large set of single-band Isis cubes to an arbitrarily large TIFF image with the given pixel type.

Author
2012-04-03 Travis Addair
History:
2012-04-04 Travis Addair - Added documentation.
History:
2012-08-28 Steven Lambright - Fixed some problems with memory allocations/deallocations and a flag on the tiff files was not being set, but it was necessary to successfully write out tiff files (TIFFTAG_ROWSPERSTRIP), References #579.
History:
2013-06-05 Jeannie Backer - Removed "get" prefix from ImageExporter method calls. References #1380.
History:
2015-02-10 Jeffrey Covington - Changed default compression to no compression. Added compression parameter to write() method. Fixes #1745.

Definition at line 41 of file TiffExporter.h.

Member Typedef Documentation

◆ WriteChannels

typedef void(ImageExporter::* Isis::ImageExporter::WriteChannels) (vector< Buffer * > &in) const
protectedinherited

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

Definition at line 98 of file ImageExporter.h.

Constructor & Destructor Documentation

◆ TiffExporter()

Isis::TiffExporter::TiffExporter ( )

Construct the TIFF exporter.

Definition at line 23 of file TiffExporter.cpp.

References m_image, m_raster, and Isis::ImageExporter::setExtension().

◆ ~TiffExporter()

Isis::TiffExporter::~TiffExporter ( )
virtual

Destruct the exporter.

Definition at line 34 of file TiffExporter.cpp.

References m_image, and m_raster.

Member Function Documentation

◆ addChannel()

Cube * Isis::ImageExporter::addChannel ( int  i)
privateinherited

Add a channel of input data to the process from the export description at the given index.

Parameters
iIndex of the channel to add within the export description
Returns
A cube pointer to the channel added, owned by the process

Definition at line 346 of file ImageExporter.cpp.

References Isis::ExportDescription::ChannelDescription::attributes(), Isis::FileName::expanded(), Isis::ExportDescription::ChannelDescription::filename(), Isis::ExportDescription::ChannelDescription::hasCustomRange(), Isis::ExportDescription::ChannelDescription::inputMaximum(), Isis::ExportDescription::ChannelDescription::inputMinimum(), Isis::Process::SetInputCube(), and Isis::ProcessExport::SetInputRange().

◆ bands()

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

Number of bands (channels) in the output image.

Returns
The depth of the output

Definition at line 138 of file ImageExporter.cpp.

Referenced by Isis::QtExporter::checkDataSize(), Isis::JP2Exporter::createBuffer(), createBuffer(), setBuffer(), Isis::JP2Exporter::write(), and write().

◆ canWriteFormat()

bool Isis::TiffExporter::canWriteFormat ( QString  format)
static

Returns true if the format is "tiff".

Parameters
formatLowercase format abbreviation
Returns
True if "tiff", false otherwise

Definition at line 169 of file TiffExporter.cpp.

Referenced by Isis::ImageExporter::fromFormat().

◆ createBuffer()

void Isis::TiffExporter::createBuffer ( )
protectedvirtual

Creates the buffer to store a chunk of streamed line data with one or more bands.

Implements Isis::StreamExporter.

Definition at line 49 of file TiffExporter.cpp.

References Isis::ImageExporter::bands(), m_raster, Isis::ImageExporter::pixelType(), Isis::ImageExporter::samples(), and Isis::IException::Unknown.

◆ createWorldFile()

void Isis::ImageExporter::createWorldFile ( FileName  outputName)
privateinherited

Creates a world file is the input has a map projection.

Parameters
outputNameName of the world file

Definition at line 364 of file ImageExporter.cpp.

References Isis::FileName::addExtension(), Isis::ProcessExport::CreateWorldFile(), Isis::Process::EndProcess(), Isis::FileName::expanded(), and Isis::FileName::removeExtension().

◆ exportDescription()

ExportDescription & Isis::ImageExporter::exportDescription ( ) const
protectedinherited

Gets the description for the output image.

Returns
The export description

Definition at line 226 of file ImageExporter.cpp.

◆ extension()

QString Isis::ImageExporter::extension ( ) const
protectedinherited

Gets the extension for the output image.

Returns
The extension for the output image

Definition at line 208 of file ImageExporter.cpp.

Referenced by Isis::JP2Exporter::write(), Isis::QtExporter::write(), and write().

◆ fromFormat()

ImageExporter * Isis::ImageExporter::fromFormat ( QString  format)
staticinherited

A static (factory) method for constructing an ImageExporter instance from an output format.

The specific subclass of the returned instance is determined from the desired output image format provided. Each subclass has knowledge of whether or not it can write a particular format. Because the ability to export an image format is not mutually exclusive amongst exporters, the order of condieration here matters. For example, using a TIFF exporter takes precedence over a Qt exporter for TIFF images, because the former can process cubes greater than 2GB while the latter cannot. It is the caller's responsibility to delete the exporter instance when they are finished with it.

Parameters
formatThe format for the output image to be created
Returns
A pointer to the instantiated exporter owned by the caller

Definition at line 390 of file ImageExporter.cpp.

References Isis::JP2Exporter::canWriteFormat(), Isis::QtExporter::canWriteFormat(), canWriteFormat(), and Isis::IException::Programmer.

◆ initialize()

void Isis::StreamExporter::initialize ( ExportDescription desc)
protectedvirtualinherited

Generic initialization with the export description.

Set the input, set the pixel type, and create the buffer.

Parameters
descExport description containing necessary channel information

Implements Isis::ImageExporter.

Definition at line 74 of file StreamExporter.cpp.

References Isis::StreamExporter::createBuffer(), and Isis::ImageExporter::initialize().

Referenced by Isis::StreamExporter::setGrayscale(), Isis::StreamExporter::setRgb(), and Isis::StreamExporter::setRgba().

◆ initializeProcess()

Cube * Isis::ImageExporter::initializeProcess ( )
protectedinherited

Sets up the export process with the parameters described within the given description.

This method determines determines whether to write the data as grayscale, RGB, or RGBA. It then opens a cube for retrieving the input data and establishing the dimensions of the output image. Next, the ProcessExport format is set to BIL and the ProcessExport output pixel type, output valid data range, and output null are set based on the given export description. Last, the absolute output pixel range is set based on the given description (this is the smallest and largest allowed pixel values in the output, including "special" pixel values).

Returns
A cube pointer to the first channel created, owned by the process

Definition at line 246 of file ImageExporter.cpp.

References Isis::ProcessExport::BIL, Isis::Cube::lineCount(), Isis::IException::Programmer, Isis::Cube::sampleCount(), Isis::ProcessExport::setFormat(), Isis::ProcessExport::SetOutputNull(), Isis::ProcessExport::SetOutputRange(), Isis::ProcessExport::SetOutputType(), Isis::ImageExporter::writeGrayscale(), Isis::ImageExporter::writeRgb(), and Isis::ImageExporter::writeRgba().

◆ inputMaximum()

double Isis::ImageExporter::inputMaximum ( int  channel) const
inherited

Returns the input maximum for the given channel.

Any value of max in the input cube will be mapped to the output max of the output channel.

Parameters
channelIndex of the channel within the process
Returns
The maximum DN in the input mapped to the maximum of the output

Definition at line 164 of file ImageExporter.cpp.

◆ inputMinimum()

double Isis::ImageExporter::inputMinimum ( int  channel) const
inherited

Returns the input minimum for the given channel.

Any value of min in the input cube will be mapped to the output min of the output channel.

Parameters
channelIndex of the channel within the process
Returns
The minimum DN in the input mapped to the minimum of the output

Definition at line 151 of file ImageExporter.cpp.

◆ lines()

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

Number of lines (rows) in the output image.

Returns
The height of the output

Definition at line 128 of file ImageExporter.cpp.

Referenced by Isis::QtExporter::checkDataSize(), Isis::QtExporter::setGrayscale(), Isis::QtExporter::setRgb(), Isis::QtExporter::setRgba(), Isis::JP2Exporter::write(), and write().

◆ operator()()

void Isis::ImageExporter::operator() ( vector< Buffer * > &  in) const
inherited

The method for writing a line of input image data (with potentially several bands representing color channels) to the output image.

It is called for each line of data in the input images (provides a vector containing the same line from each single-band input image). Enables the exporter to be used as a functor in a custom ProcessExport routine, bypassing the black-box write() method entirely.

Parameters
inVector containing a line of input data from each input channel

Definition at line 84 of file ImageExporter.cpp.

◆ outputPixelValue()

int Isis::ImageExporter::outputPixelValue ( double  dn) const
protectedvirtualinherited

Return the output clamped integer pixel value from the input double-precision DN.

Parameters
dnThe input DN
Returns
The pixel value for the output

Definition at line 325 of file ImageExporter.cpp.

Referenced by Isis::QtExporter::writeGrayscale(), Isis::StreamExporter::writeGrayscale(), Isis::QtExporter::writeRgb(), Isis::StreamExporter::writeRgb(), Isis::QtExporter::writeRgba(), and Isis::StreamExporter::writeRgba().

◆ pixelType()

PixelType Isis::ImageExporter::pixelType ( ) const
protectedinherited

Returns the pixel type.

Defaults to None if not set by the user.

Returns
The pixel type: {None, UnsignedByte, SignedWord, UnsignedWord}

Definition at line 307 of file ImageExporter.cpp.

Referenced by Isis::JP2Exporter::createBuffer(), createBuffer(), Isis::JP2Exporter::setBuffer(), setBuffer(), Isis::JP2Exporter::write(), write(), and Isis::JP2Exporter::writeLine().

◆ process()

ProcessExport & Isis::ImageExporter::process ( ) const
protectedinherited

Get a reference to the process object, useful for subclasses to access and manipulate the process.

Returns
A reference to the process object

Definition at line 297 of file ImageExporter.cpp.

◆ samples()

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

◆ setBuffer()

void Isis::TiffExporter::setBuffer ( int  s,
int  b,
int  dn 
) const
protectedvirtual

Set the DN value at the given sample and band, resolved to a single index, of the line buffer.

Parameters
sThe sample component of the index into the buffer
bThe band component of the index into the buffer
dnThe value to set at the given index

Implements Isis::StreamExporter.

Definition at line 127 of file TiffExporter.cpp.

References Isis::ImageExporter::bands(), m_raster, Isis::ImageExporter::pixelType(), Isis::IException::Programmer, and Isis::toString().

◆ setExportDescription()

void Isis::ImageExporter::setExportDescription ( ExportDescription desc)
protectedinherited

Sets the description for the output image.

Parameters
descThe export description

Definition at line 217 of file ImageExporter.cpp.

◆ setExtension()

void Isis::ImageExporter::setExtension ( QString  extension)
protectedinherited

Sets the extension for the output image and generates the extension for the world file from it.

Parameters
extensionThe extension for the output image

Definition at line 193 of file ImageExporter.cpp.

Referenced by Isis::JP2Exporter::JP2Exporter(), Isis::QtExporter::QtExporter(), and TiffExporter().

◆ setGrayscale()

void Isis::StreamExporter::setGrayscale ( ExportDescription desc)
virtualinherited

Generic initialization with the export description.

Stream exporters do not do anything special to export a grayscale image beyond setting up the appropriate number of color channels.

Parameters
descExport description containing necessary channel information

Implements Isis::ImageExporter.

Definition at line 39 of file StreamExporter.cpp.

References Isis::StreamExporter::initialize().

◆ setOutputPixelRange()

void Isis::ImageExporter::setOutputPixelRange ( double  outputPixelMinimum,
double  outputPixelMaximum 
)
inherited

Set the DN floor and ceiling for the exported image.

All DNs less than the min will be set to the min in the exported image. Similarly, all DNs greater than the max will be set to the max in the exported image.

Note: These values may be "special". For example, if Null pixels are exported to 0.0 and the minimum valid pixels are exported to 2.0, then 0.0 should be passed in for the value of the min parameter.

Parameters
minThe absolute minimum output DN value.
maxThe absolute maximum output DN value.

Definition at line 181 of file ImageExporter.cpp.

◆ setRgb()

void Isis::StreamExporter::setRgb ( ExportDescription desc)
virtualinherited

Generic initialization with the export description.

Stream exporters do not do anything special to export an RGB image beyond setting up the appropriate number of color channels.

Parameters
descExport description containing necessary channel information

Implements Isis::ImageExporter.

Definition at line 51 of file StreamExporter.cpp.

References Isis::StreamExporter::initialize().

◆ setRgba()

void Isis::StreamExporter::setRgba ( ExportDescription desc)
virtualinherited

Generic initialization with the export description.

Stream exporters do not do anything special to export an RGBA image beyond setting up the appropriate number of color channels.

Parameters
descExport description containing necessary channel information

Implements Isis::ImageExporter.

Definition at line 63 of file StreamExporter.cpp.

References Isis::StreamExporter::initialize().

◆ write()

void Isis::TiffExporter::write ( FileName  outputName,
int  quality = 100,
QString  compression = "none" 
)
virtual

Open the output file for writing, initialize its fields, then let the base ImageExporter handle the generic black-box writing routine.

Parameters
outputNameThe filename of the output cube
qualityThe quality of the output, not used for TIFF
compressionThe compression algorithm used. Currenly supports "packbits", "lzw", "deflate", and "none".

Reimplemented from Isis::ImageExporter.

Definition at line 73 of file TiffExporter.cpp.

References Isis::FileName::addExtension(), Isis::ImageExporter::bands(), Isis::FileName::expanded(), Isis::ImageExporter::extension(), Isis::ImageExporter::lines(), m_image, Isis::ImageExporter::pixelType(), Isis::IException::Programmer, Isis::ImageExporter::samples(), and Isis::ImageExporter::write().

◆ writeGrayscale()

void Isis::StreamExporter::writeGrayscale ( vector< Buffer * > &  in) const
protectedvirtualinherited

Write a line of grayscale data to the output image.

Parameters
inVector containing a single grayscale input line

Implements Isis::ImageExporter.

Definition at line 85 of file StreamExporter.cpp.

References Isis::Buffer::Line(), Isis::ImageExporter::outputPixelValue(), Isis::Buffer::SampleDimension(), Isis::StreamExporter::setBuffer(), and Isis::StreamExporter::writeLine().

◆ writeLine()

void Isis::TiffExporter::writeLine ( int  l) const
protectedvirtual

Writes a line of buffered data to the output image on disk.

Parameters
lThe line of the output image

Implements Isis::StreamExporter.

Definition at line 154 of file TiffExporter.cpp.

References m_image, m_raster, and Isis::IException::Programmer.

◆ writeRgb()

void Isis::StreamExporter::writeRgb ( vector< Buffer * > &  in) const
protectedvirtualinherited

Write a line of RGB data to the output image.

Parameters
inVector containing three input lines (red, green, blue)

Implements Isis::ImageExporter.

Definition at line 103 of file StreamExporter.cpp.

References Isis::Buffer::Line(), Isis::ImageExporter::outputPixelValue(), Isis::Buffer::SampleDimension(), Isis::StreamExporter::setBuffer(), and Isis::StreamExporter::writeLine().

◆ writeRgba()

void Isis::StreamExporter::writeRgba ( vector< Buffer * > &  in) const
protectedvirtualinherited

Write a line of RGBA data to the output image.

Parameters
inVector containing four input lines (red, green, blue, alpha)

Implements Isis::ImageExporter.

Definition at line 127 of file StreamExporter.cpp.

References Isis::Buffer::Line(), Isis::ImageExporter::outputPixelValue(), Isis::Buffer::SampleDimension(), Isis::StreamExporter::setBuffer(), and Isis::StreamExporter::writeLine().

Member Data Documentation

◆ m_bands

int Isis::ImageExporter::m_bands
privateinherited

Number of bands (channels) in the output image.

Definition at line 162 of file ImageExporter.h.

◆ m_exportDescription

ExportDescription* Isis::ImageExporter::m_exportDescription
privateinherited

! The description for the export.

This includes, pixel type, number of channels, and the output values for min valid, max valid, and special pixels

Definition at line 175 of file ImageExporter.h.

◆ m_extension

QString Isis::ImageExporter::m_extension
privateinherited

Extension to append to the output image if not already provided.

Definition at line 150 of file ImageExporter.h.

◆ m_image

TIFF* Isis::TiffExporter::m_image
private

Object responsible for writing data to the output image.

Definition at line 59 of file TiffExporter.h.

Referenced by TiffExporter(), write(), writeLine(), and ~TiffExporter().

◆ m_lines

int Isis::ImageExporter::m_lines
privateinherited

Number of lines (rows) in the output image.

Definition at line 159 of file ImageExporter.h.

◆ m_outputPixelMaximum

double Isis::ImageExporter::m_outputPixelMaximum
privateinherited

! The absolute maximum value for the output pixels.

Larger DNs will be mapped to this value.

Definition at line 170 of file ImageExporter.h.

◆ m_outputPixelMinimum

double Isis::ImageExporter::m_outputPixelMinimum
privateinherited

! The absolute minimum value for the output pixels.

Smaller DNs will be mapped to this value.

Definition at line 166 of file ImageExporter.h.

◆ m_process

ProcessExport* Isis::ImageExporter::m_process
privateinherited

The object that feeds lines to this instance and handles stretching.

Definition at line 144 of file ImageExporter.h.

◆ m_raster

unsigned char* Isis::TiffExporter::m_raster
private

Array containing all color channels for a line.

Definition at line 62 of file TiffExporter.h.

Referenced by createBuffer(), setBuffer(), TiffExporter(), writeLine(), and ~TiffExporter().

◆ m_samples

int Isis::ImageExporter::m_samples
privateinherited

Number of samples (columns) in the output image.

Definition at line 156 of file ImageExporter.h.

◆ m_worldExtension

QString Isis::ImageExporter::m_worldExtension
privateinherited

Extension to append to the output world file.

Definition at line 153 of file ImageExporter.h.

◆ m_writeMethod

WriteChannels Isis::ImageExporter::m_writeMethod
privateinherited

Method pointer to one of the pure virtual write methods.

Definition at line 147 of file ImageExporter.h.


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