프랙탈 이미지를 만들기 위해 하나의 파이썬 스크립트를 만듭니다.병렬 파이썬으로 프랙탈 및 리소스를 pp 아래에 직렬화합니다.
나는이 소스 코드를 더 빠르게 만들기 위해 파이썬 모듈을 사용하려고한다.
큰 문제는 : image.putpixel ((x, y), (i % 8 * 16, i % 4 * 32, i % 2 * 64))입니다. 이 줄의 소스 코드는 job과 같은 용도로 사용됩니다. cPickle.UnpickleableError : 피클 할 수 없습니다..
이 리소스는 pp에서 직렬화 할 수 없다고 생각합니다. 어떤 생각입니까? 고맙습니다. 문안 인사.
내 소스 코드 :
from PIL import Image
#size of image
imgx = 600
imgy = 400
#make image buffer
image = Image.new("RGB", (imgx, imgy))
# area of fractal
xa = -2.0
xb = 2.0
ya = -2.0
yb = 2.0
#define constants
max_iterations = 10 # max iterations allowed
step_derivat = 0.002e-1 # step size for numerical derivative
error = 5e-19 # max error allowed
# function will generate the newton fractal
def f(z): return z * z +complex(-0.31,0.031)
# draw derivate fractal for each y and x
for y in range(imgy):
zy = y * (yb - ya)/(imgy - 1) + ya
for x in range(imgx):
zx = x * (xb - xa)/(imgx - 1) + xa
z = complex(zx, zy)
for i in range(max_iterations):
# make complex numerical derivative
dz = (f(z + complex(step_derivat, step_derivat)) - f(z))/complex(step_derivat,step_derivat)
# Newton iteration see wikipedia
z0 = z - f(z)/dz
# stop to the error
if abs(z0 - z) < error:
break
z = z0
#I use modulo operation expression to do RGB colors of the pixels
image.putpixel((x, y), (i % 8 * 16, i % 4 * 32,i % 2 * 64))
#save the result
image.save("fractal.png", "PNG")
나는 그렇게하려고합니다. Seam이 나를 복잡하게 만든다. 왜? 나는 그 목록을 돌려 줄 수 있기 때문에. Seam pp 및 호출 함수 over : job = job_server.submit은 전역 정의에 몇 가지 문제가 있습니다. 내가 그렇게하려고하는 방법 : 나는 2 기능을 만든다. 하나는 : def newton_fractal (z) : return z * z + complex (-0.31,0.031). 내가 만든 다음 함수는 : –
큰 문제는 image.putpixel ((x, y), (i ... ob = job_server.submit (make_fractal,이 함수를 작성하는 방법을 모르겠다. 왜냐하면 pp에 관한 하나의 좋은 튜토리얼은 몇 가지 제한이 있기 때문에 일반적인 파이썬 코드를 pp 방식으로 변환하는 방법입니다. pp 모듈을 사용하는 코드는 엉망입니다. –