mirror of
https://github.com/wassname/scikit-image.git
synced 2026-08-12 12:30:16 +08:00
unwrap: Warn about singleton dimensions in 3D arrays.
This commit is contained in:
@@ -70,7 +70,10 @@ def check_wrap_around(ndim, axis):
|
||||
index_first = tuple([0] * ndim)
|
||||
index_last = tuple([-1 if n == axis else 0 for n in range(ndim)])
|
||||
# unwrap the image without wrap around
|
||||
image_unwrap_no_wrap_around = unwrap_phase(image_wrapped)
|
||||
with warnings.catch_warnings():
|
||||
# We do not want warnings about length 1 dimensions
|
||||
warnings.simplefilter("ignore")
|
||||
image_unwrap_no_wrap_around = unwrap_phase(image_wrapped)
|
||||
print('endpoints without wrap_around:',
|
||||
image_unwrap_no_wrap_around[index_first],
|
||||
image_unwrap_no_wrap_around[index_last])
|
||||
@@ -79,7 +82,10 @@ def check_wrap_around(ndim, axis):
|
||||
- image_unwrap_no_wrap_around[index_last]) > np.pi
|
||||
# unwrap the image with wrap around
|
||||
wrap_around = [n == axis for n in range(ndim)]
|
||||
image_unwrap_wrap_around = unwrap_phase(image_wrapped, wrap_around)
|
||||
with warnings.catch_warnings():
|
||||
# We do not want warnings about length 1 dimensions
|
||||
warnings.simplefilter("ignore")
|
||||
image_unwrap_wrap_around = unwrap_phase(image_wrapped, wrap_around)
|
||||
print('endpoints with wrap_around:',
|
||||
image_unwrap_wrap_around[index_first],
|
||||
image_unwrap_wrap_around[index_last])
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import numpy as np
|
||||
import warnings
|
||||
|
||||
from ._unwrap_2d import unwrap_2d
|
||||
from ._unwrap_3d import unwrap_3d
|
||||
@@ -53,6 +54,9 @@ def unwrap_phase(image, wrap_around=False):
|
||||
else:
|
||||
raise ValueError('wrap_around must be a bool or a sequence with '
|
||||
'length equal to the dimensionality of image')
|
||||
if image.ndim == 3 and 1 in image.shape:
|
||||
warnings.warn('image is 3D and has a length 1 dimension; consider '
|
||||
'using a 2D array to use the 2D unwrapping algorithm')
|
||||
|
||||
if np.ma.isMaskedArray(image):
|
||||
mask = np.require(image.mask, np.uint8, ['C'])
|
||||
|
||||
Reference in New Issue
Block a user