From b99ee153f0402ac0e887efbc05274c5dceeecce0 Mon Sep 17 00:00:00 2001 From: augustin64 Date: Tue, 1 Apr 2025 11:59:14 +0200 Subject: [PATCH] Don't forget to check the blacklist --- src/seam-carving.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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..