Isis 3 Programmer Reference
ProcessExport.h
1#ifndef ProcessExport_h
2#define ProcessExport_h
8/* SPDX-License-Identifier: CC0-1.0 */
9#include "Process.h"
10
11#include <fstream>
12#include <iostream>
13#include <string>
14
15#include <QCryptographicHash>
16#include <QString>
17
18#include "Buffer.h"
19#include "BufferManager.h"
20#include "Endian.h"
21#include "EndianSwapper.h"
22#include "SpecialPixel.h"
23#include "Stretch.h"
24#include "UserInterface.h"
25
26namespace Isis {
112
113 public:
114
122
124 virtual ~ProcessExport();
125 using Isis::Process::StartProcess; // make parents virtual function visable
126 virtual void StartProcess(void funct(Isis::Buffer &in));
127 virtual void StartProcess(void funct(std::vector<Isis::Buffer *> &in));
128 virtual void StartProcess(std::ofstream &fout);
129 void SetOutputRange(const double minimum, const double maximum);
130 void SetOutputNull(const double value);
131 void SetOutputLis(const double value);
132 void SetOutputLrs(const double value);
133 void SetOutputHis(const double value);
134 void SetOutputHrs(const double value);
135 double OutputNull();
136 double OutputLis();
137 double OutputLrs();
138 double OutputHis();
139 double OutputHrs();
140 bool HasInputRange() const;
141 void SetInputRange();
143 void SetInputRange(const double minimum, const double maximum);
144 void SetInputRange(const double minimum, const double maximum, const int index);
145 void SetInputRange(const double minimum, const double middle,
146 const double maximum);
147 void SetInputRange(const double minimum, const double middle,
148 const double maximum, const int index);
149 void CreateWorldFile(const QString &worldFile);
150 void SetOutputEndian(enum ByteOrder endianness);
151 void SetOutputType(Isis::PixelType pixelIn);
152
153 void setCanGenerateChecksum(bool flag);
154 bool canGenerateChecksum();
155 QString checksum();
156
157 double GetInputMinimum(unsigned int n=0) const;
158 double GetInputMaximum(unsigned int n=0) const;
159
162 return (p_outputMinimum);
163 };
166 return (p_outputMaximum);
167 };
168
170 void setFormat(ExportFormat format) {
171 p_format = format;
172 };
173
174
175 template <typename Functor> void ProcessCubes(const Functor & functor) {
176
177 int samples = InputCubes[0]->sampleCount();
178 int length = 0;
179 if (p_format == BIP) {
180 length = InputCubes[0]->bandCount();
181 }
182 else {
183 length = InputCubes[0]->lineCount();
184 }
185
186 // Loop and let the app programmer fiddle with the lines
187 std::vector<BufferManager *> imgrs = GetBuffers();
188 for (int k = 1; k <= length; k++) {
189 std::vector<Buffer *> ibufs;
190
191 for (unsigned int cubeIndex = 0; cubeIndex < InputCubes.size(); cubeIndex++) {
192 // Read a line of data from this cube
193 InputCubes[cubeIndex]->read(*imgrs[cubeIndex]);
194
195 // Stretch the pixels into the desired range
196 for (int sampleIndex = 0; sampleIndex < samples; sampleIndex++) {
197 (*imgrs[cubeIndex])[sampleIndex] =
198 p_str[cubeIndex]->Map((*imgrs[cubeIndex])[sampleIndex]);
199 }
200
201 ibufs.push_back(imgrs[cubeIndex]);
202 }
203
204 // Invoke the user function
205 functor(ibufs);
206
207 for (unsigned int i = 0; i < imgrs.size(); i++) imgrs[i]->next();
209 }
210 }
211
212 protected:
213
216
217 std::vector<BufferManager *> GetBuffers();
218 std::vector<BufferManager *> GetBuffersBSQ();
219 std::vector<BufferManager *> GetBuffersBIL();
220 std::vector<BufferManager *> GetBuffersBIP();
221
226
227 std::vector<double> p_inputMinimum;
230 std::vector<double> p_inputMiddle;
234 std::vector<double> p_inputMaximum;
240
243 std::vector<Stretch *> p_str;
247 double p_Null;
248 double p_Lis;
250 double p_Lrs;
252 double p_His;
254 double p_Hrs;
268 QCryptographicHash *m_cryptographicHash;
272 private:
274 void isisOut8(Buffer &in, std::ofstream &fout);
275
277 void isisOut16s(Buffer &in, std::ofstream &fout);
278
280 void isisOut16u(Buffer &in, std::ofstream &fout);
281
284 void isisOut32(Buffer &in, std::ofstream &fout);
285
288 void isisOut64(Buffer &in, std::ofstream &fout);
289
293 void InitProcess();
294
295
296 };
297};
298
299#endif
Buffer for reading and writing cube data.
Definition Buffer.h:53
Process class for exporting cubes.
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.
double GetOutputMaximum()
Get the valid maximum pixel value to be written to the output file.
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 isisOut64(Buffer &in, std::ofstream &fout)
Method for writing 64-bit signed double precision floating point pixels data to a file stream.
void setCanGenerateChecksum(bool flag)
@description Set m_canGenerateChecksum which determines if we can generate a MD5 checksum on the imag...
double GetOutputMinimum()
Get the valid minimum pixel value to be written to the output file.
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
ExportFormat
Storage order enumeration.
@ JP2
Compressed JPEG2000.
@ BSQ
Band sequential.
@ 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.
Base class for all cube processing derivatives.
Definition Process.h:143
virtual void StartProcess(void funct())
In the base class, this method will invoked a user-specified function exactly one time.
Definition Process.h:213
std::vector< Isis::Cube * > InputCubes
A vector of pointers to opened Cube objects.
Definition Process.h:185
Isis::Progress * p_progress
Pointer to a Progress object.
Definition Process.h:145
void CheckStatus()
Checks and updates the status.
Definition Progress.cpp:105
Command Line and Xml loader, validation, and access.
ByteOrder
Tests the current architecture for byte order.
Definition Endian.h:42
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
PixelType
Enumerations for Isis Pixel Types.
Definition PixelType.h:27