//! Threshold distances in order to keep similar patches
for (int dj = -(int) nHW; dj <= (int) nHW; dj++)
{
for (int di = 0; di <= (int) nHW; di++)
if (sum_table[dj + nHW + di * Ns][k_r] < threshold)
table_distance.push_back(make_pair(
sum_table[dj + nHW + di * Ns][k_r]
, k_r + di * width + dj));
for (int di = - (int) nHW; di < 0; di++)
if (sum_table[-dj + nHW + (-di) * Ns][k_r] < threshold)
table_distance.push_back(make_pair(
sum_table[-dj + nHW + (-di) * Ns][k_r + di * width + dj]
, k_r + di * width + dj));
}
This is very suspicious. Since dj takes the same negative and positive values, it means the second if test is a duplicate of the first one, however it doesn't insert the same element. Wrong check ?
https://github.com/gfacciol/bm3d/blob/5c86dfe4df9383fb22c7ee6585ef9fb529964984/bm3d.cpp#L1341
This is very suspicious. Since dj takes the same negative and positive values, it means the second if test is a duplicate of the first one, however it doesn't insert the same element. Wrong check ?