Having recently come across a paper by Shai Avidan and Ariel Shamir, and watching the totally awesome video about seam carving, I decided to try my hand at implementing their algorithm for myself. I’ve included a quick overview of what seam carving is, the MATLAB program I have created, a summary of the algorithm itself with some implementation details, as well as some notes on how to run my program, so without further ado…
You can download the zip file with all of my code here:
If you would like to run this program on your copy of MATLAB, you will need to have the image processing toolbox. I will try to remove this dependency in a later update.
You are free to modify my code and add new features, etc, and redistribute it as you see fit, but I would like to hear about it, and be given credit where it is due.
Features and functionality
The program allows the user to resize an image by removing a continuous path of pixels (a seam) vertically or horizontally from a given image. A seam is defined as a continuous path of pixels running from the top to the bottom of an image in the case of a vertical seam, while a horizontal seam is a continuous line of pixels spanning from left to right in an image. An example of a seam overlaid on an image is shown in Figure 1.
The GUI of the program I completed is included as Figure 2. The main overall functionalities include (in order from the top to bottom in the GUI) opening an image file, resetting the state of the program to initial values before the image was resized in any way, the removal of a single vertical running seam from the image, removal of a single horizontal seam from the image, input boxes for custom image resizing using repeated seam removals and/or insertions (maximum image size is 2xCurrentsize-1 in the horizontal and vertical directions), a listbox for user chosen display of the color RGB image, the gradient image, or the energymap image, and a checkbox to show the seam removed on one of the three chosen types of image chosen from the listbox.