|
NorMIT-nav
22.09
An IGT application
|
Go to the documentation of this file.
46 #define METHOD_ANISOTROPIC 3
49 #define PLANE_HEURISTIC 0
50 #define PLANE_CLOSEST 1
53 #define ANISOTROPIC_SIZE 3
54 #define ANISOTROPIC_GAUSSIAN_SIZE 3
56 #define ANISOTROPIC_METHOD_INCLUDE_ALL 0
57 #define ANISOTROPIC_METHOD_BILINEAR_ON_PLANE 1
58 #define ANISOTROPIC_METHOD_GAUSSIAN_ON_PLANE 2
60 #define ANISOTROPIC_WEIGHT_METHOD_DISTANCE 0
61 #define ANISOTROPIC_WEIGHT_METHOD_BRIGHTNESS 1
62 #define ANISOTROPIC_WEIGHT_METHOD_LATENESS 2
63 #define ANISOTROPIC_WEIGHT_METHOD_BOTH 3
65 #define ANISOTROPIC_METHOD ANISOTROPIC_METHOD_BILINEAR_ON_PLANE
103 #define CHECK_PLANE_INDICES
106 #define DEBUG_PRINTF(...) if((get_global_id(0) % 5000) == 0) printf(##__VA_ARGS__)
109 #define BOUNDS_CHECK(x, min, max)
112 #define BOUNDS_CHECK(x, min, max)
117 #define EUCLID_DIST(a, b, c) sqrt((a)*(a) + (b)*(b) + (c)*(c))
119 #define PROJECTONTOPLANE(voxel, matrix, dist) (voxel - dist*(matrix.s26AE))
121 #define PROJECTONTOPLANEEQ(voxel, eq, dist) (voxel - dist*(eq))
123 #define ISINSIDE(x, size) ((x) >= 0 && (x) < (size))
124 #define ISNOTMASKED(x, y, mask, xsize) ((mask)[(x) + (y)*(xsize)] > 0)
127 #define VOXEL(v,x,y,z) v[x + y*volume_xsize + z*volume_ysize*volume_xsize]
129 #define WEIGHT_INV(x) (1.0f/fabs(x))
130 #define WEIGHT_INV2(x) (1.0f/fabs(x*x))
131 #define WEIGHT_INV4(x) (1.0f/fabs(x*x*x*x))
132 #define WEIGHT_SUB(x) (1.0f - fabs(x))
134 #define WEIGHT_TERNARY(val, mean, factor) \
135 ((val) >= (mean) ? (factor) : 0.0f)
137 #define ANISOTROPIC_GAUSS_WEIGHT(px, var, mean, mean_id, sigma) WEIGHT_GAUSS(px.dist, sigma)
139 #ifndef ANISOTROPIC_WEIGHT_METHOD
140 #define ANISOTROPIC_WEIGHT_METHOD ANISOTROPIC_WEIGHT_METHOD_BOTH
143 #ifndef BRIGHTNESS_FACTOR
144 #define BRIGHTNESS_FACTOR 5.0f
147 #ifndef NEWNESS_FACTOR
148 #define NEWNESS_FACTOR 5.0f
151 #define ANISOTROPIC_WEIGHT_BRIGHTNESS(px, var, mean, mean_id, sigma) \
152 ((WEIGHT_GAUSS(px.dist, sigma)) + (WEIGHT_TERNARY(px.intensity, mean, BRIGHTNESS_FACTOR)))
154 #define ANISOTROPIC_WEIGHT_LATENESS(px, var, mean, mean_id, sigma) \
155 ((WEIGHT_GAUSS(px.dist, sigma)) + (WEIGHT_TERNARY(px.plane_id, mean_id, NEWNESS_FACTOR)))
157 #define ANISOTROPIC_WEIGHT_BOTH(px, var, mean, mean_id, sigma) \
158 ((WEIGHT_GAUSS(px.dist, sigma)) \
159 + (WEIGHT_TERNARY(px.plane_id, mean_id, NEWNESS_FACTOR)) \
160 + (WEIGHT_TERNARY(px.intensity, mean, BRIGHTNESS_FACTOR)))
162 #if ANISOTROPIC_WEIGHT_METHOD == ANISOTROPIC_WEIGHT_METHOD_DISTANCE
163 #define ANISOTROPIC_WEIGHT(px, var, mean, mean_id, sigma) ANISOTROPIC_GAUSS_WEIGHT(px, var, mean, mean_id, sigma)
164 #elif ANISOTROPIC_WEIGHT_METHOD == ANISOTROPIC_WEIGHT_METHOD_BRIGHTNESS
165 #define ANISOTROPIC_WEIGHT(px, var, mean, mean_id, sigma) ANISOTROPIC_WEIGHT_BRIGHTNESS(px, var, mean, mean_id, sigma)
166 #elif ANISOTROPIC_WEIGHT_METHOD == ANISOTROPIC_WEIGHT_METHOD_LATENESS
167 #define ANISOTROPIC_WEIGHT(px, var, mean, mean_id, sigma) ANISOTROPIC_WEIGHT_LATENESS(px, var, mean, mean_id, sigma)
168 #elif ANISOTROPIC_WEIGHT_METHOD == ANISOTROPIC_WEIGHT_METHOD_BOTH
169 #define ANISOTROPIC_WEIGHT(px, var, mean, mean_id, sigma) ANISOTROPIC_WEIGHT_BOTH(px, var, mean, mean_id, sigma)
173 #define WEIGHT_GAUSS_SIGMA (0.05f)
175 #define WEIGHT_GAUSS_SQRT_2PI 2.506628275f
177 #define WEIGHT_GAUSS_NONEXP_PART(sigma) (1.0f/((sigma)*WEIGHT_GAUSS_SQRT_2PI))
178 #define WEIGHT_GAUSS_EXP_PART(dist, sigma) exp(-((dist)*(dist))/(2*(sigma)*(sigma)))
180 #define WEIGHT_GAUSS(x, sigma) (WEIGHT_GAUSS_NONEXP_PART(sigma)*WEIGHT_GAUSS_EXP_PART(x, sigma))
182 #define DW_WEIGHT(x) WEIGHT_INV(x)
183 #define VNN2_WEIGHT(x) WEIGHT_INV(x)
185 #define CLOSE_PLANE_IDX(p, i) p[get_local_id(0)*(MAX_PLANES+1)+(i)]
187 #define CREATE_OUTPUT_VOLUME_TYPE(name, in_size, in_spacing, in_volume) \
188 output_volume_type name; \
189 name.size = in_size; \
190 name.spacing = in_spacing; \
191 name.volume = in_volume;
204 void printMatrix(float16 matrix);
209 int isValidPixel(int2 point,
const __global
unsigned char* mask, int2 in_size);
214 __local float4*
const plane_eqs,
215 __global float16*
const plane_matrices,
220 __global
const unsigned char* mask,
225 __local float4*
const plane_eqs,
226 __global float16*
const plane_matrices,
229 int *multistart_guesses,
230 int n_multistart_guesses,
232 __global
const unsigned char* mask,
236 #if PLANE_METHOD == PLANE_EXACT
237 #define FIND_CLOSE_PLANES(a, b, c, d, e, f, g, h, i, j) findClosestPlanes_multistart(a, b, c, d, e, f, g, 1, h, i, j)
238 #elif PLANE_METHOD == PLANE_CLOSEST
239 #ifdef MAX_MULTISTART_STARTS
240 #undef MAX_MULTISTART_STARTS
241 #define MAX_MULTISTART_STARTS 1
244 #define FIND_CLOSE_PLANES(a, b, c, d, e, f, g, h, i, j) findClosestPlanes_multistart(a, b, c, d, e, f, g, 0, h, i, j)
247 __global
const unsigned char*
getImageData(
int plane_id,
248 __global
const unsigned char* bscans_blocks[],
251 float4
transform(float16 matrix, float4 voxel);
259 int2
toImgCoord_int(float4 voxel, float16 plane_matrix, float2 in_spacing);
261 float2
toImgCoord_float(float4 voxel, float16 plane_matrix, float2 in_spacing);
265 const __global
unsigned char* image,
268 #if METHOD == METHOD_VNN
269 #define PERFORM_INTERPOLATION(a, b, c, d, e, f, g, h, i) \
270 performInterpolation_vnn(a, b, c, d, e, f, g, h, i)
271 #elif METHOD == METHOD_VNN2
272 #define PERFORM_INTERPOLATION(a, b, c, d, e, f, g, h, i) \
273 performInterpolation_vnn2(a, b, c, d, e, f, g, h, i)
274 #elif METHOD == METHOD_DW
275 #define PERFORM_INTERPOLATION(a, b, c, d, e, f, g, h, i) \
276 performInterpolation_dw(a, b, c, d, e, f, g, h, i)
277 #elif METHOD == METHOD_ANISOTROPIC
278 #define PERFORM_INTERPOLATION(a, b, c, d, e, f, g, h, i) \
279 performInterpolation_anisotropic(a, b, c, d, e, f, g, h, i)
284 __global
const float16 *plane_matrices,
285 __local
const float4 *plane_eqs,
286 __global
const unsigned char* bscans_blocks[],
289 __global
const unsigned char* mask,
294 __global
const float16 *plane_matrices,
295 __local
const float4 *plane_eqs,
296 __global
const unsigned char* bscans_blocks[],
299 __global
const unsigned char* mask,
304 __global
const float16 *plane_matrices,
305 __local
const float4 *plane_eqs,
306 __global
const unsigned char* bscans_blocks[],
309 __global
const unsigned char* mask,
314 __global
const float16 *plane_matrices,
315 __local
const float4 *plane_eqs,
316 __global
const unsigned char* bscans_blocks[],
319 __global
const unsigned char* mask,
326 __local float4 *plane_eqs);
329 __local
const float4 *plane_eqs,
333 __global
const float16 *plane_matrices,
334 __global
const unsigned char *mask);
339 float volume_xspacing,
340 float volume_yspacing,
341 float volume_zspacing,
347 __global
unsigned char* in_bscans_b0,
348 __global
unsigned char* in_bscans_b1,
349 __global
unsigned char* in_bscans_b2,
350 __global
unsigned char* in_bscans_b3,
351 __global
unsigned char* in_bscans_b4,
352 __global
unsigned char* in_bscans_b5,
353 __global
unsigned char* in_bscans_b6,
354 __global
unsigned char* in_bscans_b7,
355 __global
unsigned char* in_bscans_b8,
356 __global
unsigned char* in_bscans_b9,
357 __global
unsigned char* out_volume,
358 __global float16 *plane_matrices,
359 __global
unsigned char* mask,
360 __local float4 *plane_eqs,
float4 transform(float16 matrix, float4 voxel)
unsigned char performInterpolation_dw(__local close_plane_t *close_planes, int n_close_planes, __global const float16 *plane_matrices, __local const float4 *plane_eqs, __global const unsigned char *bscans_blocks[], int2 in_size, float2 in_spacing, __global const unsigned char *mask, float4 voxel)
float2 toImgCoord_float(float4 voxel, float16 plane_matrix, float2 in_spacing)
float2 transform_inv_xy(float16 matrix, float4 voxel)
unsigned char performInterpolation_vnn2(__local close_plane_t *close_planes, int n_close_planes, __global const float16 *plane_matrices, __local const float4 *plane_eqs, __global const unsigned char *bscans_blocks[], int2 in_size, float2 in_spacing, __global const unsigned char *mask, float4 voxel)
int findHighestIdx(__local close_plane_t *planes, int n)
struct _output_volume_type output_volume_type
int2 toImgCoord_int(float4 voxel, float16 plane_matrix, float2 in_spacing)
int findLocalMinimas(int *guesses, __local const float4 *plane_eqs, float radius, float4 voxel, float3 out_spacing, __global const float16 *plane_matrices, __global const unsigned char *mask)
int2 findClosestPlanes_multistart(__local close_plane_t *close_planes, __local float4 *const plane_eqs, __global float16 *const plane_matrices, const float4 voxel, const float radius, int *multistart_guesses, int n_multistart_guesses, bool doTermDistance, __global const unsigned char *mask, int2 in_size, float2 in_spacing)
int2 findClosestPlanes_heuristic(__local close_plane_t *close_planes, __local float4 *const plane_eqs, __global float16 *const plane_matrices, const float4 voxel, const float radius, int guess, bool doTermDistance, __global const unsigned char *mask, int2 in_size, float2 in_spacing)
void prepare_plane_eqs(__global float16 *plane_matrices, __local float4 *plane_eqs)
__kernel void voxel_methods(int volume_xsize, int volume_ysize, int volume_zsize, float volume_xspacing, float volume_yspacing, float volume_zspacing, int in_xsize, int in_ysize, float in_xspacing, float in_yspacing, __global unsigned char *in_bscans_b0, __global unsigned char *in_bscans_b1, __global unsigned char *in_bscans_b2, __global unsigned char *in_bscans_b3, __global unsigned char *in_bscans_b4, __global unsigned char *in_bscans_b5, __global unsigned char *in_bscans_b6, __global unsigned char *in_bscans_b7, __global unsigned char *in_bscans_b8, __global unsigned char *in_bscans_b9, __global unsigned char *out_volume, __global float16 *plane_matrices, __global unsigned char *mask, __local float4 *plane_eqs, __local close_plane_t *planes, float radius)
const __global unsigned char * getImageData(int plane_id, __global const unsigned char *bscans_blocks[], int2 in_size)
float4 transform_inv(float16 matrix, float4 voxel)
int2 round_int(float2 value)
unsigned char anisotropicFilter(__local const close_plane_t *pixels, int n_planes)
float bilinearInterpolation(float x, float y, const __global unsigned char *image, int in_xsize)
unsigned char performInterpolation_anisotropic(__local close_plane_t *close_planes, int n_close_planes, __global const float16 *plane_matrices, __local const float4 *plane_eqs, __global const unsigned char *bscans_blocks[], int2 in_size, float2 in_spacing, __global const unsigned char *mask, float4 voxel)
unsigned char performInterpolation_vnn(__local close_plane_t *close_planes, int n_close_planes, __global const float16 *plane_matrices, __local const float4 *plane_eqs, __global const unsigned char *bscans_blocks[], int2 in_size, float2 in_spacing, __global const unsigned char *mask, float4 voxel)
int isValidPixel(int2 point, const __global unsigned char *mask, int2 in_size)
__global unsigned char * volume
struct _close_plane close_plane_t