仅做参考,有错谅解
import numpy as np
d = np.array([[90, 90, 5, 5, 50], [90, 90, 5, 5, 5], [60, 60, 60, 5, 5], [80, 80, 60, 50, 50], [80, 80, 60, 50, 50]],dtype=int)
def mySobel(myArray, x, y):
Dx = (myArray[x + 1, y - 1] - myArray[x - 1, y - 1]) + 2 * (myArray[x + 1, y] - myArray[x - 1, y]) + (
myArray[x + 1, y + 1] - myArray[x - 1, y + 1])
Dy = (myArray[x - 1, y + 1] - myArray[x - 1, y - 1]) + 2 * (myArray[x, y + 1] - myArray[x, y - 1]) + (
myArray[x + 1, y + 1] - myArray[x + 1, y - 1])
r = abs(Dx)+abs(Dy)
print(Dx,Dy)
return r
def myroderts(myArray,x,y):
Dx = (myArray[x+1, y+1] - myArray[x, y])
Dy = (myArray[x+1, y] - myArray[x, y+1])
r = abs(Dx) + abs(Dy)
print(Dx, Dy)
return r
def myprewitt(myArray,x,y):
Dx = (myArray[x-1, y+1] + myArray[