|
Isis 3 Programmer Reference
|
36 Pixel::Pixel(
int sample,
int line,
int band,
double DN) {
51 Pixel::Pixel(
const Pixel& pixel) {
53 m_line = pixel.
line();
54 m_band = pixel.
band();
67 m_line = other.
line();
69 m_band = other.
band();
80 int Pixel::line()
const {
86 int Pixel::sample()
const {
92 int Pixel::band()
const {
98 double Pixel::DN()
const {
111 unsigned char Pixel::To8Bit(
const double d) {
113 if(d == NULL8)
return NULL1;
114 else if(d == LOW_INSTR_SAT8)
return LOW_INSTR_SAT1;
115 else if(d == LOW_REPR_SAT8)
return LOW_REPR_SAT1;
116 else if(d == HIGH_INSTR_SAT8)
return HIGH_INSTR_SAT1;
117 else if(d == HIGH_REPR_SAT8)
return HIGH_REPR_SAT1;
118 else return LOW_REPR_SAT1;
121 if(d < VALID_MIN1 - 0.5)
return LOW_REPR_SAT1;
122 else if(d > VALID_MAX1 + 0.5)
return HIGH_REPR_SAT1;
125 int itemp = (int)(d + 0.5);
126 if(itemp < VALID_MIN1)
return LOW_REPR_SAT1;
127 else if(itemp > VALID_MAX1)
return HIGH_REPR_SAT1;
128 else return (
unsigned char)(d + 0.5);
140 unsigned char Pixel::To8Bit() {
152 short int Pixel::To16Bit(
const double d) {
154 if(d == NULL8)
return NULL2;
155 else if(d == LOW_INSTR_SAT8)
return LOW_INSTR_SAT2;
156 else if(d == LOW_REPR_SAT8)
return LOW_REPR_SAT2;
157 else if(d == HIGH_INSTR_SAT8)
return HIGH_INSTR_SAT2;
158 else if(d == HIGH_REPR_SAT8)
return HIGH_REPR_SAT2;
159 else return LOW_REPR_SAT2;
162 if(d < VALID_MIN2 - 0.5)
return LOW_REPR_SAT2;
163 else if(d > VALID_MAX2 + 0.5)
return HIGH_REPR_SAT2;
168 itemp = (int)(d - 0.5);
171 itemp = (int)(d + 0.5);
174 if(itemp < VALID_MIN2)
return LOW_REPR_SAT2;
175 else if(itemp > VALID_MAX2)
return HIGH_REPR_SAT2;
176 else if(d < 0.0)
return (
short)(d - 0.5);
177 else return (
short)(d + 0.5);
189 short int Pixel::To16Bit() {
190 return To16Bit(m_DN);
200 short unsigned int Pixel::To16UBit(
const double d) {
202 if(d == NULL8)
return NULLU2;
203 else if(d == LOW_INSTR_SAT8)
return LOW_INSTR_SATU2;
204 else if(d == LOW_REPR_SAT8)
return LOW_REPR_SATU2;
205 else if(d == HIGH_INSTR_SAT8)
return HIGH_INSTR_SATU2;
206 else if(d == HIGH_REPR_SAT8)
return HIGH_REPR_SATU2;
207 else return LOW_REPR_SATU2;
210 if(d < VALID_MIN2 - 0.5)
return LOW_REPR_SATU2;
211 else if(d > VALID_MAX2 + 0.5)
return HIGH_REPR_SATU2;
216 itemp = (int)(d - 0.5);
219 itemp = (int)(d + 0.5);
222 if(itemp < VALID_MIN2)
return LOW_REPR_SATU2;
223 else if(itemp > VALID_MAX2)
return HIGH_REPR_SATU2;
224 else if(d < 0.0)
return (
short)(d - 0.5);
225 else return (
short)(d + 0.5);
237 short unsigned int Pixel::To16Ubit() {
238 return To16UBit(m_DN);
248 float Pixel::To32Bit(
const double d) {
249 if(d < (
double) VALID_MIN8) {
250 if(d == NULL8)
return(NULL4);
251 else if(d == LOW_REPR_SAT8)
return(LOW_REPR_SAT4);
252 else if(d == LOW_INSTR_SAT8)
return(LOW_INSTR_SAT4);
253 else if(d == HIGH_INSTR_SAT8)
return(HIGH_INSTR_SAT4);
254 else if(d == HIGH_REPR_SAT8)
return(HIGH_REPR_SAT4);
255 else return(LOW_REPR_SAT4);
257 else if(d > (
double) VALID_MAX8)
return(HIGH_REPR_SAT8);
258 else return((
float) d);
267 float Pixel::To32Bit() {
268 return To32Bit(m_DN);
280 double Pixel::ToDouble(
const unsigned char d) {
282 if(d == NULL1)
return(NULL8);
283 else if(d == LOW_REPR_SAT1)
return(LOW_REPR_SAT8);
284 else if(d == LOW_INSTR_SAT1)
return(LOW_INSTR_SAT8);
285 else if(d == HIGH_REPR_SAT1)
return(HIGH_REPR_SAT8);
286 else if(d == HIGH_INSTR_SAT1)
return(HIGH_INSTR_SAT8);
287 else return(LOW_REPR_SAT8);
289 else if(d > VALID_MAX1)
return(HIGH_REPR_SAT8);
290 else return((
double) d);
301 double Pixel::ToDouble(
const short int d) {
303 if(d == NULL2)
return(NULL8);
304 else if(d == LOW_REPR_SAT2)
return(LOW_REPR_SAT8);
305 else if(d == LOW_INSTR_SAT2)
return(LOW_INSTR_SAT8);
306 else if(d == HIGH_REPR_SAT2)
return(HIGH_REPR_SAT8);
307 else if(d == HIGH_INSTR_SAT2)
return(HIGH_INSTR_SAT8);
308 else return(LOW_REPR_SAT8);
310 else return((
double) d);
320 double Pixel::ToDouble(
const short unsigned int d) {
321 if(d < VALID_MINU2) {
322 if(d == NULLU2)
return(NULL8);
323 else if(d == LOW_REPR_SATU2)
return(LOW_REPR_SAT8);
324 else if(d == LOW_INSTR_SATU2)
return(LOW_INSTR_SAT8);
325 else if(d == HIGH_REPR_SATU2)
return(HIGH_REPR_SAT8);
326 else if(d == HIGH_INSTR_SATU2)
return(HIGH_INSTR_SAT8);
327 else return(LOW_REPR_SAT8);
329 else return((
double) d);
340 double Pixel::ToDouble(
const float d) {
342 if(d == NULL4)
return(NULL8);
343 else if(d == LOW_REPR_SAT4)
return(LOW_REPR_SAT8);
344 else if(d == LOW_INSTR_SAT4)
return(LOW_INSTR_SAT8);
345 else if(d == HIGH_REPR_SAT4)
return(HIGH_REPR_SAT8);
346 else if(d == HIGH_INSTR_SAT4)
return(HIGH_INSTR_SAT8);
347 else return(LOW_REPR_SAT8);
349 else if(d > VALID_MAX4)
return(HIGH_REPR_SAT8);
350 else return((
double) d);
359 double Pixel::ToDouble() {
374 float Pixel::ToFloat(
const unsigned char t) {
375 if(t < (
double) VALID_MIN1) {
376 if(t == NULL1)
return(NULL4);
377 else if(t == LOW_REPR_SAT1)
return(LOW_REPR_SAT4);
378 else if(t == LOW_INSTR_SAT1)
return(LOW_INSTR_SAT4);
379 else if(t == HIGH_INSTR_SAT1)
return(HIGH_INSTR_SAT4);
380 else if(t == HIGH_REPR_SAT1)
return(HIGH_REPR_SAT4);
381 else return(LOW_REPR_SAT4);
383 else if(t > (
double) VALID_MAX1)
return(HIGH_REPR_SAT8);
384 else return((
float) t);
395 float Pixel::ToFloat(
const short int t) {
396 if(t < (
double) VALID_MIN2) {
397 if(t == NULL2)
return(NULL4);
398 else if(t == LOW_REPR_SAT2)
return(LOW_REPR_SAT4);
399 else if(t == LOW_INSTR_SAT2)
return(LOW_INSTR_SAT4);
400 else if(t == HIGH_INSTR_SAT2)
return(HIGH_INSTR_SAT4);
401 else if(t == HIGH_REPR_SAT2)
return(HIGH_REPR_SAT4);
402 else return(LOW_REPR_SAT4);
404 else if(t > (
double) VALID_MAX2)
return(HIGH_REPR_SAT8);
405 else return((
float) t);
416 float Pixel::ToFloat(
const short unsigned int t) {
417 if(t < (
double) VALID_MINU2) {
418 if(t == NULLU2)
return(NULL4);
419 else if(t == LOW_REPR_SATU2)
return(LOW_REPR_SAT4);
420 else if(t == LOW_INSTR_SATU2)
return(LOW_INSTR_SAT4);
421 else if(t == HIGH_INSTR_SATU2)
return(HIGH_INSTR_SAT4);
422 else if(t == HIGH_REPR_SATU2)
return(HIGH_REPR_SAT4);
423 else return(LOW_REPR_SAT4);
425 else if(t > (
double) VALID_MAXU2)
return(HIGH_REPR_SAT8);
426 else return((
float) t);
437 float Pixel::ToFloat(
const double t) {
438 if(t < (
double) VALID_MIN8) {
439 if(t == NULL8)
return(NULL4);
440 else if(t == LOW_REPR_SAT8)
return(LOW_REPR_SAT4);
441 else if(t == LOW_INSTR_SAT8)
return(LOW_INSTR_SAT4);
442 else if(t == HIGH_INSTR_SAT8)
return(HIGH_INSTR_SAT4);
443 else if(t == HIGH_REPR_SAT8)
return(HIGH_REPR_SAT4);
444 else return(LOW_REPR_SAT4);
446 else if(t > (
double) VALID_MAX8)
return(HIGH_REPR_SAT8);
447 else return((
float) t);
457 float Pixel::ToFloat() {
458 return ToFloat(m_DN);
469 string Pixel::ToString(
double d) {
471 if(IsNull(d))
return string(
"Null");
472 else if(IsLrs(d))
return string(
"Lrs");
473 else if(IsHrs(d))
return string(
"Hrs");
474 else if(IsHis(d))
return string(
"His");
475 else if(IsLis(d))
return string(
"Lis");
476 else return string(
"Invalid");
480 return result.setNum(d).toStdString();
488 string Pixel::ToString() {
QString ToString(const T &value)
Helper function to convert values to strings.
bool IsSpecial(const double d)
Returns if the input pixel is special.
const double Null
Value for an Isis Null pixel.
Namespace for the standard library.
Store and/or manipulate pixel values.
This is free and unencumbered software released into the public domain.