I was wondering if anyone has used PIL with the multiprocessing module. I would like to do some pixel by pixel translations using the .load() function and shared memory with the multiprocessing module.
This is the code I have so far: def convert_to_gs_load(surf): width, height = surf.size pix = surf.load() for x in range(width): for y in range(height): alpha = 1 red, green, blue = pix[x, y] average = (red + green + blue) // 3 gs_color = (average, average, average, alpha) pix[x, y] = gs_color def convert_to_gs_load_mp(surf): width, height = surf.size pix = surf.load() t1 = multiprocessing.Process(target=gs_load, args=(pix, width, 0, height / 4)) t2 = multiprocessing.Process(target=gs_load, args=(pix, width, height / 4, height / 2)) t3 = multiprocessing.Process(target=gs_load, args=(pix, width, height / 2, 3 * height / 4)) t4 = multiprocessing.Process(target=gs_load, args=(pix, width, 3 * height / 4, height)) threads = [t1, t2, t3, t4] for thread in threads: thread.start() for thread in threads: thread.join() The problem is the 'pix' object is not in shared memory, so this doesn't work. Is there a way I could use Value or Array to store the object?
_______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig