当我移动并旋转它时,我使用的是布尔型蒙版,所以我在蒙版中释放了No.of True值,而没有。我希望所有我的True值都相等,即使在移动和旋转布尔蒙版之后也是如此。我该如何解决这个问题?
import numpy as np
import scipy
from scipy import ndimage
import skimage
from skimage import draw
mask = skimage.draw.ellipsoid(12,14,25)
# padding the boolean array
mask2 = np.pad(mask, pad_width = 50 , mode = 'constant')
# shifting the mask
shift1 = scipy.ndimage.shift(mask2, np.array([0,0,-25]))
# Rotating the shifted mask
angle1 = 30
mask3 = scipy.ndimage.interpolation.rotate(shift1,angle1 , axes (0,2), reshape = False)
# Rotating the roated mask3 along different axis
angle2 = 45
mask4 = scipy.ndimage.interpolation.rotate(mask3, angle2 , axes = (0,1), reshape = False)
# Shapes of same mask after different operations
print np.argwhere(mask == True).shape
print np.argwhere(mask2 == True).shape
print np.argwhere(shift1 == True).shape
print np.argwhere(mask3 == True).shape
print np.argwhere(mask4 == True).shape
因此,掩码是具有所有True值的数组中心的椭圆体。该椭圆体之外的值均为False。 第一步,我用False值填充数组并使其更大。这对True值没有影响,我得到的不是。和mask中的mask2中的True值相同。第二步是转移mask2,这是我的True值开始消失的原因?如何解决?在接下来的两个步骤中,旋转移位后的蒙版会降低True值。基本上到最后我都失去了面具。有什么办法可以解决?