Project 3: Seam Carving
Vibhu Ramani
October 10th, 2012
Steps:
- Compute the energy matrix of a given image. Energy matrix can be sum of the gradients across the color channels
- Using Dynamic programming find the lowest energy seam.
Initialize a scoring matrix with the values of the energy matrix.
for each pixel the lowest energy seam would be the lowest among the 3 neighbours above it and the value of the seam is that plus the energy at this pixel.
Once we reach the last row we can get the ending pixel with the lowest sum, and backtrack the path.
- Remove the seam from the image, the image is smaller by 1px in the direction opposite of the seam.
- Repeat to reduce the image size again.
Results Vertical Seams
Original Image | Basic(width-200) | Using Forward energy(width-200) |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Results Horizontal & Vertical Seams
Original Image | using forward energy(width-200)(height-200) |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Original Image | Failed resize |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Same case as the first one for the second eg. also.
For the third example the faces get distorted because the seams pass through them. The seams merge the suits as there is much energy between the locations where the suit ends for one person, and the other person is standing behind.
Extra Credit
Image expansion by inserting seams: If we want to increase the image by "x" no. of pixels in the horizontal direction we find "x" min seams as is we are going to remove them and then add pixels beside them averaging the px between which they are inserted. This way the image seems to transition and since we add the pixels to only the low energy pixels the insertion seems seemless.
Original Image | Image expanded(width+100)(height+100) |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Object Removal: If we want to remove a particular object we can create a mask and while computing the minimum seam we reduce the energy of the masked ares so much so that every seam is forced to pass through the area. Thus removing the masked area.
After the removal we insert those many seams into the image so that the image is restored back to the same size.
Original Image | Object Removed |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Forward energy: While computing the optimal minimum seam, if 2 seams have the same value we can check for the effect of the removal of each one of them and choose.
For each of the seam we see what would be the new energy of the image if removed. The seams which gets the least energy due to its removal is preferred.