Created
August 12, 2020 10:53
-
-
Save sergeyprokudin/a1233bcce40b2200841ac4979ee04c4e to your computer and use it in GitHub Desktop.
Simple functions to plot images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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