Reputation: 555
I am generating multiple 3D numpy array of size (22,6,2840),each array containing 22 array of size(6,2840).Now I want to save this array (22,6,2840) as images. I don't know if I can do that. I tried to do this using plt.savefig
but it didn't work. I am trying for more than 2 weeks to find how I can do it.
Any help would be appreciated.
signals=np.zeros((22,6,2840))
t=0
movement=int(S*256)
if(S==0):
movement=_SIZE_WINDOW_SPECTOGRAM
while data.shape[1]-(t*movement+_SIZE_WINDOW_SPECTOGRAM) > 0:
for i in range(0, 22):
start = t*movement
stop = start+_SIZE_WINDOW_SPECTOGRAM
signals[i,:]=wavelet(data[i,start:stop])
if(signalsBlock is None):
signalsBlock=np.array([signals])
else:
signalsBlock=np.append(signalsBlock, [signals], axis=0)
nSpectogram=nSpectogram+1
if(signalsBlock.shape[0]==50):
saveSignalsOnDisk(signalsBlock, nSpectogram)
signalsBlock=None
t = t+1
Upvotes: 0
Views: 165
Reputation: 1215
try using the PyPNG
library. You will have to reshape your array to a 2-D format and then write it as a png. The link to the library is here
image_2d = numpy.reshape(image_3d, (-1, column_count * plane_count))
pngWriter.write(out, image_2d)
Also, one more method by using PIL Image
is provided here. However, that works with mostly RGB style 3 channel images.
Upvotes: 1