Image Spacing Value Interactions in ITK Python Wrapping

Dear, esteemed… Here’s an easy question for your consideration. Say, I’m having this sort of interaction with ITK in Python console:

oif = itk.SpatialObjectToImageFilter[itk.SpatialObject[2], itk.Image[itk.UC, 2]].New()
s = oif.GetSpacing()
print(s)
<Swig Object of type 'double *' at 0x0000025E090D45D0>

The spacing value returned by the filter seems utterly opaque. dir(s) or help(s) don’t get me much further either.

What is the way to examine the values for individual spacing dimensions in this case, please?

@Stephen_Aylward might have something to say.

Sounds promising. :slight_smile:

SpatialObjects are using an old ITK interface style (e.g., returning const double *) that currently does not wrap well into python.

I’ve been going thru and updating the API to better support wrapping. I’ve added this to the list. I’m burried in a MetaIO issue right now, but I’ll get to this within a few weeks…or you could do it…

Would be great if you could create a new GetSpacing() function that returns a itk::Image::SpacingType variable (a vector). Since we’ll have a name collision with the old/existing function, the new function should probably be named GetSpacingVector(). Same update is needed for GetOrigin() → GetOriginVector() and perhaps others in that class.

Would be great if we could simply fix the interface and not worry about backward compatibility…but that’s a great way to make enemies… :slight_smile:

1 Like

@Stephen_Aylward — thank you for the informative response. Yes, I suspected this was the case — those are to be Python-Wrapped yet.

I do like the idea of going ahead and wrapping those, and I’ll put this on my ToDo list. I did contribute a bit in the past, and would love to do this again in the near future.

First need to get some other (older) monkeys off my back though. :monkey:

@Stephen_Aylward — is there an official page somewhere on getting started with Python wrapping apart from this: ITK/Python Wrapping - KitwarePublic?

Have you seen this?

No, I haven’t. And yes, this is what I had in mind. Thank you!

1 Like

Hi,

Sorry for the delay. I’ve finally made a pull request to address this:

2 Likes