Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- from cv2_41 import cv2
- # Just some random data
- new_array = np.ones((960, 240, 240), np.uint8)
- # And a random kernel
- kernel = np.array([[1,1],[1,1]])
- # Make this a simple python list
- dilated = []
- for i in range(32, 36):
- dilation = cv2.dilate(new_array[i], kernel, iterations = 1)
- # Add dimension "to the beginning" shape (240,240) -> (1,240,240)
- # We need this so we can stack it together at the end
- # And append this to the python list
- dilated.append(np.expand_dims(dilation, axis=0))
- # Now stack all the sub-arrays in the list vertically (one below each other, rows are first)
- result = np.vstack(dilated)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement