Skip to content

Commit d69f4ec

Browse files
Visually inspected results; look correct, getting detailed breakdown
1 parent fd6f82b commit d69f4ec

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

vcell-cli/src/test/java/org/vcell/cli/run/plotting/TestResults2DLinePlot.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public void pngRoundTripTest() throws IOException {
168168
BufferedImage roundTrippedImage = ImageIO.read(dupe);
169169
Assertions.assertEquals(originalImage.getWidth(), roundTrippedImage.getWidth());
170170
Assertions.assertEquals(originalImage.getHeight(), roundTrippedImage.getHeight());
171-
double accuracy = TestResults2DLinePlot.getAccuracyPercentage(originalImage, roundTrippedImage);
171+
double accuracy = TestResults2DLinePlot.getAccuracy(originalImage, roundTrippedImage).product();
172172
Assertions.assertTrue(accuracy > ACCURACY_THRESHOLD, String.format("accuracy: %f !> %f; file: %s", accuracy, ACCURACY_THRESHOLD, dupe.getCanonicalPath()));
173173
}
174174

@@ -189,7 +189,7 @@ public void pngLibraryLevelTest() throws IOException {
189189
BufferedImage currentImage = chart.createBufferedImage(1000,1000);
190190
Assertions.assertEquals(currentImage.getWidth(), standardImage.getWidth());
191191
Assertions.assertEquals(currentImage.getHeight(), standardImage.getHeight());
192-
double accuracy = TestResults2DLinePlot.getAccuracyPercentage(standardImage, currentImage);
192+
double accuracy = TestResults2DLinePlot.getAccuracy(standardImage, currentImage).product();
193193
Assertions.assertTrue(accuracy > ACCURACY_THRESHOLD, String.format("accuracy: %f !> %f", accuracy, ACCURACY_THRESHOLD));
194194
}
195195

@@ -237,14 +237,16 @@ public void pngExecutionLevelTest() throws IOException {
237237
Assertions.assertEquals(standardImage1.getWidth(), generatedImage1.getWidth());
238238
Assertions.assertEquals(standardImage1.getHeight(), generatedImage1.getHeight());
239239

240-
241-
double accuracy0 = TestResults2DLinePlot.getAccuracyPercentage(standardImage0, generatedImage0);
242-
double accuracy1 = TestResults2DLinePlot.getAccuracyPercentage(standardImage1, generatedImage1);
243-
String errMsg = String.format("Values Threshold (%f):\n\tTest0 - accuracy: %f; file: %s\n\tTest1 - accuracy: %f; file: %s", ACCURACY_THRESHOLD, accuracy0, generatedPlot0.getCanonicalPath(), accuracy1, generatedPlot1.getCanonicalPath());
244-
Assertions.assertTrue(accuracy0 > ACCURACY_THRESHOLD && accuracy1 > ACCURACY_THRESHOLD, errMsg);
240+
SSIMComparisonTool.Results results0 = TestResults2DLinePlot.getAccuracy(standardImage0, generatedImage0);
241+
SSIMComparisonTool.Results results1 = TestResults2DLinePlot.getAccuracy(standardImage1, generatedImage1);
242+
String errMsg = String.format("Values Threshold (%f):\n\tTest0 - accuracy: %f (%f/%f/%f); file: %s\n\tTest1 - accuracy: %f ((%f/%f/%f)); file: %s",
243+
ACCURACY_THRESHOLD,
244+
results0.product(), results0.luminanceComponent(), results0.contrastComponent(), results0.structureComponent(), generatedPlot0.getCanonicalPath(),
245+
results1.product(), results1.luminanceComponent(), results1.contrastComponent(), results1.structureComponent(), generatedPlot1.getCanonicalPath());
246+
Assertions.assertTrue(results0.product() > ACCURACY_THRESHOLD && results1.product() > ACCURACY_THRESHOLD, errMsg);
245247
}
246248

247-
private static double getAccuracyPercentage(BufferedImage original, BufferedImage generated){
249+
private static SSIMComparisonTool.Results getAccuracy(BufferedImage original, BufferedImage generated){
248250
SSIMComparisonTool ssim = new SSIMComparisonTool();
249251
return ssim.performSSIMComparison(original, generated);
250252
}

vcell-cli/src/test/java/org/vcell/cli/testsupport/SSIMComparisonTool.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public SSIMComparisonTool(double luminanceStabilizer, double contrastStabilizer,
4949
this.STRUCTURE_STABILIZER = structureStabilizer;
5050
}
5151

52-
public double performSSIMComparison(BufferedImage original, BufferedImage contender){
52+
public Results performSSIMComparison(BufferedImage original, BufferedImage contender){
5353
double[][] originalGrayscaleData = SSIMComparisonTool.getGrayScaleData(original);
5454
double[][] contenderGrayscaleData = SSIMComparisonTool.getGrayScaleData(contender);
5555
double originalPSM = SSIMComparisonTool.pixelSampleMean(originalGrayscaleData);
@@ -63,7 +63,8 @@ public double performSSIMComparison(BufferedImage original, BufferedImage conten
6363
double weightedLuminance = Math.pow(luminance, SSIMComparisonTool.ALPHA_WEIGHT);
6464
double weightedContrast = Math.pow(contrast, SSIMComparisonTool.BETA_WEIGHT);
6565
double weightedStructure = Math.pow(structure, SSIMComparisonTool.GAMMA_WEIGHT);
66-
return weightedLuminance * weightedContrast * weightedStructure;
66+
double product = weightedLuminance * weightedContrast * weightedStructure
67+
return new Results(product, weightedLuminance, weightedContrast, weightedStructure);
6768
}
6869

6970
private double luminanceCalculation(double originalPSM, double contenderPSM){
@@ -133,4 +134,6 @@ private static double[][] getGrayScaleData(BufferedImage image){
133134
}
134135
return convertedData;
135136
}
137+
138+
public record Results (double product, double luminanceComponent, double contrastComponent, double structureComponent) {}
136139
}

0 commit comments

Comments
 (0)