Advertisement
dan-masek

Untitled

Feb 21st, 2020
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. import numpy as np
  2. from cv2_41 import cv2
  3.  
  4. # Just some random data
  5. new_array = np.ones((960, 240, 240), np.uint8)
  6.  
  7. # And a random kernel
  8. kernel = np.array([[1,1],[1,1]])
  9.  
  10. # Make this a simple python list
  11. dilated = []
  12. for i in range(32, 36):
  13.   dilation = cv2.dilate(new_array[i], kernel, iterations = 1)
  14.   # Add dimension "to the beginning" shape (240,240) -> (1,240,240)
  15.   # We need this so we can stack it together at the end
  16.   # And append this to the python list
  17.   dilated.append(np.expand_dims(dilation, axis=0))
  18.  
  19. # Now stack all the sub-arrays in the list vertically (one below each other, rows are first)
  20. result = np.vstack(dilated)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement