Package seamcarving
Class SeamFinderMultiTest
- java.lang.Object
 - 
- seamcarving.SeamFinderMultiTest
 
 
- 
class SeamFinderMultiTest extends Object
Compare differentSeamFinderimplementations to check that they compute the same values. 
- 
- 
Field Summary
Fields Modifier and Type Field Description private static StringBASE_PATHThe base directory path for the images.private static doubleEPSILONError tolerance for the minimum-cost seam.private static String[]FILESThe 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 doublegetExpectedSeamEnergy(String fileName, boolean isVertical)Returns the expected energy for a minimum-cost seam in the picture corresponding to the file name.private static doublegetSeamEnergy(Picture picture, List<Integer> seam, boolean isVertical)Returns the energy of the given seam in the picture.static voidmain(String[] args)private static voidprintFail(double expectedEnergy, String seam, double seamEnergy, boolean isVertical)Prints information about a failedSeamFindertest case.private static voidtest(SeamFinder seamFinder)Tests the givenSeamFinderimplementation. 
 - 
 
- 
- 
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 givenSeamFinderimplementation.- Parameters:
 seamFinder- theSeamFinderimplementation.- 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 failedSeamFindertest 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.
 
 - 
 
 -