Question: for (int r = cost->height - 1; r >= 0; --r) { //if bottom row if (r == cost->height - 1) { //the last element
for (int r = cost->height - 1; r >= 0; --r) { //if bottom row if (r == cost->height - 1) { //the last element in seam is the min value in last row of cost seam[r] = Matrix_column_of_min_value_in_row(cost, r, 0, cost->width); } //if not bottom row else { if (seam[r 1] == 0) { seam[r] = Matrix_column_of_min_value_in_row(cost, r 1, 0, seam[r 1] 2); } else { //the next element to the left is the min value of current row, inbetween previous col -1 and previous col 2 (accessed through seam) seam[r] = Matrix_column_of_min_value_in_row(cost, r 1, seam[r 1] - 1, seam[r 1] 2); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
