def figimage(image, scale=1, dpi=None, **kwargs):
 dpi = (dpi if (dpi is not None) else mpl.rcParams['figure.dpi'])
 kwargs.setdefault('interpolation', 'nearest')
 kwargs.setdefault('cmap', 'gray')
 (h, w, d) = np.atleast_3d(image).shape
 figsize = ((np.array((w, h), dtype=float) / dpi) * scale)
 (fig, ax) = new_plot(figsize=figsize, dpi=dpi)
 fig.subplots_adjust(left=0, bottom=0, right=1, top=1)
 ax.set_axis_off()
 ax.imshow(image, **kwargs)
 ax.figure.canvas.draw()
 return (fig, ax)

def figimage ( image , scale = 1 , dpi = None , ** kwargs ) : dpi = ( dpi if ( dpi is not None ) else mpl . rcParams [ 'figure.dpi' ] ) kwargs . setdefault ( 'interpolation' , 'nearest' ) kwargs . setdefault ( 'cmap' , 'gray' ) ( h , w , d ) = np . atleast_3d ( image ) . shape figsize = ( ( np . array ( ( w , h ) , dtype = float ) / dpi ) * scale ) ( fig , ax ) = new_plot ( figsize = figsize , dpi = dpi ) fig . subplots_adjust ( left = 0 , bottom = 0 , right = 1 , top = 1 ) ax . set_axis_off ( ) ax . imshow ( image , ** kwargs ) ax . figure . canvas . draw ( ) return ( fig , ax )
return figure and axes with figure tightly surrounding image .