comparison jython_utils.py @ 1:d26f11339f08 draft

planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
author iuc
date Wed, 26 Aug 2015 14:37:41 -0400
parents 66d9e595dff2
children
comparison
equal deleted inserted replaced
0:66d9e595dff2 1:d26f11339f08
1 import imagej2_base_utils 1 import imagej2_base_utils
2 from ij import IJ 2 from ij import IJ
3 3
4 IMAGE_PLUS_IMAGE_TYPE_FIELD_VALUES = { '0':'GRAY8', '1':'GRAY16', '2':'GRAY32', 4 IMAGE_PLUS_IMAGE_TYPE_FIELD_VALUES = { '0':'GRAY8', '1':'GRAY16', '2':'GRAY32',
5 '3':'COLOR_256', '4':'COLOR_RGB' } 5 '3':'COLOR_256', '4':'COLOR_RGB' }
6
7 def asbool( val ):
8 return str( val ).lower() in [ 'yes', 'true' ]
6 9
7 def convert_before_saving_as_tiff( image_plus ): 10 def convert_before_saving_as_tiff( image_plus ):
8 # The bUnwarpJ plug-in produces TIFF image stacks consisting of 3 11 # The bUnwarpJ plug-in produces TIFF image stacks consisting of 3
9 # slices which can be viewed in ImageJ. The 3 slices are: 1) the 12 # slices which can be viewed in ImageJ. The 3 slices are: 1) the
10 # registered image, 2) the target image and 3) the black/white warp 13 # registered image, 2) the target image and 3) the black/white warp
24 tmp_dir = imagej2_base_utils.get_temp_dir() 27 tmp_dir = imagej2_base_utils.get_temp_dir()
25 tmp_out_png_path = imagej2_base_utils.get_temporary_image_path( tmp_dir, 'png' ) 28 tmp_out_png_path = imagej2_base_utils.get_temporary_image_path( tmp_dir, 'png' )
26 IJ.saveAs( image_plus, 'png', tmp_out_png_path ) 29 IJ.saveAs( image_plus, 'png', tmp_out_png_path )
27 return IJ.openImage( tmp_out_png_path ) 30 return IJ.openImage( tmp_out_png_path )
28 31
32 def get_binary_options( black_background, iterations=1, count=1, pad_edges_when_eroding='no' ):
33 options = [ 'edm=Overwrite', 'iterations=%d' % iterations, 'count=%d' % count ]
34 if asbool( pad_edges_when_eroding ):
35 options.append( 'pad' )
36 if asbool( black_background ):
37 options.append( "black" )
38 return " ".join( options )
39
29 def get_display_image_type( image_type ): 40 def get_display_image_type( image_type ):
30 return IMAGE_PLUS_IMAGE_TYPE_FIELD_VALUES.get( str( image_type ), None ) 41 return IMAGE_PLUS_IMAGE_TYPE_FIELD_VALUES.get( str( image_type ), None )
31 42
32 def handle_error( error_log, msg ): 43 def handle_error( error_log, msg ):
33 # Java writes a lot of stuff to stderr, so the received error_log 44 # Java writes a lot of stuff to stderr, so the received error_log