Set Image Direction from numpy array

It is worth noting that ITK 5.0 already includes a much cleaner approach here that avoids interacting with vnl_matrix:

new_direction = np.eye(2)
image.SetDirection(itk.matrix_from_array(new_direction))
2 Likes

@matt.mccormick — this is very nice indeed. I’m wondering, where can I have a look at the rest of Python API (list of what’s what) for my general education on the matter of Python ITK for functionality discovery?

I’m aware there’s always python online help such as dir(itk) and itk.*matrix*? and friends, along with https://docs.itk.org/en/latest/learn/python_quick_start.html, but I can’t seem to be able an equivalent to https://itk.org/Doxygen/html/index.html, which facilitates functionality discovery very much.

@constantine yes, the quick start is helpful, and the embedded docs, accessed with the Python built-ins, dir() or help() are informative, albeit verbose. One motivation for ITK-Wasm is that it enables Pythonic interfaces along with Markdown/Sphinx documentation, linkable via InterSphinx – example.

1 Like

Yes! I see ITK-Wasm (Python) API reference — it’s great.

Is there ITK Python API reference like that?

Not yet – it would come with ITK 6.

ITK 6 — this is exciting!

1 Like