如何计算GOA(梯度方向分析)图?

我现在正在遵循文档here来计算图像的goa映射,方法内容在第三节。 -> 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,0))
d_xy = gaussian_filter(u_x,2*np.sqrt(2)) )
d_yx = gaussian_filter(u_y,0))
d_yy = gaussian_filter(u_y,2*np.sqrt(2)) )

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

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

我无法弄清楚我的代码有什么问题,生成的图像与文档中提供的结果有很大不同(图1-> d,e,f),有人可以帮忙吗?

xzpxiao 回答:如何计算GOA(梯度方向分析)图?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3133847.html

大家都在问