Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.61 KB | None | 0 0
  1. import os
  2. import glob
  3. import numpy as np
  4. import pandas as pd
  5. import matplotlib.cm as cm
  6. import ipywidgets as widgets
  7. import matplotlib.pyplot as plt
  8. import xml.etree.ElementTree as ET
  9. import matplotlib.patches as patches
  10.  
  11. from PIL import Image
  12. from shutil import copyfile
  13. from ipywidgets import interact
  14. from matplotlib.cm import get_cmap
  15.  
  16. plt.rcParams['figure.figsize'] = 20, 12
  17.  
  18. def show_images(index):
  19.     fig, axes = plt.subplots(3, 2)
  20.     seg_path1 = histograms[index][0]
  21.     geo_path1 = histograms[index][1]
  22.     seg_path2 = histograms[index+1][0]
  23.     geo_path2 = histograms[index+1][1]
  24.     seg_path3 = histograms[index+2][0]
  25.     geo_path3 = histograms[index+2][1]
  26.  
  27.     img1 = Image.open(seg_path1)
  28.     img2 = Image.open(geo_path1)
  29.     img3 = Image.open(seg_path2)
  30.     img4 = Image.open(geo_path2)
  31.     img5 = Image.open(seg_path3)
  32.     img6 = Image.open(geo_path3)
  33.  
  34.     axes[0][0].set_title(str(index) + " " + os.path.basename(seg_path1))
  35.     axes[0][1].set_title(str(index) + " " + os.path.basename(geo_path1))
  36.     axes[1][0].set_title(str(index+1) + " " + os.path.basename(seg_path2))
  37.     axes[1][1].set_title(str(index+1) + " " + os.path.basename(geo_path2))
  38.     axes[2][0].set_title(str(index+2) + " " + os.path.basename(seg_path3))
  39.     axes[2][1].set_title(str(index+2) + " " + os.path.basename(geo_path3))
  40.    
  41.     axes[0][0].imshow(img1)
  42.     axes[0][1].imshow(img2)
  43.     axes[1][0].imshow(img3)
  44.     axes[1][1].imshow(img4)
  45.     axes[2][0].imshow(img5)
  46.     axes[2][1].imshow(img6)
  47.  
  48. index = widgets.IntSlider(min=0, max=len(histograms)-1, step=3,value=0)
  49. interact(show_images, index=index);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement