def plot_img_and_hist(img, axes, bins=256):
 (ax_img, ax_hist) = axes
 ax_cdf = ax_hist.twinx()
 ax_img.imshow(img, cmap=plt.cm.gray)
 ax_img.set_axis_off()
 ax_hist.hist(img.ravel(), bins=bins)
 ax_hist.ticklabel_format(axis='y', style='scientific', scilimits=(0, 0))
 ax_hist.set_xlabel('Pixel intensity')
 (xmin, xmax) = dtype_range[img.dtype.type]
 ax_hist.set_xlim(xmin, xmax)
 (img_cdf, bins) = exposure.cumulative_distribution(img, bins)
 ax_cdf.plot(bins, img_cdf, 'r')
 return (ax_img, ax_hist, ax_cdf)

def plot_img_and_hist ( img , axes , bins = 256 ) : ( ax_img , ax_hist ) = axes ax_cdf = ax_hist . twinx ( ) ax_img . imshow ( img , cmap = plt . cm . gray ) ax_img . set_axis_off ( ) ax_hist . hist ( img . ravel ( ) , bins = bins ) ax_hist . ticklabel_format ( axis = 'y' , style = 'scientific' , scilimits = ( 0 , 0 ) ) ax_hist . set_xlabel ( 'Pixel intensity' ) ( xmin , xmax ) = dtype_range [ img . dtype . type ] ax_hist . set_xlim ( xmin , xmax ) ( img_cdf , bins ) = exposure . cumulative_distribution ( img , bins ) ax_cdf . plot ( bins , img_cdf , 'r' ) return ( ax_img , ax_hist , ax_cdf )
plot an image along with its histogram and cumulative histogram .