Isis 3 Programmer Reference
Isis::QtExporter Class Reference

Exports cubes into one of several formats with Qt facilities. More...

#include <QtExporter.h>

Inheritance diagram for Isis::QtExporter:
Inheritance graph
Collaboration diagram for Isis::QtExporter:
Collaboration graph

Public Member Functions

 QtExporter (QString format)
 Construct the Qt exporter.
 
virtual ~QtExporter ()
 Destruct the exporter.
 
virtual void setGrayscale (ExportDescription &desc)
 Set the input with the description generically, check the data size for a single-band image with the established dimensions, initialize the image with the Indexed8 format, and setup the color table from 0 to 256.
 
virtual void setRgb (ExportDescription &desc)
 Set the input with the description generically, check the data size for a three-band image with the established dimensions, and initialize the image with the RGB32 format.
 
virtual void setRgba (ExportDescription &desc)
 Set the input with the description generically, check the data size for a four-band image with the established dimensions, and initialize the image with the ARGB32 format.
 
virtual void write (FileName outputName, int quality=100, QString compression="none", UserInterface *ui=nullptr)
 Let the base ImageExporter handle the generic black-box writing routine, then save the image to disk.
 
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.
 
int samples () const
 Number of samples (columns) in the output image.
 
int lines () const
 Number of lines (rows) in the output image.
 
int bands () const
 Number of bands (channels) in the output image.
 
double inputMinimum (int channel) const
 Returns the input minimum for the given channel.
 
double inputMaximum (int channel) const
 Returns the input maximum for the given channel.
 
void setOutputPixelRange (double outputPixelMinimum, double outputPixelMaximum)
 Set the DN floor and ceiling for the exported image.
 

Static Public Member Functions

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

Protected Types

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

Protected Member Functions

virtual void writeGrayscale (vector< Buffer * > &in) const
 Write a line of grayscale data to the output image.
 
virtual void writeRgb (vector< Buffer * > &in) const
 Write a line of RGB data to the output image.
 
virtual void writeRgba (vector< Buffer * > &in) const
 Write a line of RGBA data to the output image.
 
void checkDataSize (BigInt samples, BigInt lines, int bands)
 Checks that the data size for an image of the desired dimensions will be less than 2GB.
 
void setExtension (QString extension)
 Sets the extension for the output image and generates the extension for the world file from it.
 
void setExportDescription (ExportDescription &desc)
 Sets the description for the output image.
 
CubeinitializeProcess ()
 Sets up the export process with the parameters described within the given description.
 
QString extension () const
 Gets the extension for the output image.
 
ExportDescriptionexportDescription () const
 Gets the description for the output image.
 
ProcessExportprocess () const
 Get a reference to the process object, useful for subclasses to access and manipulate the process.
 
PixelType pixelType () const
 Returns the pixel type.
 
virtual int outputPixelValue (double dn) const
 Return the output clamped integer pixel value from the input double-precision DN.
 

Private Member Functions

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

Private Attributes

QImage * m_qimage
 Structure holding all output image data in memory.
 
QString m_format
 The lowercase abbreviated format of the output image.
 
ProcessExportm_process
 The object that feeds lines to this instance and handles stretching.
 
WriteChannels m_writeMethod
 Method pointer to one of the pure virtual write methods.
 
QString m_extension
 Extension to append to the output image if not already provided.
 
QString m_worldExtension
 Extension to append to the output world file.
 
int m_samples
 Number of samples (columns) in the output image.
 
int m_lines
 Number of lines (rows) in the output image.
 
int m_bands
 Number of bands (channels) in the output image.
 
double m_outputPixelMinimum
 ! The absolute minimum value for the output pixels.
 
double m_outputPixelMaximum
 ! The absolute maximum value for the output pixels.
 
ExportDescriptionm_exportDescription
 ! The description for the export.
 

Detailed Description

Exports cubes into one of several formats with Qt facilities.

Takes a series of single-banded Isis cubes and exports them into one of several possible standard image formats using Qt's QImage structure to handle reading the data into memory and setting individual pixel values. Set Qt's documentation on QImageWriter for a complete list of supported formats:

http://qt-project.org/doc/qt-4.8/qimagewriter.html#supportedImageFormats

While Qt can be used to export Isis cubes to TIFF images, it is generally recommended to use the TiffExporter class instead, which uses LibTIFF version 4 to import big TIFFs. Qt, as of version 4.8, can only import images <2GB in size.

Author
2012-04-03 Travis Addair
History

2012-04-04 Travis Addair - Added documentation.

2013-06-05 Jeannie Backer - Added initialize() method and replaced call to setInput(). Changed ImageExporter calls to new method names, where needed. References #1380.

2015-02-12 Jeffrey Covington - Added compression parameter to write() method. Fixes #1745.

Definition at line 47 of file QtExporter.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 99 of file ImageExporter.h.

Constructor & Destructor Documentation

◆ QtExporter()

Isis::QtExporter::QtExporter ( QString format)

Construct the Qt exporter.

Parameters
formatThe format to export to

Definition at line 28 of file QtExporter.cpp.

References m_format, m_qimage, and Isis::ImageExporter::setExtension().

◆ ~QtExporter()

Isis::QtExporter::~QtExporter ( )
virtual

Destruct the exporter.

Definition at line 49 of file QtExporter.cpp.

References m_qimage.

Member Function Documentation

◆ addChannel()

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

◆ bands()

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

Number of bands (channels) in the output image.

Returns
The depth of the output

Definition at line 147 of file ImageExporter.cpp.

References Isis::ImageExporter::m_bands.

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

◆ canWriteFormat()

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

Returns true if the format is supported by QImageWriter.

Parameters
formatLowercase format abbreviation
Returns
True if supported in Qt, false otherwise

Definition at line 247 of file QtExporter.cpp.

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

◆ checkDataSize()

void Isis::QtExporter::checkDataSize ( BigInt samples,
BigInt lines,
int bands )
protected

Checks that the data size for an image of the desired dimensions will be less than 2GB.

Parameters
samplesNumber of samples in the output
linesNumber of lines in the output
bandsNumber of bands in the output

Definition at line 226 of file QtExporter.cpp.

References Isis::ImageExporter::bands(), Isis::ImageExporter::lines(), Isis::ImageExporter::samples(), Isis::toString(), and Isis::IException::User.

Referenced by setGrayscale(), setRgb(), and setRgba().

◆ 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 373 of file ImageExporter.cpp.

References Isis::ImageExporter::m_worldExtension, and Isis::ImageExporter::process().

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

◆ exportDescription()

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

Gets the description for the output image.

Returns
The export description

Definition at line 235 of file ImageExporter.cpp.

References Isis::ImageExporter::m_exportDescription.

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

◆ extension()

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

Gets the extension for the output image.

Returns
The extension for the output image

Definition at line 217 of file ImageExporter.cpp.

References Isis::ImageExporter::m_extension.

Referenced by Isis::ImageExporter::setExtension(), Isis::JP2Exporter::write(), write(), and Isis::TiffExporter::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 399 of file ImageExporter.cpp.

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

◆ initialize()

void Isis::QtExporter::initialize ( ExportDescription & desc)
privatevirtual

Generic initialization with the export description.

Set the input and set the pixel type.

Parameters
descExport description containing necessary channel information

Implements Isis::ImageExporter.

Definition at line 60 of file QtExporter.cpp.

References Isis::ImageExporter::initialize(), m_format, and Isis::IException::Unknown.

Referenced by setGrayscale(), setRgb(), and 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 255 of file ImageExporter.cpp.

References Isis::ImageExporter::addChannel(), Isis::ProcessExport::BIL, Isis::ExportDescription::channelCount(), Isis::ImageExporter::exportDescription(), Isis::Cube::lineCount(), Isis::ImageExporter::m_bands, Isis::ImageExporter::m_exportDescription, Isis::ImageExporter::m_lines, Isis::ImageExporter::m_samples, Isis::ImageExporter::m_writeMethod, Isis::ExportDescription::outputPixelAbsoluteMax(), Isis::ExportDescription::outputPixelAbsoluteMin(), Isis::ExportDescription::outputPixelNull(), Isis::ExportDescription::outputPixelValidMax(), Isis::ExportDescription::outputPixelValidMin(), Isis::ImageExporter::pixelType(), Isis::ImageExporter::process(), Isis::IException::Programmer, Isis::Cube::sampleCount(), Isis::Cube::setFormat(), Isis::ImageExporter::setOutputPixelRange(), Isis::ImageExporter::writeGrayscale(), Isis::ImageExporter::writeRgb(), and Isis::ImageExporter::writeRgba().

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

◆ 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 173 of file ImageExporter.cpp.

References Isis::ProcessExport::GetInputMaximum(), and Isis::ImageExporter::m_process.

◆ 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 160 of file ImageExporter.cpp.

References Isis::ProcessExport::GetInputMinimum(), and Isis::ImageExporter::m_process.

◆ lines()

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

Number of lines (rows) in the output image.

Returns
The height of the output

Definition at line 137 of file ImageExporter.cpp.

References Isis::ImageExporter::m_lines.

Referenced by checkDataSize(), setGrayscale(), setRgb(), setRgba(), Isis::JP2Exporter::write(), and Isis::TiffExporter::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 85 of file ImageExporter.cpp.

References Isis::ImageExporter::m_writeMethod.

◆ 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 334 of file ImageExporter.cpp.

References Isis::ImageExporter::m_outputPixelMaximum, and Isis::ImageExporter::m_outputPixelMinimum.

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

◆ pixelType()

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

◆ 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 306 of file ImageExporter.cpp.

References Isis::ImageExporter::m_process.

Referenced by Isis::ImageExporter::addChannel(), Isis::ImageExporter::createWorldFile(), Isis::ImageExporter::initializeProcess(), and Isis::ImageExporter::write().

◆ samples()

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

Number of samples (columns) in the output image.

Returns
The width of the output

Definition at line 127 of file ImageExporter.cpp.

References Isis::ImageExporter::m_samples.

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

◆ setExportDescription()

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

Sets the description for the output image.

Parameters
descThe export description

Definition at line 226 of file ImageExporter.cpp.

References Isis::ImageExporter::m_exportDescription.

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

◆ 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 202 of file ImageExporter.cpp.

References Isis::ImageExporter::extension(), Isis::ImageExporter::m_extension, and Isis::ImageExporter::m_worldExtension.

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

◆ setGrayscale()

void Isis::QtExporter::setGrayscale ( ExportDescription & desc)
virtual

Set the input with the description generically, check the data size for a single-band image with the established dimensions, initialize the image with the Indexed8 format, and setup the color table from 0 to 256.

Parameters
descExport description containing necessary channel information

Implements Isis::ImageExporter.

Definition at line 78 of file QtExporter.cpp.

References checkDataSize(), initialize(), Isis::ImageExporter::lines(), m_qimage, and Isis::ImageExporter::samples().

◆ 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 190 of file ImageExporter.cpp.

References Isis::ImageExporter::m_outputPixelMaximum, and Isis::ImageExporter::m_outputPixelMinimum.

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

◆ setRgb()

void Isis::QtExporter::setRgb ( ExportDescription & desc)
virtual

Set the input with the description generically, check the data size for a three-band image with the established dimensions, and initialize the image with the RGB32 format.

Parameters
descExport description containing necessary channel information

Implements Isis::ImageExporter.

Definition at line 100 of file QtExporter.cpp.

References checkDataSize(), initialize(), Isis::ImageExporter::lines(), m_qimage, and Isis::ImageExporter::samples().

◆ setRgba()

void Isis::QtExporter::setRgba ( ExportDescription & desc)
virtual

Set the input with the description generically, check the data size for a four-band image with the established dimensions, and initialize the image with the ARGB32 format.

Parameters
descExport description containing necessary channel information

Implements Isis::ImageExporter.

Definition at line 114 of file QtExporter.cpp.

References checkDataSize(), initialize(), Isis::ImageExporter::lines(), m_qimage, and Isis::ImageExporter::samples().

◆ write()

void Isis::QtExporter::write ( FileName outputName,
int quality = 100,
QString compression = "none",
UserInterface * ui = nullptr )
virtual

Let the base ImageExporter handle the generic black-box writing routine, then save the image to disk.

Parameters
outputNameThe filename of the output cube
qualityThe quality of the output.
compressionThe compression algorithm used. Not supported for Qt.

Reimplemented from Isis::ImageExporter.

Definition at line 200 of file QtExporter.cpp.

References Isis::ImageExporter::extension(), m_format, m_qimage, Isis::IException::Programmer, and Isis::ImageExporter::write().

◆ writeGrayscale()

void Isis::QtExporter::writeGrayscale ( vector< Buffer * > & in) const
protectedvirtual

Write a line of grayscale data to the output image.

Parameters
inVector containing a single grayscale input line

Implements Isis::ImageExporter.

Definition at line 126 of file QtExporter.cpp.

References Isis::Buffer::Line(), m_qimage, Isis::ImageExporter::outputPixelValue(), and Isis::IException::User.

◆ writeRgb()

void Isis::QtExporter::writeRgb ( vector< Buffer * > & in) const
protectedvirtual

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 153 of file QtExporter.cpp.

References m_qimage, and Isis::ImageExporter::outputPixelValue().

◆ writeRgba()

void Isis::QtExporter::writeRgba ( vector< Buffer * > & in) const
protectedvirtual

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 174 of file QtExporter.cpp.

References m_qimage, and Isis::ImageExporter::outputPixelValue().

Member Data Documentation

◆ m_bands

int Isis::ImageExporter::m_bands
privateinherited

Number of bands (channels) in the output image.

Definition at line 163 of file ImageExporter.h.

Referenced by Isis::ImageExporter::bands(), Isis::ImageExporter::ImageExporter(), and Isis::ImageExporter::initializeProcess().

◆ 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 176 of file ImageExporter.h.

Referenced by Isis::ImageExporter::addChannel(), Isis::ImageExporter::exportDescription(), Isis::ImageExporter::ImageExporter(), Isis::ImageExporter::initializeProcess(), Isis::ImageExporter::pixelType(), Isis::ImageExporter::setExportDescription(), and Isis::ImageExporter::~ImageExporter().

◆ m_extension

QString Isis::ImageExporter::m_extension
privateinherited

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

Definition at line 151 of file ImageExporter.h.

Referenced by Isis::ImageExporter::extension(), Isis::ImageExporter::ImageExporter(), Isis::ImageExporter::setExtension(), and Isis::ImageExporter::write().

◆ m_format

QString Isis::QtExporter::m_format
private

The lowercase abbreviated format of the output image.

Definition at line 75 of file QtExporter.h.

Referenced by initialize(), QtExporter(), and write().

◆ m_lines

int Isis::ImageExporter::m_lines
privateinherited

Number of lines (rows) in the output image.

Definition at line 160 of file ImageExporter.h.

Referenced by Isis::ImageExporter::ImageExporter(), Isis::ImageExporter::initializeProcess(), and Isis::ImageExporter::lines().

◆ 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 171 of file ImageExporter.h.

Referenced by Isis::ImageExporter::ImageExporter(), Isis::ImageExporter::outputPixelValue(), and Isis::ImageExporter::setOutputPixelRange().

◆ 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 167 of file ImageExporter.h.

Referenced by Isis::ImageExporter::ImageExporter(), Isis::ImageExporter::outputPixelValue(), and Isis::ImageExporter::setOutputPixelRange().

◆ m_process

ProcessExport* Isis::ImageExporter::m_process
privateinherited

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

Definition at line 145 of file ImageExporter.h.

Referenced by Isis::ImageExporter::ImageExporter(), Isis::ImageExporter::inputMaximum(), Isis::ImageExporter::inputMinimum(), Isis::ImageExporter::process(), and Isis::ImageExporter::~ImageExporter().

◆ m_qimage

QImage* Isis::QtExporter::m_qimage
private

Structure holding all output image data in memory.

Definition at line 72 of file QtExporter.h.

Referenced by QtExporter(), setGrayscale(), setRgb(), setRgba(), write(), writeGrayscale(), writeRgb(), writeRgba(), and ~QtExporter().

◆ m_samples

int Isis::ImageExporter::m_samples
privateinherited

Number of samples (columns) in the output image.

Definition at line 157 of file ImageExporter.h.

Referenced by Isis::ImageExporter::ImageExporter(), Isis::ImageExporter::initializeProcess(), and Isis::ImageExporter::samples().

◆ m_worldExtension

QString Isis::ImageExporter::m_worldExtension
privateinherited

Extension to append to the output world file.

Definition at line 154 of file ImageExporter.h.

Referenced by Isis::ImageExporter::createWorldFile(), Isis::ImageExporter::ImageExporter(), and Isis::ImageExporter::setExtension().

◆ m_writeMethod

WriteChannels Isis::ImageExporter::m_writeMethod
privateinherited

Method pointer to one of the pure virtual write methods.

Definition at line 148 of file ImageExporter.h.

Referenced by Isis::ImageExporter::ImageExporter(), Isis::ImageExporter::initializeProcess(), and Isis::ImageExporter::operator()().


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