Advertisement
lamiastella

script for zeroing out 32001 vals in pixel_vals for CVAR

Jun 19th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. from PIL import Image
  2. import numpy as np
  3. import cv2
  4. import glob
  5.  
  6. im = Image.open("000000_depth.png", 'r')
  7. for file in glob.glob("*_depth.png"):
  8.     im = Image.open(file, 'r')
  9.     pixel_val = list(im.getdata())
  10.     for i in range(len(pixel_val)):
  11.         if (pixel_val[i]==32001):
  12.             pixel_val[i]=0
  13.     np_arr = np.array(pixel_val)
  14.     #print(np_arr.shape)
  15.     #print(np_arr.size)
  16.     #print(np_arr.ndim)
  17.     np_reshaped = np_arr.reshape(240, 321)
  18.     modified_depth_file = file[:-4] + '_modified.png'
  19.     cv2.imwrite(modified_depth_file, (np_reshaped).astype(np.uint16))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement