From 3f7fc07c25201c93d1dda3515620a8f9db017fb8 Mon Sep 17 00:00:00 2001 From: Leonid Kostrykin Date: Tue, 12 Mar 2024 22:47:57 +0100 Subject: [PATCH 1/2] Fix bug --- tools/2d_auto_threshold/auto_threshold.py | 2 +- tools/2d_auto_threshold/auto_threshold.xml | 6 ++++-- tools/2d_auto_threshold/test-data/out3.tif | Bin 87489 -> 87489 bytes 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/2d_auto_threshold/auto_threshold.py b/tools/2d_auto_threshold/auto_threshold.py index 0aeaa2f5..71f5fabe 100644 --- a/tools/2d_auto_threshold/auto_threshold.py +++ b/tools/2d_auto_threshold/auto_threshold.py @@ -43,7 +43,7 @@ def do_thresholding(in_fn, out_fn, th_method, block_size=5, threshold=0, invert_ parser.add_argument('th_method', choices=th_methods.keys(), help='Thresholding method') parser.add_argument('block_size', type=int, default=5, help='Odd size of pixel neighborhood for calculating the threshold') parser.add_argument('threshold', type=float, default=0, help='Manual thresholding value') - parser.add_argument('invert_output', default=False, type=bool, help='Values below/above the threshold are labeled with 0/255 if False, and with 255/0 otherwise') + parser.add_argument('--invert_output', default=False, action='store_true', help='Values below/above the threshold are labeled with 0/255 by default, and with 255/0 if this argument is used') args = parser.parse_args() do_thresholding(args.im_in, args.im_out, args.th_method, args.block_size, args.threshold, args.invert_output) diff --git a/tools/2d_auto_threshold/auto_threshold.xml b/tools/2d_auto_threshold/auto_threshold.xml index a8274cfd..c6aaf725 100644 --- a/tools/2d_auto_threshold/auto_threshold.xml +++ b/tools/2d_auto_threshold/auto_threshold.xml @@ -2,7 +2,7 @@ with scikit-image 0.18.1 - 0 + 1 operation_3443 @@ -23,7 +23,9 @@ '$th_method.method_id' '$th_method.block_size' '$th_method.threshold' - '$invert_output' + #if $invert_output: + --invert_output + #end if ]]> diff --git a/tools/2d_auto_threshold/test-data/out3.tif b/tools/2d_auto_threshold/test-data/out3.tif index e938abd4f67f4baa65fd34fe16a8e447601848ee..3baffa6345d1ddb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!P0)LH>oz1#4$V|4KRwyft>2T*GjJo(;auN|U?=Woh7Ui9F! z-oX*@7`=XmPF6TmcA}J0!&Nfn0Nt$dlprWrs9dD@iD~4()TjnX*roj8;a;jEVhj$+zs+ zB(qr-W#+8zw{64hp2Jo!5z{tgKfC8S_hX=LIx$s8lZOBT2q1s}0tg_000IagfB*sr zAb Date: Wed, 13 Mar 2024 00:02:49 +0100 Subject: [PATCH 2/2] Simplify command --- tools/2d_auto_threshold/auto_threshold.xml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/2d_auto_threshold/auto_threshold.xml b/tools/2d_auto_threshold/auto_threshold.xml index c6aaf725..cd686e52 100644 --- a/tools/2d_auto_threshold/auto_threshold.xml +++ b/tools/2d_auto_threshold/auto_threshold.xml @@ -23,9 +23,7 @@ '$th_method.method_id' '$th_method.block_size' '$th_method.threshold' - #if $invert_output: - --invert_output - #end if + $invert_output ]]> @@ -74,7 +72,7 @@ - +