mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-25 13:30:51 +08:00
Fix singleton dimension for 1 pixel image
This commit is contained in:
@@ -1016,5 +1016,7 @@ def warp(image, inverse_map=None, map_args={}, output_shape=None, order=1,
|
||||
if mode == 'constant' and not (0 <= cval <= 1):
|
||||
clipped[out == cval] = cval
|
||||
|
||||
# Remove singleton dim introduced by atleast_3d
|
||||
return clipped.squeeze()
|
||||
if clipped.shape[0] == 1 or clipped.shape[1] == 1:
|
||||
return clipped
|
||||
else: # remove singleton dim introduced by atleast_3d
|
||||
return clipped.squeeze()
|
||||
|
||||
@@ -185,16 +185,12 @@ def build_gaussian_pyramid(image, max_layer=-1, factor=2, sigma=None, order=1,
|
||||
|
||||
# build downsampled images until max_layer is reached or downsampled image
|
||||
# has size of 1 in one direction
|
||||
while True:
|
||||
while layer != max_layer:
|
||||
layer += 1
|
||||
|
||||
layer_image = pyramid_reduce(pyramid[-1], factor, sigma, order,
|
||||
mode, cval)
|
||||
|
||||
# image degraded to 1px
|
||||
if layer_image.ndim == 1:
|
||||
break
|
||||
|
||||
prev_rows = rows
|
||||
prev_cols = cols
|
||||
rows = layer_image.shape[0]
|
||||
@@ -206,9 +202,6 @@ def build_gaussian_pyramid(image, max_layer=-1, factor=2, sigma=None, order=1,
|
||||
|
||||
pyramid.append(layer_image)
|
||||
|
||||
if layer == max_layer:
|
||||
break
|
||||
|
||||
return pyramid
|
||||
|
||||
|
||||
@@ -267,7 +260,7 @@ def build_laplacian_pyramid(image, max_layer=-1, factor=2, sigma=None, order=1,
|
||||
|
||||
# build downsampled images until max_layer is reached or downsampled image
|
||||
# has size of 1 in one direction
|
||||
while True:
|
||||
while layer != max_layer:
|
||||
layer += 1
|
||||
|
||||
rows = pyramid[-1].shape[0]
|
||||
@@ -279,10 +272,6 @@ def build_laplacian_pyramid(image, max_layer=-1, factor=2, sigma=None, order=1,
|
||||
mode=mode, cval=cval)
|
||||
layer_image = _smooth(resized, sigma, mode, cval)
|
||||
|
||||
# image degraded to 1px
|
||||
if layer_image.ndim == 1:
|
||||
break
|
||||
|
||||
prev_rows = rows
|
||||
prev_cols = cols
|
||||
rows = layer_image.shape[0]
|
||||
@@ -294,7 +283,4 @@ def build_laplacian_pyramid(image, max_layer=-1, factor=2, sigma=None, order=1,
|
||||
|
||||
pyramid.append(layer_image)
|
||||
|
||||
if layer == max_layer:
|
||||
break
|
||||
|
||||
return pyramid
|
||||
|
||||
Reference in New Issue
Block a user