comparison imagej2_skeletonize3d_jython_script.py @ 0:018144807556 draft default tip

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
author bgruening
date Tue, 24 Sep 2024 17:12:52 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:018144807556
1 import sys
2
3 from ij import IJ
4
5 # Fiji Jython interpreter implements Python 2.5 which does not
6 # provide support for argparse.
7 input_file = sys.argv[-4]
8 black_background = sys.argv[-3] == "yes"
9 tmp_output_path = sys.argv[-2]
10 output_datatype = sys.argv[-1]
11
12 # Open the input image file.
13 input_image_plus = IJ.openImage(input_file)
14
15 # Create a copy of the image.
16 input_image_plus_copy = input_image_plus.duplicate()
17 image_processor_copy = input_image_plus_copy.getProcessor()
18
19 # Set binary options.
20 options = ["edm=Overwrite", "iterations=1", "count=1"]
21 if black_background:
22 options.append("black")
23 options = " ".join(options)
24 IJ.run(input_image_plus_copy, "Options...", options)
25
26 # Convert image to binary if necessary.
27 if not image_processor_copy.isBinary():
28 # Convert the image to binary grayscale.
29 IJ.run(input_image_plus_copy, "Make Binary", "")
30
31 # Run the command.
32 IJ.run(input_image_plus_copy, "Skeletonize (2D/3D)", "")
33
34 # Save the ImagePlus object as a new image.
35 IJ.saveAs(input_image_plus_copy, output_datatype, tmp_output_path)