24 #include <QCryptographicHash> 77 for (
unsigned int i = 0; i <
p_str.size(); i++) {
109 double middle = (minimum + maximum) / 2.0;
138 double middle = (minimum + maximum) / 2.0;
169 const double maximum) {
170 if (minimum >= middle) {
172 "minimum must be less than the middle [ProcessExport::SetInputRange]";
175 if (middle >= maximum) {
177 "middle must be less than the maximum [ProcessExport::SetInputRange]";
217 const double maximum,
const int index) {
218 if (minimum >= middle) {
220 "minimum must be less than the middle [ProcessExport::SetInputRange]";
223 if (middle >= maximum) {
225 "middle must be less than the maximum [ProcessExport::SetInputRange]";
228 if (index >= (
int)
InputCubes.size() || index < 0) {
230 "index out of bounds";
379 for (
unsigned int i = 0; i <
InputCubes.size(); i++) {
382 if (strType ==
"MANUAL") {
390 else if (strType !=
"NONE") {
402 if (strType ==
"PIECEWISE") {
422 bool ProcessExport::HasInputRange()
const {
431 "There is no input minimum for channel " +
IString((
int) n),
442 "There is no input maximum for channel " +
IString((
int) n),
465 if (minimum >= maximum) {
467 "minimum must be less than the maximum [ProcessExport::SetOutputRange]";
621 if (p_format < 0 || p_format > 3) {
623 "Format of the output file must be set prior to calling this method [ProcessExport::SetOutputType]";
626 if (pixelIn == Isis::UnsignedByte)
628 else if (pixelIn == Isis::UnsignedWord)
630 else if (pixelIn == Isis::SignedWord)
632 else if (pixelIn == Isis::Real)
635 "Unsupported bit type for JP2 formatted files [ProcessExport::SetOutputType]";
643 "Unsupported bit type [ProcessExport::SetOutputType]";
664 if (byteOrderIn == Isis::NoByteOrder) {
667 else if (byteOrderIn == Isis::Lsb) {
670 else if (byteOrderIn == Isis::Msb) {
709 QString msg =
"Cannot generate a checksum. Call setGenerateChecksum(true) before startProcess";
714 QString msg =
"Unable to generate a checksum. Did you call startProcess?";
738 string m =
"You have not specified any input cubes";
758 for (
unsigned int i = 0; i <
InputCubes.size(); i++) {
814 string m =
"Invalid storage order.";
823 for (
int i = 0; i < buff->
size(); i++) {
824 (*buff)[i] =
p_str[0]->Map((*buff)[i]);
856 vector<BufferManager *> imgrs = GetBuffers();
857 for (
int k = 1; k <= length; k++) {
858 vector<Buffer *> ibufs;
860 for (
unsigned int j = 0; j <
InputCubes.size(); j++) {
865 for (
int i = 0; i <
InputCubes[0]->sampleCount(); i++)
866 (*imgrs[j])[i] =
p_str[j]->Map((*imgrs[j])[i]);
868 ibufs.push_back(imgrs[j]);
874 for (
unsigned int i = 0; i < imgrs.size(); i++) imgrs[i]->next();
880 vector<BufferManager *> ProcessExport::GetBuffers() {
882 vector<BufferManager *> imgrs;
893 string m =
"Invalid storage order.";
919 vector<BufferManager *> imgrs;
920 for (
unsigned int i = 0; i <
InputCubes.size(); i++) {
921 if ((
InputCubes[i]->sampleCount() == samples) &&
926 imgrs.push_back(iline);
929 string m =
"All input cubes must have the same dimensions";
958 vector<BufferManager *> imgrs;
959 for (
unsigned int i = 0; i <
InputCubes.size(); i++) {
960 if ((
InputCubes[i]->sampleCount() == samples) &&
965 imgrs.push_back(iline);
968 string m =
"All input cubes must have the same dimensions";
996 vector<BufferManager *> imgrs;
997 for (
unsigned int i = 0; i <
InputCubes.size(); i++) {
1001 imgrs.push_back(iband);
1004 string m =
"All input cubes must have the same dimensions";
1041 string m =
"Output stream cannot be generated for requested storage order type.";
1051 QByteArray byteArray;
1053 for (
int i = 0; i < buff->
size(); i++) {
1054 (*buff)[i] =
p_str[0]->Map((*buff)[i]);
1055 byteArray.append((*buff)[i]);
1074 for (
int i = 0; i < buff->
size(); i++) {
1075 (*buff)[i] =
p_str[0]->Map((*buff)[i]);
1110 char *out8 =
new char[in.
size()];
1111 for (
int samp = 0; samp < in.
size(); samp++) {
1112 double pixel = in[samp];
1116 else if (pixel >= 255.0) {
1117 out8[samp] = (char)255;
1120 out8[samp] = (char)(in[samp] + 0.5);
1123 fout.write(out8, in.
size());
1147 short *out16s =
new short[in.
size()];
1148 for (
int samp = 0; samp < in.
size(); samp++) {
1149 double pixel = in[samp];
1151 if (pixel <= -32768.0) {
1152 tempShort = (short)32768;
1153 tempShort = -1 * tempShort;
1155 else if (pixel >= 32767.0) {
1156 tempShort = (short)32767;
1160 if (in[samp] < 0.0) {
1161 tempShort = (short)(in[samp] - 0.5);
1164 tempShort = (short)(in[samp] + 0.5);
1167 void *p_swap = &tempShort;
1170 fout.write((
char *)out16s, in.
size() * 2);
1194 unsigned short *out16u =
new unsigned short[in.
size()];
1195 for (
int samp = 0; samp < in.
size(); samp++) {
1196 double pixel = in[samp];
1197 unsigned short tempShort;
1201 else if (pixel >= 65535.0) {
1205 tempShort = (
unsigned short)(in[samp] + 0.5);
1207 unsigned short *p_swap = &tempShort;
1211 fout.write((
char *)out16u, in.
size() * 2);
1234 int *out32 =
new int[in.
size()];
1235 for (
int samp = 0; samp < in.
size(); samp++) {
1236 double pixel = in[samp];
1238 if (pixel <= -((
double)FLT_MAX)) {
1239 tempFloat = -((double)FLT_MAX);
1241 else if (pixel >= (
double)FLT_MAX) {
1242 tempFloat = (double)FLT_MAX;
1245 tempFloat = (double)in[samp];
1247 void *p_swap = &tempFloat;
1250 fout.write((
char *)out32, in.
size() * 4);
1270 os.open(worldFile.toLatin1().data(), ios::out);
1273 os << std::fixed << setprecision(15)
1280 os << std::fixed << setprecision(15)
1284 os << std::fixed << setprecision(15)
1285 << proj->
XCoord() << endl;
1288 os << std::fixed << setprecision(15)
1289 << proj->
YCoord() << endl;
bool canGenerateChecksum()
Return if we can generate a checksum
Buffer for reading and writing cube data.
virtual ~ProcessExport()
Destructor.
bool m_canGenerateChecksum
Flag to determine if a file checksum will be generated.
void SetMaximumSteps(const int steps)
This sets the maximum number of steps in the process.
void isisOut16s(Buffer &in, std::ofstream &fout)
Method for writing 16-bit signed pixel data to a file stream.
static UserInterface & GetUserInterface()
Returns the UserInterface object.
void SetOutputLis(const double value)
Set output special pixel value for LIS.
bool p_His_Set
Indicates whether p_His has been set (i.e.
void SetOutputHis(const double value)
Set output special pixel value for HIS.
void SetOutputNull(const double value)
Set output special pixel value for NULL.
std::vector< BufferManager * > GetBuffersBIL()
A single line of input data from each input cube will be passed to the line processing function...
Namespace for the standard library.
ByteOrder
Tests the current architecture for byte order.
ByteOrder p_endianType
The byte order of the output file.
bool p_Null_Set
Indicates whether p_Null has been set (i.e.
unsigned short int UnsignedShortInt(void *buf)
Swaps an unsigned short integer value.
ExportFormat p_format
Current storage order.
double p_His
The output value for pixels whose input DNs are High Instrument Saturation values.
std::vector< BufferManager * > GetBuffersBSQ()
A single line of input data from each input cube will be passed to the line processing function...
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, or SetWorld returned with success.
double OutputHis()
Return the output special pixel value for HIS.
bool IsValidPixel(const double d)
Returns if the input pixel is valid.
void setCanGenerateChecksum(bool flag)
Set m_canGenerateChecksum which determines if we can generate a MD5 checksum on the image data...
double OutputNull()
Return the output special pixel value for NULL.
void isisOut8(Buffer &in, std::ofstream &fout)
Method for writing 8-bit unsigned pixel data to a file stream.
This error is for when a programmer made an API call that was illegal.
void CheckStatus()
Checks and updates the status.
int size() const
Returns the total number of pixels in the shape buffer.
PixelType
Enumerations for Isis Pixel Types.
void CreateWorldFile(const QString &worldFile)
Create a standard world file for the input cube.
double OutputLrs()
Return the output special pixel value for LRS.
std::vector< double > p_inputMinimum
Minimum pixel value in the input cube to be mapped to the minimum value in the Buffer.
bool begin()
Moves the shape buffer to the first position.
double OutputHrs()
Return the output special pixel value for HRS.
Buffer manager, for moving through a cube in lines.
void SetOutputRange(const double minimum, const double maximum)
Set output pixel range in Buffer.
Base class for Map Projections.
bool p_Lrs_Set
Indicates whether p_Lrs has been set (i.e.
EndianSwapper * p_endianSwap
Object to swap the endianness of the raw output to either MSB or LSB.
double p_Lrs
The output value for pixels whose input DNs are Low Representation Saturation values.
void SetOutputType(Isis::PixelType pixelIn)
Set output pixel bit type in Buffer.
double p_Null
The output value for pixels whose input DNs are Null values.
Container of a cube histogram.
void SetText(const QString &text)
Changes the value of the text string reported just before 0% processed.
Manages a Buffer over a cube.
void SetInputRange()
Set input pixel range from user.
double p_Hrs
The output value for pixels whose input DNs are High Representation Saturation values.
bool p_Lis_Set
Indicates whether p_Lis has been set (i.e.
double GetInputMinimum(unsigned int n=0) const
Get the valid minimum pixel value for the Nth input cube.
std::vector< double > p_inputMaximum
Maximum pixel value in the input cube to be mapped to the maximum value in the Buffer.
#define _FILEINFO_
Macro for the filename and line number.
void SetOutputHrs(const double value)
Set output special pixel value for HRS.
bool next()
Moves the shape buffer to the next position.
void setFormat(ExportFormat format)
Sets the storage order of the output file.
bool IsLsb()
Return true if this host is an LSB first machine and false if it is not.
double Percent(const double percent) const
Computes and returns the value at X percent of the histogram.
void isisOut32(Buffer &in, std::ofstream &fout)
Method for writing 32-bit signed floating point pixels data to a file stream.
double YCoord() const
This returns the projection Y provided SetGround, SetCoordinate, SetUniversalGround, or SetWorld returned with success.
virtual void StartProcess(void funct(Isis::Buffer &in))
This method invokes the process operation over a single input cube.
double GetDouble(const QString ¶mName) const
Allows the retrieval of a value for a parameter of type "double".
QString checksum()
Generates a file checksum.
void InitProcess()
Convenience method that checks to make sure the user is only using valid input to the StartProcess me...
void Clear(const QString ¶mName)
Clears the value(s) in the named parameter.
double p_outputMinimum
Desired minimum pixel value in the Buffer.
bool end() const
Returns true if the shape buffer has accessed the end of the cube.
Buffer manager, for moving through a cube in bands.
double p_outputMiddle
Middle pixel value (minimum+maximun)/2.0 in the Buffer.
double p_outputMaximum
Desired maximum pixel value in the Buffer.
Band interleaved by pixel.
bool SetWorld(const double x, const double y)
This method is used to set a world coordinate.
Isis::Progress * p_progress
Pointer to a Progress object.
double GetInputMaximum(unsigned int n=0) const
Get the valid maximum pixel value for the Nth input cube.
Band interleaved by line.
Adds specific functionality to C++ strings.
bool p_Hrs_Set
Indicates whether p_Hrs has been set (i.e.
Namespace for ISIS/Bullet specific routines.
int ExportFloat(void *buf)
Swaps a floating point value for Exporting.
short int ShortInt(void *buf)
Swaps a short integer value.
std::vector< BufferManager * > GetBuffersBIP()
A single band of input data from each input cube will be passed to the band processing function...
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...
double OutputLis()
Return the output special pixel value for LIS.
void SetOutputLrs(const double value)
Set output special pixel value for LRS.
double Median() const
Returns the median.
void isisOut16u(Buffer &in, std::ofstream &fout)
Method for writing 16-bit unsigned pixel data to a file stream.
PixelType p_pixelType
The bits per pixel of the output image.
QString GetString(const QString ¶mName) const
Allows the retrieval of a value for a parameter of type "string".
Base class for all cube processing derivatives.
void SetOutputEndian(enum ByteOrder endianness)
Set byte endianness of the output cube.
QCryptographicHash * m_cryptographicHash
A cryptographic hash that will generate an MD5 checksum of the image data.
void PutDouble(const QString ¶mName, const double &value)
Allows the insertion of a value for a parameter of type "double".
double p_Lis
The output value for pixels whose input DNs are Low Instrument Saturation values. ...
std::vector< Stretch * > p_str
Stretch object to ensure a reasonable range of pixel values in the output data.
std::vector< Isis::Cube * > InputCubes
A vector of pointers to opened Cube objects.