saveTempFile(sample);
saveTempFile(result);
// NOTE: imageEvaluator is called once per criterion as the used
// minimee evaluator will do separate calls anyway
ImageCompareEvaluator imageEvaluator = new ImageCompareEvaluator();
for (String measureUri : measureUris) {
Scale scale = null;
String mode = null;
if (MeasureConstants.IMAGE_CONTENT_IS_EQUAL.equals(measureUri)) {
mode = "equal";
scale = new BooleanScale();
} else if (MeasureConstants.ABSOLUTE_ERROR_AE.equals(measureUri)) {
mode = "ae";
scale = new PositiveFloatScale();
} else if (MeasureConstants.PEAK_ABSOLUTE_ERROR_PAE.equals(measureUri)) {
mode = "pae";
scale = new PositiveFloatScale();
} else if (MeasureConstants.PEAK_SIGNAL_TO_NOISE_RATIO.equals(measureUri)) {
mode = "psnr";
scale = new PositiveFloatScale();
} else if (MeasureConstants.MEAN_ABSOLUTE_ERROR.equals(measureUri)) {
mode = "mae";
scale = new PositiveFloatScale();
} else if (MeasureConstants.MEAN_SQUARED_ERROR.equals(measureUri)) {
mode = "mse";
scale = new PositiveFloatScale();
} else if (MeasureConstants.IMAGE_DISTANCE_RMSE.equals(measureUri)) {
mode = "rmse";
scale = new PositiveFloatScale();
}
if (mode != null) {
if (mode.equals("equal")) {
Double d = imageEvaluator.evaluate(tempDir.getAbsolutePath(), tempFiles.get(sample),
tempFiles.get(result), "AE");
if (d != null && d.compareTo(Scale.MAX_VALUE) != 0) {
Value v = scale.createValue();
((BooleanValue) v).bool(d.compareTo(0.0) == 0);
v.setComment("ImageMagick compare returned " + Double.toString(d) + " different pixels");
results.put(measureUri, v);
}
} else {
Double d = imageEvaluator.evaluate(tempDir.getAbsolutePath(), tempFiles.get(sample),
tempFiles.get(result), mode);
if (d != null && d.compareTo(Scale.MAX_VALUE) != 0) {
Value v = scale.createValue();
if (v instanceof FloatValue) {
((FloatValue) v).setValue(d);