// =======================================================================================================
void CGreedyDetection::updateCostsOfOnePatch(IplImage *in_ProbMap, 
                                             int in_iScaledPatchI,
                                             int in_iScaledPatchJ,
                                             float in_fPatchGivenCost,
                                             float in_fPatchDeltaCost,
                                             float in_fPatchBgCost,
                                             IplImage *io_AccumMap,
                                             bool init, int iScale,
                                             int firstScaledRow, int lastScaledRow,
                                             int firstScaledCol, int lastScaledCol)
{
    int curHeight = in_ProbMap->height;
    int curWidth = in_ProbMap->width;

    int forestPatchSize = uForest.getPatchSize();


    if (init)
    {
        for (int ii = firstScaledRow; ii < lastScaledRow; ii ++)
        {
            float *probMapPoint = (float*)(&(CV_IMAGE_ELEM( in_ProbMap, float, ii, firstScaledCol )));
            float *accumPoint = (float*)(&(CV_IMAGE_ELEM( io_AccumMap, float, ii, firstScaledCol )));

            for (int jj = firstScaledCol; jj < lastScaledCol; jj ++)
            {
                // update accumulator value at scale iScale

                float prob = *probMapPoint;

                if (prob > m_fProbVoteThreshold)
                {
                    float voteForPoint = safeLog (prob);
                    float costForPoint = (-voteForPoint) - in_fPatchBgCost;
                    float cur_cost = std::min(0.0f , costForPoint - in_fPatchGivenCost);
                    *accumPoint += cur_cost;
                }

                probMapPoint ++;
                accumPoint ++;
            }
        }
    }
    else
    {
Beispiel #2
0
double logL(double p, double k, double n) {
    return k * safeLog(p) + (n - k) * safeLog(1.0 - p);
}