def generate_dog(img, nb_octaves, nb_per_octave=4):
"""Generate the difference of gaussians of an image.
Args:
img The input image
nb_octaves Number of octaves (groups of images with similar smoothing/sigmas)
nb_per_octave Number of images in one octave (with increasing smoothing/sigmas)
Returns:
List of (difference image, sigma value)
"""
spaces = []
sigma_start = 1.6
k_start = math.sqrt(2)
for i in range(nb_octaves):
sigma = sigma_start * (2 ** i)
last_gauss = None
for j in range(nb_per_octave+1):
k = k_start ** (j+1)
gauss = filters.gaussian_filter(img, k*sigma)
if last_gauss is not None:
diff = gauss - last_gauss
spaces.append((diff, k*sigma))
last_gauss = gauss
return spaces
评论列表
文章目录