mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Fix for bool images`
This commit is contained in:
@@ -595,6 +595,12 @@ def files_image_diff(file1: str, file2: str, attributes: Optional[Dict[str, Any]
|
||||
if arr1.shape != arr2.shape:
|
||||
raise AssertionError(f"Image dimensions did not match ({arr1.shape}, {arr2.shape}).")
|
||||
|
||||
# Handle `bool` images by converting them to `uint8`
|
||||
if numpy.issubdtype(arr1.dtype, bool):
|
||||
arr1 = arr1.astype(numpy.uint8)
|
||||
if numpy.issubdtype(arr2.dtype, bool):
|
||||
arr2 = arr2.astype(numpy.uint8)
|
||||
|
||||
distance = get_image_metric(attributes)(arr1, arr2)
|
||||
distance_eps = attributes.get("eps", DEFAULT_EPS)
|
||||
if distance > distance_eps:
|
||||
|
||||
@@ -27,6 +27,11 @@
|
||||
<param name="in" value="im4_float.tif" />
|
||||
<output name="out" value="im4_float.tif" compare="image_diff" />
|
||||
</test>
|
||||
<!-- test pair of equal images (bool tiff) -->
|
||||
<test>
|
||||
<param name="in" value="im3_b_bool.tiff" />
|
||||
<output name="out" value="im3_b_bool.tiff" compare="image_diff" metric="iou" pin_labels="0" />
|
||||
</test>
|
||||
<!-- test pair of different images -->
|
||||
<test>
|
||||
<param name="in" value="im2_a.png" />
|
||||
|
||||
Reference in New Issue
Block a user