Как рассчитать карту GOA (анализ градиентной ориентации)? - PullRequest
0 голосов
/ 09 ноября 2019

Я сейчас следую за документом здесь , чтобы вычислить карты GOA изображения, содержание метода находится в РАЗДЕЛЕ III. -> A. Вектор элементов -> 1. Ориентационный анализ градиентного векторного поля

моя версия на python 3.7.0 и моя версия opencv 3.4.2, мой код приведен ниже (используя sigma = 2 * sqrt (2) для создания первой производной)

from scipy.ndimage import gaussian_filter
import numpy as np
import cv2

# compute the first derivative of the original image in both horizontal and vertical direction
g_x = gaussian_filter(image_new,  sigma = (2*np.sqrt(2), 0))
g_y = gaussian_filter(image_new,  sigma = ( 0, 2*np.sqrt(2)))

# compute the magnitude
mag = np.sqrt(np.power(g_x, 2)+np.power(g_y, 2))

# normalise the gradient vectors computed above
u_x = (g_x / mag).astype(np.uint8)
u_y = (g_y / mag).astype(np.uint8)

#followed instruction, if the magnitude is less than 3(out of 255), then the unit vector should be assigned to 0
u_x[mag < 3] = 0
u_y[mag < 3] = 0

# compute the first derivatives of unit vectors
d_xx = gaussian_filter(u_x,   sigma = (2*np.sqrt(2), 0))
d_xy = gaussian_filter(u_x,  sigma = ( 0, 2*np.sqrt(2)) )
d_yx = gaussian_filter(u_y,   sigma = (2*np.sqrt(2), 0))
d_yy = gaussian_filter(u_y,  sigma = ( 0, 2*np.sqrt(2)) )

# first derivative again
second_d_xx = gaussian_filter(d_xx,   sigma = (2*np.sqrt(2), 0))
second_d_xy = gaussian_filter(d_xy,  sigma = ( 0, 2*np.sqrt(2)) )
second_d_yx = gaussian_filter(d_yx,   sigma = (2*np.sqrt(2), 0))
second_d_yy = gaussian_filter(d_yy,  sigma = ( 0, 2*np.sqrt(2)) )

# the result
D = second_d_xx+second_d_xy+ second_d_yx+second_d_yy

Я не могу понять, что не так с моим кодом, полученное изображение сильно отличается от результата, представленного в документации (рис. 1 -> d, e, f), кто-то может помочь?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...