Mercurial > hg > match-vamp
changeset 59:fb6e4829c1af cheap_diagonals
Weight of sqrt(2) in both cases
author | Chris Cannam |
---|---|
date | Fri, 14 Nov 2014 12:35:36 +0000 |
parents | bbdcf79f3916 |
children | ad417dd05e0b |
files | src/Finder.cpp src/Matcher.cpp |
diffstat | 2 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Finder.cpp Fri Nov 14 10:26:13 2014 +0000 +++ b/src/Finder.cpp Fri Nov 14 12:35:36 2014 +0000 @@ -210,6 +210,8 @@ void Finder::recalculatePathCostMatrix(int r1, int c1, int r2, int c2) { + float diagonalWeight = sqrtf(2.f); + if (!find(r1,c1)) { std::cerr << "recalculatePathCostMatrix(" << r1 << "," << c1 << "): out of bounds" << std::endl; throw "recalculatePathCostMatrix index out of bounds"; @@ -230,7 +232,7 @@ if ((c > prevRowStart) && (c <= prevRowStop)) { // diagonal from (r-1,c-1) min = pm1->m_bestPathCost[r-1][c-pm1->m_first[r-1]-1] + - newCost; + newCost * diagonalWeight; dir = Matcher::AdvanceBoth; } if ((c >= prevRowStart) && (c < prevRowStop)) {
--- a/src/Matcher.cpp Fri Nov 14 10:26:13 2014 +0000 +++ b/src/Matcher.cpp Fri Nov 14 12:35:36 2014 +0000 @@ -254,6 +254,12 @@ void Matcher::setValue(int i, int j, Advance dir, double value, float dMN) { + float diagonalWeight = sqrtf(2.f); + + if (dir == AdvanceBoth) { + dMN *= diagonalWeight; + } + if (m_firstPM) { int jdx = j - m_first[i];