Seam carving on downloaded image

castle
out
I tried my code on this downloaded image, and i did the seam carving 1000 times on it. And the result came like this. Could this be a correct result ?

First regarding the eroded thin base of the castle:
This might seem odd at first glance as we humans pay a lot of attention to such semantic details. But from the energy perspective it makes sense to cut a seam there:
The only homogeneous blue area of the sky left is around the castle and to left is more distorted with clouds.
Therefore, the seam makes the small jump to form light blue to the white of the stones. In the stones, there is a large white area that can be carved away.
Together this results in a thin base.
You will not notice this behavior for smaller values of n as it costs much less energy to simply carve away the blue sky than to jump from the sky to the stones.

Regarding the lower right corner: If you think about seam carving, you notice that we always remove exactly one pixel per row and shrink the image accordingly. Therefore, no new pixels are ever introduced. Especially, it should be impossible to introduce or grow black areas where no black was before.

1 Like

Thank you for this detailed answer, i will search for the problem which causes this result in the lower right corner.

As an addition to Marcels answer: For me this looks like some problem with the use of the (current) width w which controls where black pixels should form and which part of the image should be considered for seamcarving. But that’s just a wild guess, so I might as well be wrong.

1 Like

It was indeed a problem with the width. I gave w0 in calucate optimal path when i should have given w. Thank you very much