I'm trying to make a Python program with NumPy, but I ran into a problem:
width, height, pngData, metaData = png.Reader(file).asDirect()
planeCount = metaData['planes']
print('Bildgroesse: ' + str(width) + 'x' + str(height) + ' Pixel')
image_2d = np.vstack(list(map(np.uint8, pngData)))
imageOriginal_3d = np.reshape(image_2d, (width, height, planeCount))
imageEdited_3d = imageOriginal_3d
This is my code, to read in a PNG image. Now I want to edit imageEdited_3d
but NOT imageOriginal_3d
, like this:
imageEdited_3d[x,y,0] = 255
But then the imareOriginal_3d
variable has the same values as the imageEdited_3d
one...
Does anyone know, how I can fix this? So it doesn't only creates a reference, but it creates a real copy? :/
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…