0

I'm having some trouble understanding seam insertion for image enlarging with Seam Carving. AFIK to enlarge an image by k pixels it's necessary to remove k seams, recording their coordinates and using them to reproduce the process backwards, i.e. re-add the deleted seams but duplicating them and applying some kind of average with neighbouring seams (I'm not concerned with this, since it should be the easy part). My confussion comes with the correctness of the recorded coordinates: they are local to the image from which the seam was removed, so by 'restoring' the first seam every other recorded seam coordinates turn invalid. Am I supposed to correct these coordinates checking if every pixel coordinate of every remaining to add seam comes after the previously added seams? This seems rather cumbersome and highly inefficient, given that I've read inserting seams should be trivial once the seam removal part has been achieved (it has).

I'm not sure if I'm communicating my doubt properly. Let me know if that's not the case, although I tried to be as clear as possible.

HastatusXXI
  • 101
  • 9
  • 1
    You should probably remove `python` and `numpy` tag because your question is about general algorithm. For seam-carving, I only did seam removal before, but I believe the reason to dry-run seam-removal before seam-insertion is to avoid inserting to the same position again and again. You have to fix indices anyway when inserting even if you can avoid "fixing" in removal part. The general process should be trivial. Just scan through seams that would be inserted before this one, and increment by number of indices that is smaller than the current one. – ZisIsNotZis Dec 03 '18 at 04:16
  • Thank you, the "fixing" seems unavoidable, as you're pointing out. I'll give it a try. – HastatusXXI Dec 03 '18 at 12:16

1 Answers1

0

As pointed out in the cooments, you have to fix indices anyway when inserting even if you can avoid "fixing" in removal part.

You can find a full implementation of seam carving and seam insertion in python here.

rikyeah
  • 1,896
  • 4
  • 11
  • 21