Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //THIS IS TO FORM THE THIRD GRID(from the energy grid)
- //this is the grid you use to calculate what your vertical seam's path is
- //from top to bottom
- //push back our initial row
- //The First Row of Your Energy Grid
- for (int i = 0; i < Columns; ++i){
- DynamicSums[0].push_back(Weighted[0][i]);
- }
- for (int i = 1; i < Rows; ++i){
- DynamicSums.push_back(emptyVector);
- for (int j = 0; j < Columns; ++j){
- CurrentMin = -1;
- if (j - 1 >= 0){//check if we can go up and left
- CurrentMin = Weighted[i][j] + DynamicSums[i - 1][j - 1];
- }
- if (CurrentMin == -1){//case where you are on left wall of grid
- CurrentMin = Weighted[i][j] + DynamicSums[i - 1][j];
- }
- else{
- CurrentMin = min(CurrentMin, Weighted[i][j] + DynamicSums[i - 1][j]);
- }
- if (j + 1 < Columns){//check if we can go up and right
- CurrentMin = min(CurrentMin, Weighted[i][j] + DynamicSums[i - 1][j + 1]);
- }
- DynamicSums[i].push_back(CurrentMin);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement