mirror of
https://github.com/wassname/scikit-image.git
synced 2026-08-06 13:30:21 +08:00
BUG: fix one additional location where ndimage mode conversion was needed
This commit is contained in:
@@ -12,6 +12,17 @@ from ..util import img_as_float
|
||||
from ._warps_cy import _warp_fast
|
||||
|
||||
|
||||
def _to_ndimage_mode(mode):
|
||||
""" Convert from a numpy.pad mode name to the corresponding ndimage
|
||||
mode. """
|
||||
mode = _mode_deprecations(mode.lower())
|
||||
mode_translation_dict = dict(edge='nearest', symmetric='reflect',
|
||||
reflect='mirror')
|
||||
if mode in mode_translation_dict:
|
||||
mode = mode_translation_dict[mode]
|
||||
return mode
|
||||
|
||||
|
||||
def _center_and_normalize_points(points):
|
||||
"""Center and normalize image points.
|
||||
|
||||
@@ -1142,7 +1153,6 @@ def _clip_warp_output(input_image, output_image, order, mode, cval, clip):
|
||||
produce values outside the given input range.
|
||||
|
||||
"""
|
||||
mode = _mode_deprecations(mode)
|
||||
if clip and order != 0:
|
||||
min_val = input_image.min()
|
||||
max_val = input_image.max()
|
||||
@@ -1390,8 +1400,9 @@ 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
|
||||
|
||||
ndi_mode = _to_ndimage_mode(mode)
|
||||
warped = ndi.map_coordinates(image, coords, prefilter=prefilter,
|
||||
mode=mode, order=order, cval=cval)
|
||||
mode=ndi_mode, order=order, cval=cval)
|
||||
|
||||
|
||||
_clip_warp_output(image, warped, order, mode, cval, clip)
|
||||
|
||||
@@ -3,21 +3,11 @@ from scipy import ndimage as ndi
|
||||
|
||||
from ..measure import block_reduce
|
||||
from ._geometric import (warp, SimilarityTransform, AffineTransform,
|
||||
_convert_warp_input, _clip_warp_output)
|
||||
_convert_warp_input, _clip_warp_output,
|
||||
_to_ndimage_mode)
|
||||
from .._shared.utils import _mode_deprecations
|
||||
|
||||
|
||||
def _to_ndimage_mode(mode):
|
||||
""" Convert from a numpy.pad mode name to the corresponding ndimage
|
||||
mode. """
|
||||
mode = _mode_deprecations(mode.lower())
|
||||
mode_translation_dict = dict(edge='nearest', symmetric='reflect',
|
||||
reflect='mirror')
|
||||
if mode in mode_translation_dict:
|
||||
mode = mode_translation_dict[mode]
|
||||
return mode
|
||||
|
||||
|
||||
def resize(image, output_shape, order=1, mode='constant', cval=0, clip=True,
|
||||
preserve_range=False):
|
||||
"""Resize image to match a certain size.
|
||||
@@ -88,7 +78,7 @@ def resize(image, output_shape, order=1, mode='constant', cval=0, clip=True,
|
||||
# 3-dimensional interpolation
|
||||
if len(output_shape) == 3 and (image.ndim == 2
|
||||
or output_shape[2] != image.shape[2]):
|
||||
mode = _to_ndimage_mode(mode)
|
||||
ndi_mode = _to_ndimage_mode(mode)
|
||||
dim = output_shape[2]
|
||||
if image.ndim == 2:
|
||||
image = image[:, :, np.newaxis]
|
||||
@@ -105,7 +95,7 @@ def resize(image, output_shape, order=1, mode='constant', cval=0, clip=True,
|
||||
image = _convert_warp_input(image, preserve_range)
|
||||
|
||||
out = ndi.map_coordinates(image, coord_map, order=order,
|
||||
mode=mode, cval=cval)
|
||||
mode=ndi_mode, cval=cval)
|
||||
|
||||
_clip_warp_output(image, out, order, mode, cval, clip)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user