[SciPy-User] how use the tutorial "Extending ndimage in C"
moscardi
eric.moscardi at sophia.inria.fr
Fri Oct 22 12:39:18 EDT 2010
Of course,
The simple shift function, referenced on the scipy.ndimage page (http://docs.scipy.org/doc/scipy/reference/tutorial/ndimage.html#ndimage-ccallbacks), doesn't compile.
static int
_shift_function(int *output_coordinates, double* input_coordinates,
int output_rank, int input_rank, void *callback_data)
{
int ii;
/* get the shift from the callback data pointer: */
double shift = *(double*)callback_data;
/* calculate the coordinates: */
for(ii = 0; ii < irank; ii++)
icoor[ii] = ocoor[ii] - shift;
/* return OK status: */
return 1;
}
because the arguments are not correctly named (irank -> input_rank, icoor ->input_coordinates, ocoor -> output_coordinates).
I rename them, I compile and I try to run the python code used as example :
>>> import example
>>> array = arange(12, shape=(4,3), type = Float64)
>>> fnc = example.shift_function(0.5)
>>> print geometric_transform(array, fnc)
I add :
>>> from numpy import array
but the following syntax is not correct :
array = arange(12, shape=(4,3), type = Float64)
So I run :
>>> from numpy import array
>>> import example
>>> from scipy.ndimage import geometric_transform
>>> array = np.arange(12, dtype = np.float64).reshape(4,3)
>>> fnc = example.shift_function(0.5)
>>> print geometric_transform(array, fnc)
And the result is not :
[[ 0. 0. 0. ]
[ 0. 1.3625 2.7375]
[ 0. 4.8125 6.1875]
[ 0. 8.2625 9.6375]]
but I have as result :
[[ 0. 0. 0.]
[ 0. 0. 0.]
[ 0. 0. 0.]
[ 0. 0. 0.]]
Any ideas ?
Thanks,
Eric
On Oct 22, 2010, at 6:19 PM, Robert Kern wrote:
> On Fri, Oct 22, 2010 at 11:15, moscardi <eric.moscardi at sophia.inria.fr> wrote:
>> Hello,
>> i try to use the tutorial named "Extending ndimage in C" but It doesn't
>> work.
>
> Please never just say "It doesn't work." Show us exactly what you
> tried. Show us exactly what results you got (copy-and-paste any error
> messages; never paraphrase). Tell us what results you expected.
>
> --
> Robert Kern
>
> "I have come to believe that the whole world is an enigma, a harmless
> enigma that is made terrible by our own mad attempt to interpret it as
> though it had an underlying truth."
> -- Umberto Eco
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
Eric MOSCARDI
INRIA - Virtual Plants
CIRAD, Avenue Agropolis
34398 Montpellier Cedex 5, France
04 67 61 58 00 (ask number 60 09)
email : eric.moscardi at sophia.inria.fr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20101022/932b521f/attachment.html>
More information about the SciPy-User
mailing list