-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathim3Dto2D.c
80 lines (64 loc) · 1.96 KB
/
im3Dto2D.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 im3Dto2D.c
*/
#include "CommandLineInterface/CLIcore.h"
#include "COREMOD_memory/COREMOD_memory.h"
// ==========================================
// Forward declaration(s)
// ==========================================
imageID image_basic_3Dto2D(const char *__restrict IDname);
// ==========================================
// Command line interface wrapper function(s)
// ==========================================
static errno_t image_basic_3Dto2D_cli() // collapse first 2 axis into one
{
if(CLI_checkarg(1, CLIARG_IMG) == 0)
{
image_basic_3Dto2D(data.cmdargtoken[1].val.string);
return CLICMD_SUCCESS;
}
else
{
return CLICMD_INVALID_ARG;
}
}
// ==========================================
// Register CLI command(s)
// ==========================================
errno_t __attribute__((cold)) im3Dto2D_addCLIcmd()
{
RegisterCLIcommand("im3Dto2D",
__FILE__,
image_basic_3Dto2D_cli,
"collapse first 2 axis of 3D image (in place)",
"<image name>",
"im3Dto2D im1",
"long image_basic_3Dto2D(const char *IDname)");
return RETURN_SUCCESS;
}
/* ----------------------------------------------------------------------
*
* turns a 3D image into a 2D image by collapsing first 2 axis
*
*
* ---------------------------------------------------------------------- */
imageID image_basic_3Dto2D_byID(imageID ID)
{
if(data.image[ID].md[0].naxis != 3)
{
printf("ERROR: image needs to have 3 axis\n");
}
else
{
data.image[ID].md[0].size[0] *= data.image[ID].md[0].size[1];
data.image[ID].md[0].size[1] = data.image[ID].md[0].size[2];
data.image[ID].md[0].naxis = 2;
}
return ID;
}
imageID image_basic_3Dto2D(const char *__restrict IDname)
{
imageID ID;
ID = image_ID(IDname);
image_basic_3Dto2D_byID(ID);
return ID;
}