I'm trying to open image in .b file, take a subpart and write in a new file in an other folder (the same were is my python script)
here is my code :
import numpy as np
for i in range(11):
# open and read :
filename='data/img_t'+str(i+700)+'.b'
data=np.fromfile(filename, dtype=np.float64, sep="")
data=data.reshape([9636,9636])
# take a part :
r = 2200
c = 2200
lenr = data.shape[0]/r
lenc = data.shape[1]/c
data1=np.array([data[i*r:(i+1)*r,j*c:(j+1)*c] for (i,j) in np.ndindex(lenr,lenc)]).reshape(lenr,lenc,r,c)
# write in new file :
outfn='img_part_'+str(i+700)+'.b'
out_file = open(outfn, "wb")
out_file.write(data1[1,1])
out_file.close()
My problem is that it only create img_part_703.b which is very strange...
I also try :
data1[1,1].tofile(outfn, sep="", format="%s")
but same problem....