Isis Developer Reference
ProcessExport.h
Go to the documentation of this file.
1 #ifndef ProcessExport_h
2 #define ProcessExport_h
3 
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 
26 namespace Isis {
111  class ProcessExport : public Isis::Process {
112 
113  public:
114 
117  BSQ,
118  BIL,
119  BIP,
120  JP2
121  };
122 
123  ProcessExport();
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();
142  void SetInputRange(UserInterface &ui);
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 
161  double GetOutputMinimum() {
162  return (p_outputMinimum);
163  };
165  double GetOutputMaximum() {
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 
223  double p_outputMiddle;
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;
257  bool p_Null_Set;
259  bool p_Lis_Set;
261  bool p_Lrs_Set;
263  bool p_His_Set;
265  bool p_Hrs_Set;
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
Isis::EndianSwapper::UnsignedShortInt
unsigned short int UnsignedShortInt(void *buf)
Swaps an unsigned short integer value.
Definition: EndianSwapper.cpp:197
Stretch.h
Isis::Process::InputCubes
std::vector< Isis::Cube * > InputCubes
A vector of pointers to opened Cube objects.
Definition: Process.h:185
Isis::ProcessExport::p_Lis
double p_Lis
The output value for pixels whose input DNs are Low Instrument Saturation values.
Definition: ProcessExport.h:248
Isis::ProcessExport::SetOutputLis
void SetOutputLis(const double value)
Set output special pixel value for LIS.
Definition: ProcessExport.cpp:491
Isis::LineManager
Buffer manager, for moving through a cube in lines.
Definition: LineManager.h:39
Isis::ProcessExport::GetBuffers
std::vector< BufferManager * > GetBuffers()
Definition: ProcessExport.cpp:870
Isis::Histogram::Percent
double Percent(const double percent) const
Computes and returns the value at X percent of the histogram.
Definition: Histogram.cpp:351
Isis::Progress::CheckStatus
void CheckStatus()
Checks and updates the status.
Definition: Progress.cpp:105
Isis::Projection::Resolution
double Resolution() const
This method returns the resolution for mapping world coordinates into projection coordinates.
Definition: Projection.cpp:675
Isis::BufferManager::next
bool next()
Moves the shape buffer to the next position.
Definition: BufferManager.h:106
Isis::ProcessExport::m_canGenerateChecksum
bool m_canGenerateChecksum
Flag to determine if a file checksum will be generated.
Definition: ProcessExport.h:270
Histogram.h
Isis::ProcessExport::ExportFormat
ExportFormat
Storage order enumeration.
Definition: ProcessExport.h:116
Isis::IsLsb
bool IsLsb()
Return true if this host is an LSB first machine and false if it is not.
Definition: Endian.h:67
SpecialPixel.h
Process.h
Isis::Progress::SetMaximumSteps
void SetMaximumSteps(const int steps)
This sets the maximum number of steps in the process.
Definition: Progress.cpp:85
Isis::ProcessExport::p_endianType
ByteOrder p_endianType
The byte order of the output file.
Definition: ProcessExport.h:239
Isis::ProcessExport::SetInputRange
void SetInputRange()
Set input pixel range from user.
Definition: ProcessExport.cpp:359
Isis::ProcessExport::setCanGenerateChecksum
void setCanGenerateChecksum(bool flag)
@description Set m_canGenerateChecksum which determines if we can generate a MD5 checksum on the imag...
Definition: ProcessExport.cpp:673
Isis::ProcessExport::p_format
ExportFormat p_format
Current storage order.
Definition: ProcessExport.h:215
Isis::ProcessExport::p_Hrs
double p_Hrs
The output value for pixels whose input DNs are High Representation Saturation values.
Definition: ProcessExport.h:254
BufferManager.h
Isis::VALID_MIN1
const unsigned char VALID_MIN1
Definition: SpecialPixel.h:181
LineManager.h
Isis::ProcessExport::m_cryptographicHash
QCryptographicHash * m_cryptographicHash
A cryptographic hash that will generate an MD5 checksum of the image data.
Definition: ProcessExport.h:268
Isis::UnsignedWord
@ UnsignedWord
Definition: PixelType.h:31
IsisAml::GetDouble
double GetDouble(const QString &paramName) const
Allows the retrieval of a value for a parameter of type "double".
Definition: IsisAml.cpp:891
Isis::Process
Base class for all cube processing derivatives.
Definition: Process.h:143
Isis::ProcessExport::CreateWorldFile
void CreateWorldFile(const QString &worldFile)
Create a standard world file for the input cube.
Definition: ProcessExport.cpp:1255
Isis::ProcessExport::OutputHrs
double OutputHrs()
Return the output special pixel value for HRS.
Definition: ProcessExport.cpp:577
Isis::ProcessExport::SetOutputHrs
void SetOutputHrs(const double value)
Set output special pixel value for HRS.
Definition: ProcessExport.cpp:536
ProcessExport.h
Isis::ProcessExport::GetBuffersBIL
std::vector< BufferManager * > GetBuffersBIL()
A single line of input data from each input cube will be passed to the line processing function.
Definition: ProcessExport.cpp:944
Isis::ProcessExport::setFormat
void setFormat(ExportFormat format)
Sets the storage order of the output file.
Definition: ProcessExport.h:170
Isis::BandManager
Buffer manager, for moving through a cube in bands.
Definition: BandManager.h:33
Isis::ProcessExport::OutputLrs
double OutputLrs()
Return the output special pixel value for LRS.
Definition: ProcessExport.cpp:561
Isis::SignedWord
@ SignedWord
Definition: PixelType.h:32
Isis::ProcessExport::p_His
double p_His
The output value for pixels whose input DNs are High Instrument Saturation values.
Definition: ProcessExport.h:252
Isis::ProcessExport::GetBuffersBSQ
std::vector< BufferManager * > GetBuffersBSQ()
A single line of input data from each input cube will be passed to the line processing function.
Definition: ProcessExport.cpp:905
BandManager.h
Isis::ProcessExport::OutputHis
double OutputHis()
Return the output special pixel value for HIS.
Definition: ProcessExport.cpp:569
Isis::ProcessExport::p_outputMaximum
double p_outputMaximum
Desired maximum pixel value in the Buffer.
Definition: ProcessExport.h:225
Isis::EndianSwapper::ExportFloat
int ExportFloat(void *buf)
Swaps a floating point value for Exporting.
Definition: EndianSwapper.cpp:99
Isis::EndianSwapper::ShortInt
short int ShortInt(void *buf)
Swaps a short integer value.
Definition: EndianSwapper.cpp:174
Preference.h
Isis::ProcessExport::OutputNull
double OutputNull()
Return the output special pixel value for NULL.
Definition: ProcessExport.cpp:545
Isis::Process::StartProcess
virtual void StartProcess(void funct())
In the base class, this method will invoked a user-specified function exactly one time.
Definition: Process.h:213
Isis::ProcessExport::SetOutputRange
void SetOutputRange(const double minimum, const double maximum)
Set output pixel range in Buffer.
Definition: ProcessExport.cpp:454
Isis::ProcessExport::p_Lrs
double p_Lrs
The output value for pixels whose input DNs are Low Representation Saturation values.
Definition: ProcessExport.h:250
Isis::BufferManager::begin
bool begin()
Moves the shape buffer to the first position.
Definition: BufferManager.h:96
Isis::ProcessExport::p_outputMiddle
double p_outputMiddle
Middle pixel value (minimum+maximun)/2.0 in the Buffer.
Definition: ProcessExport.h:223
Isis::ProcessExport::SetOutputHis
void SetOutputHis(const double value)
Set output special pixel value for HIS.
Definition: ProcessExport.cpp:521
Isis::ProcessExport::p_Null
double p_Null
The output value for pixels whose input DNs are Null values.
Definition: ProcessExport.h:247
Isis::BufferManager
Manages a Buffer over a cube.
Definition: BufferManager.h:52
Isis::ByteOrder
ByteOrder
Tests the current architecture for byte order.
Definition: Endian.h:42
Isis::Buffer
Buffer for reading and writing cube data.
Definition: Buffer.h:53
Isis::BufferManager::end
bool end() const
Returns true if the shape buffer has accessed the end of the cube.
Definition: BufferManager.h:115
Isis::ProcessExport::p_Lis_Set
bool p_Lis_Set
Indicates whether p_Lis has been set (i.e.
Definition: ProcessExport.h:259
Isis::ProcessExport::SetOutputType
void SetOutputType(Isis::PixelType pixelIn)
Set output pixel bit type in Buffer.
Definition: ProcessExport.cpp:608
Isis::NoByteOrder
@ NoByteOrder
Definition: Endian.h:43
Isis::ProcessExport::p_inputMinimum
std::vector< double > p_inputMinimum
Minimum pixel value in the input cube to be mapped to the minimum value in the Buffer.
Definition: ProcessExport.h:227
Buffer.h
Endian.h
Isis::Application::GetUserInterface
static UserInterface & GetUserInterface()
Returns the UserInterface object.
Definition: Application.cpp:463
Isis::VALID_MAX2
const short VALID_MAX2
Definition: SpecialPixel.h:159
Isis::VALID_MIN2
const short VALID_MIN2
Definition: SpecialPixel.h:153
Isis::ProcessExport::GetInputMaximum
double GetInputMaximum(unsigned int n=0) const
Get the valid maximum pixel value for the Nth input cube.
Definition: ProcessExport.cpp:429
_FILEINFO_
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:24
Isis::ProcessExport::StartProcess
virtual void StartProcess(void funct(Isis::Buffer &in))
This method invokes the process operation over a single input cube.
Definition: ProcessExport.cpp:790
EndianSwapper.h
Isis::ProcessExport::p_Hrs_Set
bool p_Hrs_Set
Indicates whether p_Hrs has been set (i.e.
Definition: ProcessExport.h:265
Isis::Progress::SetText
void SetText(const QString &text)
Changes the value of the text string reported just before 0% processed.
Definition: Progress.cpp:61
Application.h
Isis::ProcessExport::p_endianSwap
EndianSwapper * p_endianSwap
Object to swap the endianness of the raw output to either MSB or LSB.
Definition: ProcessExport.h:237
Isis::NULL8
const double NULL8
Definition: SpecialPixel.h:94
Isis::ProcessExport::SetOutputLrs
void SetOutputLrs(const double value)
Set output special pixel value for LRS.
Definition: ProcessExport.cpp:506
Isis::ProcessExport::GetOutputMaximum
double GetOutputMaximum()
Get the valid maximum pixel value to be written to the output file.
Definition: ProcessExport.h:165
Isis::ProcessExport::SetOutputEndian
void SetOutputEndian(enum ByteOrder endianness)
Set byte endianness of the output cube.
Definition: ProcessExport.cpp:649
Isis::ProcessExport::BIL
@ BIL
Band interleaved by line.
Definition: ProcessExport.h:118
Isis::Msb
@ Msb
Definition: Endian.h:45
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::Projection::SetWorld
virtual bool SetWorld(const double x, const double y)
This method is used to set a world coordinate.
Definition: Projection.cpp:497
Isis::ProcessExport::p_str
std::vector< Stretch * > p_str
Stretch object to ensure a reasonable range of pixel values in the output data.
Definition: ProcessExport.h:243
Isis::ProcessExport::JP2
@ JP2
Compressed JPEG2000.
Definition: ProcessExport.h:120
Isis::VALID_MAXU2
const unsigned short VALID_MAXU2
Definition: SpecialPixel.h:168
Isis::ProcessExport::p_Lrs_Set
bool p_Lrs_Set
Indicates whether p_Lrs has been set (i.e.
Definition: ProcessExport.h:261
IsisAml::Clear
void Clear(const QString &paramName)
Clears the value(s) in the named parameter.
Definition: IsisAml.cpp:1852
Isis::ProcessExport::checksum
QString checksum()
@description Generates a file checksum.
Definition: ProcessExport.cpp:694
Isis::PixelType
PixelType
Enumerations for Isis Pixel Types.
Definition: PixelType.h:27
IException.h
Isis::ProcessExport::GetBuffersBIP
std::vector< BufferManager * > GetBuffersBIP()
A single band of input data from each input cube will be passed to the band processing function.
Definition: ProcessExport.cpp:982
Isis::ProcessExport::canGenerateChecksum
bool canGenerateChecksum()
@description Return if we can generate a checksum
Definition: ProcessExport.cpp:684
Isis::IException::Programmer
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:146
Isis::Histogram::Median
double Median() const
Returns the median.
Definition: Histogram.cpp:319
std
Namespace for the standard library.
Isis::Histogram
Container of a cube histogram.
Definition: Histogram.h:74
Isis::IsValidPixel
bool IsValidPixel(const double d)
Returns if the input pixel is valid.
Definition: SpecialPixel.h:223
Isis::UserInterface
Command Line and Xml loader, validation, and access.
Definition: UserInterface.h:140
IsisAml::GetString
QString GetString(const QString &paramName) const
Allows the retrieval of a value for a parameter of type "string".
Definition: IsisAml.cpp:692
Isis::ProcessExport::ProcessCubes
void ProcessCubes(const Functor &functor)
Definition: ProcessExport.h:175
Isis::ProcessExport::GetOutputMinimum
double GetOutputMinimum()
Get the valid minimum pixel value to be written to the output file.
Definition: ProcessExport.h:161
Isis::ProcessExport::GetInputMinimum
double GetInputMinimum(unsigned int n=0) const
Get the valid minimum pixel value for the Nth input cube.
Definition: ProcessExport.cpp:418
Isis::ProcessExport::p_inputMaximum
std::vector< double > p_inputMaximum
Maximum pixel value in the input cube to be mapped to the maximum value in the Buffer.
Definition: ProcessExport.h:234
Isis::ProcessExport::p_inputMiddle
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.
Definition: ProcessExport.h:230
Isis::EndianSwapper
Byte swapper.
Definition: EndianSwapper.h:38
Isis::ProcessExport::p_His_Set
bool p_His_Set
Indicates whether p_His has been set (i.e.
Definition: ProcessExport.h:263
Isis::Process::p_progress
Isis::Progress * p_progress
Pointer to a Progress object.
Definition: Process.h:145
Isis::VALID_MINU2
const unsigned short VALID_MINU2
Definition: SpecialPixel.h:162
IsisAml::PutDouble
void PutDouble(const QString &paramName, const double &value)
Allows the insertion of a value for a parameter of type "double".
Definition: IsisAml.cpp:361
Isis::VALID_MAX1
const unsigned char VALID_MAX1
Definition: SpecialPixel.h:187
Isis::Buffer::size
int size() const
Returns the total number of pixels in the shape buffer.
Definition: Buffer.h:97
Projection.h
Isis::IString
Adds specific functionality to C++ strings.
Definition: IString.h:165
Isis::ProcessExport::BIP
@ BIP
Band interleaved by pixel.
Definition: ProcessExport.h:119
Isis::Projection::YCoord
double YCoord() const
This returns the projection Y provided SetGround, SetCoordinate, SetUniversalGround,...
Definition: Projection.cpp:400
UserInterface.h
Isis::Lsb
@ Lsb
Definition: Endian.h:44
Isis::Projection
Base class for Map Projections.
Definition: Projection.h:155
Isis::ProcessExport::HasInputRange
bool HasInputRange() const
Definition: ProcessExport.cpp:412
Isis::UnsignedByte
@ UnsignedByte
Definition: PixelType.h:29
Isis::ProcessExport::SetOutputNull
void SetOutputNull(const double value)
Set output special pixel value for NULL.
Definition: ProcessExport.cpp:476
Isis::Projection::XCoord
double XCoord() const
This returns the projection X provided SetGround, SetCoordinate, SetUniversalGround,...
Definition: Projection.cpp:387
Isis::ProcessExport::BSQ
@ BSQ
Band sequential.
Definition: ProcessExport.h:117
Isis::ProcessExport::p_outputMinimum
double p_outputMinimum
Desired minimum pixel value in the Buffer.
Definition: ProcessExport.h:222
Isis::ProcessExport
Process class for exporting cubes.
Definition: ProcessExport.h:111
Isis::ProcessExport::p_Null_Set
bool p_Null_Set
Indicates whether p_Null has been set (i.e.
Definition: ProcessExport.h:257
Isis::ProcessExport::p_pixelType
PixelType p_pixelType
The bits per pixel of the output image.
Definition: ProcessExport.h:241
Isis::ProcessExport::ProcessExport
ProcessExport()
Constructs an Export object.
Definition: ProcessExport.cpp:28
Isis::ProcessExport::OutputLis
double OutputLis()
Return the output special pixel value for LIS.
Definition: ProcessExport.cpp:553
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::ProcessExport::~ProcessExport
virtual ~ProcessExport()
Destructor.
Definition: ProcessExport.cpp:58
Isis::Real
@ Real
Definition: PixelType.h:35