Skip to content

Useless loop #3

@ArtemZamuruev

Description

@ArtemZamuruev

Hi! I have your implementation of ViBe+ reviewed and realized that in function

void ViBePlus::UpdatePixSampleSumSquare(int i, int j, int k, int val)
{
    double res = 0;
    UpdatePixSampleAve(i, j, k, val);
    for(int m = 0; m < num_samples; m++)
        res += pow(samples[i][j][m] - samples_ave[i][j], 2);
    res /= num_samples;
    samples_sumsqr[i][j] = res;
}

the loop is useless. Because it's adding to res a value of expression pow(samples[i][j][k] - samples_ave[i][j], 2) <num_samples> times. Then res is dividing by num_samples. So this loop and dividing are equals to res = pow(samples[i][j][k] - samples_ave[i][j], 2).

That is why I'm suggesting that there must be a samples[i][j][m] instead of samples[i][j][k]. Otherwise this loop is useless.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions