Class SeamCarver
- java.lang.Object
-
- SeamCarver
-
public class SeamCarver extends Object
Seam carving, an approach for content-aware image resizing. Given aPicture, anEnergyFunction, and aSeamFinderalgorithm,removeHorizontal()orremoveVertical()seams from the picture.- See Also:
Picture,EnergyFunction,SeamFinder
-
-
Field Summary
Fields Modifier and Type Field Description private EnergyFunctionfTheEnergyFunctionfor determining the minimum-cost seam.private static StringINPUT_PATHPath to the input image.private static StringOUTPUT_PATHPath to the output image.private PicturepictureThePicture.private SeamFinderseamFinderTheSeamFinderimplementation.
-
Constructor Summary
Constructors Constructor Description SeamCarver(File file, EnergyFunction f, SeamFinder seamFinder)Constructs a seam carver by reading thePicturefrom the file, using the givenEnergyFunctionandSeamFinderimplementations.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidmain(String[] args)private static intpromptForSize(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
TheEnergyFunctionfor determining the minimum-cost seam.
-
seamFinder
private final SeamFinder seamFinder
TheSeamFinderimplementation.
-
-
Constructor Detail
-
SeamCarver
public SeamCarver(File file, EnergyFunction f, SeamFinder seamFinder) throws IOException
Constructs a seam carver by reading thePicturefrom the file, using the givenEnergyFunctionandSeamFinderimplementations.- 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.
-
-