For this project, I had to implement a seam-carving algorithm in MATLAB. Seam-carving is a method of image-resizing that takes into account the energy of each pixel of the image. It finds the path of lowest total energy that goes either horizontally or vertically and removes that "seam". This will remove the nonimportant parts of the image first and keep the shape of the more important part of the image.
To find the least important seam to remove, I used Dynamic programming. Starting from the bottom row, for each pixel, I kept track of the path of least energy from that pixel to a pixel in the bottom row, and also the total energy of this path. Then I found the pixel in the top row with the path of least energy and removed this path from the image. I then recalculated the energy function of this new image. I repeat this process for however many pixels I want to remove.
Original Image
Seam-Carved Image
Original Image
Horizontal Seam-Carved Image
Vertical Seam-Carved Image
The border here got a little warped.
Original Image
Seam-Carved Image
Original Image
Seam-Carved Image
Original Image
Seam-Carved Image
Original Image
Seam-Carved Image
Original Image
Seam-Carved Image
To my surprise, this image did not resize well from seam-carving. Perhaps it is because his shirt is a more constant color than the background building.
I tried to do seam-insertion by finding the n lowest energy seams in the image, where n is the number of seams I wanted to insert, and then duplicating them. I had trouble dealing with the offset of the seam in my carved image and the same seam in my seam-inserted image. But here are my results:
Original Image
Seam-Inserted Image
Original Image
Seam-Inserted Image
Original Image
Seam-Inserted Image
The edges of important objects in each of these scenes are warped and fuzzy