2017-11-02 1 views
0

Ich möchte einen schwarzen Rahmen um ein Bild erstellen. Leider habe ich folgenden Fehler.Erstellen Sie einen schwarzen Rahmen um ein Bild

ValueError: could not broadcast input array from shape (512,512) into shape (562,562) 

Hier ist mein Code:

import numpy as np 
import matplotlib.pyplot as plt 
import scipy as sc 
import scipy.misc 

im = sc.misc.ascent() 

blackFrame= np.zeros((im.shape[0]+100,im.shape[1]+100)) 
blackFrame[50:,50:] = im[:,:] 
plt.imshow(blackFrame, cmap="gray", vmin=0, vmax=250) 
plt.show() 

Es funktioniert, wenn ich blackFrame[100:,100:] = im[:,:] schreiben, aber es ist nicht das, was ich will.

Antwort

2

Dies könnte helfen: blackFrame[50:50+im.shape[0],50:50+im.shape[1]] = im[:,:]

Verwandte Themen