Skip to content

Instantly share code, notes, and snippets.

@stephengruppetta
Created November 22, 2023 23:09
Show Gist options
  • Save stephengruppetta/d49a9ed0419968acaa8cf627743fe68b to your computer and use it in GitHub Desktop.
Save stephengruppetta/d49a9ed0419968acaa8cf627743fe68b to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
image = plt.imread("gardens.jpg")
# Create a figure with two subplots
fig, (ax_left, ax_right) = plt.subplots(nrows=1, ncols=2)
ax_left.imshow(image)
ax_left.axis("off")
# Extract the red channel from the image
image_red = image.copy()
image_red[:, :, 1:] = 0
ax_right.imshow(image_red)
ax_right.axis("off")
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment