7 |
* |
* |
8 |
* To View the Image |
* To View the Image |
9 |
* ========================= |
* ========================= |
10 |
* ./unu reshape -i mip.txt -s 200 200 | ./unu quantize -b 8 -o new.png |
* unu reshape -i mip.txt -s 200 200 | unu quantize -b 8 -o new.png |
11 |
*/ |
*/ |
12 |
#include <OpenCL/OpenCl.h> |
#include <OpenCL/OpenCl.h> |
13 |
#include <assert.h> |
#include <assert.h> |
17 |
#include <sys/stat.h> |
#include <sys/stat.h> |
18 |
#include <teem/nrrd.h> |
#include <teem/nrrd.h> |
19 |
|
|
20 |
#define SIZE 200 |
#define SIZE 640 |
21 |
|
|
22 |
//Loads the Kernel from a file |
//Loads the Kernel from a file |
23 |
char * loadKernel (const char * filename) |
char * loadKernel (const char * filename) |
59 |
max = matrix[i]; |
max = matrix[i]; |
60 |
|
|
61 |
} |
} |
|
printf("Max: %f\n",max); |
|
62 |
fclose(out_file); |
fclose(out_file); |
63 |
|
|
64 |
|
|
311 |
|
|
312 |
size_t global_work_size[2], local_work_size[2]; |
size_t global_work_size[2], local_work_size[2]; |
313 |
|
|
314 |
global_work_size[0] = 256; |
global_work_size[0] = SIZE; |
315 |
global_work_size[1] = 256; |
global_work_size[1] = SIZE; |
316 |
|
|
317 |
local_work_size[0] = 1; |
local_work_size[0] = 1; |
318 |
local_work_size[1] = 1; |
local_work_size[1] = 1; |
327 |
err |=clSetKernelArg(kernel,index++,sizeof(cl_int2), &workDim); |
err |=clSetKernelArg(kernel,index++,sizeof(cl_int2), &workDim); |
328 |
err |=clSetKernelArg(kernel,index++,sizeof(cl_mem), &sAxis_mem); |
err |=clSetKernelArg(kernel,index++,sizeof(cl_mem), &sAxis_mem); |
329 |
|
|
|
printf("error:%d\n",err); |
|
330 |
assert(err == CL_SUCCESS); |
assert(err == CL_SUCCESS); |
331 |
|
|
332 |
|
|
350 |
|
|
351 |
return CL_SUCCESS; |
return CL_SUCCESS; |
352 |
} |
} |
353 |
|
|
354 |
int main (int argc, char ** argv) |
int main (int argc, char ** argv) |
355 |
{ |
{ |
356 |
char * dataFile = "txs.nrrd"; |
char * dataFile = "../../data/txs.nrrd"; |
357 |
float transformMatrix[16]; |
float transformMatrix[16]; |
358 |
float inverseMatrix[16]; |
float inverseMatrix[16]; |
359 |
|
|
360 |
|
if (argc == 2) { |
361 |
|
dataFile = argv[1]; |
362 |
|
} |
363 |
|
|
364 |
float * out; |
float * out; |
365 |
out = (float *) malloc(sizeof(float) * (SIZE * SIZE)); |
out = (float *) malloc(sizeof(float) * (SIZE * SIZE)); |
366 |
Nrrd * nin = loadNrrdFile(dataFile); |
Nrrd * nin = loadNrrdFile(dataFile); |