Advertisement
lamiastella

python_script_conversion

Jun 19th, 2017
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.06 KB | None | 0 0
  1. import numpy as np
  2. from matplotlib import pyplot as plt
  3. import matplotlib
  4. import glob
  5. import cv2
  6. import scipy
  7. from scipy import misc
  8.  
  9.  
  10. for file in glob.glob("*_depth.npy"):
  11.     im = np.load(file)
  12.     #print(type(im))
  13.     #print(im.shape)
  14.     #print(im.size)
  15.     #print(im.ndim)
  16.     #print(np.max(im, axis=0))
  17.     '''for i in range(480):
  18.        for j in range(640):
  19.            if (im[i][j]==32001):
  20.                im[i][j]==0'''
  21.  
  22.     r = np.ptp(im,axis=1)
  23.  
  24.     depth_image_filename = file[:-4]+'_modified'+'.png'
  25.  
  26.     cv2.imwrite(depth_image_filename, (im).astype(np.uint16))
  27.  
  28. from PIL import Image
  29.  
  30. '''for file in glob.glob("*_depth_modified.png"):
  31.    im = Image.open(file, 'r')
  32.    pixel_val = list(im.getdata())
  33.    for val in pixel_val:
  34.        if (val==32001):
  35.            val=0
  36. '''
  37. #from PIL import Image
  38.  
  39. #imag = Image.open('000000_depth_modified.png')
  40. #print(type(imag))
  41. #cv2.imwrite("moon.png", (im*32).astype(np.uint16))
  42.  
  43. from PIL import Image
  44. im = Image.open("000000_depth.png", 'r')
  45. pixel_val = list(im.getdata())
  46. print(pixel_val)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement