Ответ таков:
- Реализация весовых функций в соответствии с бумагой неверна, вниз правильная.
- Они поменяли сигнал на функцию взвешивания и повернули вспять это снова в расчете матриц, поэтому нет никакой разницы.
def compute_weights(image,mask,alpha, beta, eps=1.e-6):
# Weight calculation is main difference in multispectral version
# Original gradient**2 replaced with sum of gradients ** 2
intra_gradients = np.concatenate([np.diff(image, axis=ax).ravel()
for ax in [1, 0] ], axis=0) ** 2 # gradient ^2
# print('intra_gradients shape',intra_gradients.shape)
# 5-Connected
inter_gradients = np.concatenate([np.diff(mask, axis=ax).ravel()
for ax in [1, 0] ], axis=0)**2
# inter_gradients = np.concatenate((inter_gradients,(mask-image).ravel()),axis=0)**2 # gradient ^2
# print('inter_gradients shape',inter_gradients.shape)
#----------------------------------------
# 1-Connected
# inter_gradients = (image - mask)**2
#----------------------------------------
# Normalize gradients
intra_gradients = (intra_gradients - np.amin(intra_gradients))/(np.amax(intra_gradients)- np.amin(intra_gradients))
inter_gradients = (inter_gradients - np.amin(inter_gradients))/(np.amax(inter_gradients)- np.amin(inter_gradients))
# print('Intra Gradiesnt_Shape: ',intra_gradients.shape)
# All dimensions considered together in this standard deviation
#------------------------------------------------------
intra_scale_factor = -beta / (10 * image.std())
intra_weights = np.exp(intra_scale_factor * intra_gradients)
intra_weights += eps
#------------------------------------------------------
inter_scale_factor = -alpha / (10 * image.std())
inter_weights = np.exp(inter_scale_factor * inter_gradients)
inter_weights += eps
#------------------------------------------------------
return -intra_weights, inter_weights # [W_old , w_new]