Я пытаюсь понять не-максимальное подавление путем интерполяции из Не-максимальное подавление путем интерполяции
он упоминает - "линейная интерполяция используется между двумя соседними пикселями, которые охватываютНаправление градиента "
Любой намек на схему алгоритма? До сих пор я реализовал подавление не-максимума без интерполяции следующим образом:
def non_maximum_suppression_no_interpolation(G, theta):
H, W = G.shape
# We will start with a black image where all pixel values are zero.
out = np.zeros((H, W))
# Round the gradient direction to the nearest 45 degrees
theta = np.floor((theta + 22.5) / 45) * 45
PI = 180
for i in range(1, H-1):
for j in range(1, W-1):
direction = theta[i,j]
# (0 <= direction < 22.5) or (337.5 <= direction < 360)
if (0 <= direction < PI / 8) or (15 * PI / 8 <= direction <= 2 * PI) or (7 * PI / 8 <= direction < 9 * PI / 8):
# left and right
before_pixel = G[i, j - 1]
after_pixel = G[i, j + 1]
# (22.5 <= direction < 67.5) or (202.5 <= direction < 247.5)
elif (PI / 8 <= direction < 3 * PI / 8) or (9 * PI / 8 <= direction < 11 * PI / 8):
before_pixel = G[i + 1, j - 1] # south-west
after_pixel = G[i - 1, j + 1] # north-east
#(67.5 <= direction < 112.5) or ()
elif (3 * PI / 8 <= direction < 5 * PI / 8) or (11 * PI / 8 <= direction < 13 * PI / 8):
before_pixel = G[i - 1, j]
after_pixel = G[i + 1, j]
else:
before_pixel = G[i - 1, j - 1]
after_pixel = G[i + 1, j + 1]
if G[i, j] >= before_pixel and G[i, j] >= after_pixel:
out[i, j] = G[i, j]
else:
out[i, j] = 0
return out