Proposal: Aliases of `itk.D`, `itk.US`, `itk.SLL`, ... for specific sizes of numeric types

The ITK Python package allows specifying the pixel type of an image by passing an itkCType object, for example itk.D for the C type double, itk.US for unsigned short and itk.SLL for signed long long. As in itk.Image[itk.D, 2], itk.Image[itk.US, 2], itk.Image[itk.SLL, 2]. While this notation is very concise, I believe it would be handy for ITK users to allow directly specifying the number of bits of the C type, just like in C and C++ with int8_t, int16_t, int32_t, etc. (See Fixed width integer types (since C++11) - cppreference.com and Fixed width floating-point types (since C++23) - cppreference.com).

Pull request ENH: Add ctype aliases for numeric types of specific sizes to Python by N-Dekker · Pull Request #6762 · InsightSoftwareConsortium/ITK · GitHub proposes this feature, simply by adding the following aliases to ITK Python:

float32_t = F
float64_t = D
uint8_t = UC
uint16_t = US
uint32_t = UI
uint64_t = UL if UL.dtype.itemsize == 8 else ULL
int8_t = SC
int16_t = SS
int32_t = SI
int64_t = SL if SL.dtype.itemsize == 8 else SLL

To be used, for example, in itk.Image[itk.float64_t, 2], itk.Image[itk.uint16, 2], or itk.Image[itk.int64_t, 2].

Please approve this pull request if you like it!

1 Like

Thanks for approving and merging ENH: Add ctype aliases for numeric types of specific sizes to Python by N-Dekker · Pull Request #6762 · InsightSoftwareConsortium/ITK · GitHub !

Here is a proposed use case of itk.int64_t and itk.uint64_t:

1 Like