Mercurial > repos > iuc > imagej2_skeletonize3d
comparison jython_script.py @ 0:8b787f641b9c draft
planemo upload commit 98c34e070343a117019ffd25a3af117808159bf5-dirty
| author | iuc |
|---|---|
| date | Tue, 04 Aug 2015 13:21:32 -0400 |
| parents | |
| children | 269923244cc8 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:8b787f641b9c |
|---|---|
| 1 import jython_utils | |
| 2 import sys | |
| 3 from ij import IJ | |
| 4 from ij import ImagePlus | |
| 5 | |
| 6 VALID_IMAGE_TYPES = [ ImagePlus.GRAY8 ] | |
| 7 | |
| 8 # Fiji Jython interpreter implements Python 2.5 which does not | |
| 9 # provide support for argparse. | |
| 10 error_log = sys.argv[ -4 ] | |
| 11 input = sys.argv[ -3 ] | |
| 12 tmp_output_path = sys.argv[ -2 ] | |
| 13 output_datatype = sys.argv[ -1 ] | |
| 14 | |
| 15 # Open the input image file. | |
| 16 input_image_plus = IJ.openImage( input ) | |
| 17 bit_depth = input_image_plus.getBitDepth() | |
| 18 image_type = input_image_plus.getType() | |
| 19 | |
| 20 # Create a copy of the image. | |
| 21 input_image_plus_copy = input_image_plus.createImagePlus() | |
| 22 image_processor_copy = input_image_plus.getProcessor().duplicate() | |
| 23 input_image_plus_copy.setProcessor( "iCopy", image_processor_copy ) | |
| 24 | |
| 25 try: | |
| 26 if image_type not in VALID_IMAGE_TYPES: | |
| 27 # Convert the image to binary grayscale. | |
| 28 IJ.run( input_image_plus_copy, "Make Binary","iterations=1 count=1 edm=Overwrite do=Nothing" ) | |
| 29 # Run the command. | |
| 30 IJ.run( input_image_plus_copy, "Skeletonize (2D/3D)", "" ) | |
| 31 # Save the ImagePlus object as a new image. | |
| 32 IJ.saveAs( input_image_plus_copy, output_datatype, tmp_output_path ) | |
| 33 except Exception, e: | |
| 34 jython_utils.handle_error( error_log, str( e ) ) |
