Commit f0faf9e1ec1b4a281f662cac9be8ed89bce6e624
1 parent
cc3c0dc3
Exists in
ff_mask
Adapted invesalius cython extensions to use fused types
Showing
2 changed files
with
11 additions
and
4 deletions
Show diff stats
invesalius/data/cy_my_types.pxd
@@ -2,4 +2,11 @@ import numpy as np | @@ -2,4 +2,11 @@ import numpy as np | ||
2 | cimport numpy as np | 2 | cimport numpy as np |
3 | cimport cython | 3 | cimport cython |
4 | 4 | ||
5 | -ctypedef np.int16_t image_t | 5 | +# ctypedef np.uint16_t image_t |
6 | + | ||
7 | +ctypedef fused image_t: | ||
8 | + np.float64_t | ||
9 | + np.int16_t | ||
10 | + np.uint8_t | ||
11 | + | ||
12 | +ctypedef np.uint8_t mask_t |
invesalius/data/transforms.pyx
@@ -12,7 +12,7 @@ from cython.parallel import prange | @@ -12,7 +12,7 @@ from cython.parallel import prange | ||
12 | @cython.boundscheck(False) # turn of bounds-checking for entire function | 12 | @cython.boundscheck(False) # turn of bounds-checking for entire function |
13 | @cython.cdivision(True) | 13 | @cython.cdivision(True) |
14 | @cython.wraparound(False) | 14 | @cython.wraparound(False) |
15 | -cdef inline void mul_mat4_vec4(np.float64_t[:, :] M, | 15 | +cdef inline void mul_mat4_vec4(double[:, :] M, |
16 | double* coord, | 16 | double* coord, |
17 | double* out) nogil: | 17 | double* out) nogil: |
18 | 18 | ||
@@ -25,7 +25,7 @@ cdef inline void mul_mat4_vec4(np.float64_t[:, :] M, | @@ -25,7 +25,7 @@ cdef inline void mul_mat4_vec4(np.float64_t[:, :] M, | ||
25 | @cython.boundscheck(False) # turn of bounds-checking for entire function | 25 | @cython.boundscheck(False) # turn of bounds-checking for entire function |
26 | @cython.cdivision(True) | 26 | @cython.cdivision(True) |
27 | @cython.wraparound(False) | 27 | @cython.wraparound(False) |
28 | -cdef image_t coord_transform(image_t[:, :, :] volume, np.float64_t[:, :] M, int x, int y, int z, double sx, double sy, double sz, short minterpol, image_t cval) nogil: | 28 | +cdef image_t coord_transform(image_t[:, :, :] volume, double[:, :] M, int x, int y, int z, double sx, double sy, double sz, short minterpol, image_t cval) nogil: |
29 | 29 | ||
30 | cdef double coord[4] | 30 | cdef double coord[4] |
31 | coord[0] = z*sz | 31 | coord[0] = z*sz |
@@ -71,7 +71,7 @@ cdef image_t coord_transform(image_t[:, :, :] volume, np.float64_t[:, :] M, int | @@ -71,7 +71,7 @@ cdef image_t coord_transform(image_t[:, :, :] volume, np.float64_t[:, :] M, int | ||
71 | @cython.wraparound(False) | 71 | @cython.wraparound(False) |
72 | def apply_view_matrix_transform(image_t[:, :, :] volume, | 72 | def apply_view_matrix_transform(image_t[:, :, :] volume, |
73 | spacing, | 73 | spacing, |
74 | - np.float64_t[:, :] M, | 74 | + double[:, :] M, |
75 | unsigned int n, str orientation, | 75 | unsigned int n, str orientation, |
76 | int minterpol, | 76 | int minterpol, |
77 | image_t cval, | 77 | image_t cval, |