-
Notifications
You must be signed in to change notification settings - Fork 1
/
vec_to_2Dimage.c
147 lines (129 loc) · 3.17 KB
/
vec_to_2Dimage.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
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
#include "CommandLineInterface/CLIcore.h"
// Local variables pointers
static char *imvecname;
static char *inpixiname;
static char *inpixmultname;
static char *outimname;
static long *xsizein;
static long *ysizein;
static CLICMDARGDEF farg[] = {{
CLIARG_IMG,
".inim",
"input vector",
"imvec",
CLIARG_VISIBLE_DEFAULT,
(void **) &imvecname,
NULL
},
{
CLIARG_IMG,
".inpixi",
"pixel index image",
"pixi",
CLIARG_VISIBLE_DEFAULT,
(void **) &inpixiname,
NULL
},
{
CLIARG_IMG,
".inpixmult",
"input pixel mult image",
"pixmult",
CLIARG_VISIBLE_DEFAULT,
(void **) &inpixmultname,
NULL
},
{
CLIARG_STR,
".outim",
"output 2D image",
"outim",
CLIARG_VISIBLE_DEFAULT,
(void **) &outimname,
NULL
},
{
CLIARG_INT64,
".xsize",
"X size",
"512",
CLIARG_VISIBLE_DEFAULT,
(void **) &xsizein,
NULL
},
{
CLIARG_INT64,
".ysize",
"Y size",
"512",
CLIARG_VISIBLE_DEFAULT,
(void **) &ysizein,
NULL
}
};
static CLICMDDATA CLIcmddata =
{
"vec2im", "remap vector to image", CLICMD_FIELDS_DEFAULTS
};
// detailed help
static errno_t help_function()
{
return RETURN_SUCCESS;
}
//
//
//
errno_t linopt_imtools_vec_to_2DImage(const char *IDvec_name,
const char *IDpixindex_name,
const char *IDpixmult_name,
const char *ID_name,
long xsize,
long ysize,
imageID *outID)
{
DEBUG_TRACE_FSTART();
imageID ID;
imageID IDvec;
long k;
imageID IDpixindex, IDpixmult;
long NBpix;
IDvec = image_ID(IDvec_name);
IDpixindex = image_ID(IDpixindex_name);
IDpixmult = image_ID(IDpixmult_name);
NBpix = data.image[IDpixindex].md[0].nelement;
FUNC_CHECK_RETURN(create_2Dimage_ID(ID_name, xsize, ysize, &ID));
for(k = 0; k < NBpix; k++)
{
data.image[ID].array.F[data.image[IDpixindex].array.SI64[k]] =
data.image[IDvec].array.F[k] / data.image[IDpixmult].array.F[k];
}
if(outID != NULL)
{
*outID = ID;
}
DEBUG_TRACE_FEXIT();
return RETURN_SUCCESS;
}
static errno_t compute_function()
{
DEBUG_TRACE_FSTART();
INSERT_STD_PROCINFO_COMPUTEFUNC_START
linopt_imtools_vec_to_2DImage(imvecname,
inpixiname,
inpixmultname,
outimname,
*xsizein,
*ysizein,
NULL);
INSERT_STD_PROCINFO_COMPUTEFUNC_END
DEBUG_TRACE_FEXIT();
return RETURN_SUCCESS;
}
INSERT_STD_FPSCLIfunctions
// Register function in CLI
errno_t
CLIADDCMD_linopt_imtools__vec_to_2DImage()
{
INSERT_STD_CLIREGISTERFUNC
return RETURN_SUCCESS;
}