Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
mmtalaie | 2711067741 | 4 years ago |
4 changed files with 134 additions and 14 deletions
@ -1,16 +1,117 @@ |
|||
// #define TEST |
|||
#define X 95 |
|||
#define Y 22 |
|||
|
|||
//#define USE_DBL |
|||
#ifdef USE_DBL |
|||
#define TYPE_FLT double |
|||
#define TYPE_INT long |
|||
#define MASK 0xFFFF |
|||
#define SHIFT 16 |
|||
#define EPSILSON 4.94065645841247E-324 |
|||
#else |
|||
#define TYPE_FLT float |
|||
#define TYPE_INT int |
|||
#define MASK 0x00FF |
|||
#define SHIFT 8 |
|||
#define EPSILSON 1.401298E-45 |
|||
#endif |
|||
|
|||
constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | |
|||
CLK_ADDRESS_CLAMP_TO_EDGE | |
|||
CLK_FILTER_LINEAR; |
|||
|
|||
|
|||
struct input |
|||
{ |
|||
int criFilterMode; |
|||
int frameCntr; |
|||
int scenariFrameNo; |
|||
float zeroSteeringFrameWeight; |
|||
float nonZeroSteeringFrameWeight; |
|||
}; |
|||
|
|||
kernel void Cri(read_only image2d_array_t input_frame, read_write image2d_t output_frame, struct input params) |
|||
|
|||
TYPE_FLT read_data(image2d_t input_frame, int x, int z) |
|||
{ |
|||
int2 gid = (int2)(x, z); |
|||
uint4 pixel = read_imageui(input_frame, sampler, gid); |
|||
TYPE_INT temp = (TYPE_INT)((TYPE_INT)pixel.x & MASK) | |
|||
(TYPE_INT)(((TYPE_INT)pixel.y & MASK) << SHIFT) | |
|||
(TYPE_INT)(((TYPE_INT)pixel.z & MASK) << (SHIFT * 2)) | |
|||
(TYPE_INT)(((TYPE_INT)pixel.w & MASK) << (SHIFT * 3)); |
|||
TYPE_FLT raw_data = *((TYPE_FLT*)(&temp)); |
|||
return raw_data; |
|||
} |
|||
|
|||
|
|||
// kernel void Cri(read_only image2d_array_t input_frame, read_write image2d_t output_frame, struct input params) |
|||
// { |
|||
// //int2 gid = (int2)(get_global_id(0), get_global_id(1)); |
|||
// //TYPE_FLT input = read_data(input_frame[0], gid.x, gid.y); |
|||
// int4 gid = ((int4)(get_global_size(0), get_global_size(1),get_global_size(2) , 0)); |
|||
// // printf(" :hi! I am the cri kernel 1"); |
|||
// // const int rows = get_image_height(input_frame); |
|||
// // const int cols = get_image_width(input_frame); |
|||
// printf("gid : %d\n",gid.z); |
|||
// // printf(input_frame); |
|||
// // int4 f = read_imagei(input_frame, (rows,cols,1,1)); |
|||
// // printf("out: %a | ", f.x); |
|||
// // output_frame = input_frame; |
|||
// printf(" :hi! I am the cri kernel"); |
|||
// } |
|||
int isNonzeropixel(int x, int y, image2d_t arrayInput) |
|||
{ |
|||
if(read_data(x,y,input_frame) == 0.0F) |
|||
return 0; |
|||
else |
|||
return 1; |
|||
} |
|||
|
|||
kernel void Cri(read_only image2d_t input_frame1, read_only image2d_t input_frame2, read_only image2d_t input_frame3, |
|||
read_only image2d_t input_frame4, read_only image2d_t input_frame5, read_only image2d_t input_frame6, |
|||
read_only image2d_t input_frame7, read_only image2d_t input_frame8, read_only image2d_t input_frame9, |
|||
read_only image2d_t input_frame10, read_only image2d_t input_frame11, read_write image2d_t output_frame, struct input params) |
|||
{ |
|||
int2 gid = (int2)(get_global_id(0), get_global_id(1)); |
|||
image2d_t imgArray[11] = {input_frame1, input_frame2, input_frame3, |
|||
input_frame4, input_frame5, input_frame6, |
|||
input_frame7, input_frame8, input_frame9, |
|||
input_frame10, input_frame11}; |
|||
|
|||
const int rows = get_image_height(input_frame); |
|||
const int cols = get_image_width(input_frame); |
|||
int4 f = read_imagei(input_frame, (rows,cols,1,1)); |
|||
printf("out: %a | ", f.x); |
|||
// printf(" :hi! I am the cri kernel"); |
|||
|
|||
int nonZeroFrameNo = 0; |
|||
int i = 1; |
|||
for(i= 1; i < 11;i++) |
|||
{ |
|||
nonZeroFrameNo = nonZeroFrameNo + isNonzeropixel(gid.x,gid.y,imgArray[i]); |
|||
} |
|||
|
|||
float additionalPoint = (1 - params.zeroSteeringFrameWeight - nonZeroFrameNo * params.nonZeroSteeringFrameWeight); |
|||
float pixelWeight[12] = {0.0F}; |
|||
float sum = 0; |
|||
for(i = 1; i < 11; i++) |
|||
{ |
|||
pixelWeight[i] = params.nonZeroSteeringFrameWeight + additionalPoint * params.nonZeroSteeringFrameWeight/(params.nonZeroSteeringFrameWeight * nonZeroFrameNo + params.zeroSteeringFrameWeight); |
|||
sum = pixelWeight[i]; |
|||
} |
|||
pixelWeight[0] = 1 - sum; |
|||
|
|||
TYPE_FLT output_data = 0; |
|||
for(i = 0; i < 11; i++) |
|||
{ |
|||
output_data = output_data + (pixelWeight[i] * read_data(gid.x,gid.y,imgArray[i]) |
|||
} |
|||
|
|||
TYPE_INT out = *((TYPE_INT*)(&output_data)); |
|||
|
|||
uint4 pixel; |
|||
pixel.x = (TYPE_INT)(out & MASK); |
|||
pixel.y = (TYPE_INT)((out >> SHIFT) & MASK); |
|||
pixel.z = (TYPE_INT)((out >> (SHIFT *2)) & MASK); |
|||
pixel.w = (TYPE_INT)((out >> (SHIFT * 3)) & MASK); |
|||
|
|||
write_imageui(output_frame, gid, pixel); |
|||
} |
Loading…
Reference in new issue