Mercurial > repos > iuc > imagej2_skeletonize3d
diff jython_script.py @ 1:269923244cc8 draft
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
| author | iuc |
|---|---|
| date | Wed, 26 Aug 2015 14:38:34 -0400 |
| parents | 8b787f641b9c |
| children |
line wrap: on
line diff
--- a/jython_script.py Tue Aug 04 13:21:32 2015 -0400 +++ b/jython_script.py Wed Aug 26 14:38:34 2015 -0400 @@ -1,33 +1,35 @@ import jython_utils import sys from ij import IJ -from ij import ImagePlus - -VALID_IMAGE_TYPES = [ ImagePlus.GRAY8 ] # Fiji Jython interpreter implements Python 2.5 which does not # provide support for argparse. -error_log = sys.argv[ -4 ] -input = sys.argv[ -3 ] +error_log = sys.argv[ -5 ] +input = sys.argv[ -4 ] +black_background = 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: - if image_type not in VALID_IMAGE_TYPES: + # Set binary options. + options = jython_utils.get_binary_options( black_background=black_background ) + IJ.run( input_image_plus_copy, "Options...", options ) + + # Convert image to binary if necessary. + if not image_processor_copy.isBinary(): # Convert the image to binary grayscale. - IJ.run( input_image_plus_copy, "Make Binary","iterations=1 count=1 edm=Overwrite do=Nothing" ) + IJ.run( input_image_plus_copy, "Make Binary", "" ) + # Run the command. IJ.run( input_image_plus_copy, "Skeletonize (2D/3D)", "" ) + # Save the ImagePlus object as a new image. IJ.saveAs( input_image_plus_copy, output_datatype, tmp_output_path ) except Exception, e:
