USGS

Isis 3.0 Application Source Code Reference

Home

apollocal.cpp

Go to the documentation of this file.
00001 #include "Isis.h"
00002 #include "SpecialPixel.h"
00003 #include "ProcessByTile.h"
00004 #include "Pvl.h"
00005 #include "CubeAttribute.h"
00006 #include "PvlTranslationTable.h"
00007 
00008 using namespace std;
00009 using namespace Isis;
00010 
00011 void cal (vector<Buffer *> &in, 
00012           vector<Buffer *> &out);
00013 
00014 void IsisMain() {
00015   // We will be processing by line
00016   ProcessByTile p;
00017   p.SetTileSize(128, 128);
00018 
00019   Cube *inCube = p.SetInputCube("FROM");
00020 
00021   PvlGroup &dataDir =
00022       Preference::Preferences().FindGroup("DataDirectory");
00023   PvlTranslationTable tTable(
00024       (QString)p.MissionData("base", "translations/MissionName2DataDir.trn"));
00025   QString missionDir = dataDir[tTable.Translate("MissionName",
00026       (inCube->group("Instrument")).FindKeyword("SpacecraftName")[0])][0];
00027   QString camera =
00028       (inCube->group("Instrument")).FindKeyword("InstrumentId")[0];
00029 
00030   CubeAttributeInput cai;
00031   p.SetInputCube(missionDir + "/calibration/" + camera + "_flatfield.cub", cai);
00032 
00033   CubeAttributeOutput cao;
00034   cao.setPixelType(Real);
00035   p.SetOutputCube(
00036       FileName(Application::GetUserInterface().GetAsString("TO")).expanded(),
00037       cao, inCube->sampleCount(), inCube->lineCount(),
00038       inCube->bandCount());
00039 
00040   p.StartProcess(cal);
00041   p.EndProcess();
00042 }
00043 
00044 void cal (vector<Buffer *> &in, vector<Buffer *> &out) {
00045   Buffer &inp = *in[0];      // Input Cube
00046   Buffer &fff = *in[1];      // Flat Field File
00047   Buffer &outp = *out[0];    // Output Cube
00048 
00049   
00050   // Loop for each pixel in the line.
00051   for (int i=0; i<inp.size(); i++) {
00052     if (IsSpecial(inp[i])) {
00053       outp[i] = inp[i];
00054     }
00055     else if (IsSpecial(fff[i])) {
00056       outp[i] = Null;
00057     }
00058     else {
00059       outp[i] = 65535.0*(1.0 - log(65536 - inp[i])/log(2.0)/16.0);    // Log Filter the film negative (and multiply by 2^16/16 to maintain the range of values)
00060       outp[i] -=  1300.0;    // subtract dark current
00061       outp[i] /= fff[i];    // divide flat field to remove vignetting effects
00062     }
00063   }
00064 }