forked from kif/sift_pyocl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
56 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,47 @@ | ||
#define ABS(i) ( (i<0.0f) ? (-i):(i) ) | ||
|
||
void __kernel interpolate(image3d_t volume, | ||
float* img, | ||
sampler_t sampler, | ||
global float* img, | ||
int img_width, | ||
int img_height, | ||
float3* point, | ||
float3* norm) | ||
{ | ||
global float* point, | ||
global float3* norm) | ||
{ | ||
int pos_x = get_global_id(0); | ||
int pos_y = get_global_id(1); | ||
if (pos_x>=img_width)||(pos_y>img_height) | ||
if ((pos_x>=img_width)||(pos_y>img_height)) | ||
return; | ||
float center_x = get_global_id(0)/2.0f; | ||
float center_y = get_global_id(1)/2.0f; | ||
float3 n_norm = normalize(norm[0]); | ||
float3 u_norm, v_norm | ||
float3 u_norm, v_norm; | ||
float3 pos; | ||
float nx = n_norm.x, | ||
ny = n_norm.y, | ||
nz = n_norm.z; | ||
float ax = abs(nx), | ||
ay = abs(ny), | ||
az = abs(nz); | ||
float ax = ABS(nx), | ||
ay = ABS(ny), | ||
az = ABS(nz); | ||
|
||
if (ax>=az) && (ay>=az) //z smallest | ||
if ((ax>=az) && (ay>=az)) //z smallest | ||
u_norm = (float3)( -ny, nx, 0.0f); | ||
else if (ax>=ay) && (az>=ay) //y smallest | ||
else if ((ax>=ay) && (az>=ay)) //y smallest | ||
u_norm = (float3)( -nz, 0.0f, nx); | ||
else if (ay>=ax) && (az>=ax) //x smallest | ||
else if ((ay>=ax) && (az>=ax)) //x smallest | ||
u_norm = (float3)( 0.0f, -nz, ny); | ||
|
||
//define 2 largest components a,b,c | ||
//create orthogonal vector -b a 0 | ||
// create third vector by cross product | ||
//use them to | ||
|
||
v_norm = cross(n_norm,u_norm); | ||
// u_norm, v_norm, n_norm is a direct orthonormal ref | ||
float3 tx=(float3)(u_norm.x,v_norm.x,n_norm.x); | ||
float3 ty=(float3)(u_norm.y,v_norm.y,n_norm.y); | ||
float3 tz=(float3)(u_norm.z,v_norm.z,n_norm.z); | ||
//transposed version | ||
float3 pos_uvn = (float3)(2.0f*((float)pos_x/(float)img_width)-1.0f, | ||
2.0f*((float)pos_y/(float)img_height)-1.0f, | ||
0.0f); | ||
float4 pos_xyz = (float4)(dot(tx,pos_uvn)+point[0], | ||
dot(ty,pos_uvn)+point[1], | ||
dot(tz,pos_uvn)+point[2], | ||
0.0f); | ||
|
||
float4 res = read_imagef(volume, sampler, pos_xyz); | ||
img[pos_x+img_width*pos_y] = res.x; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters