Tesi Robotica Un coprocessore per Stereo-Matching: Profiling ... | Page 56
i
i
“MF_Tesi” — 2011/9/12 — 11:39 — page 56 — #56
i
4.3. IMPLEMENTAZIONE IN C
2
7
12
17
22
27
i
56
void calculateScore(dirVal **score, uint8_t *ptrL, uint8_t *ptrR, int gap
, int egap, int linesize)
{
int row, col;
int mismatch, north, west, diag, best;
#ifdef DEBUG
printf("+++++++++++++----CALCOLO DELLA MATRICE DEGLI SCORE
----+++++++++++++\n");
#endif
for(row = 1; row < linesize; row++)
{
for(col = 1; col < linesize; col++)
{
#ifdef DEBUG
printScore(score, linesize);
#endif
mismatch = abs(ptrL[3 * (row - 1) + RED] ptrR[3 * (col - 1) + RED]) +
abs(ptrL[3 * (row - 1) + GREEN] ptrR[3 * (col - 1) + GREEN]) +
abs(ptrL[3 * (row - 1) + BLUE] ptrR[3 * (col - 1) + BLUE]);
diag = score[row - 1][col - 1].v + (255 - mismatch);
west = score[row][col - 1].v +
((egap > gap) && score[row][col - 1].isGap ? egap : gap
);
north = score[row - 1][col].v +
((egap > gap) && score[row - 1][col].isGap ? egap : gap
);
#ifdef DEBUG
printf("sono nella cella (%d, %d)\n", row, col);
printf("la diagonale vale %d, nord vale %d, ovest vale %d\
n", diag, north, west);
#endif
32
best = max(max(diag, west), north);
#ifdef DEBUG
printf("scelgo %d, cioe’ ", best);
i
i
i
i