Last active
April 15, 2024 03:22
-
-
Save ctmakro/3ae3cd9538390b706820cd01dac6861f to your computer and use it in GitHub Desktop.
Display numpy ndarray as Image in Jupyter/IPython notebook
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
# if input image is in range 0..1, please first multiply img by 255 | |
# assume image is ndarray of shape [height, width, channels] where channels can be 1, 3 or 4 | |
def imshow(img): | |
import cv2 | |
import IPython | |
_,ret = cv2.imencode('.jpg', img) | |
i = IPython.display.Image(data=ret) | |
IPython.display.display(i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you! Image shows directly in Jupyter Lab ❤️