Hi guys, I load a palette image (I've attach it), with 1000 colors, and I want to quantize and dithering it.
The error is in palette.putpalette(pal) Another, question, is this the best way of Quantize an image mapping it to that palette and dithering ? Thanks a lot! Andres Moreira. ==== CODE ==== import Image def extract_colour(image, colour_map): palette_im = Image.open(colour_map) palette_count = len(palette_im.getdata()) pal = reduce(lambda a,b:a+b, [(x[1][0],x[1][1],x[1][2]) for x in palette_im.getcolors(maxcolors=palette_count)]) # create palette palette = Image.new("P", (1,1)) palette.putpalette(pal) im = Image.open(image).convert("RGB").quantize(palette=palette) im2 = im.convert("RGBA", dither=Image.FLOYDSTEINBERG) return im2.getcolors() ========== Trace back ========== *** glibc detected *** /usr/bin/python: malloc(): memory corruption: 0x0000000002a5b950 *** ======= Backtrace: ========= /lib/libc.so.6[0x7fc416162fef] /lib/libc.so.6(__libc_malloc+0x98)[0x7fc416164828] /usr/bin/python(PyArena_New+0x26)[0x4c1be6] /usr/bin/python(PyRun_StringFlags+0x3e)[0x4c52fe] /usr/bin/python[0x49bfe5] /usr/bin/python(PyEval_EvalFrameEx+0x4e23)[0x4a2b03] /usr/bin/python(PyEval_EvalFrameEx+0x60ce)[0x4a3dae] /usr/bin/python(PyEval_EvalCodeEx+0x869)[0x4a4649] /usr/bin/python[0x5329ad] /usr/bin/python(PyObject_Call+0x5d)[0x41d3bd] /usr/bin/python[0x424f48] /usr/bin/python(PyObject_Call+0x5d)[0x41d3bd] /usr/bin/python(PyEval_CallObjectWithKeywords+0x56)[0x49cd46] /usr/bin/python[0x42b51a] /usr/bin/python(_PyObject_Str+0x6f)[0x45179f] /usr/bin/python(PyObject_Str+0x13)[0x451853] /usr/bin/python[0x45d9da] /usr/bin/python[0x46bc03] /usr/bin/python(PyObject_Call+0x5d)[0x41d3bd] /usr/bin/python(PyEval_EvalFrameEx+0x232f)[0x4a000f] /usr/bin/python(PyEval_EvalFrameEx+0x60ce)[0x4a3dae] /usr/bin/python(PyEval_EvalCodeEx+0x869)[0x4a4649] /usr/bin/python[0x5329ad] /usr/bin/python(PyObject_Call+0x5d)[0x41d3bd] /usr/bin/python[0x424f48] /usr/bin/python(PyObject_Call+0x5d)[0x41d3bd] /usr/bin/python(PyEval_CallObjectWithKeywords+0x56)[0x49cd46] /usr/bin/python[0x474efe] /usr/bin/python(_PyObject_Str+0x6f)[0x45179f] /usr/bin/python(PyObject_Str+0x13)[0x451853] /usr/bin/python[0x45d9da] /usr/bin/python[0x46bc03] /usr/bin/python(PyObject_Call+0x5d)[0x41d3bd] /usr/bin/python(PyEval_EvalFrameEx+0x232f)[0x4a000f] /usr/bin/python(PyEval_EvalCodeEx+0x869)[0x4a4649] /usr/bin/python[0x532ab4] /usr/bin/python(PyObject_Call+0x5d)[0x41d3bd] /usr/bin/python(PyEval_EvalFrameEx+0x3780)[0x4a1460] /usr/bin/python(PyEval_EvalCodeEx+0x869)[0x4a4649] /usr/bin/python[0x5329ad] /usr/bin/python(PyObject_Call+0x5d)[0x41d3bd] /usr/bin/python[0x424f48] /usr/bin/python(PyObject_Call+0x5d)[0x41d3bd] /usr/bin/python[0x425be2] /usr/bin/python(PyObject_Call+0x5d)[0x41d3bd] /usr/bin/python(PyEval_EvalFrameEx+0x232f)[0x4a000f] /usr/bin/python(PyEval_EvalCodeEx+0x869)[0x4a4649] /usr/bin/python(PyEval_EvalFrameEx+0x4fd0)[0x4a2cb0] /usr/bin/python(PyEval_EvalCodeEx+0x869)[0x4a4649] /usr/bin/python(PyEval_EvalFrameEx+0x4fd0)[0x4a2cb0] /usr/bin/python(PyEval_EvalCodeEx+0x869)[0x4a4649] /usr/bin/python(PyEval_EvalFrameEx+0x4fd0)[0x4a2cb0] /usr/bin/python(PyEval_EvalCodeEx+0x869)[0x4a4649] /usr/bin/python(PyEval_EvalCode+0x32)[0x4a4762] /usr/bin/python(PyRun_FileExFlags+0x13c)[0x4c4c3c] /usr/bin/python(PyRun_SimpleFileExFlags+0x1fb)[0x4c4f6b] /usr/bin/python(Py_Main+0xb9e)[0x4189ce] /lib/libc.so.6(__libc_start_main+0xe6)[0x7fc4161065a6] /usr/bin/python[0x417ae9] ======= Memory map: ======== 00400000-00616000 r-xp 00000000 08:02 1353694 /usr/bin/python2.6 00815000-00816000 r--p 00215000 08:02 1353694 /usr/bin/python2.6 00816000-00876000 rw-p 00216000 08:02 1353694 /usr/bin/python2.6 00876000-00885000 rw-p 00876000 00:00 0 02466000-02cd3000 rw-p 02466000 00:00 0 [heap] 3c63400000-3c63422000 r-xp 00000000 08:02 1355378 /usr/lib/libjpeg.so.62.0.0 3c63422000-3c63622000 ---p 00022000 08:02 1355378 /usr/lib/libjpeg.so.62.0.0 3c63622000-3c63623000 rw-p 00022000 08:02 1355378 /usr/lib/libjpeg.so.62.0.0 7fc40c000000-7fc40c021000 rw-p 7fc40c000000 00:00 0 7fc40c021000-7fc410000000 ---p 7fc40c021000 00:00 0 7fc413ccf000-7fc413ce5000 r-xp 00000000 08:02 63477 /lib/libgcc_s.so.1 7fc413ce5000-7fc413ee5000 ---p 00016000 08:02 63477 /lib/libgcc_s.so.1 7fc413ee5000-7fc413ee6000 r--p 00016000 08:02 63477 /lib/libgcc_s.so.1 7fc413ee6000-7fc413ee7000 rw-p 00017000 08:02 63477 /lib/libgcc_s.so.1 7fc413ee7000-7fc413f21000 r-xp 00000000 08:02 127451 /usr/lib/python2.6/dist-packages/PIL/_imaging.so 7fc413f21000-7fc414120000 ---p 0003a000 08:02 127451 /usr/lib/python2.6/dist-packages/PIL/_imaging.sAborted
<<attachment: map1000.png>>
_______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig