Created
March 13, 2017 01:02
-
-
Save Lyken17/971cd19b78d5611efcdaa10596a6da9e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# In[127]: | |
import numpy as np | |
from scipy.signal import convolve2d as conv2d | |
p_label = np.array([[[1, 0, 0], [1, 0, 0], [1, 0, 0], [1, 0, 0], [1, 0, 0], [1, 0, 0]], | |
[[1, 0, 0], [1, 0, 0], [0, 1, 0], [0, 1, 0], [1, 0, 0], [1, 0, 0]], | |
[[1, 0, 0], [1, 0, 0], [0, 1, 0], [0, 1, 0], [1, 0, 0], [1, 0, 0]], | |
[[1, 0, 0], [1, 0, 0], [1, 0, 0], [1, 0, 0], [1, 0, 0], [1, 0, 0]]]) | |
# In[128]: | |
p_label.shape | |
# In[133]: | |
kernel = np.array([[1, 2, 1], [2, 4, 2], [1, 2, 1]]) / 16.0 | |
# In[134]: | |
kernel, kernel.shape | |
# In[135]: | |
print(p_label[:,:,0]) | |
print(conv2d(p_label[:,:,0], kernel, boundary='fill', mode='same')) | |
# In[136]: | |
print(p_label[:,:,1]) | |
print(conv2d(p_label[:,:,1], kernel, boundary='fill', mode='same')) | |
# In[ ]: | |
# In[ ]: | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment