#include #include #include #include #include #include #include /** * Cube::ObjectMerger(): * A Function that takes a Cube's list of Detections and * combines those that are close (according to the * thresholds specified in the parameter list par). * It also excludes those that do not make the minimum * number of channels requirement. */ void Cube::ObjectMerger() { if(this->objectList.size() > 0){ // make a vector "currentList", which starts as a copy of the Cube's objectList, // but is the one worked on. vector *currentList = new vector (this->objectList.size()); *currentList = this->objectList; vector ::iterator iter; // The Cube's objectList is cleared, and then the final objects are added to it at the end. this->objectList.clear(); int counter, compCounter,numLoops; bool areNear,isMatch; long gap; bool isVerb = this->par.isVerbose(); if(this->par.getFlagGrowth()) numLoops=2; else numLoops = 1; for(int nloop = 0; nloop < numLoops; nloop++){ counter=0; while( counter < (currentList->size()-1) ){ if(isVerb){ std::cout.setf(std::ios::right); if(nloop>0) std::cout << "Progress#2: " << std::setw(6) << counter << "/" ; else std::cout << "Progress: " << std::setw(6) << counter << "/" ; std::cout.unsetf(std::ios::right); std::cout.setf(std::ios::left); std::cout << std::setw(6) << currentList->size() << "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b" << std::flush; if(nloop>0) std::cout << "\b\b" << std::flush; ; std::cout.unsetf(std::ios::left); } compCounter = counter + 1; do { Detection *obj1 = new Detection; *obj1 = currentList->at(counter); Detection *obj2 = new Detection; *obj2 = currentList->at(compCounter); if(areClose(*obj1, *obj2, this->par)){ obj1->addAnObject( *obj2 ); iter = currentList->begin() + compCounter; currentList->erase(iter); iter = currentList->begin() + counter; currentList->erase(iter); currentList->push_back( *obj1 ); if(isVerb){ std::cout.setf(std::ios::right); std::cout << "Progress: " << std::setw(6) << counter << "/"; std::cout.unsetf(std::ios::right); std::cout.setf(std::ios::left); std::cout << std::setw(6) << currentList->size() << "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b" << std::flush; std::cout.unsetf(std::ios::left); } compCounter = counter + 1; } else compCounter++; delete obj2; delete obj1; } while( (compCountersize()) ); counter++; } // end of while(counter<(currentList->size()-1)) loop if( (nloop==0) && (this->par.getFlagGrowth()) ) { std::cout << "Growing objects... "<< std::flush; this->setCubeStats(); vector *newList = new vector ; std::cout<< "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"<size();i++){ std::cout<< "\b\b\b\b\b\b"<at(i); growObject(*obj,*this); newList->push_back(*obj); delete obj; } delete currentList; currentList = newList; std::cout.unsetf(std::ios::left); std::cout<< "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"<size()){ (*currentList)[listCounter].addOffsets(this->par); (*currentList)[listCounter].calcParams(); // Now, for each object in the newly modified list, we need to check if // they pass the requirements on the minimum no. of channels and minimum // number of spatial pixels // If not, remove from list. if( (*currentList)[listCounter].hasEnoughChannels(this->par.getMinChannels()) && ((*currentList)[listCounter].getSpatialSize() >= this->par.getMinPix()) ){ listCounter++; if(isVerb){ std::cout << "Final total:"<erase(currentList->begin()+listCounter); } this->objectList = *currentList; currentList->clear(); delete currentList; } }