Package seamcarving.seamfinding
Class SeamFinderMultiTest
- java.lang.Object
-
- seamcarving.seamfinding.SeamFinderMultiTest
-
class SeamFinderMultiTest extends Object
Compare differentSeamFinder
implementations to check that they compute the same values.
-
-
Field Summary
Fields Modifier and Type Field Description private static String
BASE_PATH
The base directory path for the images.private static double
EPSILON
Error tolerance for the minimum-cost seam.private static String[]
FILES
The image files (.png) and corresponding expected seam costs (.txt) in theBASE_PATH
.
-
Constructor Summary
Constructors Constructor Description SeamFinderMultiTest()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static double
getExpectedSeamEnergy(String fileName, boolean isVertical)
Returns the expected energy for a minimum-cost seam in the picture corresponding to the file name.private static double
getSeamEnergy(Picture picture, List<Integer> seam, boolean isVertical)
Returns the energy of the given seam in the picture.static void
main(String[] args)
private static void
printFail(double expectedEnergy, String seam, double seamEnergy, boolean isVertical)
Prints information about a failedSeamFinder
test case.private static void
test(SeamFinder seamFinder)
Tests the givenSeamFinder
implementation.
-
-
-
Field Detail
-
EPSILON
private static final double EPSILON
Error tolerance for the minimum-cost seam.- See Also:
- Constant Field Values
-
BASE_PATH
private static final String BASE_PATH
The base directory path for the images.- See Also:
- Constant Field Values
-
-
Method Detail
-
main
public static void main(String[] args) throws IOException
- Throws:
IOException
-
test
private static void test(SeamFinder seamFinder) throws IOException
Tests the givenSeamFinder
implementation.- Parameters:
seamFinder
- theSeamFinder
implementation.- Throws:
IOException
- if an error occurs during reading.
-
printFail
private static void printFail(double expectedEnergy, String seam, double seamEnergy, boolean isVertical)
Prints information about a failedSeamFinder
test case.- Parameters:
expectedEnergy
- the expected energy for a minimum-cost seam.seam
- the values of the seam computed by the testing algorithm.seamEnergy
- the actual energy of the seam computed by the testing algorithm.isVertical
- true if the seam is vertical.
-
getSeamEnergy
private static double getSeamEnergy(Picture picture, List<Integer> seam, boolean isVertical)
Returns the energy of the given seam in the picture.- Parameters:
picture
- the input picture.seam
- the computed seam.isVertical
- true if the seam is vertical.- Returns:
- the energy of the given seam in the picture.
-
getExpectedSeamEnergy
private static double getExpectedSeamEnergy(String fileName, boolean isVertical) throws FileNotFoundException
Returns the expected energy for a minimum-cost seam in the picture corresponding to the file name.- Parameters:
fileName
- the base file name of the picture.isVertical
- true if the seam is vertical.- Returns:
- the expected energy for a minimum-cost seam in the picture corresponding to the file name.
- Throws:
FileNotFoundException
- if the expected seam cost file for the given orientation is missing.
-
-