0

I use np.save to save numpy array , I want to save this numpy array as an image without frame. I tried to do this using plt.savefig but it did't work.I am trying for more than 2 weeks to find how I can do it.

Any help would be appreciated.

def saveSignalsOnDisk(signalsBlock, nSpectogram):
    global SecondPartPathOutput
    global FirstPartPathOutput
    global legendOfOutput
    global isPreictal

    if not os.path.exists(FirstPartPathOutput):
        os.makedirs(FirstPartPathOutput)
    if not os.path.exists(FirstPartPathOutput+SecondPartPathOutput):
        os.makedirs(FirstPartPathOutput+SecondPartPathOutput) 
    print('HERE\n')
    print(FirstPartPathOutput+SecondPartPathOutput+'/spec_'+isPreictal+'_'+str(nSpectogram-signalsBlock.shape[0])+'_'+str(nSpectogram-1))
    print('HERE\n')
    np.save(FirstPartPathOutput+SecondPartPathOutput+'/spec_'+isPreictal+'_'+str(nSpectogram-signalsBlock.shape[0])+'_'+str(nSpectogram-1), signalsBlock)
    legendOfOutput=legendOfOutput+str(nSpectogram-signalsBlock.shape[0])+' '+str(nSpectogram-1) +' '+SecondPartPathOutput+'/spec_'+isPreictal+'_'+str(nSpectogram-signalsBlock.shape[0])+'_'+str(nSpectogram-1) +'.npy\n'
Edayildiz
  • 505
  • 1
  • 9
  • Does this answer your question? [Saving a Numpy array as an image](https://stackoverflow.com/questions/902761/saving-a-numpy-array-as-an-image) – JohanC Aug 31 '20 at 21:32
  • See also [Converting a NumPy array to a PIL image](https://stackoverflow.com/questions/10965417/how-to-convert-a-numpy-array-to-pil-image-applying-matplotlib-colormap) – JohanC Aug 31 '20 at 21:35
  • @JohanC I want to save each image on this way `FirstPartPathOutput+SecondPartPathOutput+'/spec_'+isPreictal+'_'+str(nSpectogram-signalsBlock.shape[0])+'_'+str(nSpectogram-1)`. Each method gave me error I don't how to save images on this way – Edayildiz Aug 31 '20 at 21:46

0 Answers0