Seam - acnelson12/CS-335-Algorithms GitHub Wiki
The Seam class handles calculation of seams and the removal of seams from images. As mandated by the specifications, it contains the methods verticalSeamShrink
and horizontalSeamShrink
. At this point, I have only made the constructors visible because they are very trivial, and I have made fastVSShrink
and fastHSShrink
visible because they are not required by the specifications and give relatively little information away that has not already been given away below.
Program Flow
I have outlined the flow of my program here. For the most part, each bullet point corresponds to a method call (I used ten semi-colons in verticalSeamShrink
, and two belong to a for
statement).
verticalSeamShrink
This method is required to accept a UWECImage
argument. It carries out a simple list of tasks:
- Find the energy of every pixel.
- Find the minimum energy required to get to every pixel (the optimal path from the top of the image).
- Find the path to the bottom with the lowest energy (this is the seam).
- Draw the seam.
- Refresh the image on the screen.
- Pause, if necessary, to give the user a chance to see the seam.
- Remove the seam.
- Refresh the image on the screen.
horizontalSeamShrink
This method is also required to accept a UWECImage
argument. It carries out a list of tasks similar to verticalSeamShrink
:
- Create a transposed version of the image.
- Find the energy of every pixel. (on transpose)
- Find the minimum energy required to get to every pixel (the optimal path from the top of the image). (on transpose)
- Find the path to the bottom with the lowest energy (this is the seam). (on transpose)
- Draw the seam. (on original)
- Refresh the image on the screen.
- Pause, if necessary, to give the user a chance to see the seam.
- Remove the seam. (on transpose)
- Transpose the transposed image to restore it to its original orientation.
- Replace the original image with the second.
- Refresh the image on the screen.