Class SeamCarver
- java.lang.Object
-
- SeamCarver
-
public class SeamCarver extends Object
Seam carving, an approach for content-aware image resizing. Given aPicture
, anEnergyFunction
, and aSeamFinder
algorithm,removeHorizontal()
orremoveVertical()
seams from the picture.- See Also:
Picture
,EnergyFunction
,SeamFinder
-
-
Field Summary
Fields Modifier and Type Field Description private EnergyFunction
f
TheEnergyFunction
for determining the minimum-cost seam.private static String
INPUT_PATH
Path to the input image.private static String
OUTPUT_PATH
Path to the output image.private Picture
picture
ThePicture
.private SeamFinder
seamFinder
TheSeamFinder
implementation.
-
Constructor Summary
Constructors Constructor Description SeamCarver(File file, EnergyFunction f, SeamFinder seamFinder)
Constructs a seam carver by reading thePicture
from the file, using the givenEnergyFunction
andSeamFinder
implementations.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
main(String[] args)
private static int
promptForSize(String dimension, int max)
Gets new size for resizing image.List<Integer>
removeHorizontal()
Removes and returns a minimum-cost horizontal seam from the picture.List<Integer>
removeVertical()
Removes and returns a minimum-cost vertical seam from the picture.
-
-
-
Field Detail
-
INPUT_PATH
private static final String INPUT_PATH
Path to the input image.- See Also:
- Constant Field Values
-
OUTPUT_PATH
private static final String OUTPUT_PATH
Path to the output image.- See Also:
- Constant Field Values
-
f
private final EnergyFunction f
TheEnergyFunction
for determining the minimum-cost seam.
-
seamFinder
private final SeamFinder seamFinder
TheSeamFinder
implementation.
-
-
Constructor Detail
-
SeamCarver
public SeamCarver(File file, EnergyFunction f, SeamFinder seamFinder) throws IOException
Constructs a seam carver by reading thePicture
from the file, using the givenEnergyFunction
andSeamFinder
implementations.- Parameters:
file
- the file path to the image.f
- theEnergyFunction
.seamFinder
- theSeamFinder
.- Throws:
IOException
- if an error occurs during reading.
-
-
Method Detail
-
main
public static void main(String[] args) throws IOException
- Throws:
IOException
-
promptForSize
private static int promptForSize(String dimension, int max)
Gets new size for resizing image.- Parameters:
dimension
- the type of dimension ("width" or "height").max
- the current dimension of this type.- Returns:
- the new dimension to resize to.
-
removeHorizontal
public List<Integer> removeHorizontal()
Removes and returns a minimum-cost horizontal seam from the picture.- Returns:
- a minimum-cost horizontal seam.
-
-