Mercurial > repos > iuc > imagej2_make_binary
diff 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 |
line wrap: on
line diff
--- a/jython_utils.py Tue Aug 04 13:20:29 2015 -0400 +++ b/jython_utils.py Wed Aug 26 14:37:41 2015 -0400 @@ -4,6 +4,9 @@ IMAGE_PLUS_IMAGE_TYPE_FIELD_VALUES = { '0':'GRAY8', '1':'GRAY16', '2':'GRAY32', '3':'COLOR_256', '4':'COLOR_RGB' } +def asbool( val ): + return str( val ).lower() in [ 'yes', 'true' ] + def convert_before_saving_as_tiff( image_plus ): # The bUnwarpJ plug-in produces TIFF image stacks consisting of 3 # slices which can be viewed in ImageJ. The 3 slices are: 1) the @@ -26,6 +29,14 @@ IJ.saveAs( image_plus, 'png', tmp_out_png_path ) return IJ.openImage( tmp_out_png_path ) +def get_binary_options( black_background, iterations=1, count=1, pad_edges_when_eroding='no' ): + options = [ 'edm=Overwrite', 'iterations=%d' % iterations, 'count=%d' % count ] + if asbool( pad_edges_when_eroding ): + options.append( 'pad' ) + if asbool( black_background ): + options.append( "black" ) + return " ".join( options ) + def get_display_image_type( image_type ): return IMAGE_PLUS_IMAGE_TYPE_FIELD_VALUES.get( str( image_type ), None )
