In this work, I implemented and improved two Siggraph papers in my Digital Image Processing term project. when I was a graduate student.
References
[1]Shai Avidan, Ariel Sharmir, “Seam Carving for
Content-Aware Image Resizing,” Siggraph,
2007
[2]Michael Rubinstein, Ariel Sharmir, Shai Avidan, “Improved
Seam Caring for Video Retargeting,” Siggraph,
2008
Problem
Description and Motivation
Introduction
Figure 1
As figure1, the image at the left-hand side is the original one, and the images at the right-hand side are the result. The image at the right bottom is the one which is wrapped to the required size. This one keeps all information in the image. However, it looks strange, because the aspect ratios of the objects in the image are changed. And the image at the right top is the one that is resized by this algorithm. It gets rid of the pixels that are not important in the original image. It looks better.
This paper proposes a simple image operation, which is called seam-carving, and it can change the size of an image by gracefully carving-out or inserting pixels in different parts of the image. The authors in this paper provide several applications of seam carving and insertion, such as aspect ratio change, image retargeting, image content enhancement, and object removal.
The same research team proposed an improved seam carving for video retargeting [2] in the next year in Siggraph2008. The main change of the algorithm is that it can do the seam carve in the videos.
This paper proposes a simple image operation, which is called seam-carving, and it can change the size of an image by gracefully carving-out or inserting pixels in different parts of the image. The authors in this paper provide several applications of seam carving and insertion, such as aspect ratio change, image retargeting, image content enhancement, and object removal.
The same research team proposed an improved seam carving for video retargeting [2] in the next year in Siggraph2008. The main change of the algorithm is that it can do the seam carve in the videos.
Figure 2
In figure 2, the algorithm deletes or adds the different pixels in all frames in the whole video sequence. However, it keeps the sequence smooth, because the algorithm also considers the energy between the frames. So that, the object in the video will not vibrate after we resize the video.
Implement and Improvement
Figure 4
Although we modified the data type to be
vector by vector, we still thought that it took too muct time when we tried
to use it in our GUI design. We redesigned
a class type called Matrix.
We use two functions to implement “resize,” and the functions are
We use two functions to implement “resize,” and the functions are
void RowResize(int newRow = 0);
void ColResize(int newCol = 0);
Every time we want to change our image size, we have to call these two
functions to resize the image. A class named DP is used, and this class is used to implement the main
function of seam curve. At first, the RGB color image is transfered to Y domain, and our entire algorithm is applied on
Y only. After the seam that we want to add or delete is obtained , we added or deleted the seam in RGB domain
at the same position of Y domain.
After that, we compute the energy of the whole image by using the formulas. If we want to make the image “narrower,”
we accumulate the energy row by row.
Then we get the point that has the minimum energy at the last row. That point is our start point. Start from the start point and we trace back to the first row. Every row j we
only take the point (i+1, j), (i, j), (i-1, j) into consideration. ( (i,j+1) is the point we take at row j+1 ) And we choose the point which has the minimum
energy from these three points only.
After that, we can get a curve that can be deleted.
If we want to make
the image “10 pixels wider,” we add ten seams by using the method I mentioned. We copy these 10 seams and interpolate them into the positions next to the original ones. If we want to make the image narrower after that, we delete the seams that we added first. We do not have to re-compute the
algorithm. The paper [1] says that if we resize
the image for many times, the main object would become bigger and bigger. However, we solved this problem by saving the seams.
Figure6 is our GUI interface
Figure 6
Then we tried to implement [2]. The constraints in the paper [1] is 2D, but we have to use 3D constraints (including time domain). We can transform X-Y domain to X-t domain. That means we can use the same constraints if we look from the top arrow and the front arrow of figure 12.
Figure 7
Major Results
Figure 8
We compared the executing time of three kinds of algorithms in [1]. 2-D vector is the Matrix method. We applied the 2-D vector in our image seam cut algorithm.
Figure 9
Figure 9 is our result after resizing the image to be half width of the original image. It looks still good. The stone in the middle keeps large enough but the sea becomes smaller. Figure 10 is our result after resizing the image to be 1.5x width of the original image. The stone in the middle almost keeps the same size. Our algorithm would not change the size of major objects in the image too much.
The red line in figure 11 is our curves to cut. They are 1, 2, 3, 4, 5, 7, 10, 15, 20, 40 cuts. We can find out that almost all the curves are in the “sea” but not on the “dolphin.”
Figure 11
Following is our result of seam carving in video sequence.
Figure 12 Figure 13 Figure 14
Figure 12 is our original video, and figure 13 is our result by using back energy, and figure 14 is our result by using forward energy. We can find out that the line enclosed by a red circle in figure 13 is not continuous, but there is no discontinuous line in figure 14. This is because the forward energy also takes the result of seam carving into consideration. We analyze the seams we cut in backward energy, we find out that most of the seams are cut in the same place, so that the line is broken.
Figure 15
Figure 16
In figure 15, the ten seams are cut in our algorithm by using backward energy. Most of them are cut in the same place. In figure 16, ten seams are cut in our algorithm by using forward energy. These ten seams are not in the same place, so we would not get the same artifacts. However, we need about 80 minutes executing time to cut one single seam by using backward energy, the executing time we need to use forward energy is much larger.














No comments:
Post a Comment