"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "skimage/feature/sift.py" between
scikit-image-0.19.1.tar.gz and scikit-image-0.19.2.tar.gz

About: scikit-image is a collection of algorithms for image processing in Python.

sift.py  (scikit-image-0.19.1):sift.py  (scikit-image-0.19.2)
skipping to change at line 149 skipping to change at line 149
float_dtype : type float_dtype : type
The datatype of the image. The datatype of the image.
scalespace_sigmas : (n_octaves, n_scales + 3) array scalespace_sigmas : (n_octaves, n_scales + 3) array
The sigma value of all scales in all octaves. The sigma value of all scales in all octaves.
keypoints : (N, 2) array keypoints : (N, 2) array
Keypoint coordinates as ``(row, col)``. Keypoint coordinates as ``(row, col)``.
positions : (N, 2) array positions : (N, 2) array
Subpixel-precision keypoint coordinates as ``(row, col)``. Subpixel-precision keypoint coordinates as ``(row, col)``.
sigmas : (N, ) array sigmas : (N, ) array
The corresponding sigma (blur) value of a keypoint. The corresponding sigma (blur) value of a keypoint.
sigmas : (N, ) array scales : (N, ) array
The corresponding scale of a keypoint. The corresponding scale of a keypoint.
orientations : (N, ) array orientations : (N, ) array
The orientations of the gradient around every keypoint. The orientations of the gradient around every keypoint.
octaves : (N, ) array octaves : (N, ) array
The corresponding octave of a keypoint. The corresponding octave of a keypoint.
descriptors : (N, n_hist*n_hist*n_ori) array descriptors : (N, n_hist*n_hist*n_ori) array
The descriptors of a keypoint. The descriptors of a keypoint.
Notes Notes
----- -----
skipping to change at line 333 skipping to change at line 333
to the image borders to the image borders
""" """
extrema_pos = [] extrema_pos = []
extrema_scales = [] extrema_scales = []
extrema_sigmas = [] extrema_sigmas = []
threshold = self.c_dog * 0.8 threshold = self.c_dog * 0.8
for o, (octave, delta) in enumerate(zip(dogspace, self.deltas)): for o, (octave, delta) in enumerate(zip(dogspace, self.deltas)):
# find extrema # find extrema
keys = _local_max(np.ascontiguousarray(octave), threshold) keys = _local_max(np.ascontiguousarray(octave), threshold)
if keys.size == 0: if keys.size == 0:
extrema_pos.append(np.empty((0, 2)))
continue continue
# localize extrema # localize extrema
oshape = octave.shape oshape = octave.shape
refinement_iterations = 5 refinement_iterations = 5
offset_max = 0.6 offset_max = 0.6
for i in range(refinement_iterations): for i in range(refinement_iterations):
if i > 0: if i > 0:
# exclude any keys that have moved out of bounds # exclude any keys that have moved out of bounds
keys = keys[self._inrange(keys, oshape), :] keys = keys[self._inrange(keys, oshape), :]
skipping to change at line 411 skipping to change at line 412
sigmas = self.scalespace_sigmas[o, keys[:, 2]] * np.power( sigmas = self.scalespace_sigmas[o, keys[:, 2]] * np.power(
sigmaratio, off[:, 2]) sigmaratio, off[:, 2])
border_filter = np.all( border_filter = np.all(
np.logical_and((yx - sigmas[:, np.newaxis]) > 0.0, np.logical_and((yx - sigmas[:, np.newaxis]) > 0.0,
(yx + sigmas[:, np.newaxis]) < img_shape), (yx + sigmas[:, np.newaxis]) < img_shape),
axis=1) axis=1)
extrema_pos.append(yx[border_filter]) extrema_pos.append(yx[border_filter])
extrema_scales.append(keys[border_filter, 2]) extrema_scales.append(keys[border_filter, 2])
extrema_sigmas.append(sigmas[border_filter]) extrema_sigmas.append(sigmas[border_filter])
if not extrema_pos: octave_indices = np.concatenate([np.full(len(p), i)
for i, p in enumerate(extrema_pos)])
if len(octave_indices) == 0:
raise RuntimeError( raise RuntimeError(
"SIFT found no features. Try passing in an image containing " "SIFT found no features. Try passing in an image containing "
"greater intensity contrasts between adjacent pixels.") "greater intensity contrasts between adjacent pixels.")
octave_indices = np.concatenate([np.full(len(p), i)
for i, p in enumerate(extrema_pos)])
extrema_pos = np.concatenate(extrema_pos) extrema_pos = np.concatenate(extrema_pos)
extrema_scales = np.concatenate(extrema_scales) extrema_scales = np.concatenate(extrema_scales)
extrema_sigmas = np.concatenate(extrema_sigmas) extrema_sigmas = np.concatenate(extrema_sigmas)
return extrema_pos, extrema_scales, extrema_sigmas, octave_indices return extrema_pos, extrema_scales, extrema_sigmas, octave_indices
def _fit(self, h): def _fit(self, h):
"""Refine the position of the peak by fitting it to a parabola""" """Refine the position of the peak by fitting it to a parabola"""
return (h[0] - h[2]) / (2 * (h[0] + h[2] - 2 * h[1])) return (h[0] - h[2]) / (2 * (h[0] + h[2] - 2 * h[1]))
def _compute_orientation(self, positions_oct, scales_oct, sigmas_oct, def _compute_orientation(self, positions_oct, scales_oct, sigmas_oct,
skipping to change at line 441 skipping to change at line 443
""" """
gradient_space = [] gradient_space = []
# list for keypoints that have more than one reference orientation # list for keypoints that have more than one reference orientation
keypoint_indices = [] keypoint_indices = []
keypoint_angles = [] keypoint_angles = []
keypoint_octave = [] keypoint_octave = []
orientations = np.zeros_like(sigmas_oct, dtype=self.float_dtype) orientations = np.zeros_like(sigmas_oct, dtype=self.float_dtype)
key_count = 0 key_count = 0
for o, (octave, delta) in enumerate(zip(gaussian_scalespace, for o, (octave, delta) in enumerate(zip(gaussian_scalespace,
self.deltas)): self.deltas)):
gradient_space.append(np.gradient(octave))
in_oct = octaves == o in_oct = octaves == o
if not np.any(in_oct):
continue
positions = positions_oct[in_oct] positions = positions_oct[in_oct]
scales = scales_oct[in_oct] scales = scales_oct[in_oct]
sigmas = sigmas_oct[in_oct] sigmas = sigmas_oct[in_oct]
gradient_space.append(np.gradient(octave))
oshape = octave.shape[:2] oshape = octave.shape[:2]
# convert to octave's dimensions # convert to octave's dimensions
yx = positions / delta yx = positions / delta
sigma = sigmas / delta sigma = sigmas / delta
# dimensions of the patch # dimensions of the patch
radius = 3 * self.lambda_ori * sigma radius = 3 * self.lambda_ori * sigma
p_min = np.maximum(0, p_min = np.maximum(0,
yx - radius[:, np.newaxis] + 0.5).astype(int) yx - radius[:, np.newaxis] + 0.5).astype(int)
p_max = np.minimum(yx + radius[:, np.newaxis] + 0.5, p_max = np.minimum(yx + radius[:, np.newaxis] + 0.5,
 End of changes. 7 change blocks. 
5 lines changed or deleted 10 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)