_
This commit is contained in:
parent
e736801961
commit
04f85b9b65
@ -1,4 +1,4 @@
|
|||||||
import pygame
|
import math
|
||||||
from numpy import array as a
|
from numpy import array as a
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
@ -77,15 +77,17 @@ def get_edges_values(input):
|
|||||||
img1 = np.zeros(shape=asnumpy_gray.shape)
|
img1 = np.zeros(shape=asnumpy_gray.shape)
|
||||||
for y in range(1, len(img1) - 1):
|
for y in range(1, len(img1) - 1):
|
||||||
for x in range(1, len(img1[y]) - 1):
|
for x in range(1, len(img1[y]) - 1):
|
||||||
inx = 0.
|
inx0 = 0.
|
||||||
|
inx1 = 0.
|
||||||
for ax in range(-1, 2):
|
for ax in range(-1, 2):
|
||||||
for b in range(-1, 2):
|
for b in range(-1, 2):
|
||||||
try:
|
try:
|
||||||
inx += asnumpy_gray[y + ax][x + b] * sobel_0[ax + 1][b + 1] + asnumpy_gray[y + ax][x + b] * sobel_1[ax + 1][b + 1]
|
inx0 += asnumpy_gray[y + ax][x + b] * sobel_0[ax + 1][b + 1]
|
||||||
|
inx1 += asnumpy_gray[y + ax][x + b] * sobel_1[ax + 1][b + 1]
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
img1[y][x] = inx
|
img1[y][x] = math.sqrt(inx0 ** 2 + inx1 ** 2)
|
||||||
return img1
|
return img1
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user