-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcubecollapse.c
80 lines (63 loc) · 1.96 KB
/
cubecollapse.c
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
/** @file cubecollapse.c
*/
#include <sched.h>
#include "CommandLineInterface/CLIcore.h"
#include "COREMOD_memory/COREMOD_memory.h"
// ==========================================
// Forward declaration(s)
// ==========================================
imageID cube_collapse(const char *__restrict ID_in_name,
const char *__restrict ID_out_name);
// ==========================================
// Command line interface wrapper function(s)
// ==========================================
static errno_t image_basic_cubecollapse_cli()
{
if(0 + CLI_checkarg(1, 4) + CLI_checkarg(2, 3) == 0)
{
cube_collapse(data.cmdargtoken[1].val.string,
data.cmdargtoken[2].val.string);
return CLICMD_SUCCESS;
}
else
{
return CLICMD_INVALID_ARG;
}
}
// ==========================================
// Register CLI command(s)
// ==========================================
errno_t __attribute__((cold)) cubecollapse_addCLIcmd()
{
RegisterCLIcommand(
"cubecollapse",
__FILE__,
image_basic_cubecollapse_cli,
"collapse a cube along z",
"cubecollapse <inim> <outim>",
"cubecollapse im1 outim",
"long cube_collapse(const char *ID_in_name, const char *ID_out_name)");
return RETURN_SUCCESS;
}
imageID cube_collapse(const char *__restrict ID_in_name,
const char *__restrict ID_out_name)
{
imageID IDin;
imageID IDout;
long xsize, ysize, ksize;
long ii, kk;
IDin = image_ID(ID_in_name);
xsize = data.image[IDin].md[0].size[0];
ysize = data.image[IDin].md[0].size[1];
ksize = data.image[IDin].md[0].size[2];
create_2Dimage_ID(ID_out_name, xsize, ysize, &IDout);
for(ii = 0; ii < xsize * ysize; ii++)
{
for(kk = 0; kk < ksize; kk++)
{
data.image[IDout].array.F[ii] +=
data.image[IDin].array.F[kk * xsize * ysize + ii];
}
}
return (IDout);
}