Numpy:不允许使用负尺寸
Numpy: negative dimensions are not allowed
使用 GeFolki 对不同的卫星数据集进行配准时,我在尝试操作数据时收到以下 ValueError。
你能解释一下我做错了什么吗?请帮助我
from skimage.transform import resize
nx = int(round(dimx/fdecimation))
ny = int(round(dimy/fdecimation))
Mg = resize(Master,(nx, ny),1,'constant')
nsx = int(round(dimxn/fdecimation))
nsy = int(round(dimyn/fdecimation))
Sg = resize(Slave,(nsx, nsy),1,'constant')
# Rank computation and Criterion on images after deximation
from rank import rank_sup as rank_filter_sup
from rank import rank_inf as rank_filter_inf
Mg_rank = rank_filter_inf(Mg, rank) # rank sup : high value pixels have low rank
Sg_rank = rank_filter_inf(Sg, rank)
R=np.zeros((nx-nsx-1,ny-nsy-1));
indices=np.nonzero(Sg_rank);
test2=Sg_rank[indices];
for k in range(0,nx-nsx-1):
for p in range(0,ny-nsy-1):
test1=Mg_rank[k:k+nsx,p:p+nsy];
test1=test1[indices];
test=(test1-test2)**2
R[k,p]=test.mean();
ValueError Traceback (most recent call last)
<ipython-input-24-bebe7595123d> in <module>
17 Sg_rank = rank_filter_inf(Sg, rank)
18
---> 19 R=np.zeros((nx-nsx-1,ny-nsy-1));
20 indices=np.nonzero(Sg_rank);
21 test2=Sg_rank[indices];
ValueError: negative dimensions are not allowed
显然 nx-nsx-1
、ny-nsy-1
之一是负数,但您不能创建负数 rows/columns 的 0 数组。我建议打印出这些值并查看它们在哪里变为负值以修复它。
使用 GeFolki 对不同的卫星数据集进行配准时,我在尝试操作数据时收到以下 ValueError。
你能解释一下我做错了什么吗?请帮助我
from skimage.transform import resize
nx = int(round(dimx/fdecimation))
ny = int(round(dimy/fdecimation))
Mg = resize(Master,(nx, ny),1,'constant')
nsx = int(round(dimxn/fdecimation))
nsy = int(round(dimyn/fdecimation))
Sg = resize(Slave,(nsx, nsy),1,'constant')
# Rank computation and Criterion on images after deximation
from rank import rank_sup as rank_filter_sup
from rank import rank_inf as rank_filter_inf
Mg_rank = rank_filter_inf(Mg, rank) # rank sup : high value pixels have low rank
Sg_rank = rank_filter_inf(Sg, rank)
R=np.zeros((nx-nsx-1,ny-nsy-1));
indices=np.nonzero(Sg_rank);
test2=Sg_rank[indices];
for k in range(0,nx-nsx-1):
for p in range(0,ny-nsy-1):
test1=Mg_rank[k:k+nsx,p:p+nsy];
test1=test1[indices];
test=(test1-test2)**2
R[k,p]=test.mean();
ValueError Traceback (most recent call last)
<ipython-input-24-bebe7595123d> in <module>
17 Sg_rank = rank_filter_inf(Sg, rank)
18
---> 19 R=np.zeros((nx-nsx-1,ny-nsy-1));
20 indices=np.nonzero(Sg_rank);
21 test2=Sg_rank[indices];
ValueError: negative dimensions are not allowed
显然 nx-nsx-1
、ny-nsy-1
之一是负数,但您不能创建负数 rows/columns 的 0 数组。我建议打印出这些值并查看它们在哪里变为负值以修复它。