Created
June 3, 2021 14:27
-
-
Save usr-ein/7df58ba2329cb0a8b769cb57385c43af to your computer and use it in GitHub Desktop.
View numpy arrays images side by side in Jupyter
This file contains hidden or 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
from PIL import Image | |
import io | |
from ipywidgets import widgets | |
import IPython.display as display | |
def view(*arrs): | |
ims = [] | |
for arr in arrs: | |
output = io.BytesIO() | |
im = Image.fromarray(arr).resize((500,500), Image.NEAREST) | |
im.save(output, format="PNG") | |
ims += [widgets.Image( | |
value=output.getvalue(), | |
format='png', | |
width=500, | |
height=500, | |
)] | |
sidebyside = widgets.HBox(ims) | |
display.display(sidebyside) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment