diff --git a/src/seam-carving.cpp b/src/seam-carving.cpp index d233292..77abee8 100644 --- a/src/seam-carving.cpp +++ b/src/seam-carving.cpp @@ -220,7 +220,7 @@ void seam_carving(unsigned char* source, int width, int height, int nbChannels, if (test_energy) { // Update blacklist for (auto i=0; i < dim_long; i++) { int j, cur_j = 0; // cur_j is the index relative to the current carved image. j is absolute in the source image - for (j=0; j < dim_large && cur_j < opt_seam[i]; j++) { + for (j=0; j < dim_large && (cur_j < opt_seam[i] || complete_blacklist[im_index(i, j)]); j++) { if (!complete_blacklist[im_index(i, j)]) { cur_j++; } } assert(cur_j == opt_seam[i]); // Else, j == width and cur_j is not in the source image..