14#include "SpecialPixel.h"
15#include "IException.h"
27 p_lis = Isis::LOW_INSTR_SAT8;
28 p_lrs = Isis::LOW_REPR_SAT8;
29 p_his = Isis::HIGH_INSTR_SAT8;
30 p_hrs = Isis::HIGH_REPR_SAT8;
51 string msg =
"Input pairs must be in ascending order";
80 if(
p_input.size() == 0)
return value;
112 while(start != end) {
113 int middle = (start + end) / 2;
115 if(middle == start) {
118 else if(value <
p_input[middle]) {
146 std::pair<double, double> io;
150 pairs = pairs.simplified().trimmed();
152 if (pairs.contains(
":")) {
155 QString firstPair = pairList.takeFirst();
157 QStringList firstPairValues = firstPair.split(
":");
159 if (firstPairValues.count() == 2) {
160 io.first =
toDouble(firstPairValues.first());
161 io.second =
toDouble(firstPairValues.last());
163 pairs = pairList.join(
" ");
187 std::pair<double, double> pear;
189 QString p = pairs.simplified().trimmed();
190 p.replace(QRegExp(
"[\\s]*:"),
":");
191 p.replace(QRegExp(
":[\\s]*"),
":");
192 QStringList pairList = p.split(
" ", Qt::SkipEmptyParts);
195 foreach(QString singlePair, pairList) {
225 std::pair<double, double> pear;
229 std::vector<double> converted;
232 while(p.size() > 0) {
234 pear.first = hist->Percent(pear.first);
239 bool collision =
false;
241 while(!collision && k < converted.size()) {
242 if(pear.first == converted[k]) {
251 converted.push_back(pear.first);
258 pairs +
"]", _FILEINFO_);
273 for(
int i = 0; i <
p_pairs; i++) {
288 if(index >=
p_pairs || index < 0) {
303 if(index >=
p_pairs || index < 0) {
345 PvlKeyword outputs = grp.findKeyword(
"Output");
347 if(inputs.size() != outputs.size()) {
348 QString msg =
"Invalid Pvl file: The number of Input values must equal the number of Output values";
351 for(
int i = 0; i < inputs.size(); i++) {
367 void Stretch::Save(QString &file, QString &grpName) {
373 void Stretch::Save(
Isis::Pvl &pvl, QString &grpName) {
377 for(
int i = 0; i <
Pairs(); i++) {
381 grp->addKeyword(inputs);
382 grp->addKeyword(outputs);
Container of a cube histogram.
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
@ Programmer
This error is for when a programmer made an API call that was illegal.
Contains multiple PvlContainers.
Container for cube-like labels.
A single keyword-value pair.
@ Traverse
Search child objects.
void CopyPairs(const Stretch &other)
Copies the stretch pairs from another Stretch object, but maintains special pixel values.
void Parse(const QString &pairs)
Parses a string of the form "i1:o1 i2:o2...iN:oN" where each i:o represents an input:output pair.
void AddPair(const double input, const double output)
Adds a stretch pair to the list of pairs.
int p_pairs
Number of stretch pairs.
double p_null
Mapping of input NULL values go to this value (default NULL)
Stretch()
Constructs a Stretch object with default mapping of special pixel values to themselves.
std::pair< double, double > NextPair(QString &pairs)
Given a string containing stretch pairs for example "0:0 50:0 100:255 255:255" evaluate the first pai...
std::vector< double > p_output
Array for output side of stretch pairs.
double p_lrs
Mapping of input LRS values go to this value (default LRS)
double Output(const int index) const
Returns the value of the output side of the stretch pair at the specified index.
double p_minimum
By default this value is set to p_lrs.
double Input(const int index) const
Returns the value of the input side of the stretch pair at the specified index.
double p_maximum
By default this value is set to p_hrs.
std::vector< double > p_input
Array for input side of stretch pairs.
double p_hrs
Mapping of input HRS values go to this value (default HRS)
double p_his
Mapping of input HIS values go to this value (default HIS)
double Map(const double value) const
Maps an input value to an output value based on the stretch pairs and/or special pixel mappings.
int Pairs() const
Returns the number of stretch pairs.
void Load(Pvl &pvl, QString &grpName)
Loads the stretch pairs from the pvl file into the Stretch object.
double p_lis
Mapping of input LIS values go to this value (default LIS)
QString Text() const
Converts stretch pair to a string.
This is free and unencumbered software released into the public domain.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
bool IsNullPixel(const double d)
Returns if the input pixel is null.
bool IsHrsPixel(const double d)
Returns if the input pixel is high representation saturation.
bool IsValidPixel(const double d)
Returns if the input pixel is valid.
const double Null
Value for an Isis Null pixel.
bool IsHisPixel(const double d)
Returns if the input pixel is high instrument saturation.
double toDouble(const QString &string)
Global function to convert from a string to a double.
bool IsLisPixel(const double d)
Returns if the input pixel is low instrument saturation.
Namespace for the standard library.