[4dd432]: contrib / brl / bseg / boxm2 / ocl / cl / bit / normalize_kernels.cl  Maximize  Restore  History

Download this file

270 lines (230 with data), 9.4 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
#if NVIDIA
#pragma OPENCL EXTENSION cl_khr_gl_sharing : enable
#endif
#ifdef RENDER
__kernel void normalize_render_kernel(__global float * exp_img,
__global float* vis_img,
__global uint4* imgdims)
{
int i=0,j=0;
i=get_global_id(0);
j=get_global_id(1);
int imindex=j*get_global_size(0)+i;
// check to see if the thread corresponds to an actual pixel as in some
// cases #of threads will be more than the pixels.
if (i>=(*imgdims).z || j>=(*imgdims).w)
return;
//normalize image with respect to visibility
float vis = vis_img[imindex];
exp_img[imindex] = exp_img[imindex] + (vis*0.5f);
}
__kernel void normalize_render_rgb_kernel(__global float4* exp_img,
__global float* vis_img,
__global uint4* imgdims)
{
int i=0,j=0;
i=get_global_id(0);
j=get_global_id(1);
int imindex=j*get_global_size(0)+i;
// check to see if the thread corresponds to an actual pixel as in some
// cases #of threads will be more than the pixels.
if (i>=(*imgdims).z || j>=(*imgdims).w)
return;
//normalize image with respect to visibility
float vis = vis_img[imindex];
exp_img[imindex] = exp_img[imindex]+ (vis*0.5f);
}
#endif
#ifdef RENDER_NAA
__kernel void normalize_render_kernel(__global float * exp_img,
__global float* vis_img,
__global uint4* imgdims,
__global float* background_radiance)
{
int i=0,j=0;
i=get_global_id(0);
j=get_global_id(1);
int imindex=j*get_global_size(0)+i;
// check to see if the thread corresponds to an actual pixel as in some
// cases #of threads will be more than the pixels.
if (i>=(*imgdims).z || j>=(*imgdims).w)
return;
//normalize image with respect to visibility
float vis = vis_img[imindex];
exp_img[imindex] = exp_img[imindex] + (vis*(*background_radiance));
}
#endif
#ifdef RENDER_DEPTH
__kernel void normalize_render_depth_kernel(__global float * exp_img,
__global float * var_img,
__global float* prob_img,
__global uint4* imgdims,
__global float * t_infinity,
__global float * sub_block_dim)
{
int i=0,j=0;
i=get_global_id(0);
j=get_global_id(1);
int imindex=j*get_global_size(0)+i;
// check to see if the thread corresponds to an actual pixel as in some
// cases #of threads will be more than the pixels.
if (i>=(*imgdims).z || j>=(*imgdims).w)
return;
//normalize image with respect to visibility
float prob = prob_img[imindex];
float mean = exp_img[imindex] + t_infinity[imindex]*prob;
float var = var_img[imindex] + t_infinity[imindex]*t_infinity[imindex]*prob - mean*mean;
//float mean = exp_img[imindex] + t_infinity[imindex]*prob * (*sub_block_dim);
//float var = var_img[imindex]
// + (t_infinity[imindex]*(*sub_block_dim)*t_infinity[imindex]*(*sub_block_dim))*prob
// - mean*mean;
exp_img[imindex]=mean;
var_img[imindex]=var;
}
#endif
#ifdef NORMALIZE_RENDER_GL
__kernel void normalize_render_kernel_gl(__global uint * exp_img,
__global float* vis_img,
__global uint4* imgdims)
{
int i=0,j=0;
i=get_global_id(0);
j=get_global_id(1);
int imindex=j*get_global_size(0)+i;
// check to see if the thread corresponds to an actual pixel as in some
// cases #of threads will be more than the pixels.
if (i<(*imgdims).x || j<(*imgdims).y|| i>=(*imgdims).z || j>=(*imgdims).w)
return;
float intensity = as_float(exp_img[imindex]);
float vis = vis_img[imindex];
intensity += vis*1.0f;
exp_img[imindex] =(rgbaFloatToInt((float4) intensity));//(intensity-*min_i)/range) ;
}
__kernel void normalize_render_kernel_rgb_gl( __global float4* exp_img,
__global float* vis_img,
__global uint4* imgdims,
__global uint* gl_im,
__global bool* is_bw)
{
int i=0,j=0;
i=get_global_id(0);
j=get_global_id(1);
int imindex=j*get_global_size(0)+i;
// check to see if the thread corresponds to an actual pixel as in some
// cases #of threads will be more than the pixels.
if (i<(*imgdims).x || j<(*imgdims).y|| i>=(*imgdims).z || j>=(*imgdims).w)
return;
float vis = vis_img[imindex];
float4 intensity = exp_img[imindex] + (vis*0.0f);
if ( *is_bw )
gl_im[imindex] = rgbaFloatToInt(intensity);//(intensity-*min_i)/range) ;
else
gl_im[imindex] = rgbaFloatToInt( (float4) intensity.x );//(intensity-*min_i)/range) ;
}
#endif
#ifdef RENDER_GL
__kernel void render_kernel_gl(__constant float *min_i,
__constant float *max_i,
__constant float *tf,
__global float *vis_img,
__global float *exp_img,
__global uint *out_img,
__global uint4 *imgdims)
{
int i=0,j=0;
i=get_global_id(0);
j=get_global_id(1);
int imindex=j*get_global_size(0)+i;
// check to see if the thread corresponds to an actual pixel as in some
// cases #of threads will be more than the pixels.
if (i<(*imgdims).x || j<(*imgdims).y|| i>=(*imgdims).z || j>=(*imgdims).w)
return;
float intensity = exp_img[imindex];
float range=(*max_i-*min_i);
//intensity+=(vis_img[imindex]*((*max_i+*min_i)/2));
//intensity=clamp(intensity,*mini,*maxi);
int index=(int)max(floor((intensity-*min_i)/range*255.0f),0.0f);
out_img[imindex] =rgbaFloatToInt((float4 )tf[index]);//(intensity-*min_i)/range) ;
}
__kernel void render_kernel_rgb_gl(__constant float *min_i,
__constant float *max_i,
__constant float *tf,
__global float *vis_img,
__global float4 *exp_img,
__global uint *out_img,
__global uint4 *imgdims)
{
int i=0,j=0;
i=get_global_id(0);
j=get_global_id(1);
int imindex=j*get_global_size(0)+i;
// check to see if the thread corresponds to an actual pixel as in some
// cases #of threads will be more than the pixels.
if (i<(*imgdims).x || j<(*imgdims).y|| i>=(*imgdims).z || j>=(*imgdims).w)
return;
float4 intensity = exp_img[imindex];
//normalize
intensity = intensity + vis_img[imindex] * 0.0f;
//write to gl image
out_img[imindex] = rgbaFloatToInt(intensity);
}
#endif
#ifdef CHANGE
__kernel void normalize_change_kernel(__global float* exp_img /* background probability density*/ ,
__global float* prob_exp_img ,
__global float* vis_img,
__global uint4* imgdims,
__global int * rbelief)
{
int i=0,j=0;
i=get_global_id(0);
j=get_global_id(1);
int imindex=j*get_global_size(0)+i;
// check to see if the thread corresponds to an actual pixel as in some
// cases #of threads will be more than the pixels.
if (i>=(*imgdims).z || j>=(*imgdims).w) {
return;
}
//get vis, if it's greater than some threshold, we don't have enough information
float vis = vis_img[imindex];
if (vis > .2f) {
exp_img[imindex] = 0.0f;
return;
}
float prob_int = exp_img[imindex] ;
//prob_int+=vis;
float prob_exp_int = prob_exp_img[imindex];
//prob_exp_int+=vis;
//compute foreground belief
if ( *rbelief == 0 ) {
float fgbelief = 1.0f/(1.0f+prob_int);
exp_img[imindex] = fgbelief;
}
else {
float fgbelief = 1.0f/(1.0f+prob_int); // - 0.5f*min(prob_int,1/prob_int);
float raybelief = prob_exp_int/(1.0f+prob_exp_int); //-0.5*min(prob_exp_int,1/prob_exp_int);
//thresh
exp_img[imindex] = raybelief*fgbelief; //(raybelief > .25) ? fgbelief : 0.0f;
}
}
#endif
#ifdef PROB_IMAGE
__kernel void normalize_probability_image_kernel(__global float * prob_img ,
__global float* vis_img,
__global uint4* imgdims)
{
int i=0,j=0;
i=get_global_id(0);
j=get_global_id(1);
int imindex=j*get_global_size(0)+i;
// check to see if the thread corresponds to an actual pixel as in some
// cases #of threads will be more than the pixels.
if (i>=(*imgdims).z || j>=(*imgdims).w) {
return;
}
float vis = vis_img[imindex];
float prob = prob_img[imindex] +vis;
float raybelief=prob/(1.0f+prob)-0.5*min(prob,1/prob);
prob_img[imindex]=raybelief;
}
#endif

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks