Mercurial > repos > iuc > imagej2_make_binary
diff jython_script.py @ 1:d26f11339f08 draft
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
| author | iuc |
|---|---|
| date | Wed, 26 Aug 2015 14:37:41 -0400 |
| parents | 66d9e595dff2 |
| children |
line wrap: on
line diff
--- a/jython_script.py Tue Aug 04 13:20:29 2015 -0400 +++ b/jython_script.py Wed Aug 26 14:37:41 2015 -0400 @@ -1,40 +1,36 @@ import jython_utils import sys from ij import IJ -from ij import ImagePlus # Fiji Jython interpreter implements Python 2.5 which does not # provide support for argparse. error_log = sys.argv[ -8 ] input = sys.argv[ -7 ] -iterations = sys.argv[ -6 ] -count = sys.argv[ -5 ] -black_background = sys.argv[ -4 ] -pad_edges_when_eroding = sys.argv[ -3 ] +iterations = int( sys.argv[ -6 ] ) +count = int( sys.argv[ -5 ] ) +black_background = jython_utils.asbool( sys.argv[ -4 ] ) +pad_edges_when_eroding = jython_utils.asbool( sys.argv[ -3 ] ) tmp_output_path = sys.argv[ -2 ] output_datatype = sys.argv[ -1 ] # Open the input image file. input_image_plus = IJ.openImage( input ) -bit_depth = input_image_plus.getBitDepth() -image_type = input_image_plus.getType() # Create a copy of the image. -input_image_plus_copy = input_image_plus.createImagePlus() -image_processor_copy = input_image_plus.getProcessor().duplicate() -input_image_plus_copy.setProcessor( "iCopy", image_processor_copy ) +input_image_plus_copy = input_image_plus.duplicate() +image_processor_copy = input_image_plus_copy.getProcessor() try: - options = [ "iterations=&iterations" "count=&count" ] - if black_background == "yes": - options.append( "black" ) - if pad_edges_when_eroding == "yes": - options.append( "pad" ) - # The following have no affect within this tool, but are necessary. - options.append( "edm=Overwrite" ) - options.append( "do=Nothing" ) + # Set binary options. + options = jython_utils.get_binary_options( black_background=black_background, + iterations=iterations, + count=count, + pad_edges_when_eroding=pad_edges_when_eroding ) + IJ.run( input_image_plus_copy, "Options...", options ) + # Run the command. - IJ.run( input_image_plus_copy, "Make Binary", " ".join( options ) ) + IJ.run( input_image_plus_copy, "Make Binary", "" ) + # Save the ImagePlus object as a new image. IJ.saveAs( input_image_plus_copy, output_datatype, tmp_output_path ) except Exception, e:
