0
這裏是我使用的邊緣檢測代碼Sobel operator:爲什麼我的Sobel邊緣檢測代碼不起作用?
from PIL import Image
import numpy as np
from scipy import misc
a = np.array([1, 2, 1])
b = np.array([1, 0, -1])
Gy = np.outer(a, b)
Gx = np.rot90(Gy, k=3)
def apply(X):
a = (X * Gx)
b = (X * Gy)
return np.abs(a.sum()) + np.abs(b.sum())
data = np.uint8(misc.lena())
data2 = np.copy(data)
center = offset = 1
for i in range(offset, data.shape[0]-offset):
for j in range(offset, data.shape[1]-offset):
X = data[i-offset:i+offset+1, j-offset:j+offset+1]
data[i, j] = apply(X)
image = Image.fromarray(data)
image.show()
image = Image.fromarray(data2)
image.show()
導致:
相反的:
對於它的價值,我相當肯定我的循環和圖像克恩的一般想法els是正確的。例如,我能夠產生這種自定義過濾器(高斯中心減去):
這有什麼錯我的Sobel濾波器?
它始終是一個好習慣,有獨立的輸入輸出圖像。 – Piglet