Skeletonization icon indicating copy to clipboard operation
Skeletonization copied to clipboard

ValueError: operands could not be broadcast together with shapes (3,3) (0,0)

Open FJGEODEV opened this issue 4 years ago • 1 comments

Hi, thanks for this good work, I was trying your method on my own image.

When calculating flux, I had this error message:


ValueError Traceback (most recent call last) in 1 #Calculate flux map ----> 2 fluxMap = flux(mir_delD_xn,mir_delD_yn) 3 plt.imshow(np.nan_to_num(fluxMap)) 4 plt.title('Flux Map') 5 plt.show()

~/CODES/Skeletonization-master/skeleton2Graph.py in flux(delD_xn, delD_yn) 199 print(pix[0],pix[1]) 200 print(delD_xn[pix[0]-1:pix[0]+2,pix[1]-1:pix[1]+2].shape) --> 201 flux_x = Nx * delD_xn[pix[0]-1:pix[0]+2,pix[1]-1:pix[1]+2] 202 flux_y = Ny * delD_yn[pix[0]-1:pix[0]+2,pix[1]-1:pix[1]+2] 203 flux_x[1,1] = np.nan

ValueError: operands could not be broadcast together with shapes (3,3) (0,0)

I print out some more information in flux function:

Nx = -1/np.sqrt(2) * np.array([[-1, 0, 1],[-np.sqrt(2), 0, np.sqrt(2)],[-1, 0, 1]]) print('NX=', Nx.shape) Ny = -1/np.sqrt(2) * np.array([[-1, -np.sqrt(2), -1],[0, 0, 0],[1, np.sqrt(2), 1]]) print('NY=', Ny.shape) flux = np.zeros(delD_xn.shape) print('flux=', flux.shape)

flux.fill(np.nan)
nonNanPix = np.argwhere(np.invert(np.isnan(delD_xn) | np.isnan(delD_yn)))
print('nonNanPix=', nonNanPix.shape)

for pix in nonNanPix: print(pix[0],pix[1]) print(delD_xn[pix[0]-1:pix[0]+2,pix[1]-1:pix[1]+2].shape) ..............................

NX= (3, 3) NY= (3, 3) flux= (1603, 1335) nonNanPix= (1456285, 2) 0 0 (0, 0)

It looks that something wrong to find out nonNanPix, but I don;t understand why, I also attached my image, could you take a look? Thanks.

Fan

flux_error

FJGEODEV avatar Mar 26 '20 04:03 FJGEODEV

Hi, just check other issues reported last year and found it is same issue, but I still can;t figure it out, here is some output:

print(delD_norm.min(),delD_norm.max()) 0.0 380.9160012391183

with np.errstate(divide='ignore',invalid='ignore'): delD_xn = delD_x / delD_norm delD_yn = delD_y / delD_norm print(delD_xn.min(),delD_xn.max()) print(delD_yn.min(),delD_yn.max())

nan nan nan nan

print(mir_delD_xn.shape) print(mir_delD_yn.shape) (1603, 1335) (1603, 1335)

Could you just try my image? The white color is 1, black is 0.

Thanks.

FJGEODEV avatar Mar 26 '20 20:03 FJGEODEV