SDDS ToolKit Programs and Libraries for C and Python
All Classes Files Functions Variables Macros Pages
sddsimageprofiles.c
Go to the documentation of this file.
1/**
2 * @file sddsimageprofiles.c
3 * @brief Analyze images stored as horizontal lines (one per column) based on the ideas of B-X Yang.
4 *
5 * @details
6 * This program processes image data stored in SDDS (Self Describing Data Set) format,
7 * allowing for various profile analyses such as center line, integrated, averaged, or peak profiles.
8 * It can handle background subtraction and define specific areas of interest within the image.
9 *
10 * @section Usage
11 * ```
12 * sddsimageprofiles [<inputfile>] [<outputfile>]
13 * [-pipe=[input][,output]]
14 * -columnPrefix=<prefix>
15 * [-profileType={x|y}]
16 * [-method={centerLine|integrated|averaged|peak}]
17 * [-background=<filename>]
18 * [-areaOfInterest=<rowStart>,<rowEnd>,<columnStart>,<columnEnd>]
19 * ```
20 *
21 * @section Options
22 * | Required | Description |
23 * |----------|-----------------------------------------------------------------------------|
24 * | `-columnPrefix` | Set the column prefix. |
25 *
26 * | Option | Description |
27 * |-------------------|--------------------------------------------------------------------------------------|
28 * | `-pipe` | Specify input and/or output via pipe. |
29 * | `-profileType` | Choose profile type: `x` or `y`. |
30 * | `-method` | Select the method for profile analysis: `centerLine`, `integrated`, `averaged`, `peak`.|
31 * | `-background` | Specify a background image file. |
32 * | `-areaOfInterest` | Define the area of interest within the image. |
33 *
34 * @copyright
35 * - (c) 2002 The University of Chicago, as Operator of Argonne National Laboratory.
36 * - (c) 2002 The Regents of the University of California, as Operator of Los Alamos National Laboratory.
37 *
38 * @license
39 * This file is distributed under the terms of the Software License Agreement
40 * found in the file LICENSE included with this distribution.
41 *
42 * @authors
43 * - R. Soliday
44 * - Xuesong Jiao
45 */
46
47#include "mdb.h"
48#include "SDDS.h"
49#include "scan.h"
50
51/* Enumeration for option types */
52enum option_type {
53 SET_PIPE,
54 SET_PROFILETYPE,
55 SET_COLPREFIX,
56 SET_METHOD,
57 SET_AREAOFINTEREST,
58 SET_BACKGROUND,
59 N_OPTIONS,
60};
61
62char *option[N_OPTIONS] = {
63 "pipe", "profileType", "columnPrefix",
64 "method", "areaOfInterest", "background"};
65
66char *USAGE =
67 "sddsimageprofiles [<inputfile>] [<outputfile>]\n"
68 " [-pipe=[input][,output]]\n"
69 " -columnPrefix=<prefix>\n"
70 " [-profileType={x|y}]\n"
71 " [-method={centerLine|integrated|averaged|peak}]\n"
72 " [-background=<filename>]\n"
73 " [-areaOfInterest=<rowStart>,<rowEnd>,<columnStart>,<columnEnd>]\n"
74 "Options:\n"
75 " -pipe=[input][,output] Specify input and/or output via pipe.\n"
76 " -columnPrefix=<prefix> Set the column prefix.\n"
77 " -profileType={x|y} Choose profile type: 'x' or 'y'.\n"
78 " -method={centerLine|integrated|averaged|peak} Select the method for profile analysis.\n"
79 " -background=<filename> Specify a background image file.\n"
80 " -areaOfInterest=<rowStart>,<rowEnd>,<columnStart>,<columnEnd> Define the area of interest.\n\n"
81 "Program by Robert Soliday. (\"" __DATE__ " " __TIME__ "\", SVN revision: " SVN_VERSION ")\n\n"
82 "-method:\n"
83 " If this option is not specified, it is a real profile.\n"
84 " If centerLine is specified, it will find the row with the\n"
85 " greatest integrated profile and display that line only.\n"
86 " If integrated is specified, it will sum all the profiles\n"
87 " together. If averaged is specified, it will divide the sum\n"
88 " of all the profiles by the number of profiles. If peak is\n"
89 " specified, it will find the peak point and display the profile\n"
90 " for that row.\n";
91
92typedef struct {
93 short *shortData;
94 unsigned short *ushortData;
95 int32_t *longData;
96 uint32_t *ulongData;
97 int64_t *long64Data;
98 uint64_t *ulong64Data;
99 float *floatData;
100 double *doubleData;
101} IMAGE_DATA;
102
103int xImageProfile(IMAGE_DATA *data, int32_t *type, int64_t rows, SDDS_DATASET *SDDS_dataset,
104 long method, int64_t x1, int64_t x2, long y1, long y2, long *colIndex, double *colIndex2);
105
106int yImageProfile(IMAGE_DATA *data, int32_t *type, int64_t rows, SDDS_DATASET *SDDS_dataset,
107 long method, int64_t x1, int64_t x2, long y1, long y2, long *colIndex, double *colIndex2);
108
109int64_t xPeakLine(IMAGE_DATA *data, int32_t *type, long *colIndex, int64_t x1, int64_t x2, long y1, long y2);
110
111long yPeakLine(IMAGE_DATA *data, int32_t *type, long *colIndex, int64_t x1, int64_t x2, long y1, long y2);
112
113int64_t xCenterLine(IMAGE_DATA *data, int32_t *type, long *colIndex, int64_t x1, int64_t x2, long y1, long y2);
114
115long yCenterLine(IMAGE_DATA *data, int32_t *type, long *colIndex, int64_t x1, int64_t x2, long y1, long y2);
116
117int64_t GetData(SDDS_DATASET *SDDS_orig, char *input, IMAGE_DATA **data, int32_t **type, long **colIndex,
118 double **colIndex2, char *colPrefix, long *validColumns);
119
120int main(int argc, char **argv) {
121 SDDS_DATASET SDDS_dataset, SDDS_orig, SDDS_bg;
122 long i_arg;
123 SCANNED_ARG *s_arg;
124 IMAGE_DATA *data = NULL, *bg_data = NULL;
125 char *input = NULL, *output = NULL, *colPrefix = NULL, *background = NULL;
126 long profileType = 1, noWarnings = 0, tmpfile_used = 0, method = 0;
127 unsigned long pipeFlags = 0;
128 int64_t rows, bg_rows, j;
129 long i, validColumns = 0, bg_validColumns = 0;
130 int32_t *type = NULL, *bg_type = NULL;
131
132 int64_t rowStart = 1, rowEnd = 0;
133 long columnStart = 1, columnEnd = 0;
134
135 long *colIndex, *bg_colIndex;
136 double *colIndex2, *bg_colIndex2;
137
139 argc = scanargs(&s_arg, argc, argv);
140
141 if (argc < 3)
142 bomb(NULL, USAGE);
143
144 for (i_arg = 1; i_arg < argc; i_arg++) {
145 if (s_arg[i_arg].arg_type == OPTION) {
146 switch (match_string(s_arg[i_arg].list[0], option, N_OPTIONS, 0)) {
147 case SET_PROFILETYPE:
148 if (s_arg[i_arg].n_items != 2)
149 SDDS_Bomb("invalid -profileType syntax");
150 if (strcmp("x", s_arg[i_arg].list[1]) == 0)
151 profileType = 1;
152 if (strcmp("y", s_arg[i_arg].list[1]) == 0)
153 profileType = 2;
154 break;
155 case SET_COLPREFIX:
156 if (s_arg[i_arg].n_items != 2)
157 SDDS_Bomb("invalid -columnPrefix syntax");
158 colPrefix = s_arg[i_arg].list[1];
159 break;
160 case SET_METHOD:
161 if (s_arg[i_arg].n_items != 2)
162 SDDS_Bomb("invalid -method syntax");
163 if ((strncasecmp("centralLine", s_arg[i_arg].list[1], strlen(s_arg[i_arg].list[1])) == 0) ||
164 (strncasecmp("centerLine", s_arg[i_arg].list[1], strlen(s_arg[i_arg].list[1])) == 0))
165 method = 1;
166 if (strncasecmp("integrated", s_arg[i_arg].list[1], strlen(s_arg[i_arg].list[1])) == 0)
167 method = 2;
168 if (strncasecmp("averaged", s_arg[i_arg].list[1], strlen(s_arg[i_arg].list[1])) == 0)
169 method = 3;
170 if (strncasecmp("peak", s_arg[i_arg].list[1], strlen(s_arg[i_arg].list[1])) == 0)
171 method = 4;
172 break;
173 case SET_AREAOFINTEREST:
174 if (s_arg[i_arg].n_items != 5)
175 SDDS_Bomb("invalid -areaOfInterest syntax");
176 if (sscanf(s_arg[i_arg].list[1], "%" SCNd64, &rowStart) != 1 || rowStart <= 0)
177 SDDS_Bomb("invalid -areaOfInterest syntax or value");
178 if (sscanf(s_arg[i_arg].list[2], "%" SCNd64, &rowEnd) != 1 || rowEnd <= 0)
179 SDDS_Bomb("invalid -areaOfInterest syntax or value");
180 if (sscanf(s_arg[i_arg].list[3], "%ld", &columnStart) != 1 || columnStart <= 0)
181 SDDS_Bomb("invalid -areaOfInterest syntax or value");
182 if (sscanf(s_arg[i_arg].list[4], "%ld", &columnEnd) != 1 || columnEnd <= 0)
183 SDDS_Bomb("invalid -areaOfInterest syntax or value");
184 break;
185 case SET_BACKGROUND:
186 if (s_arg[i_arg].n_items != 2)
187 SDDS_Bomb("invalid -background syntax");
188 background = s_arg[i_arg].list[1];
189 break;
190 case SET_PIPE:
191 if (!processPipeOption(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1, &pipeFlags))
192 SDDS_Bomb("invalid -pipe syntax");
193 break;
194 default:
195 fprintf(stderr, "error: unknown switch: %s\n", s_arg[i_arg].list[0]);
196 exit(EXIT_FAILURE);
197 break;
198 }
199 } else {
200 if (input == NULL)
201 input = s_arg[i_arg].list[0];
202 else if (output == NULL)
203 output = s_arg[i_arg].list[0];
204 else
205 SDDS_Bomb("too many filenames");
206 }
207 }
208
209 if (colPrefix == NULL) {
210 fprintf(stderr, "error: missing columnPrefix\n");
211 exit(EXIT_FAILURE);
212 }
213
214 processFilenames("sddsimageprofiles", &input, &output, pipeFlags, noWarnings, &tmpfile_used);
215
216 /* Read in the image file */
217 rows = GetData(&SDDS_orig, input, &data, &type, &colIndex, &colIndex2, colPrefix, &validColumns);
218
219 if (rows < 0) {
220 fprintf(stderr, "error: no rows in image file\n");
221 exit(EXIT_FAILURE);
222 }
223
224 if (background != NULL) {
225 /* Read in the background image file */
226 bg_rows = GetData(&SDDS_bg, background, &bg_data, &bg_type, &bg_colIndex, &bg_colIndex2, colPrefix, &bg_validColumns);
227 if (rows != bg_rows) {
228 fprintf(stderr, "error: background has a different number of rows\n");
229 exit(EXIT_FAILURE);
230 }
231 if (validColumns != bg_validColumns) {
232 fprintf(stderr, "error: background has a different number of columns\n");
233 exit(EXIT_FAILURE);
234 }
235 /* Subtract the background from the image file */
236 for (i = 0; i < validColumns; i++) {
237 if (type[colIndex[i]] != bg_type[bg_colIndex[i]]) {
238 fprintf(stderr, "error: column types don't match with background image\n");
239 exit(EXIT_FAILURE);
240 }
241 if (colIndex2[i] != bg_colIndex2[i]) {
242 fprintf(stderr, "error: image rows don't match with background image\n");
243 exit(EXIT_FAILURE);
244 }
245 switch (type[colIndex[i]]) {
246 case SDDS_SHORT:
247 for (j = 0; j < rows; j++)
248 data[colIndex[i]].shortData[j] -= bg_data[bg_colIndex[i]].shortData[j];
249 break;
250 case SDDS_USHORT:
251 for (j = 0; j < rows; j++)
252 data[colIndex[i]].ushortData[j] -= bg_data[bg_colIndex[i]].ushortData[j];
253 break;
254 case SDDS_LONG:
255 for (j = 0; j < rows; j++)
256 data[colIndex[i]].longData[j] -= bg_data[bg_colIndex[i]].longData[j];
257 break;
258 case SDDS_ULONG:
259 for (j = 0; j < rows; j++)
260 data[colIndex[i]].ulongData[j] -= bg_data[bg_colIndex[i]].ulongData[j];
261 break;
262 case SDDS_LONG64:
263 for (j = 0; j < rows; j++)
264 data[colIndex[i]].long64Data[j] -= bg_data[bg_colIndex[i]].long64Data[j];
265 break;
266 case SDDS_ULONG64:
267 for (j = 0; j < rows; j++)
268 data[colIndex[i]].ulong64Data[j] -= bg_data[bg_colIndex[i]].ulong64Data[j];
269 break;
270 case SDDS_FLOAT:
271 for (j = 0; j < rows; j++)
272 data[colIndex[i]].floatData[j] -= bg_data[bg_colIndex[i]].floatData[j];
273 break;
274 case SDDS_DOUBLE:
275 for (j = 0; j < rows; j++)
276 data[colIndex[i]].doubleData[j] -= bg_data[bg_colIndex[i]].doubleData[j];
277 break;
278 default:
279 continue;
280 }
281 }
282 }
283
284 /* Initialize the output file and define the columns */
285 if (!SDDS_InitializeOutput(&SDDS_dataset, SDDS_ASCII, 1, NULL, NULL, output)) {
286 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
287 exit(EXIT_FAILURE);
288 }
289
290 if (profileType == 1) {
291 if (SDDS_DefineParameter(&SDDS_dataset, "Zone", NULL, NULL, NULL, NULL, SDDS_STRING, 0) == -1) {
292 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
293 exit(EXIT_FAILURE);
294 }
295 if (SDDS_DefineColumn(&SDDS_dataset, "x", NULL, NULL, NULL, NULL, SDDS_LONG64, 0) == -1) {
296 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
297 exit(EXIT_FAILURE);
298 }
299 if (SDDS_DefineColumn(&SDDS_dataset, "y", NULL, NULL, NULL, NULL, SDDS_DOUBLE, 0) == -1) {
300 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
301 exit(EXIT_FAILURE);
302 }
303 } else {
304 if (SDDS_DefineParameter(&SDDS_dataset, "Zone", NULL, NULL, NULL, NULL, SDDS_STRING, 0) == -1) {
305 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
306 exit(EXIT_FAILURE);
307 }
308 if (SDDS_DefineColumn(&SDDS_dataset, "x", NULL, NULL, NULL, NULL, SDDS_DOUBLE, 0) == -1) {
309 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
310 exit(EXIT_FAILURE);
311 }
312 if (SDDS_DefineColumn(&SDDS_dataset, "y", NULL, NULL, NULL, NULL, SDDS_DOUBLE, 0) == -1) {
313 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
314 exit(EXIT_FAILURE);
315 }
316 }
317 if (SDDS_WriteLayout(&SDDS_dataset) == 0) {
318 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
319 exit(EXIT_FAILURE);
320 }
321
322 if ((rowEnd > rows) || (rowEnd < rowStart))
323 rowEnd = rows;
324
325 if ((columnEnd > validColumns) || (columnEnd < columnStart))
326 columnEnd = validColumns;
327
328 if (profileType == 1) {
329 xImageProfile(data, type, rows, &SDDS_dataset, method, rowStart - 1, rowEnd, columnStart - 1, columnEnd, colIndex, colIndex2);
330 } else {
331 yImageProfile(data, type, rows, &SDDS_dataset, method, rowStart - 1, rowEnd, columnStart - 1, columnEnd, colIndex, colIndex2);
332 }
333
334 /* Close the output file */
335 if (SDDS_Terminate(&SDDS_dataset) != 1) {
336 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
337 exit(EXIT_FAILURE);
338 }
339
340 for (i = 0; i < validColumns; i++) {
341 switch (type[colIndex[i]]) {
342 case SDDS_SHORT:
343 free(data[colIndex[i]].shortData);
344 break;
345 case SDDS_USHORT:
346 free(data[colIndex[i]].ushortData);
347 break;
348 case SDDS_LONG:
349 free(data[colIndex[i]].longData);
350 break;
351 case SDDS_ULONG:
352 free(data[colIndex[i]].ulongData);
353 break;
354 case SDDS_LONG64:
355 free(data[colIndex[i]].long64Data);
356 break;
357 case SDDS_ULONG64:
358 free(data[colIndex[i]].ulong64Data);
359 break;
360 case SDDS_FLOAT:
361 free(data[colIndex[i]].floatData);
362 break;
363 case SDDS_DOUBLE:
364 free(data[colIndex[i]].doubleData);
365 break;
366 default:
367 continue;
368 }
369 }
370 free(data);
371 free(type);
372 if (background != NULL) {
373 for (i = 0; i < validColumns; i++) {
374 switch (bg_type[bg_colIndex[i]]) {
375 case SDDS_SHORT:
376 free(bg_data[bg_colIndex[i]].shortData);
377 break;
378 case SDDS_USHORT:
379 free(bg_data[bg_colIndex[i]].ushortData);
380 break;
381 case SDDS_LONG:
382 free(bg_data[bg_colIndex[i]].longData);
383 break;
384 case SDDS_ULONG:
385 free(bg_data[bg_colIndex[i]].ulongData);
386 break;
387 case SDDS_LONG64:
388 free(bg_data[bg_colIndex[i]].long64Data);
389 break;
390 case SDDS_ULONG64:
391 free(bg_data[bg_colIndex[i]].ulong64Data);
392 break;
393 case SDDS_FLOAT:
394 free(bg_data[bg_colIndex[i]].floatData);
395 break;
396 case SDDS_DOUBLE:
397 free(bg_data[bg_colIndex[i]].doubleData);
398 break;
399 default:
400 continue;
401 }
402 }
403 free(bg_data);
404 free(bg_type);
405 }
406
407 return EXIT_SUCCESS;
408}
409
410int xImageProfile(IMAGE_DATA *data, int32_t *type, int64_t rows, SDDS_DATASET *SDDS_dataset, long method,
411 int64_t x1, int64_t x2, long y1, long y2, long *colIndex, double *colIndex2) {
412 int64_t i, k = 0;
413 int j;
414 double val = 0;
415 long center;
416 int64_t *index;
417 double *values;
418 char value[100];
419 index = malloc(sizeof(int64_t) * rows);
420 values = malloc(sizeof(double) * rows);
421
422 if (method == 0) { /* Highest point */
423 for (i = x1; i < x2; i++) {
424 switch (type[colIndex[y1]]) {
425 case SDDS_SHORT:
426 val = data[colIndex[y1]].shortData[i];
427 break;
428 case SDDS_USHORT:
429 val = data[colIndex[y1]].ushortData[i];
430 break;
431 case SDDS_LONG:
432 val = data[colIndex[y1]].longData[i];
433 break;
434 case SDDS_ULONG:
435 val = data[colIndex[y1]].ulongData[i];
436 break;
437 case SDDS_LONG64:
438 val = data[colIndex[y1]].long64Data[i];
439 break;
440 case SDDS_ULONG64:
441 val = data[colIndex[y1]].ulong64Data[i];
442 break;
443 case SDDS_FLOAT:
444 val = data[colIndex[y1]].floatData[i];
445 break;
446 case SDDS_DOUBLE:
447 val = data[colIndex[y1]].doubleData[i];
448 break;
449 }
450 for (j = y1 + 1; j < y2; j++) {
451 switch (type[colIndex[j]]) {
452 case SDDS_SHORT:
453 if (val < data[colIndex[j]].shortData[i])
454 val = data[colIndex[j]].shortData[i];
455 break;
456 case SDDS_USHORT:
457 if (val < data[colIndex[j]].ushortData[i])
458 val = data[colIndex[j]].ushortData[i];
459 break;
460 case SDDS_LONG:
461 if (val < data[colIndex[j]].longData[i])
462 val = data[colIndex[j]].longData[i];
463 break;
464 case SDDS_ULONG:
465 if (val < data[colIndex[j]].ulongData[i])
466 val = data[colIndex[j]].ulongData[i];
467 break;
468 case SDDS_LONG64:
469 if (val < data[colIndex[j]].long64Data[i])
470 val = data[colIndex[j]].long64Data[i];
471 break;
472 case SDDS_ULONG64:
473 if (val < data[colIndex[j]].ulong64Data[i])
474 val = data[colIndex[j]].ulong64Data[i];
475 break;
476 case SDDS_FLOAT:
477 if (val < data[colIndex[j]].floatData[i])
478 val = data[colIndex[j]].floatData[i];
479 break;
480 case SDDS_DOUBLE:
481 if (val < data[colIndex[j]].doubleData[i])
482 val = data[colIndex[j]].doubleData[i];
483 break;
484 }
485 }
486 index[k] = i + 1;
487 values[k] = val;
488 k++;
489 }
490 } else if ((method == 1) || (method == 4)) { /* Center line or peak */
491 if (method == 4) {
492 center = yPeakLine(data, type, colIndex, x1, x2, y1, y2);
493 } else {
494 center = yCenterLine(data, type, colIndex, x1, x2, y1, y2);
495 }
496 for (i = x1; i < x2; i++) {
497 switch (type[colIndex[center]]) {
498 case SDDS_SHORT:
499 val = data[colIndex[center]].shortData[i];
500 break;
501 case SDDS_USHORT:
502 val = data[colIndex[center]].ushortData[i];
503 break;
504 case SDDS_LONG:
505 val = data[colIndex[center]].longData[i];
506 break;
507 case SDDS_ULONG:
508 val = data[colIndex[center]].ulongData[i];
509 break;
510 case SDDS_LONG64:
511 val = data[colIndex[center]].long64Data[i];
512 break;
513 case SDDS_ULONG64:
514 val = data[colIndex[center]].ulong64Data[i];
515 break;
516 case SDDS_FLOAT:
517 val = data[colIndex[center]].floatData[i];
518 break;
519 case SDDS_DOUBLE:
520 val = data[colIndex[center]].doubleData[i];
521 break;
522 }
523 index[k] = i + 1;
524 values[k] = val;
525 k++;
526 }
527 } else if ((method == 2) || (method == 3)) { /* Integrated or Averaged profile */
528 for (i = x1; i < x2; i++) {
529 val = 0;
530 for (j = y1; j < y2; j++) {
531 switch (type[colIndex[j]]) {
532 case SDDS_SHORT:
533 val += data[colIndex[j]].shortData[i];
534 break;
535 case SDDS_USHORT:
536 val += data[colIndex[j]].ushortData[i];
537 break;
538 case SDDS_LONG:
539 val += data[colIndex[j]].longData[i];
540 break;
541 case SDDS_ULONG:
542 val += data[colIndex[j]].ulongData[i];
543 break;
544 case SDDS_LONG64:
545 val += data[colIndex[j]].long64Data[i];
546 break;
547 case SDDS_ULONG64:
548 val += data[colIndex[j]].ulong64Data[i];
549 break;
550 case SDDS_FLOAT:
551 val += data[colIndex[j]].floatData[i];
552 break;
553 case SDDS_DOUBLE:
554 val += data[colIndex[j]].doubleData[i];
555 break;
556 }
557 }
558 index[k] = i + 1;
559 if (method == 2)
560 values[k] = val;
561 else
562 values[k] = val / (y2 - y1);
563 k++;
564 }
565 }
566
567 if (SDDS_StartPage(SDDS_dataset, x2 - x1) == 0) {
568 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
569 exit(EXIT_FAILURE);
570 }
571 sprintf(value, "(%" PRId64 ",%ld) x (%" PRId64 ",%ld)", x1 + 1, y1 + 1, x2, y2);
572 if (SDDS_SetParameters(SDDS_dataset, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE, "Zone", value, NULL) != 1) {
573 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
574 exit(EXIT_FAILURE);
575 }
576 if (SDDS_SetColumn(SDDS_dataset, SDDS_SET_BY_NAME, index, k, "x", NULL) != 1) {
577 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
578 exit(EXIT_FAILURE);
579 }
580 if (SDDS_SetColumn(SDDS_dataset, SDDS_SET_BY_NAME, values, k, "y", NULL) != 1) {
581 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
582 exit(EXIT_FAILURE);
583 }
584 if (SDDS_WritePage(SDDS_dataset) != 1) {
585 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
586 exit(EXIT_FAILURE);
587 }
588 free(index);
589 free(values);
590 return 0;
591}
592
593int yImageProfile(IMAGE_DATA *data, int32_t *type, int64_t rows, SDDS_DATASET *SDDS_dataset, long method,
594 int64_t x1, int64_t x2, long y1, long y2, long *colIndex, double *colIndex2) {
595 int i, k = 0;
596 int64_t j;
597 double val;
598 int64_t center;
599
600 double *index;
601 double *values;
602 char value[100];
603
604 index = malloc(sizeof(double) * (y2 - y1));
605 values = malloc(sizeof(double) * (y2 - y1));
606
607 if (method == 0) { /* Highest point */
608 for (i = y1; i < y2; i++) {
609 switch (type[colIndex[i]]) {
610 case SDDS_SHORT:
611 val = data[colIndex[i]].shortData[x1];
612 break;
613 case SDDS_USHORT:
614 val = data[colIndex[i]].ushortData[x1];
615 break;
616 case SDDS_LONG:
617 val = data[colIndex[i]].longData[x1];
618 break;
619 case SDDS_ULONG:
620 val = data[colIndex[i]].ulongData[x1];
621 break;
622 case SDDS_LONG64:
623 val = data[colIndex[i]].long64Data[x1];
624 break;
625 case SDDS_ULONG64:
626 val = data[colIndex[i]].ulong64Data[x1];
627 break;
628 case SDDS_FLOAT:
629 val = data[colIndex[i]].floatData[x1];
630 break;
631 case SDDS_DOUBLE:
632 val = data[colIndex[i]].doubleData[x1];
633 break;
634 default:
635 continue;
636 }
637 for (j = x1 + 1; j < x2; j++) {
638 switch (type[colIndex[i]]) {
639 case SDDS_SHORT:
640 if (val < data[colIndex[i]].shortData[j]) {
641 val = data[colIndex[i]].shortData[j];
642 }
643 break;
644 case SDDS_USHORT:
645 if (val < data[colIndex[i]].ushortData[j]) {
646 val = data[colIndex[i]].ushortData[j];
647 }
648 break;
649 case SDDS_LONG:
650 if (val < data[colIndex[i]].longData[j]) {
651 val = data[colIndex[i]].longData[j];
652 }
653 break;
654 case SDDS_ULONG:
655 if (val < data[colIndex[i]].ulongData[j]) {
656 val = data[colIndex[i]].ulongData[j];
657 }
658 break;
659 case SDDS_LONG64:
660 if (val < data[colIndex[i]].long64Data[j]) {
661 val = data[colIndex[i]].long64Data[j];
662 }
663 break;
664 case SDDS_ULONG64:
665 if (val < data[colIndex[i]].ulong64Data[j]) {
666 val = data[colIndex[i]].ulong64Data[j];
667 }
668 break;
669 case SDDS_FLOAT:
670 if (val < data[colIndex[i]].floatData[j]) {
671 val = data[colIndex[i]].floatData[j];
672 }
673 break;
674 case SDDS_DOUBLE:
675 if (val < data[colIndex[i]].doubleData[j]) {
676 val = data[colIndex[i]].doubleData[j];
677 }
678 break;
679 default:
680 continue;
681 }
682 }
683 index[k] = colIndex2[i];
684 values[k] = val;
685 k++;
686 }
687 } else if ((method == 1) || (method == 4)) { /* Center line or peak */
688 if (method == 4) {
689 center = xPeakLine(data, type, colIndex, x1, x2, y1, y2);
690 } else {
691 center = xCenterLine(data, type, colIndex, x1, x2, y1, y2);
692 }
693 for (i = y1; i < y2; i++) {
694 switch (type[colIndex[i]]) {
695 case SDDS_SHORT:
696 val = data[colIndex[i]].shortData[center];
697 break;
698 case SDDS_USHORT:
699 val = data[colIndex[i]].ushortData[center];
700 break;
701 case SDDS_LONG:
702 val = data[colIndex[i]].longData[center];
703 break;
704 case SDDS_ULONG:
705 val = data[colIndex[i]].ulongData[center];
706 break;
707 case SDDS_LONG64:
708 val = data[colIndex[i]].long64Data[center];
709 break;
710 case SDDS_ULONG64:
711 val = data[colIndex[i]].ulong64Data[center];
712 break;
713 case SDDS_FLOAT:
714 val = data[colIndex[i]].floatData[center];
715 break;
716 case SDDS_DOUBLE:
717 val = data[colIndex[i]].doubleData[center];
718 break;
719 default:
720 continue;
721 }
722 index[k] = colIndex2[i];
723 values[k] = val;
724 k++;
725 }
726 } else if ((method == 2) || (method == 3)) { /* Integrated or Averaged profile */
727 for (i = y1; i < y2; i++) {
728 val = 0;
729 switch (type[colIndex[i]]) {
730 case SDDS_SHORT:
731 for (j = x1; j < x2; j++)
732 val += data[colIndex[i]].shortData[j];
733 break;
734 case SDDS_USHORT:
735 for (j = x1; j < x2; j++)
736 val += data[colIndex[i]].ushortData[j];
737 break;
738 case SDDS_LONG:
739 for (j = x1; j < x2; j++)
740 val += data[colIndex[i]].longData[j];
741 break;
742 case SDDS_ULONG:
743 for (j = x1; j < x2; j++)
744 val += data[colIndex[i]].ulongData[j];
745 break;
746 case SDDS_LONG64:
747 for (j = x1; j < x2; j++)
748 val += data[colIndex[i]].long64Data[j];
749 break;
750 case SDDS_ULONG64:
751 for (j = x1; j < x2; j++)
752 val += data[colIndex[i]].ulong64Data[j];
753 break;
754 case SDDS_FLOAT:
755 for (j = x1; j < x2; j++)
756 val += data[colIndex[i]].floatData[j];
757 break;
758 case SDDS_DOUBLE:
759 for (j = x1; j < x2; j++)
760 val += data[colIndex[i]].doubleData[j];
761 break;
762 default:
763 continue;
764 }
765 index[k] = colIndex2[i];
766 if (method == 2)
767 values[k] = val;
768 else
769 values[k] = val / (x2 - x1);
770 k++;
771 }
772 }
773
774 if (SDDS_StartPage(SDDS_dataset, k) == 0) {
775 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
776 exit(EXIT_FAILURE);
777 }
778 sprintf(value, "(%" PRId64 ",%ld) x (%" PRId64 ",%ld)", x1 + 1, y1 + 1, x2, y2);
779 if (SDDS_SetParameters(SDDS_dataset, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE, "Zone", value, NULL) != 1) {
780 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
781 exit(EXIT_FAILURE);
782 }
783 if (SDDS_SetColumn(SDDS_dataset, SDDS_SET_BY_NAME, index, k, "y", NULL) != 1) {
784 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
785 exit(EXIT_FAILURE);
786 }
787 if (SDDS_SetColumn(SDDS_dataset, SDDS_SET_BY_NAME, values, k, "x", NULL) != 1) {
788 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
789 exit(EXIT_FAILURE);
790 }
791 if (SDDS_WritePage(SDDS_dataset) != 1) {
792 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
793 exit(EXIT_FAILURE);
794 }
795 free(index);
796 free(values);
797 return 0;
798}
799
800int64_t xPeakLine(IMAGE_DATA *data, int32_t *type, long *colIndex, int64_t x1, int64_t x2, long y1, long y2) {
801 int64_t i, j;
802 double maxValue = 0;
803 int64_t index = 0;
804
805 index = x1;
806 switch (type[colIndex[y1]]) {
807 case SDDS_SHORT:
808 maxValue = data[colIndex[y1]].shortData[x1];
809 break;
810 case SDDS_USHORT:
811 maxValue = data[colIndex[y1]].ushortData[x1];
812 break;
813 case SDDS_LONG:
814 maxValue = data[colIndex[y1]].longData[x1];
815 break;
816 case SDDS_ULONG:
817 maxValue = data[colIndex[y1]].ulongData[x1];
818 break;
819 case SDDS_LONG64:
820 maxValue = data[colIndex[y1]].long64Data[x1];
821 break;
822 case SDDS_ULONG64:
823 maxValue = data[colIndex[y1]].ulong64Data[x1];
824 break;
825 case SDDS_FLOAT:
826 maxValue = data[colIndex[y1]].floatData[x1];
827 break;
828 case SDDS_DOUBLE:
829 maxValue = data[colIndex[y1]].doubleData[x1];
830 break;
831 }
832 for (i = y1; i < y2; i++) {
833 for (j = x1; j < x2; j++) {
834 switch (type[colIndex[i]]) {
835 case SDDS_SHORT:
836 if (maxValue < data[colIndex[i]].shortData[j]) {
837 maxValue = data[colIndex[i]].shortData[j];
838 index = j;
839 }
840 break;
841 case SDDS_USHORT:
842 if (maxValue < data[colIndex[i]].ushortData[j]) {
843 maxValue = data[colIndex[i]].ushortData[j];
844 index = j;
845 }
846 break;
847 case SDDS_LONG:
848 if (maxValue < data[colIndex[i]].longData[j]) {
849 maxValue = data[colIndex[i]].longData[j];
850 index = j;
851 }
852 break;
853 case SDDS_ULONG:
854 if (maxValue < data[colIndex[i]].ulongData[j]) {
855 maxValue = data[colIndex[i]].ulongData[j];
856 index = j;
857 }
858 break;
859 case SDDS_LONG64:
860 if (maxValue < data[colIndex[i]].long64Data[j]) {
861 maxValue = data[colIndex[i]].long64Data[j];
862 index = j;
863 }
864 break;
865 case SDDS_ULONG64:
866 if (maxValue < data[colIndex[i]].ulong64Data[j]) {
867 maxValue = data[colIndex[i]].ulong64Data[j];
868 index = j;
869 }
870 break;
871 case SDDS_FLOAT:
872 if (maxValue < data[colIndex[i]].floatData[j]) {
873 maxValue = data[colIndex[i]].floatData[j];
874 index = j;
875 }
876 break;
877 case SDDS_DOUBLE:
878 if (maxValue < data[colIndex[i]].doubleData[j]) {
879 maxValue = data[colIndex[i]].doubleData[j];
880 index = j;
881 }
882 break;
883 }
884 }
885 }
886 return index;
887}
888
889long yPeakLine(IMAGE_DATA *data, int32_t *type, long *colIndex, int64_t x1, int64_t x2, long y1, long y2) {
890 int i;
891 int64_t j;
892 double maxValue = 0;
893 long index = 0;
894
895 index = y1;
896 switch (type[colIndex[y1]]) {
897 case SDDS_SHORT:
898 maxValue = data[colIndex[y1]].shortData[x1];
899 break;
900 case SDDS_USHORT:
901 maxValue = data[colIndex[y1]].ushortData[x1];
902 break;
903 case SDDS_LONG:
904 maxValue = data[colIndex[y1]].longData[x1];
905 break;
906 case SDDS_ULONG:
907 maxValue = data[colIndex[y1]].ulongData[x1];
908 break;
909 case SDDS_LONG64:
910 maxValue = data[colIndex[y1]].long64Data[x1];
911 break;
912 case SDDS_ULONG64:
913 maxValue = data[colIndex[y1]].ulong64Data[x1];
914 break;
915 case SDDS_FLOAT:
916 maxValue = data[colIndex[y1]].floatData[x1];
917 break;
918 case SDDS_DOUBLE:
919 maxValue = data[colIndex[y1]].doubleData[x1];
920 break;
921 }
922 for (i = y1; i < y2; i++) {
923 for (j = x1; j < x2; j++) {
924 switch (type[colIndex[i]]) {
925 case SDDS_SHORT:
926 if (maxValue < data[colIndex[i]].shortData[j]) {
927 maxValue = data[colIndex[i]].shortData[j];
928 index = i;
929 }
930 break;
931 case SDDS_USHORT:
932 if (maxValue < data[colIndex[i]].ushortData[j]) {
933 maxValue = data[colIndex[i]].ushortData[j];
934 index = i;
935 }
936 break;
937 case SDDS_LONG:
938 if (maxValue < data[colIndex[i]].longData[j]) {
939 maxValue = data[colIndex[i]].longData[j];
940 index = i;
941 }
942 break;
943 case SDDS_ULONG:
944 if (maxValue < data[colIndex[i]].ulongData[j]) {
945 maxValue = data[colIndex[i]].ulongData[j];
946 index = i;
947 }
948 break;
949 case SDDS_LONG64:
950 if (maxValue < data[colIndex[i]].long64Data[j]) {
951 maxValue = data[colIndex[i]].long64Data[j];
952 index = i;
953 }
954 break;
955 case SDDS_ULONG64:
956 if (maxValue < data[colIndex[i]].ulong64Data[j]) {
957 maxValue = data[colIndex[i]].ulong64Data[j];
958 index = i;
959 }
960 break;
961 case SDDS_FLOAT:
962 if (maxValue < data[colIndex[i]].floatData[j]) {
963 maxValue = data[colIndex[i]].floatData[j];
964 index = i;
965 }
966 break;
967 case SDDS_DOUBLE:
968 if (maxValue < data[colIndex[i]].doubleData[j]) {
969 maxValue = data[colIndex[i]].doubleData[j];
970 index = i;
971 }
972 break;
973 }
974 }
975 }
976 return index;
977}
978
979int64_t xCenterLine(IMAGE_DATA *data, int32_t *type, long *colIndex, int64_t x1, int64_t x2, long y1, long y2) {
980 int64_t i, j, start = 1;
981 double val = 0, maxValue = 0;
982 int64_t index = 0;
983
984 for (i = x1; i < x2; i++) {
985 val = 0;
986 for (j = y1; j < y2; j++) {
987 switch (type[colIndex[j]]) {
988 case SDDS_SHORT:
989 val += data[colIndex[j]].shortData[i];
990 break;
991 case SDDS_USHORT:
992 val += data[colIndex[j]].ushortData[i];
993 break;
994 case SDDS_LONG:
995 val += data[colIndex[j]].longData[i];
996 break;
997 case SDDS_ULONG:
998 val += data[colIndex[j]].ulongData[i];
999 break;
1000 case SDDS_LONG64:
1001 val += data[colIndex[j]].long64Data[i];
1002 break;
1003 case SDDS_ULONG64:
1004 val += data[colIndex[j]].ulong64Data[i];
1005 break;
1006 case SDDS_FLOAT:
1007 val += data[colIndex[j]].floatData[i];
1008 break;
1009 case SDDS_DOUBLE:
1010 val += data[colIndex[j]].doubleData[i];
1011 break;
1012 }
1013 }
1014 if (start == 1) {
1015 index = i;
1016 maxValue = val;
1017 start = 0;
1018 } else {
1019 if (val > maxValue) {
1020 index = i;
1021 maxValue = val;
1022 }
1023 }
1024 }
1025 return index;
1026}
1027
1028long yCenterLine(IMAGE_DATA *data, int32_t *type, long *colIndex, int64_t x1, int64_t x2, long y1, long y2) {
1029 int i, start = 1;
1030 int64_t j;
1031 double val, maxValue = 0;
1032 long index = 0;
1033
1034 for (i = y1; i < y2; i++) {
1035 val = 0;
1036 for (j = x1; j < x2; j++)
1037 switch (type[colIndex[i]]) {
1038 case SDDS_SHORT:
1039 val += data[colIndex[i]].shortData[j];
1040 break;
1041 case SDDS_USHORT:
1042 val += data[colIndex[i]].ushortData[j];
1043 break;
1044 case SDDS_LONG:
1045 val += data[colIndex[i]].longData[j];
1046 break;
1047 case SDDS_ULONG:
1048 val += data[colIndex[i]].ulongData[j];
1049 break;
1050 case SDDS_LONG64:
1051 val += data[colIndex[i]].long64Data[j];
1052 break;
1053 case SDDS_ULONG64:
1054 val += data[colIndex[i]].ulong64Data[j];
1055 break;
1056 case SDDS_FLOAT:
1057 val += data[colIndex[i]].floatData[j];
1058 break;
1059 case SDDS_DOUBLE:
1060 val += data[colIndex[i]].doubleData[j];
1061 break;
1062 default:
1063 continue;
1064 }
1065 if (start == 1) {
1066 index = i;
1067 maxValue = val;
1068 start = 0;
1069 } else {
1070 if (val > maxValue) {
1071 index = i;
1072 maxValue = val;
1073 }
1074 }
1075 }
1076 return index;
1077}
1078
1079int64_t GetData(SDDS_DATASET *SDDS_orig, char *input, IMAGE_DATA **data, int32_t **type, long **colIndex,
1080 double **colIndex2, char *colPrefix, long *validColumns) {
1081 int64_t rows;
1082 long i, j, temp;
1083 double temp2;
1084 int32_t orig_column_names;
1085 char **orig_column_name;
1086
1087 /* Open image file */
1088 if (!SDDS_InitializeInput(SDDS_orig, input)) {
1089 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
1090 exit(EXIT_FAILURE);
1091 }
1092
1093 /* Read column names */
1094 if (!(orig_column_name = SDDS_GetColumnNames(SDDS_orig, &orig_column_names))) {
1095 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
1096 exit(EXIT_FAILURE);
1097 }
1098
1099 /* Allocate memory for image file data */
1100 *data = malloc(sizeof(IMAGE_DATA) * orig_column_names);
1101 *type = malloc(sizeof(int32_t) * orig_column_names);
1102
1103 /* Read page */
1104 if (SDDS_ReadPage(SDDS_orig) != 1) {
1105 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
1106 exit(EXIT_FAILURE);
1107 }
1108
1109 /* Get number of rows */
1110 rows = SDDS_RowCount(SDDS_orig);
1111 *colIndex = malloc(sizeof(long) * orig_column_names);
1112 *colIndex2 = malloc(sizeof(double) * orig_column_names);
1113
1114 /* Read all numerical data from file */
1115 for (i = 0; i < orig_column_names; i++) {
1116 (*type)[i] = SDDS_GetNamedColumnType(SDDS_orig, orig_column_name[i]);
1117 if ((*type)[i] == 0) {
1118 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
1119 exit(EXIT_FAILURE);
1120 }
1121
1122 switch ((*type)[i]) {
1123 case SDDS_SHORT:
1124 (*data)[i].shortData = SDDS_GetColumn(SDDS_orig, orig_column_name[i]);
1125 break;
1126 case SDDS_USHORT:
1127 (*data)[i].ushortData = SDDS_GetColumn(SDDS_orig, orig_column_name[i]);
1128 break;
1129 case SDDS_LONG:
1130 (*data)[i].longData = SDDS_GetColumn(SDDS_orig, orig_column_name[i]);
1131 break;
1132 case SDDS_ULONG:
1133 (*data)[i].ulongData = SDDS_GetColumn(SDDS_orig, orig_column_name[i]);
1134 break;
1135 case SDDS_LONG64:
1136 (*data)[i].long64Data = SDDS_GetColumn(SDDS_orig, orig_column_name[i]);
1137 break;
1138 case SDDS_ULONG64:
1139 (*data)[i].ulong64Data = SDDS_GetColumn(SDDS_orig, orig_column_name[i]);
1140 break;
1141 case SDDS_FLOAT:
1142 (*data)[i].floatData = SDDS_GetColumn(SDDS_orig, orig_column_name[i]);
1143 break;
1144 case SDDS_DOUBLE:
1145 (*data)[i].doubleData = SDDS_GetColumn(SDDS_orig, orig_column_name[i]);
1146 break;
1147 default:
1148 continue;
1149 }
1150 if (strncmp(colPrefix, orig_column_name[i], strlen(colPrefix)) != 0) {
1151 continue;
1152 }
1153 (*colIndex)[*validColumns] = i;
1154 *validColumns += 1;
1155 }
1156
1157 if (SDDS_Terminate(SDDS_orig) != 1) {
1158 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
1159 exit(EXIT_FAILURE);
1160 }
1161
1162 if (*validColumns == 0) {
1163 fprintf(stderr, "error: no valid columns in image file\n");
1164 exit(EXIT_FAILURE);
1165 }
1166 /* For each valid column read the row from the column name */
1167 for (i = 0; i < *validColumns; i++) {
1168 (*colIndex2)[i] = atof(orig_column_name[(*colIndex)[i]] + strlen(colPrefix));
1169 }
1170 /* Sort columns by their row value ('row' is not related to the SDDS rows) */
1171 for (i = 0; i < *validColumns; i++) {
1172 for (j = i + 1; j < *validColumns; j++) {
1173 if ((*colIndex2)[j] < (*colIndex2)[i]) {
1174 temp = (*colIndex)[i];
1175 temp2 = (*colIndex2)[i];
1176 (*colIndex)[i] = (*colIndex)[j];
1177 (*colIndex2)[i] = (*colIndex2)[j];
1178 (*colIndex)[j] = temp;
1179 (*colIndex2)[j] = temp2;
1180 }
1181 }
1182 }
1183 return rows;
1184}
SDDS (Self Describing Data Set) Data Types Definitions and Function Prototypes.
int32_t SDDS_StartPage(SDDS_DATASET *SDDS_dataset, int64_t expected_n_rows)
int32_t SDDS_SetParameters(SDDS_DATASET *SDDS_dataset, int32_t mode,...)
int32_t SDDS_SetColumn(SDDS_DATASET *SDDS_dataset, int32_t mode, void *data, int64_t rows,...)
Sets the values for one data column in the current data table of an SDDS dataset.
void * SDDS_GetColumn(SDDS_DATASET *SDDS_dataset, char *column_name)
Retrieves a copy of the data for a specified column, including only rows marked as "of interest".
int32_t SDDS_InitializeInput(SDDS_DATASET *SDDS_dataset, char *filename)
Definition SDDS_input.c:49
int32_t SDDS_Terminate(SDDS_DATASET *SDDS_dataset)
int32_t SDDS_ReadPage(SDDS_DATASET *SDDS_dataset)
int32_t SDDS_InitializeOutput(SDDS_DATASET *SDDS_dataset, int32_t data_mode, int32_t lines_per_row, const char *description, const char *contents, const char *filename)
Initializes the SDDS output dataset.
int32_t SDDS_WritePage(SDDS_DATASET *SDDS_dataset)
Writes the current data table to the output file.
int32_t SDDS_DefineColumn(SDDS_DATASET *SDDS_dataset, const char *name, const char *symbol, const char *units, const char *description, const char *format_string, int32_t type, int32_t field_length)
Defines a data column within the SDDS dataset.
int32_t SDDS_WriteLayout(SDDS_DATASET *SDDS_dataset)
Writes the SDDS layout header to the output file.
int32_t SDDS_DefineParameter(SDDS_DATASET *SDDS_dataset, const char *name, const char *symbol, const char *units, const char *description, const char *format_string, int32_t type, char *fixed_value)
Defines a data parameter with a fixed string value.
int32_t SDDS_GetNamedColumnType(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the data type of a column in the SDDS dataset by its name.
char ** SDDS_GetColumnNames(SDDS_DATASET *SDDS_dataset, int32_t *number)
Retrieves the names of all columns in the SDDS dataset.
void SDDS_PrintErrors(FILE *fp, int32_t mode)
Prints recorded error messages to a specified file stream.
Definition SDDS_utils.c:432
void SDDS_RegisterProgramName(const char *name)
Registers the executable program name for use in error messages.
Definition SDDS_utils.c:288
void SDDS_Bomb(char *message)
Terminates the program after printing an error message and recorded errors.
Definition SDDS_utils.c:342
#define SDDS_ULONG
Identifier for the unsigned 32-bit integer data type.
Definition SDDStypes.h:67
#define SDDS_FLOAT
Identifier for the float data type.
Definition SDDStypes.h:43
#define SDDS_STRING
Identifier for the string data type.
Definition SDDStypes.h:85
#define SDDS_ULONG64
Identifier for the unsigned 64-bit integer data type.
Definition SDDStypes.h:55
#define SDDS_LONG
Identifier for the signed 32-bit integer data type.
Definition SDDStypes.h:61
#define SDDS_SHORT
Identifier for the signed short integer data type.
Definition SDDStypes.h:73
#define SDDS_USHORT
Identifier for the unsigned short integer data type.
Definition SDDStypes.h:79
#define SDDS_DOUBLE
Identifier for the double data type.
Definition SDDStypes.h:37
#define SDDS_LONG64
Identifier for the signed 64-bit integer data type.
Definition SDDStypes.h:49
void bomb(char *error, char *usage)
Reports error messages to the terminal and aborts the program.
Definition bomb.c:26
long match_string(char *string, char **option, long n_options, long mode)
Matches a given string against an array of option strings based on specified modes.
int scanargs(SCANNED_ARG **scanned, int argc, char **argv)
Definition scanargs.c:36
long processPipeOption(char **item, long items, unsigned long *flags)
Definition scanargs.c:356
void processFilenames(char *programName, char **input, char **output, unsigned long pipeFlags, long noWarnings, long *tmpOutputUsed)
Definition scanargs.c:390