// The input buffer has a raw 16 bit buffer but the values are still 0 to 255 void FixDns8 (Buffer &buf) { // Convert all 8bit image values of =255 (xFF) to 16bit NULL, count as gap // Convert all 8bit image values of =254 (xFE) to 16bit HIS, count as HIS // Convert all 8bit image values of =0 (x00) to 16bit LIS, count as NULL // Convert 8bit image data to 16bit by applying the LUT short int *raw = (short int*)(buf.RawBuffer()); for (int i=0; i<buf.size(); i++) { if (raw[i] == (short int)255) { buf[i] = Isis::NULL8; gapCount[section]++; } else if (raw[i] == (short int)254) { buf[i] = Isis::HIGH_INSTR_SAT8; hisCount[section]++; } else if (raw[i] == (short int)0) { buf[i] = Isis::LOW_INSTR_SAT8; lisCount[section]++; } else { // It's valid so just run it thru the lookup table to get a 16 bit dn buf[i] = stretch.Map(buf[i]); validCount[section]++; } } }
// Adjust FROM histogram to resemble MATCH's histogram void remap(vector<Buffer *> &in, vector<Buffer *> &out) { Buffer &from = *in[0]; Buffer &to = *out[0]; for(int i = 0; i < from.size(); i++) { to[i] = stretch.Map(from[i]); } } // end remap
// Adjust FROM cumulative distribution to be flatter void remap(Buffer &in, Buffer &out) { for (int i = 0; i < in.size(); i++) { out[i] = stretch.Map(in[i]); } } // end remap .
//! Separates each of the individual WAC framelets into the right place void separateFramelets(Buffer &in) { // this is true if uv is summed and mixed with unsummed vis bool extractMiddleSamples = false; // This is the framelet set the line belongs to int frameletSet = 0; // this is the offset into the set int frameletSetOffset = 0; // this is true if framelet belongs in an even cube bool even = false; // line # in current framelet int frameletLineOffset = 0; // this is the framelet number the current line belongs in int framelet = getFrameletNumber(in.Line(), frameletSet, frameletSetOffset, frameletLineOffset, even); // this is the output file the current line belongs in Cube *outfile = NULL; // uv and vis outputs if(viseven && uveven) { if(framelet < 2 && even) { outfile = uveven; extractMiddleSamples = true; } else if(framelet < 2) { outfile = uvodd; extractMiddleSamples = true; } else if(even) { outfile = viseven; } else { outfile = visodd; } } // vis output else if(viseven) { if(even) { outfile = viseven; } else { outfile = visodd; } } // uv output else { extractMiddleSamples = true; if(even) { outfile = uveven; } else { outfile = uvodd; } } // We know our output file now, so get a linemanager for writing LineManager mgr(*outfile); // line is framelet * frameletLineOffset + frameletSetOffset int outLine = 1; int outBand = framelet + 1; // if both vis & uv on, outLine is a calculation based on the current line // being uv or vis and the general calculation (above) does not work if(viseven && uveven) { // uv file if(framelet < 2) { outLine = frameletSet * 4 + 1 + padding[framelet]; } // vis file else { outLine = frameletSet * 14 + 1 + padding[framelet]; outBand -= 2; // uv is not in vis file } } // only vis on else if(viseven) { outLine = frameletSet * 14 + 1 + padding[framelet]; } // only uv on else { outLine = frameletSet * 4 + 1 + padding[framelet]; } if(flip) { outLine = outfile->lineCount() - (outLine - 1); } outLine += frameletLineOffset; mgr.SetLine(outLine, outBand); if(!extractMiddleSamples) { for(int i = 0; i < in.size(); i++) { if(i >= mgr.size()) { QString msg = "The input file has an unexpected number of samples"; throw IException(IException::Unknown, msg, _FILEINFO_); } mgr[i] = lookupTable.Map(in[i]); } } else { // read middle of input... int startSamp = (in.size() / 2) - mgr.size() / 2; int endSamp = (in.size() / 2) + mgr.size() / 2; if(mgr.size() > in.size()) { QString msg = "Output number of samples calculated is invalid"; throw IException(IException::Unknown, msg, _FILEINFO_); } for(int inputSamp = startSamp; inputSamp < endSamp; inputSamp++) { mgr[inputSamp - startSamp] = lookupTable.Map(in[inputSamp]); } } outfile->write(mgr); }