[PYTHON MATRIX-SIG] NumPy and PIL extension module
viennet@ura1507.univ-paris13.fr
viennet@ura1507.univ-paris13.fr
Tue, 6 May 1997 08:50:41 +0100 (WET DST)
Zachary Roadhouse writes:
> Okay, taking a crack at it. Does this do what I want it too (copy the
> data from the image which is char** to the array which is int*)?
>
> array = PyArray_FromDims(2,dims,PyArray_INT);
>
> i_ptr = (int*)array->data;
>
> for (yy = 0; yy < array->dimensions[0]; ++yy) {
> for(xx = 0; xx < array->dimensions[1]; ++xx)
> ptr[xx] = im->image8[yy][xx];
> ptr += array->dimensions[1];
> }
>
> return PyArray_Return(array);
At first glance, this seems ok.
But why don't you use UCHAR typecode ? NumPy will later automagically
convert an UCHAR array to INT if necessary.
Emmanuel
--
Emmanuel Viennet: <viennet@ura1507.univ-paris13.fr>
LIPN - Institut Galilee - Universite Paris-Nord
93430 Villetaneuse - France
_______________
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
_______________