[Numpy-discussion] array is not writable

Mark Wendell mark.wendell@gmail....
Wed Aug 26 22:49:11 CDT 2009


Figured this much out: if I do an np.copy of the original array to a
new array, then I can edit individual 'color' values with impunity. So
I guess the original array from the pil object still shares memory
with that image object somehow, making it unwritable?

thanks
Mark

On Wed, Aug 26, 2009 at 7:48 PM, Mark Wendell <mark.wendell@gmail.com> wrote:
>
> Hi all - I'm playing with editing image data converted from PIL objects, and running into a situation where numpy tells me that an 'array is not writable'. Not sure I understand what that means, or how to get around it. Here's a sample interactive session:
>
> >>> import Image
> >>> import numpy as np
> >>> im = Image.open("rgb.0001.jpg")
> >>> a = np.asarray(im)
> >>> a.shape
> (512, 512, 3)
> >>> a.dtype
> dtype('uint8')
> >>> a[0,0,0]
> 254
> >>> a[0,0,0] = 10
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> RuntimeError: array is not writeable
>
>
> Any help appreciated. Thanks,
> Mark
>
> PIL 1.1.6
> numpy 1.2.1
> Ubuntu 9.04
>
> --
> --
> Mark Wendell



--
--
Mark Wendell


More information about the NumPy-Discussion mailing list