Skip to content

Instantly share code, notes, and snippets.

@sergeyprokudin
Created August 12, 2020 10:53
Show Gist options
  • Save sergeyprokudin/a1233bcce40b2200841ac4979ee04c4e to your computer and use it in GitHub Desktop.
Save sergeyprokudin/a1233bcce40b2200841ac4979ee04c4e to your computer and use it in GitHub Desktop.
Simple functions to plot images
import numpy as np
import matplotlib.pyplot as plt
def show_img(img, figsize=(10, 10)):
'''
Show image using matplotlib
Parameters
----------
img : array of shape [img_width, img_height, 3]
'''
plt.figure(figsize=figsize)
plt.axis('off')
plt.imshow(img)
plt.show()
return
def show_img_pair(img1, img2):
'''
Combine two images for a side-by-side comparison
Parameters
----------
img1 : array of shape [img_height, img_width, 3]
img2 : array of shape [img_height, img_width, 3]
'''
img_height, img_width, n_channels = img1.shape
img_res = np.zeros([img_height, img_width*2, n_channels])
img_res[:,0:img_width, :] = img1
img_res[:,img_width:, :] = img2
show_img(img_res)
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment