我正在尝试生成一些分形图像,我可以做得很好。但是,我在保存图像时遇到一些问题,因为它以灰度而不是颜色保存它们。当我用 python 打开它们时,它显示了正确的颜色。
代码如下
from PIL import Image
import ImageDraw
from scipy import misc
from array import *
import matplotlib.pyplot as plt
import scipy
image = Image.new("L",(SIZE, SIZE)) # create a image SIZE x SIZE
d = ImageDraw.Draw(image)
#iterate over x and y, setting a col value for each pixel
d.point((x, y), col ) # it then colors the point (x,y)
image.save("beta"+str(alpha)+".png", "PNG")
Run Code Online (Sandbox Code Playgroud)
我使用的是 macOS X、Python 2.7.5。