Reputation: 51
Using GeFolki for the coregistration of different satellite datasets I receive the following ValueError trying to manipulate the data.
Could you explain what am I doing wrong? Please Help me
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
Upvotes: 0
Views: 3290
Reputation: 12397
Apparently one of nx-nsx-1
,ny-nsy-1
is negative, but you cannot create an array of 0s with negative number of rows/columns. I suggest printing out those values and see where they get negative to fix it.
Upvotes: 2