Skip to content

Commit

Permalink
Update test macros
Browse files Browse the repository at this point in the history
  • Loading branch information
kostrykin committed Apr 4, 2024
1 parent 6904d1d commit db53a89
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,13 @@ For testing of **binary image outputs** we recommend using the `mae` metric (mea
```xml
<expand macro="tests/binary_image_diff" name="output" value="output.tif" ftype="tiff"/>
```
The macro also ensures that the image contains two distinct label values, which are not interchangable.

For testing of non-binary **label map outputs** with interchangeable labels, we recommend using the `iou` metric (one minus the *intersection over the union*). With the default value of `eps` of 0.01, this asserts that there is no labeled image region with an *intersection over the union* of less than 99%:
```xml
<expand macro="tests/label_image_diff" name="output" value="output.tif" ftype="tiff"/>
```
At the moment it is not possible to *pin* specific labels, for example to verify that the background is assigned the correct label, but this will hopefully be added in the future.
Label 0 is commonly connotated as the image background, and is not interchangable by default. Use `pin_labels=""` to make it interchangable.

For testing of **intensity image outputs** we recommend the `rms` metric (root mean square), because it is very sensitive to large pixel value differences, but tolerates smaller differences:
```xml
Expand Down
16 changes: 9 additions & 7 deletions macros/tests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
token_metric="mae"
token_eps="0.01">

<output name="@NAME@" value="@VALUE@" ftype="@FTYPE@" compare="image_diff" metric="@METRIC@" eps="@EPS@">
<output name="@NAME@" value="@VALUE@" ftype="@FTYPE@" compare="image_diff" metric="@METRIC@" eps="@EPS@" pin_labels="0">
<assert_contents>
<has_image_n_labels n="2"/>
<yield/>
Expand All @@ -19,11 +19,12 @@

<xml
name="tests/label_image_diff"
tokens="name,value,ftype,metric,eps"
tokens="name,value,ftype,metric,eps,pin_labels"
token_metric="iou"
token_eps="0.01">
token_eps="0.01"
token_pin_labels="0">

<output name="@NAME@" value="@VALUE@" ftype="@FTYPE@" compare="image_diff" metric="@METRIC@" eps="@EPS@">
<output name="@NAME@" value="@VALUE@" ftype="@FTYPE@" compare="image_diff" metric="@METRIC@" eps="@EPS@" pin_labels="@PIN_LABELS@">
<assert_contents>
<yield/>
</assert_contents>
Expand Down Expand Up @@ -53,7 +54,7 @@
token_metric="mae"
token_eps="0.01">

<element name="@NAME@" value="@VALUE@" ftype="@FTYPE@" compare="image_diff" metric="@METRIC@" eps="@EPS@">
<element name="@NAME@" value="@VALUE@" ftype="@FTYPE@" compare="image_diff" metric="@METRIC@" eps="@EPS@" pin_labels="0">
<assert_contents>
<has_image_n_labels n="2"/>
<yield/>
Expand All @@ -66,9 +67,10 @@
name="tests/label_image_diff/element"
tokens="name,value,ftype,metric,eps"
token_metric="iou"
token_eps="0.01">
token_eps="0.01"
token_pin_labels="0">

<element name="@NAME@" value="@VALUE@" ftype="@FTYPE@" compare="image_diff" metric="@METRIC@" eps="@EPS@">
<element name="@NAME@" value="@VALUE@" ftype="@FTYPE@" compare="image_diff" metric="@METRIC@" eps="@EPS@" pin_labels="@PIN_LABELS@">
<assert_contents>
<yield/>
</assert_contents>
Expand Down

0 comments on commit db53a89

Please sign in to comment.