-
Notifications
You must be signed in to change notification settings - Fork 84
Closed
Labels
refactoringIssues related to code refactoring.Issues related to code refactoring.staleIssues lack of activities.Issues lack of activities.
Milestone
Description
Subject of the feature
Once we merged #719, we will have two nearly identical gaussian kernels
def gaussian_kernel1d_size(kernel_size: int) -> tf.Tensor:
"""
Return a the 1D Gaussian kernel for LocalNormalizedCrossCorrelation.
Sum of the weights is 1.
:param kernel_size: scalar, size of the 1-D kernel
:return: filters, of shape (kernel_size, )
"""
mean = (kernel_size - 1) / 2.0
sigma = kernel_size / 3
grid = tf.range(0, kernel_size, dtype=tf.float32)
filters = tf.exp(-tf.square(grid - mean) / (2 * sigma ** 2))
filters = filters / tf.reduce_sum(filters)
return filters
def gaussian_kernel1d_sigma(sigma: int) -> tf.Tensor:
"""
Calculate a gaussian kernel.
:param sigma: number defining standard deviation for
gaussian kernel.
:return: shape = (dim, )
"""
assert sigma > 0
tail = int(sigma * 3)
kernel = tf.exp([-0.5 * x ** 2 / sigma ** 2 for x in range(-tail, tail + 1)])
kernel = kernel / tf.reduce_sum(kernel)
return kernelTherefore it's better to merge them, so that kernel accepts uniformly the size as an argument.
The Cauchy kernel needs to be updated to
Metadata
Metadata
Assignees
Labels
refactoringIssues related to code refactoring.Issues related to code refactoring.staleIssues lack of activities.Issues lack of activities.