#NEWLINE# def imshow( img , ax = None ) : #NEWLINE# #INDENT# '\n    Displays an image, taking care of rescaling it and taking care of gray versus color.\n\n    Parameters\n    ----------\n    img : numpy array, HxW or or HxWx1 or HxWx3 size\n    ax : axes object    \n\n    ' #NEWLINE# if ( prm is None ) : #NEWLINE# #INDENT# fig = plt . figure ( ) #NEWLINE# ax = fig . add_subplot ( 111 ) #NEWLINE# #UNINDENT# prm = dict ( interpolation = 'none' ) #NEWLINE# if ( ( img . ndim == 2 ) or ( img . shape [ 2 ] == 1 ) ) : #NEWLINE# #INDENT# prm [ 'cmap' ] = plt . cm . gray #NEWLINE# if ( img . ndim > 2 ) : #NEWLINE# #INDENT# img = img [ : , : , 0 ] #NEWLINE# #UNINDENT# #UNINDENT# img -= img . min ( ) #NEWLINE# img /= img . max ( ) #NEWLINE# ax . imshow ( img , ** prm ) #NEWLINE# ax . get_xaxis ( ) . set_visible ( False ) #NEWLINE# ax . get_yaxis ( ) . set_visible ( False )