Package seamcarving
Class SeamCarver
- java.lang.Object
-
- seamcarving.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 Picture
picture()
Returns a copy of the current picture.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.private static void
validate(Picture picture, List<Integer> seam)
Checks that the seam is a valid horizontal seam in 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
-
validate
private static void validate(Picture picture, List<Integer> seam)
Checks that the seam is a valid horizontal seam in the picture.- Parameters:
picture
- the input picture.seam
- the seam to remove.
-
picture
private Picture picture()
Returns a copy of the current picture.- Returns:
- a copy of the current picture.
-
removeHorizontal
public List<Integer> removeHorizontal()
Removes and returns a minimum-cost horizontal seam from the picture.- Returns:
- a minimum-cost horizontal seam.
-
-