Facebook
From Edgy Crane, 1 Week ago, written in Python.
Embed
Download Paste or View Raw
Hits: 32
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import matplotlib.pyplot as plt
  4. from matplotlib import rc
  5. import numpy as np
  6. from skimage import img_as_float, color
  7. from datetime import datetime
  8. from skimage import filters, io, morphology, feature, data
  9. from scipy import ndimage
  10. from skimage import measure
  11.  
  12. airplaneFile = "F:\\Studia\\PUT\\V\\Komunikacja człowiek-komputer\\Zadanie 4- Samoloty\\Samolot\\samolot"
  13. savePath = "C:\\Users\\Szczepan\\Desktop\\" + 'Samolociki' + datetime.now().strftime('%Y%m%d%H%M%S') +'.pdf'
  14. fileExtension = ".jpg"
  15. numOfImages = 20
  16.  
  17.  
  18. def loadFiles(numOfImage):
  19.     img = [[]] * numOfImage
  20.     for i in range(0, numOfImage):
  21.         if i < 10:
  22.             img[i] = io.imread(airplaneFile + "0" + str(i) + fileExtension, as_grey=False)
  23.         else:
  24.             img[i] = io.imread(airplaneFile + str(i) + fileExtension, as_grey=False)
  25.     return img
  26.  
  27. def plot(numOfImage):
  28.     size = 400
  29.     fig, axes = plt.subplots(nrows= numOfImage,  sharex=True, sharey=True, figsize=(1.61* size, size))
  30.     fig.subplots_adjust(top=1.00, bottom=0.05, left=0.25, right=0.95)
  31.     rc('legend', fontsize=10)
  32.     return fig, axes
  33.  
  34. def main():
  35.     grayscale_image = img_as_float(data.camera()[::2, ::2])
  36.     img = color.gray2rgb(grayscale_image) #WczytujÄ™ pliki
  37.     fig, axes = plot(numOfImages)
  38.     for i in range (0, numOfImages):
  39.  
  40.         im = axes[i].imshow(img)
  41.         im.set_extent([0, 1, 0, 1])
  42.  
  43.         axes[i].yaxis.set_visible(False)
  44.  
  45.         pos = list(axes[i].get_position().bounds)
  46.         x_text = pos[0] - 0.25
  47.         y_text = pos[1] + pos[3]/2.
  48.         fig.text(x_text, y_text, i, va='center', ha='left', fontsize=10)
  49.  
  50.  
  51.     fig.savefig(savePath)
  52.  
  53.  
  54. if _name_ == '_main_':
  55.     main()