gfacciol / bm3d

GNU General Public License v3.0
96 stars 24 forks source link

Very suspicious piece of code #8

Open axeldavy opened 6 years ago

axeldavy commented 6 years ago

https://github.com/gfacciol/bm3d/blob/5c86dfe4df9383fb22c7ee6585ef9fb529964984/bm3d.cpp#L1341

            //! 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 ?