1 //******************************************************************* 2 // 3 // License: See top level LICENSE.txt file. 4 // 5 // AUTHOR: Oscar Kramer (okramer@imagelinks.com) 6 // 7 // DESCRIPTION: Contains implementation of class 8 // 9 // LIMITATIONS: None. 10 // 11 //***************************************************************************** 12 // $Id: ossimAtbMatchPoint.cpp 15766 2009-10-20 12:37:09Z gpotts $ 13 14 #include <ossim/imaging/ossimAtbMatchPoint.h> 15 #include <ossim/imaging/ossimAtbPointSource.h> 16 #include <ossim/imaging/ossimGridRemapEngine.h> 17 #include <ossim/imaging/ossimGridRemapSource.h> 18 19 //*** 20 // Define Trace flags for use within this file: 21 //*** 22 #include <ossim/base/ossimTrace.h> 23 static ossimTrace traceExec ("ossimAtbMatchPoint:exec"); 24 static ossimTrace traceDebug ("ossimAtbMatchPoint:debug"); 25 26 using namespace std; 27 28 //***************************************************************************** 29 // DESTRUCTOR: ~ossimAtbMatchPoint() 30 // 31 // Need to delete each instance of an ossimAtbPointSource in thePointSourceList 32 // 33 //***************************************************************************** ~ossimAtbMatchPoint()34ossimAtbMatchPoint::~ossimAtbMatchPoint() 35 { 36 thePointSourceList.clear(); 37 } 38 39 //***************************************************************************** 40 // METHOD: ossimAtbMatchPoint::addImage() 41 // 42 // Adds a new contribution to the sample set. 43 // 44 //***************************************************************************** addImage(ossimGridRemapSource * remapper)45void ossimAtbMatchPoint::addImage(ossimGridRemapSource* remapper) 46 { 47 static const char MODULE[] = "ossimAtbMatchPoint::addImage()"; 48 if (traceExec()) CLOG << "entering..." << endl; 49 50 //*** 51 // Assure that this image contains the view point corresponding to this 52 // matchpoint: 53 //*** 54 if (!remapper->getBoundingRect().pointWithin(theViewPoint)) 55 { 56 if (traceExec()) CLOG << "returning..." << endl; 57 return; 58 } 59 60 //*** 61 // Instantiate a point source for this image at this view point and 62 // save it in the list: 63 //*** 64 ossimAtbPointSource* point_source = new ossimAtbPointSource(remapper, 65 theViewPoint); 66 thePointSourceList.push_back(point_source); 67 68 if (traceExec()) CLOG << "returning..." << endl; 69 return; 70 } 71 72 73 //***************************************************************************** 74 // METHOD: ossimAtbMatchPoint::assignRemapValues() 75 // 76 // The target parameter value computed given all contributions. The target 77 // value is then used to establish the remap parameters for each image at this 78 // points location. 79 // 80 //***************************************************************************** assignRemapValues()81bool ossimAtbMatchPoint::assignRemapValues() 82 { 83 static const char MODULE[] = "ossimAtbMatchPoint::assignRemapValues()"; 84 if (traceExec()) CLOG << "entering..." << endl; 85 86 //*** 87 // Determine the number of contributors. We require minimum of two: 88 //*** 89 ossim_uint32 num_contributors = (ossim_uint32)thePointSourceList.size(); 90 if (num_contributors < 2) 91 return false; 92 93 //*** 94 // Hand off the computation of the target pixel to the ATB engine being 95 // used. The engine implements the methods for computing targets, as these 96 // will vary according to algorithm being used: 97 //*** 98 theGridRemapEngine->assignRemapValues(thePointSourceList); 99 100 if (traceExec()) CLOG << "returning..." << endl; 101 return true; 102 } 103 104 105 //***************************************************************************** 106 // METHOD: ossimAtbMatchPoint::setKernelSize(N) 107 // 108 // Hook to set the size of the kernel used by all point sources in computing 109 // their mean pixel value. The kernels will be resized to NxN. 110 // 111 //***************************************************************************** setKernelSize(int side_size)112void ossimAtbMatchPoint::setKernelSize(int side_size) 113 { 114 static const char MODULE[] = "ossimAtbController::setKernelSize(N)"; 115 if (traceExec()) CLOG << "entering..." << endl; 116 117 vector<ossimAtbPointSource*>::iterator psi = thePointSourceList.begin(); 118 while (psi != thePointSourceList.end()) 119 (*psi)->setKernelSize(side_size); 120 121 if (traceExec()) CLOG << "returning..." << endl; 122 return; 123 } 124 125 126 //***************************************************************************** 127 // METHOD: ossimAtbMatchPoint::setAtbRemapEngine 128 // 129 //***************************************************************************** setGridRemapEngine(ossimGridRemapEngine * engine)130void ossimAtbMatchPoint::setGridRemapEngine(ossimGridRemapEngine* engine) 131 { 132 static const char MODULE[] = "ossimAtbMatchPoint::setAtbRemapEngine"; 133 if (traceExec()) CLOG << "entering..." << endl; 134 135 theGridRemapEngine = engine; 136 137 //*** 138 // Need to communicate this change of engine to the point sources that use 139 // it to arrive at a "source value": 140 //*** 141 vector<ossimAtbPointSource*>::iterator source = thePointSourceList.begin(); 142 while (source != thePointSourceList.end()) 143 { 144 (*source)->setGridRemapEngine(engine); 145 source++; 146 } 147 148 if (traceExec()) CLOG << "returning..." << endl; 149 return; 150 } 151