changeset 4:37662cbf44b8 draft

planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/overlay_images/ commit 85185439087caafebf1c75dc78b61a2a1f181225
author imgteam
date Fri, 17 Nov 2023 23:34:57 +0000
parents 22ff7c705a83
children 002f7bad3e82
files overlay_images.py overlay_images.xml test-data/sample1.tif test-data/sample1_uint16.tif test-data/sample1_uint8.tif test-data/test4.png
diffstat 6 files changed, 27 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/overlay_images.py	Wed Nov 08 19:57:15 2023 +0000
+++ b/overlay_images.py	Fri Nov 17 23:34:57 2023 +0000
@@ -33,15 +33,17 @@
     img = np.squeeze(img)
     assert img.ndim == 2 or (img.ndim == 3 and img.shape[-1] in (3, 4))
     if str(img.dtype).startswith('float'):
-        img = np.round(img * 255).astype('uint8')
-    elif img.dtype == 'uint16':
-        img = img // 256
-    elif img.dtype != 'uint8':
+        img = np.round(img * 255).astype(np.uint8)
+    elif img.dtype == np.uint16:
+        img = (img // 256).astype(np.uint8)
+    elif img.dtype != np.uint8:
         raise ValueError(f'unknown dtype: {img.dtype}')
     if img.ndim == 2:
-        return np.dstack([img] * 3).copy()
+        result = np.dstack([img] * 3).copy()
     else:
-        return img[:, :, :3].copy()
+        result = img[:, :, :3].copy()
+    assert result.dtype == np.uint8, result.dtype
+    return result
 
 
 def coloc_vis(in_red_fn, in_green_fn, out_fn):
--- a/overlay_images.xml	Wed Nov 08 19:57:15 2023 +0000
+++ b/overlay_images.xml	Fri Nov 17 23:34:57 2023 +0000
@@ -1,5 +1,9 @@
-<tool id="ip_overlay_images" name="Overlay images" version="0.0.3-3" profile="20.05">
+<tool id="ip_overlay_images" name="Overlay images" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="20.05">
     <description></description>
+    <macros>
+        <token name="@TOOL_VERSION@">0.0.4</token>
+        <token name="@VERSION_SUFFIX@">0</token>
+    </macros>
     <edam_operations>
         <edam_operation>operation_3443</edam_operation>
     </edam_operations>
@@ -81,7 +85,7 @@
             <output name="out_tiff" value="test2.tif" ftype="tiff" compare="sim_size" delta_frac="0.1"/>
         </test>
         <test expect_num_outputs="1">
-            <param name="im1" value="sample1.tif"/>
+            <param name="im1" value="sample1_uint8.tif"/>
             <param name="im2" value="mask1.tif"/>
             <param name="method" value="seg_contour"/>
             <param name="thickness" value="2"/>
@@ -89,8 +93,16 @@
             <param name="show_label" value="--show_label"/>
             <output name="out_png" value="test3.png" ftype="png" compare="sim_size" delta_frac="0.1"/>
         </test>
-        <test expect_num_outputs="1">
-            <param name="im1" value="sample1.tif"/>
+        <test expect_num_outputs="1"><!-- segemtation overlay, 8bit test -->
+            <param name="im1" value="sample1_uint8.tif"/>
+            <param name="im2" value="mask2.tif"/>
+            <param name="method" value="seg_contour"/>
+            <param name="thickness" value="2"/>
+            <param name="color" value="#ff0000"/>
+            <output name="out_png" value="test4.png" ftype="png" compare="sim_size" delta_frac="0.1"/>
+        </test>
+        <test expect_num_outputs="1"><!-- segmentation overlay, 16bit test -->
+            <param name="im1" value="sample1_uint16.tif"/>
             <param name="im2" value="mask2.tif"/>
             <param name="method" value="seg_contour"/>
             <param name="thickness" value="2"/>
@@ -99,9 +111,9 @@
         </test>
     </tests>
     <help>
-    **What it does**
-
-    This tool overlays two image to visualize 1) image blending, 2) colocalization, or 3) a segmentation mask over an image.
+    <![CDATA[
+        This tool overlays two image to visualize 1) image blending, 2) colocalization, or 3) a segmentation mask over an image.
+    ]]>
     </help>
     <citations>
         <citation type="doi">10.1016/j.jbiotec.2017.07.019</citation>
Binary file test-data/sample1.tif has changed
Binary file test-data/sample1_uint16.tif has changed
Binary file test-data/sample1_uint8.tif has changed
Binary file test-data/test4.png has changed