Mercurial > repos > imgteam > imagej2_math
comparison imagej2_make_binary_jython_script.py @ 0:dbacd5d06c27 draft
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit b08f0e6d1546caaf627b21f8c94044285d5d5b9c-dirty"
author | imgteam |
---|---|
date | Tue, 17 Sep 2019 17:10:07 -0400 |
parents | |
children | d48c999b3b96 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:dbacd5d06c27 |
---|---|
1 import jython_utils | |
2 import sys | |
3 from ij import IJ | |
4 | |
5 # Fiji Jython interpreter implements Python 2.5 which does not | |
6 # provide support for argparse. | |
7 error_log = sys.argv[ -8 ] | |
8 input = sys.argv[ -7 ] | |
9 iterations = int( sys.argv[ -6 ] ) | |
10 count = int( sys.argv[ -5 ] ) | |
11 black_background = jython_utils.asbool( sys.argv[ -4 ] ) | |
12 pad_edges_when_eroding = jython_utils.asbool( sys.argv[ -3 ] ) | |
13 tmp_output_path = sys.argv[ -2 ] | |
14 output_datatype = sys.argv[ -1 ] | |
15 | |
16 # Open the input image file. | |
17 input_image_plus = IJ.openImage( input ) | |
18 | |
19 # Create a copy of the image. | |
20 input_image_plus_copy = input_image_plus.duplicate() | |
21 image_processor_copy = input_image_plus_copy.getProcessor() | |
22 | |
23 try: | |
24 # Set binary options. | |
25 options = jython_utils.get_binary_options( black_background=black_background, | |
26 iterations=iterations, | |
27 count=count, | |
28 pad_edges_when_eroding=pad_edges_when_eroding ) | |
29 IJ.run( input_image_plus_copy, "Options...", options ) | |
30 | |
31 # Run the command. | |
32 IJ.run( input_image_plus_copy, "Make Binary", "" ) | |
33 | |
34 # Save the ImagePlus object as a new image. | |
35 IJ.saveAs( input_image_plus_copy, output_datatype, tmp_output_path ) | |
36 except Exception, e: | |
37 jython_utils.handle_error( error_log, str( e ) ) |