comparison imagej2_make_binary_jython_script.py @ 0:95b7592729e2 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:03:42 -0400
parents
children aa4a5a8c4cfd
comparison
equal deleted inserted replaced
-1:000000000000 0:95b7592729e2
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 ) )