Harmonize all ndimage usage across the library

Only two forms remain in use:

- `from scipy import ndimage as ndi`
- `from scipy.ndimage import function`
This commit is contained in:
Juan Nunez-Iglesias
2015-06-09 15:18:37 +10:00
parent 82a5d0c5d9
commit 0d134987f9
47 changed files with 173 additions and 185 deletions
+5 -6
View File
@@ -2,11 +2,10 @@ import six
import math
import warnings
import numpy as np
from scipy import ndimage, spatial
from scipy import ndimage as ndi, spatial
from .._shared.utils import get_bound_method_class, safe_as_int
from ..util import img_as_float
from ..exposure import rescale_intensity
from ._warps_cy import _warp_fast
@@ -1054,7 +1053,7 @@ def warp_coords(coord_map, shape, dtype=np.float64):
users who would like, for example, to re-use a particular coordinate
mapping, to use specific dtypes at various points along the the
image-warping process, or to implement different post-processing logic
than `warp` performs after the call to `ndimage.map_coordinates`.
than `warp` performs after the call to `ndi.map_coordinates`.
Examples
@@ -1352,7 +1351,7 @@ def warp(image, inverse_map=None, map_args={}, output_shape=None, order=1,
warped = np.dstack(dims)
if warped is None:
# use ndimage.map_coordinates
# use ndi.map_coordinates
if (isinstance(inverse_map, np.ndarray)
and inverse_map.shape == (3, 3)):
@@ -1388,8 +1387,8 @@ def warp(image, inverse_map=None, map_args={}, output_shape=None, order=1,
# Pre-filtering not necessary for order 0, 1 interpolation
prefilter = order > 1
warped = ndimage.map_coordinates(image, coords, prefilter=prefilter,
mode=mode, order=order, cval=cval)
warped = ndi.map_coordinates(image, coords, prefilter=prefilter,
mode=mode, order=order, cval=cval)
_clip_warp_output(image, warped, order, mode, cval, clip)
+3 -3
View File
@@ -1,5 +1,5 @@
import numpy as np
from scipy import ndimage
from scipy import ndimage as ndi
from ..measure import block_reduce
from ._geometric import (warp, SimilarityTransform, AffineTransform,
@@ -81,8 +81,8 @@ def resize(image, output_shape, order=1, mode='constant', cval=0, clip=True,
image = _convert_warp_input(image, preserve_range)
out = ndimage.map_coordinates(image, coord_map, order=order,
mode=mode, cval=cval)
out = ndi.map_coordinates(image, coord_map, order=order,
mode=mode, cval=cval)
_clip_warp_output(image, out, order, mode, cval, clip)
+5 -5
View File
@@ -1,5 +1,5 @@
import numpy as np
from scipy import ndimage
from scipy import ndimage as ndi
from .. import measure, morphology
from ._hough_transform import _hough_circle
@@ -63,10 +63,10 @@ def hough_line_peaks(hspace, angles, dists, min_distance=9, min_angle=10,
distance_size = 2 * min_distance + 1
angle_size = 2 * min_angle + 1
hspace_max = ndimage.maximum_filter1d(hspace, size=distance_size, axis=0,
mode='constant', cval=0)
hspace_max = ndimage.maximum_filter1d(hspace_max, size=angle_size, axis=1,
mode='constant', cval=0)
hspace_max = ndi.maximum_filter1d(hspace, size=distance_size, axis=0,
mode='constant', cval=0)
hspace_max = ndi.maximum_filter1d(hspace_max, size=angle_size, axis=1,
mode='constant', cval=0)
mask = (hspace == hspace_max)
hspace *= mask
hspace_t = hspace > threshold
+6 -6
View File
@@ -1,6 +1,6 @@
import math
import numpy as np
from scipy import ndimage
from scipy import ndimage as ndi
from ..transform import resize
from ..util import img_as_float
@@ -13,12 +13,12 @@ def _smooth(image, sigma, mode, cval):
# apply Gaussian filter to all dimensions independently
if image.ndim == 3:
for dim in range(image.shape[2]):
ndimage.gaussian_filter(image[..., dim], sigma,
output=smoothed[..., dim],
mode=mode, cval=cval)
else:
ndimage.gaussian_filter(image, sigma, output=smoothed,
ndi.gaussian_filter(image[..., dim], sigma,
output=smoothed[..., dim],
mode=mode, cval=cval)
else:
ndi.gaussian_filter(image, sigma, output=smoothed,
mode=mode, cval=cval)
return smoothed