Isis 3 Programmer Reference
|
Export Isis cubes into standard formats. More...
#include <ImageExporter.h>
Public Member Functions | |
ImageExporter () | |
Construct the exporter. | |
virtual | ~ImageExporter () |
Destruct the exporter. | |
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. | |
virtual void | write (FileName outputName, int quality=100, QString compression="none", UserInterface *ui=nullptr) |
Export the Isis cube channels to the given standard 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. | |
virtual void | setGrayscale (ExportDescription &desc)=0 |
Pure virtual method for setting up an export to a grayscale image. | |
virtual void | setRgb (ExportDescription &desc)=0 |
Pure virtual method for setting up an export to an RGB image. | |
virtual void | setRgba (ExportDescription &desc)=0 |
Pure virtual method for setting up an export to an RGBA image. | |
Static Public Member Functions | |
static ImageExporter * | fromFormat (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 | initialize (ExportDescription &desc)=0 |
Generic initialization with the export description. | |
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. | |
Cube * | initializeProcess () |
Sets up the export process with the parameters described within the given description. | |
QString | extension () const |
Gets the extension for the output image. | |
ExportDescription & | exportDescription () const |
Gets the description for the output image. | |
ProcessExport & | process () 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. | |
virtual void | writeGrayscale (vector< Buffer * > &in) const =0 |
Pure virtual method for writing a line of grayscale data to the output image. | |
virtual void | writeRgb (vector< Buffer * > &in) const =0 |
Pure virtual method for writing a line of RGB data to the output image. | |
virtual void | writeRgba (vector< Buffer * > &in) const =0 |
Pure virtual method for writing a line of RGBA data to the output image. | |
Private Member Functions | |
Cube * | addChannel (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 | |
ProcessExport * | m_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. | |
ExportDescription * | m_exportDescription |
! The description for the export. | |
Export Isis cubes into standard formats.
Abstract base class for a series of image exporters. Each exporter handles a specialized suite of standard image formats, and can be used as a black-box with the write() method, or for finer control, the importer can act as a functor in a ProcessExport routine.
2012-04-04 Travis Addair - Added documentation.
2012-08-28 Steven Lambright - The world file should no longer overwrite the output image. This is related to #832/#970. References #579.
2013-06-05 Jeannie Backer - Changed member function and variable names for clarity. Added ExportDescription member variable, mutator, and accessor. Removed "get" prefix from method names to bring class closer to Isis coding standards. Added accessor for extension and pixel type. Added pure virtual initialize() method to be called in the setGrayscale(), setRgb(), and setRgba() methods. References #1380.
2015-02-12 Jeffrey Covington - Added optional parameter to virtual method write() to choose a compression algorithm. Fixes #1745.
Definition at line 55 of file ImageExporter.h.
|
protected |
Friendly alias for a method used to write a particular color channel.
Definition at line 99 of file ImageExporter.h.
Isis::ImageExporter::ImageExporter | ( | ) |
Construct the exporter.
Definition at line 29 of file ImageExporter.cpp.
References m_bands, m_exportDescription, m_extension, m_lines, m_outputPixelMaximum, m_outputPixelMinimum, m_process, m_samples, m_worldExtension, and m_writeMethod.
|
virtual |
Destruct the exporter.
Also deletes the process object.
Definition at line 67 of file ImageExporter.cpp.
References m_exportDescription, and m_process.
|
private |
Add a channel of input data to the process from the export description at the given index.
i | Index of the channel to add within the export description |
Definition at line 355 of file ImageExporter.cpp.
References Isis::ExportDescription::ChannelDescription::attributes(), Isis::ExportDescription::channel(), Isis::FileName::expanded(), Isis::ExportDescription::ChannelDescription::filename(), Isis::ExportDescription::ChannelDescription::hasCustomRange(), Isis::ExportDescription::ChannelDescription::inputMaximum(), Isis::ExportDescription::ChannelDescription::inputMinimum(), m_exportDescription, and process().
Referenced by initializeProcess().
int Isis::ImageExporter::bands | ( | ) | const |
Number of bands (channels) in the output image.
Definition at line 147 of file ImageExporter.cpp.
References m_bands.
Referenced by Isis::QtExporter::checkDataSize(), Isis::JP2Exporter::createBuffer(), Isis::TiffExporter::createBuffer(), Isis::TiffExporter::setBuffer(), Isis::JP2Exporter::write(), and Isis::TiffExporter::write().
|
private |
Creates a world file is the input has a map projection.
outputName | Name of the world file |
Definition at line 373 of file ImageExporter.cpp.
References m_worldExtension, and process().
Referenced by write().
|
protected |
Gets the description for the output image.
Definition at line 235 of file ImageExporter.cpp.
References m_exportDescription.
Referenced by initializeProcess().
|
protected |
Gets the extension for the output image.
Definition at line 217 of file ImageExporter.cpp.
References m_extension.
Referenced by setExtension(), Isis::JP2Exporter::write(), Isis::QtExporter::write(), and Isis::TiffExporter::write().
|
static |
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.
format | The format for the output image to be created |
Definition at line 399 of file ImageExporter.cpp.
References Isis::JP2Exporter::canWriteFormat(), Isis::QtExporter::canWriteFormat(), Isis::TiffExporter::canWriteFormat(), and Isis::IException::Programmer.
|
protectedpure virtual |
Generic initialization with the export description.
Set the export description given the pixel type of the passed in description. Use the number of channels in the export description to determine the write method (i.e. grayscale, rgb, or rgba). This will also set the member variables for the number of samples, lines, and bands.
desc | Export description containing necessary channel information |
Implemented in Isis::QtExporter, and Isis::StreamExporter.
Definition at line 59 of file ImageExporter.cpp.
References initializeProcess(), and setExportDescription().
Referenced by Isis::QtExporter::initialize(), and Isis::StreamExporter::initialize().
|
protected |
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).
Definition at line 255 of file ImageExporter.cpp.
References addChannel(), Isis::ProcessExport::BIL, Isis::ExportDescription::channelCount(), exportDescription(), Isis::Cube::lineCount(), m_bands, m_exportDescription, m_lines, m_samples, m_writeMethod, Isis::ExportDescription::outputPixelAbsoluteMax(), Isis::ExportDescription::outputPixelAbsoluteMin(), Isis::ExportDescription::outputPixelNull(), Isis::ExportDescription::outputPixelValidMax(), Isis::ExportDescription::outputPixelValidMin(), pixelType(), process(), Isis::IException::Programmer, Isis::Cube::sampleCount(), Isis::Cube::setFormat(), setOutputPixelRange(), writeGrayscale(), writeRgb(), and writeRgba().
Referenced by initialize().
double Isis::ImageExporter::inputMaximum | ( | int | channel | ) | const |
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.
channel | Index of the channel within the process |
Definition at line 173 of file ImageExporter.cpp.
References Isis::ProcessExport::GetInputMaximum(), and m_process.
double Isis::ImageExporter::inputMinimum | ( | int | channel | ) | const |
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.
channel | Index of the channel within the process |
Definition at line 160 of file ImageExporter.cpp.
References Isis::ProcessExport::GetInputMinimum(), and m_process.
int Isis::ImageExporter::lines | ( | ) | const |
Number of lines (rows) in the output image.
Definition at line 137 of file ImageExporter.cpp.
References m_lines.
Referenced by Isis::QtExporter::checkDataSize(), Isis::QtExporter::setGrayscale(), Isis::QtExporter::setRgb(), Isis::QtExporter::setRgba(), Isis::JP2Exporter::write(), and Isis::TiffExporter::write().
void Isis::ImageExporter::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.
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.
in | Vector containing a line of input data from each input channel |
Definition at line 85 of file ImageExporter.cpp.
References m_writeMethod.
|
protectedvirtual |
Return the output clamped integer pixel value from the input double-precision DN.
dn | The input DN |
Definition at line 334 of file ImageExporter.cpp.
References m_outputPixelMaximum, and m_outputPixelMinimum.
Referenced by Isis::QtExporter::writeGrayscale(), Isis::StreamExporter::writeGrayscale(), Isis::QtExporter::writeRgb(), Isis::StreamExporter::writeRgb(), Isis::QtExporter::writeRgba(), and Isis::StreamExporter::writeRgba().
|
protected |
Returns the pixel type.
Defaults to None if not set by the user.
Definition at line 316 of file ImageExporter.cpp.
References m_exportDescription, and Isis::ExportDescription::pixelType().
Referenced by Isis::JP2Exporter::createBuffer(), Isis::TiffExporter::createBuffer(), initializeProcess(), Isis::JP2Exporter::setBuffer(), Isis::TiffExporter::setBuffer(), Isis::JP2Exporter::write(), Isis::TiffExporter::write(), and Isis::JP2Exporter::writeLine().
|
protected |
Get a reference to the process object, useful for subclasses to access and manipulate the process.
Definition at line 306 of file ImageExporter.cpp.
References m_process.
Referenced by addChannel(), createWorldFile(), initializeProcess(), and write().
int Isis::ImageExporter::samples | ( | ) | const |
Number of samples (columns) in the output image.
Definition at line 127 of file ImageExporter.cpp.
References m_samples.
Referenced by Isis::QtExporter::checkDataSize(), Isis::JP2Exporter::createBuffer(), Isis::TiffExporter::createBuffer(), Isis::QtExporter::setGrayscale(), Isis::QtExporter::setRgb(), Isis::QtExporter::setRgba(), Isis::JP2Exporter::write(), and Isis::TiffExporter::write().
|
protected |
Sets the description for the output image.
desc | The export description |
Definition at line 226 of file ImageExporter.cpp.
References m_exportDescription.
Referenced by initialize().
|
protected |
Sets the extension for the output image and generates the extension for the world file from it.
extension | The extension for the output image |
Definition at line 202 of file ImageExporter.cpp.
References extension(), m_extension, and m_worldExtension.
Referenced by Isis::JP2Exporter::JP2Exporter(), Isis::QtExporter::QtExporter(), and Isis::TiffExporter::TiffExporter().
|
pure virtual |
Pure virtual method for setting up an export to a grayscale image.
desc | The description describing the export parameters |
Implemented in Isis::QtExporter, and Isis::StreamExporter.
void Isis::ImageExporter::setOutputPixelRange | ( | double | outputPixelMinimum, |
double | outputPixelMaximum ) |
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.
min | The absolute minimum output DN value. |
max | The absolute maximum output DN value. |
Definition at line 190 of file ImageExporter.cpp.
References m_outputPixelMaximum, and m_outputPixelMinimum.
Referenced by initializeProcess().
|
pure virtual |
Pure virtual method for setting up an export to an RGB image.
desc | The description describing the export parameters |
Implemented in Isis::QtExporter, and Isis::StreamExporter.
|
pure virtual |
Pure virtual method for setting up an export to an RGBA image.
desc | The description describing the export parameters |
Implemented in Isis::QtExporter, and Isis::StreamExporter.
|
virtual |
Export the Isis cube channels to the given standard image.
If supported by the specific exporter child, will also produce an image with the given scaled quality. Will also use the selected compression algorithm if supported by the image format. This will do a black-box export using a ProcessExport routine. After the export is completed, a world file will also be created if a map projection exists.
outputName | The filename of the output cube |
quality | The quality of the output from 0 to 100, defaults to 100 |
compression | The compression algorithm used. Image format specific. |
ui | The optional user interface to set the input image pixel range. |
Reimplemented in Isis::JP2Exporter, Isis::QtExporter, and Isis::TiffExporter.
Definition at line 103 of file ImageExporter.cpp.
References createWorldFile(), m_extension, and process().
Referenced by Isis::JP2Exporter::write(), Isis::QtExporter::write(), and Isis::TiffExporter::write().
|
protectedpure virtual |
Pure virtual method for writing a line of grayscale data to the output image.
in | Vector containing a single grayscale input line |
Implemented in Isis::QtExporter, and Isis::StreamExporter.
Referenced by initializeProcess().
|
protectedpure virtual |
Pure virtual method for writing a line of RGB data to the output image.
in | Vector containing three input lines (red, green, blue) |
Implemented in Isis::QtExporter, and Isis::StreamExporter.
Referenced by initializeProcess().
|
protectedpure virtual |
Pure virtual method for writing a line of RGBA data to the output image.
in | Vector containing four input lines (red, green, blue, alpha) |
Implemented in Isis::QtExporter, and Isis::StreamExporter.
Referenced by initializeProcess().
|
private |
Number of bands (channels) in the output image.
Definition at line 163 of file ImageExporter.h.
Referenced by bands(), ImageExporter(), and initializeProcess().
|
private |
! 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 addChannel(), exportDescription(), ImageExporter(), initializeProcess(), pixelType(), setExportDescription(), and ~ImageExporter().
|
private |
Extension to append to the output image if not already provided.
Definition at line 151 of file ImageExporter.h.
Referenced by extension(), ImageExporter(), setExtension(), and write().
|
private |
Number of lines (rows) in the output image.
Definition at line 160 of file ImageExporter.h.
Referenced by ImageExporter(), initializeProcess(), and lines().
|
private |
! 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 ImageExporter(), outputPixelValue(), and setOutputPixelRange().
|
private |
! 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 ImageExporter(), outputPixelValue(), and setOutputPixelRange().
|
private |
The object that feeds lines to this instance and handles stretching.
Definition at line 145 of file ImageExporter.h.
Referenced by ImageExporter(), inputMaximum(), inputMinimum(), process(), and ~ImageExporter().
|
private |
Number of samples (columns) in the output image.
Definition at line 157 of file ImageExporter.h.
Referenced by ImageExporter(), initializeProcess(), and samples().
|
private |
Extension to append to the output world file.
Definition at line 154 of file ImageExporter.h.
Referenced by createWorldFile(), ImageExporter(), and setExtension().
|
private |
Method pointer to one of the pure virtual write methods.
Definition at line 148 of file ImageExporter.h.
Referenced by ImageExporter(), initializeProcess(), and operator()().