Fix singleton dimension for 1 pixel image

This commit is contained in:
Johannes Schönberger
2012-09-07 18:26:57 +02:00
parent c42b3d656d
commit b7e965eec0
2 changed files with 6 additions and 18 deletions
+4 -2
View File
@@ -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()
+2 -16
View File
@@ -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