From 77de4b7b31a0b456395cbcf89d68ead7fdc2e63b Mon Sep 17 00:00:00 2001 From: Gerber van der Graaf Date: Tue, 29 Jun 2010 19:15:19 +0200 Subject: [PATCH] Added option -U output file name contains first and last numbered image --- man/gpiv_combing.1 | 19 ++++++++++++------ src/misc/combing.c | 58 +++++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 62 insertions(+), 15 deletions(-) diff --git a/man/gpiv_combing.1 b/man/gpiv_combing.1 index 147cb3c..e019e2a 100644 --- a/man/gpiv_combing.1 +++ b/man/gpiv_combing.1 @@ -14,7 +14,8 @@ for cross-correlation. [\fB-p\fR | \fB--print\fR] [\fB-s\fR | \fB--skip\fR \fIS\fR] [\fB-t\fR | \fB--type] -[\fB-u\fR | \fB--suf_num\fR \fIN\fR] +[\fB-u\fR | \fB--suf_num\fR \fIM\fR] +[\fB-U\fR | \fB--Suf_num\fR \fIM\fR] [\fB-v\fR | \fB--version\fR] [\fB-V\fR | \fB--verbose\fR] [\fB-w\fR | \fB--warning\fR] @@ -77,14 +78,20 @@ binary (r), hdf5 (gpi), gif, tif, bmp and pgm. The format of the output image will always be png. .TP -\fB-u\fR | \fB--suf_num\fR \fIN\fR -If images are numbered instead of having suffixes \fB_a\fR and \fB_b\fR. \fIN\fR +\fB-u\fR | \fB--suf_num\fR \fIM\fR +If images are numbered instead of having suffixes \fB_a\fR and \fB_b\fR. \fIM\fR represents the first of the two numbered frames which will be combined -with frame \fIN\fR + 1. The combined image will be named to -file_basename\fIN\fR\fB.png\fR. So, only odd or even numbered images +with frame \fIM\fR + 1. The combined image will be named to +file_basename\fIM\fR\fB.png\fR. So, only odd or even numbered images will result to be loaded in \fBgpiv_rr\fR (or \fBgpiv\fR) for cross-correlation. +.TP +\fB-U\fR | \fB--Suf_num\fR \fIM\fR +Same as \fB-u\fR | \fB--suf_num\fR \fIM\fR, but with the difference that the +output image will be called file_basename\fIM\fR-\fIN\fR.\fBpng\fR, where \fIN\fR +is the number of the second image (default: \fIM\fR + 1). + .TP \fB-v\fR | \fB--version\fR Print version information on standard output, then exit successfully. @@ -122,7 +129,6 @@ As PNG is default image format, -t key is not needed. Two images with names turt gpiv_combing -a _slow -b _fast turtle - .TP For two numbered images img03.png and img04.png only the starting number will have to defined: .br @@ -132,6 +138,7 @@ gpiv_combing -u 3 img0 Two numbered images img03.png and img09.png will have to be combined by skipping 5 images in-between. If \fB-d\fR | \fB--dt\fR \fIS\fR is used, the correct separation time between the combined frames is calculated from \fIS\fR: gpiv_combing -u 3 -s 5 img0 .br + .TP .SH SEE ALSO diff --git a/src/misc/combing.c b/src/misc/combing.c index 7e1367d..d323306 100644 --- a/src/misc/combing.c +++ b/src/misc/combing.c @@ -41,8 +41,8 @@ #define PARFILE "gpivrc" /* Parameter file name */ #define USAGE "\ Usage: gpiv_combing [-h | --help] [-p | --print] [-v | --version] \n\ -[-a | --suf_a] [-b | --suf_b] [-d | --dt] [-u | --suf_num] [s | --suf_skip] \n\ -[-t | type] [-w | --warning] file_basename \n\ +[-a | --suf_a] [-b | --suf_b] [-d | --dt] [-u | --suf_num] [-U | --Suf_num] \n\ +[-s | --suf_skip] [-t | type] [-w | --warning] file_basename \n\ \n\ keys: \n\ -h | --help: this on-line help \n\ @@ -53,11 +53,14 @@ keys: \n\ -b | --suf_b S: use a suffix of the second image (default: _b) \n\ -d | --dt S: separation time delta t between subsequent \n\ recordings [in milliseconds] \n\ --u | --suf_num N: use numbered images, instead of suf_a/suf_b, of which \n\ - the first one with number N and the second N+1. \n\ - The converted image will be named to file_base_name + N \n\ --s | --skip S: skip S numbers; the first image with number N will \n\ - combine with the second image N+S+1 (default: S = 0) \n\ +-u | --suf_num M: use numbered images, instead of suf_a/suf_b, of which \n\ + the first one with number M and the second N (default: M+1). \n \ + The converted image will be named to file_base_nameM \n\ +-U | --Suf_num M: use numbered images, instead of suf_a/suf_b, of which \n\ + the first one with number M and the second N (default: M+1). \n \ + The converted image will be named to file_base_nameM-N. \n\ +-s | --skip S: skip S numbers; the first image with number M will \n\ + combine with the second image M+S+1 (default: S = 0) \n\ -t | type: input image type (tif, gif, bmp, pgm, r, gpi). Default: png. \n \ Output image will be in png format. \n\ -w | --warning: Warns if an input image already contains two frames. \n\ @@ -76,6 +79,7 @@ static gboolean verbose = FALSE; static gboolean print_par = FALSE; static gint num = 0; +static gint numboth = 0; static gint skip = 0; static gchar *suf_a = "_a"; static gchar *suf_b = "_b"; @@ -84,6 +88,7 @@ static gboolean warning = FALSE; static gboolean num__set = FALSE; +static gboolean numboth__set = FALSE; static gboolean skip__set = FALSE; static gboolean suf_a__set = FALSE; static gboolean suf_b__set = FALSE; @@ -175,6 +180,13 @@ command_args (int argc, num__set = TRUE; break; + case 'U': + numboth = atoi(*++argv); + argc_next = 1; + --argc; + numboth__set = TRUE; + break; + case 't': itype = g_strdup(*++argv); argc_next = 1; @@ -223,11 +235,16 @@ command_args (int argc, argc_next = 1; --argc; skip__set = TRUE; - } else if (strcmp("-num", *argv) == 0) { + } else if (strcmp("-suf_num", *argv) == 0) { num = atoi(*++argv); argc_next = 1; --argc; num__set = TRUE; + } else if (strcmp("-Suf_num", *argv) == 0) { + numboth = atoi(*++argv); + argc_next = 1; + --argc; + numboth__set = TRUE; } else if (strcmp("-type", *argv) == 0) { itype = g_strdup(*++argv); argc_next = 1; @@ -256,10 +273,14 @@ command_args (int argc, gpiv_error ("\n%s", USAGE); } - if (num__set && (suf_a__set || suf_b__set)) { + if ((num__set || numboth__set) && (suf_a__set || suf_b__set)) { gpiv_error ("\nA suffix has been defined as well as numbered filenames."); } + if (num__set && numboth__set) { + gpiv_error ("\nOnly choose one of the options '-u' or '-U' to use numbered filenames."); + } + if (skip__set == TRUE && image_par->t_scale__set == TRUE) { @@ -270,6 +291,7 @@ command_args (int argc, if (suf_a__set) g_message("comand_args: suf_a = %s", suf_a); if (suf_b__set) g_message("comand_args: suf_b = %s", suf_b); if (num__set) g_message("comand_args: num = %d", num); + if (numboth__set) g_message("comand_args: numboth = %d", numboth); if (skip__set) g_message("comand_args: skip = %d", skip); if (image_par->t_scale__set) g_message("comand_args: t_scale = %f", image_par->t_scale); @@ -310,6 +332,18 @@ make_fname (char *fname, fname_base, num + 1 + skip, itype); if (verbose) printf("\n#input image #2 is: %s", fname_in2); } + } else if (numboth__set) { + if (fname_in1 != NULL ) { + g_snprintf(fname_in1, GPIV_MAX_CHARS, "%s%d.%s", + fname_base, numboth, itype); + if (verbose) printf("\n#input image #1 is: %s", fname_in1); + } + + if (fname_in2 != NULL ) { + g_snprintf(fname_in2, GPIV_MAX_CHARS, "%s%d.%s", + fname_base, numboth + 1 + skip, itype); + if (verbose) printf("\n#input image #2 is: %s", fname_in2); + } } else { if (fname_in1 != NULL ) { g_snprintf(fname_in1, GPIV_MAX_CHARS, "%s%s.%s", @@ -333,6 +367,12 @@ make_fname (char *fname, dirname, G_DIR_SEPARATOR_S, fname_base, num, GPIV_EXT_PNG_IMAGE); if (verbose) printf("\n#output image file is: %s", fname_out); + } else if (numboth__set) { + g_snprintf(fname_out, GPIV_MAX_CHARS, "%s%s%s%d-%d%s", + dirname, G_DIR_SEPARATOR_S, fname_base, + numboth, numboth + skip + 1, + GPIV_EXT_PNG_IMAGE); + if (verbose) printf("\n#output image file is: %s", fname_out); } else { g_snprintf(fname_out, GPIV_MAX_CHARS, "%s%s%s%s", dirname, G_DIR_SEPARATOR_S, fname_base, -- 2.11.4.GIT