9#include <QCryptographicHash>
12#include "ProcessExport.h"
13#include "Preference.h"
14#include "IException.h"
15#include "LineManager.h"
16#include "BandManager.h"
17#include "SpecialPixel.h"
20#include "Application.h"
21#include "EndianSwapper.h"
22#include "Projection.h"
62 for (
unsigned int i = 0; i <
p_str.size(); i++) {
94 double middle = (minimum + maximum) / 2.0;
123 double middle = (minimum + maximum) / 2.0;
154 const double maximum) {
155 if (minimum >= middle) {
157 "minimum must be less than the middle [ProcessExport::SetInputRange]";
158 throw IException(IException::Programmer, message, _FILEINFO_);
160 if (middle >= maximum) {
162 "middle must be less than the maximum [ProcessExport::SetInputRange]";
163 throw IException(IException::Programmer, message, _FILEINFO_);
202 const double maximum,
const int index) {
203 if (minimum >= middle) {
205 "minimum must be less than the middle [ProcessExport::SetInputRange]";
206 throw IException(IException::Programmer, message, _FILEINFO_);
208 if (middle >= maximum) {
210 "middle must be less than the maximum [ProcessExport::SetInputRange]";
211 throw IException(IException::Programmer, message, _FILEINFO_);
213 if (index >= (
int)
InputCubes.size() || index < 0) {
215 "index out of bounds";
216 throw IException(IException::Programmer, message, _FILEINFO_);
368 for (
unsigned int i = 0; i <
InputCubes.size(); i++) {
370 QString strType = ui.
GetString(
"STRETCH");
371 if (strType ==
"MANUAL") {
379 else if (strType !=
"NONE") {
391 if (strType ==
"PIECEWISE") {
412 bool ProcessExport::HasInputRange()
const {
420 throw IException(IException::Programmer,
421 "There is no input minimum for channel " + IString((
int) n),
431 throw IException(IException::Programmer,
432 "There is no input maximum for channel " + IString((
int) n),
455 if (minimum >= maximum) {
457 "minimum must be less than the maximum [ProcessExport::SetOutputRange]";
458 throw IException(IException::Programmer, message, _FILEINFO_);
613 "Format of the output file must be set prior to calling this method [ProcessExport::SetOutputType]";
614 throw IException(IException::Programmer, message, _FILEINFO_);
616 if (pixelIn == Isis::UnsignedByte)
618 else if (pixelIn == Isis::UnsignedWord)
620 else if (pixelIn == Isis::SignedWord)
622 else if (pixelIn == Isis::Real)
625 "Unsupported bit type for JP2 formatted files [ProcessExport::SetOutputType]";
626 throw IException(IException::Programmer, message, _FILEINFO_);
633 "Unsupported bit type [ProcessExport::SetOutputType]";
634 throw IException(IException::Programmer, message, _FILEINFO_);
654 if (byteOrderIn == Isis::NoByteOrder) {
657 else if (byteOrderIn == Isis::Lsb) {
660 else if (byteOrderIn == Isis::Msb) {
699 QString msg =
"Cannot generate a checksum. Call setGenerateChecksum(true) before startProcess";
700 throw IException(IException::Programmer, msg, _FILEINFO_);
704 QString msg =
"Unable to generate a checksum. Did you call startProcess?";
705 throw IException(IException::Programmer, msg, _FILEINFO_);
728 string m =
"You have not specified any input cubes";
729 throw IException(IException::Programmer, m, _FILEINFO_);
748 for (
unsigned int i = 0; i <
InputCubes.size(); i++) {
804 string m =
"Invalid storage order.";
805 throw IException(IException::Programmer, m, _FILEINFO_);
813 for (
int i = 0; i < buff->
size(); i++) {
814 (*buff)[i] =
p_str[0]->Map((*buff)[i]);
846 vector<BufferManager *> imgrs = GetBuffers();
847 for (
int k = 1; k <= length; k++) {
848 vector<Buffer *> ibufs;
850 for (
unsigned int j = 0; j <
InputCubes.size(); j++) {
855 for (
int i = 0; i <
InputCubes[0]->sampleCount(); i++)
856 (*imgrs[j])[i] =
p_str[j]->Map((*imgrs[j])[i]);
858 ibufs.push_back(imgrs[j]);
864 for (
unsigned int i = 0; i < imgrs.size(); i++) imgrs[i]->next();
870 vector<BufferManager *> ProcessExport::GetBuffers() {
872 vector<BufferManager *> imgrs;
883 string m =
"Invalid storage order.";
884 throw IException(IException::Programmer, m, _FILEINFO_);
909 vector<BufferManager *> imgrs;
910 for (
unsigned int i = 0; i <
InputCubes.size(); i++) {
911 if ((
InputCubes[i]->sampleCount() == samples) &&
916 imgrs.push_back(iline);
919 string m =
"All input cubes must have the same dimensions";
920 throw IException(IException::Programmer, m, _FILEINFO_);
948 vector<BufferManager *> imgrs;
949 for (
unsigned int i = 0; i <
InputCubes.size(); i++) {
950 if ((
InputCubes[i]->sampleCount() == samples) &&
955 imgrs.push_back(iline);
958 string m =
"All input cubes must have the same dimensions";
959 throw IException(IException::Programmer, m, _FILEINFO_);
986 vector<BufferManager *> imgrs;
987 for (
unsigned int i = 0; i <
InputCubes.size(); i++) {
991 imgrs.push_back(iband);
994 string m =
"All input cubes must have the same dimensions";
995 throw IException(IException::Programmer, m, _FILEINFO_);
1031 string m =
"Output stream cannot be generated for requested storage order type.";
1032 throw IException(IException::Programmer, m, _FILEINFO_);
1041 QByteArray byteArray;
1043 for (
int i = 0; i < buff->
size(); i++) {
1044 (*buff)[i] =
p_str[0]->Map((*buff)[i]);
1045 byteArray.append((*buff)[i]);
1064 for (
int i = 0; i < buff->
size(); i++) {
1065 (*buff)[i] =
p_str[0]->Map((*buff)[i]);
1100 char *out8 =
new char[in.
size()];
1101 for (
int samp = 0; samp < in.
size(); samp++) {
1102 double pixel = in[samp];
1106 else if (pixel >= 255.0) {
1107 out8[samp] = (char)255;
1110 out8[samp] = (char)(in[samp] + 0.5);
1113 fout.write(out8, in.
size());
1137 short *out16s =
new short[in.
size()];
1138 for (
int samp = 0; samp < in.
size(); samp++) {
1139 double pixel = in[samp];
1141 if (pixel <= -32768.0) {
1142 tempShort = (short)32768;
1143 tempShort = -1 * tempShort;
1145 else if (pixel >= 32767.0) {
1146 tempShort = (short)32767;
1150 if (in[samp] < 0.0) {
1151 tempShort = (short)(in[samp] - 0.5);
1154 tempShort = (short)(in[samp] + 0.5);
1157 void *p_swap = &tempShort;
1160 fout.write((
char *)out16s, in.
size() * 2);
1184 unsigned short *out16u =
new unsigned short[in.
size()];
1185 for (
int samp = 0; samp < in.
size(); samp++) {
1186 double pixel = in[samp];
1187 unsigned short tempShort;
1191 else if (pixel >= 65535.0) {
1195 tempShort = (
unsigned short)(in[samp] + 0.5);
1197 unsigned short *p_swap = &tempShort;
1201 fout.write((
char *)out16u, in.
size() * 2);
1224 int *out32 =
new int[in.
size()];
1225 for (
int samp = 0; samp < in.
size(); samp++) {
1226 double pixel = in[samp];
1228 if (pixel <= -((
double)FLT_MAX)) {
1229 tempFloat = -((double)FLT_MAX);
1231 else if (pixel >= (
double)FLT_MAX) {
1232 tempFloat = (double)FLT_MAX;
1235 tempFloat = (double)in[samp];
1237 void *p_swap = &tempFloat;
1240 fout.write((
char *)out32, in.
size() * 4);
1260 os.open(worldFile.toLatin1().data(), ios::out);
1263 os << std::fixed << setprecision(15)
1270 os << std::fixed << setprecision(15)
1274 os << std::fixed << setprecision(15)
1275 << proj->
XCoord() << endl;
1278 os << std::fixed << setprecision(15)
1279 << proj->
YCoord() << endl;
1283 catch(IException &e) {
static UserInterface & GetUserInterface()
Returns the UserInterface object.
Buffer manager, for moving through a cube in bands.
Buffer for reading and writing cube data.
int size() const
Returns the total number of pixels in the shape buffer.
Manages a Buffer over a cube.
bool begin()
Moves the shape buffer to the first position.
bool end() const
Returns true if the shape buffer has accessed the end of the cube.
bool next()
Moves the shape buffer to the next position.
Container of a cube histogram.
double Median() const
Returns the median.
double Percent(const double percent) const
Computes and returns the value at X percent of the histogram.
Buffer manager, for moving through a cube in lines.
double OutputNull()
Return the output special pixel value for NULL.
void InitProcess()
Convenience method that checks to make sure the user is only using valid input to the StartProcess me...
double p_Lis
The output value for pixels whose input DNs are Low Instrument Saturation values.
ExportFormat p_format
Current storage order.
std::vector< Stretch * > p_str
Stretch object to ensure a reasonable range of pixel values in the output data.
double OutputHis()
Return the output special pixel value for HIS.
double OutputLrs()
Return the output special pixel value for LRS.
bool p_Null_Set
Indicates whether p_Null has been set (i.e.
std::vector< BufferManager * > GetBuffersBSQ()
A single line of input data from each input cube will be passed to the line processing function.
QCryptographicHash * m_cryptographicHash
A cryptographic hash that will generate an MD5 checksum of the image data.
QString checksum()
@description Generates a file checksum.
void SetOutputHrs(const double value)
Set output special pixel value for HRS.
void CreateWorldFile(const QString &worldFile)
Create a standard world file for the input cube.
void SetOutputLrs(const double value)
Set output special pixel value for LRS.
double OutputLis()
Return the output special pixel value for LIS.
std::vector< BufferManager * > GetBuffersBIP()
A single band of input data from each input cube will be passed to the band processing function.
double p_outputMinimum
Desired minimum pixel value in the Buffer.
std::vector< double > p_inputMiddle
Middle pixel value in the input cube to be mapped to the (minimum+maximum)/2.0 value in the Buffer.
void setCanGenerateChecksum(bool flag)
@description Set m_canGenerateChecksum which determines if we can generate a MD5 checksum on the imag...
bool p_His_Set
Indicates whether p_His has been set (i.e.
void SetOutputNull(const double value)
Set output special pixel value for NULL.
double GetInputMinimum(unsigned int n=0) const
Get the valid minimum pixel value for the Nth input cube.
void isisOut8(Buffer &in, std::ofstream &fout)
Method for writing 8-bit unsigned pixel data to a file stream.
std::vector< BufferManager * > GetBuffersBIL()
A single line of input data from each input cube will be passed to the line processing function.
void isisOut16u(Buffer &in, std::ofstream &fout)
Method for writing 16-bit unsigned pixel data to a file stream.
double p_outputMaximum
Desired maximum pixel value in the Buffer.
bool p_Lrs_Set
Indicates whether p_Lrs has been set (i.e.
void isisOut32(Buffer &in, std::ofstream &fout)
Method for writing 32-bit signed floating point pixels data to a file stream.
double OutputHrs()
Return the output special pixel value for HRS.
bool p_Hrs_Set
Indicates whether p_Hrs has been set (i.e.
bool m_canGenerateChecksum
Flag to determine if a file checksum will be generated.
std::vector< double > p_inputMaximum
Maximum pixel value in the input cube to be mapped to the maximum value in the Buffer.
void SetOutputType(Isis::PixelType pixelIn)
Set output pixel bit type in Buffer.
void isisOut16s(Buffer &in, std::ofstream &fout)
Method for writing 16-bit signed pixel data to a file stream.
void SetOutputLis(const double value)
Set output special pixel value for LIS.
void SetOutputEndian(enum ByteOrder endianness)
Set byte endianness of the output cube.
virtual void StartProcess(void funct(Isis::Buffer &in))
This method invokes the process operation over a single input cube.
void SetInputRange()
Set input pixel range from user.
bool canGenerateChecksum()
@description Return if we can generate a checksum
@ JP2
Compressed JPEG2000.
@ BIL
Band interleaved by line.
@ BIP
Band interleaved by pixel.
ProcessExport()
Constructs an Export object.
bool p_Lis_Set
Indicates whether p_Lis has been set (i.e.
double p_Lrs
The output value for pixels whose input DNs are Low Representation Saturation values.
double p_Null
The output value for pixels whose input DNs are Null values.
PixelType p_pixelType
The bits per pixel of the output image.
ByteOrder p_endianType
The byte order of the output file.
void setFormat(ExportFormat format)
Sets the storage order of the output file.
double p_outputMiddle
Middle pixel value (minimum+maximun)/2.0 in the Buffer.
virtual ~ProcessExport()
Destructor.
double GetInputMaximum(unsigned int n=0) const
Get the valid maximum pixel value for the Nth input cube.
void SetOutputRange(const double minimum, const double maximum)
Set output pixel range in Buffer.
EndianSwapper * p_endianSwap
Object to swap the endianness of the raw output to either MSB or LSB.
double p_His
The output value for pixels whose input DNs are High Instrument Saturation values.
void SetOutputHis(const double value)
Set output special pixel value for HIS.
std::vector< double > p_inputMinimum
Minimum pixel value in the input cube to be mapped to the minimum value in the Buffer.
double p_Hrs
The output value for pixels whose input DNs are High Representation Saturation values.
Process()
Constructs a Process Object.
std::vector< Isis::Cube * > InputCubes
A vector of pointers to opened Cube objects.
Isis::Progress * p_progress
Pointer to a Progress object.
void CheckStatus()
Checks and updates the status.
Base class for Map Projections.
double Resolution() const
This method returns the resolution for mapping world coordinates into projection coordinates.
double XCoord() const
This returns the projection X provided SetGround, SetCoordinate, SetUniversalGround,...
virtual bool SetWorld(const double x, const double y)
This method is used to set a world coordinate.
double YCoord() const
This returns the projection Y provided SetGround, SetCoordinate, SetUniversalGround,...
Command Line and Xml loader, validation, and access.
double GetDouble(const QString ¶mName) const
Allows the retrieval of a value for a parameter of type "double".
QString GetString(const QString ¶mName) const
Allows the retrieval of a value for a parameter of type "string".
void PutDouble(const QString ¶mName, const double &value)
Allows the insertion of a value for a parameter of type "double".
void Clear(const QString ¶mName)
Clears the value(s) in the named parameter.
This is free and unencumbered software released into the public domain.
Namespace for the standard library.