Skip to content

Instantly share code, notes, and snippets.

@TuringNPcomplete
Last active October 26, 2021 17:02
Show Gist options
  • Save TuringNPcomplete/f8b0d57d44a610c76f01500eeaec8852 to your computer and use it in GitHub Desktop.
Save TuringNPcomplete/f8b0d57d44a610c76f01500eeaec8852 to your computer and use it in GitHub Desktop.
A modified version of fastai's show_images function that applies an appropriate colormap to 2D images
def Dim_Imsshow(ims, nrows=1, ncols=None, titles= None, **kwargs):
"Show all images 'ims' as subplots with 'rows' using 'titles'."
if ncols is None: ncols = int(math.ceil(len(ims)/nrows))
if titles is None: titles = [None]*len(ims)
axs = subplots(nrows, ncols, **kwargs)[1].flat
for im,t,ax in zip(ims, titles, axs):
if im.ndim < 3:
show_image(im, ax = ax, title= t, cmap='gray')
else:
show_image(im, ax = ax, title= t)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment