|
| 1 | +## Evaluation Possibilities |
| 2 | + |
| 3 | +Any class derived from `BaseVolumeRenderer` can make use of the built-in support for evaluating the parameters of an algorithm. To do so, one has to override the virtual function `FillParameterSpace` like this in the header file: |
| 4 | + |
| 5 | +```c++ |
| 6 | +virtual void FillParameterSpace(ParameterSpace& pspace) override; |
| 7 | +``` |
| 8 | +
|
| 9 | +The implementation then needs to add the parameters that shall be evaluated. In the following example, two parameters are added: |
| 10 | +
|
| 11 | +* the number of ambient occlusion shells `ambient_occlusion_shells`, to be evaluated in the range \[1, 20\] with a stepping of 1. This is an integer parameter. |
| 12 | +
|
| 13 | +* the radius for ambient occlusion `ambient_occlusion_radius`, to be evaluated in the range \[0.1, 1.5\] with a stepping of 0.1. This is a float parameter. |
| 14 | +
|
| 15 | +The code will interpret this as a 2-dimensional parameter space and evaluate all parameter combinations. In this example, that is $20 \times 15 = 300$ parameter combinations. |
| 16 | +
|
| 17 | +```c++ |
| 18 | +void RC1PExtinctionBasedShading::FillParameterSpace(ParameterSpace& pspace) |
| 19 | +{ |
| 20 | + pspace.ClearParameterDimensions(); |
| 21 | + pspace.AddParameterDimension(new ParameterRangeInt("AmbientOccShells", &ambient_occlusion_shells, 1, 20, 1)); |
| 22 | + pspace.AddParameterDimension(new ParameterRangeFloat("AmbientOccRadius", &ambient_occlusion_radius, 0.1f, 1.5f, 0.1f)); |
| 23 | +} |
| 24 | +``` |
| 25 | + |
| 26 | +The user is able to start the evaluation from the GUI by pressing the "Start Evaluation" button in the "Rendering Manager". The code in `BaseVolumeRenderer` will then measure the frames per second and take a snapshot for every parameter combination. The results are stored in a newly created subfolder of the current folder (probably under 'data'). It is named according to the scheme 'eval_DATE_TIME'. This folder contains a file 'eval.csv' with the measurements and a subfolder 'img' with the images. |
| 27 | + |
| 28 | +#### Plotting Performance |
| 29 | + |
| 30 | +Assume that 'eval.csv' looks like this: |
| 31 | + |
| 32 | +|StepSize|TimePerFrame (ms)|FramesPerSecond|ImageFile| |
| 33 | +|--------|-----------------|---------------|---------| |
| 34 | +|0.200000|18.950000 |52.770449 |0000.png | |
| 35 | +|0.300000|13.610000 |73.475386 |0001.png | |
| 36 | +|0.400000|10.870000 |91.996320 |0002.png | |
| 37 | +|0.500000|9.220000 |108.459870 |0003.png | |
| 38 | +|0.600000|8.030000 |124.533001 |0004.png | |
| 39 | +|0.700000|7.310000 |136.798906 |0005.png | |
| 40 | +|0.800000|6.640000 |150.602410 |0006.png | |
| 41 | +|0.900000|6.170000 |162.074554 |0007.png | |
| 42 | +|1.000000|5.760000 |173.611111 |0008.png | |
| 43 | +|1.100000|5.470000 |182.815356 |0009.png | |
| 44 | +|1.200000|5.200000 |192.307692 |0010.png | |
| 45 | +|1.300000|5.010000 |199.600798 |0011.png | |
| 46 | +|1.400000|4.720000 |211.864407 |0012.png | |
| 47 | +|1.500000|4.600000 |217.391304 |0013.png | |
| 48 | +|1.600000|4.460000 |224.215247 |0014.png | |
| 49 | +|1.700000|4.270000 |234.192037 |0015.png | |
| 50 | +|1.800000|4.250000 |235.294118 |0016.png | |
| 51 | +|1.900000|4.120000 |242.718447 |0017.png | |
| 52 | + |
| 53 | +It can be plotted like this: |
| 54 | + |
| 55 | +```py |
| 56 | +from matplotlib import pyplot as plt |
| 57 | +import pandas as pd |
| 58 | +import numpy as np |
| 59 | + |
| 60 | +d = pd.read_csv('eval.csv', quotechar='"') |
| 61 | + |
| 62 | +plt.plot(d['StepSize'], d['FramesPerSecond'], linestyle='dotted', marker='o') |
| 63 | +plt.title('Performance') |
| 64 | +plt.ylabel('Frames per Second') |
| 65 | +plt.xlabel('Step Size') |
| 66 | + |
| 67 | +plt.show() |
| 68 | +``` |
| 69 | + |
| 70 | +#### Computing Image Differences |
| 71 | + |
| 72 | +The difference between the images can be assessed using different metrics. One example is the Structural Similarity Index Measure (SSIM). A simple call to [ImageMagick Compare](https://imagemagick.org/script/compare.php) suffices to measure this: |
| 73 | + |
| 74 | +```console |
| 75 | +magick compare -metric SSIM 0000.png 0001.png cmp_0000_0001.png |
| 76 | +``` |
| 77 | + |
| 78 | +This also creates a comparison image where the differences are highlighted. Note that a number of [different metrics](https://imagemagick.org/script/command-line-options.php#metric) are supported and choosing the right one depends on the application. Some of the metrics also have parameters that may need attention. |
0 commit comments