rspfNormalizedS16RemapTable::rspfNormalizedS16RemapTable() : rspfNormalizedRemapTable() { if (!theTableIsInitialized) { const rspf_int32 ENTRIES = getEntries(); const rspf_float64 DENOMINATOR = getNormalizer(); //--- // Initialize the remap table. // // Specialized for elevation, make -32768 and -32767 map to 0 since // DTED NULL is -32767. // // NOTE: Zero will always remap back to -32768 with this hack. This // could cause issues on writers that use pixFromNorm(). (drb) //--- theTable[0] = 0.0; // Index zero always for null. theTable[1] = 0.0; // Specialized for DTED. for (rspf_int32 i = 2; i < ENTRIES; ++i) { theTable[i] = static_cast<rspf_float64>(i)/DENOMINATOR; } theTableIsInitialized = true; } }
void AdaptiveManifoldFilterN::initSrcAndJoint(InputArray src_, InputArray joint_) { srcSize = src_.size(); smallSize = getSmallSize(); srcCnNum = src_.channels(); split(src_, srcCn); if (src_.depth() != CV_32F) { for (int i = 0; i < srcCnNum; i++) srcCn[i].convertTo(srcCn[i], CV_32F); } if (joint_.empty() || joint_.getObj() == src_.getObj()) { jointCnNum = srcCnNum; if (src_.depth() == CV_32F) { jointCn = srcCn; } else { jointCn.resize(jointCnNum); for (int i = 0; i < jointCnNum; i++) srcCn[i].convertTo(jointCn[i], CV_32F, getNormalizer(src_.depth())); } } else { splitChannels(joint_, jointCn); jointCnNum = (int)jointCn.size(); int jointDepth = jointCn[0].depth(); Size jointSize = jointCn[0].size(); CV_Assert( jointSize == srcSize && (jointDepth == CV_8U || jointDepth == CV_16U || jointDepth == CV_32F) ); if (jointDepth != CV_32F) { for (int i = 0; i < jointCnNum; i++) jointCn[i].convertTo(jointCn[i], CV_32F, getNormalizer(jointDepth)); } } }
rspfNormalizedU16RemapTable::rspfNormalizedU16RemapTable() : rspfNormalizedRemapTable() { if (!theTableIsInitialized) { const rspf_int32 ENTRIES = getEntries(); const rspf_float64 DENOMINATOR = getNormalizer(); //--- // Initialize the remap table. //--- theTable[0] = 0.0; // Index zero always for null. for (rspf_int32 i = 1; i < ENTRIES; ++i) { theTable[i] = static_cast<rspf_float64>(i)/DENOMINATOR; } theTableIsInitialized = true; } }
/** * \fn void Localization::resample(int no) * resample the population and remove the unrelevant particles * */ void Localization::resample(int no){ // Calculate the mean of the population if(no != 0) itsKeepParticles = no; float totalProb=getNormalizer(); float mean = totalProb/itsNumParticles; float stddev = 0.0 ; float minProb = 0.0 ; for (std::vector<class pParticle>::iterator iter = pList.begin(); iter != pList.end() ; iter++ ) { stddev += ( iter->prob - mean ) * ( iter->prob - mean ); if ( iter -> prob < minProb ) minProb = iter->prob; } stddev = stddev / itsNumParticles; stddev = sqrt ( stddev ); // Now since we have standard deviation and mean at hand we can calculate what particles to say good bye to // if particles' probability is less than mean - ( (stddev + (mean - minProb - stddev)) / 2 ) and not greater than 0.01, then we will discard them for (std::vector<class pParticle>::iterator iter = pList.begin(); iter != pList.end() ; iter++ ) { if( iter -> prob < 0.01 && ( iter -> prob < mean - (stddev + (mean - minProb - stddev ) )/2.0 ) ) { pList.erase(iter); itsNumParticles --; } } std::sort(pList.begin(), pList.end(), greater<pParticle>() ); }