ich habe folgendes Problem mit den Bildfunktionen von scipy:
Code: Alles auswählen
import numpy
import scipy
# Path and name of the image
path = 'lena512.png'
# Height and width of the image
height = 512
width = 512
# Read image
input_image = scipy.misc.imread(path)
# Write image into 2D-array
image = numpy.empty( (height,width) )
for i in range(height):
for j in range(width):
image[i][j] = input_image[i][j][0]
scipy.misc.imsave('imsave.png', image)
print image
Die Ausgabe der Pixelwerte in der letzten Zeile ist aber auf jeden Fall korrekt (überprüft), es liegt also an der Funktion scipy.misc.imsave.
Da es sich bei dem Bild um ein Bild in Graustufen handelt, wird es für eine spätere Verarbeitung erstmal in ein 2D-Array umgeschrieben. Für out.png macht es dann auch keinen Unterschied, ob man das 2D-Array image übergibt oder ob man wieder in ein 3D-Array mit drei Farbkanälen umschreibt, das Bild ist verfälscht.
Habt ihr eine Idee?
Grüße, Max