|
@@ -19,6 +19,10 @@ typedef struct {
|
|
|
guint v_size[3];
|
|
|
} Params;
|
|
|
|
|
|
+const int COLOR_RED = 31;
|
|
|
+const int COLOR_GREEN = 32;
|
|
|
+const int COLOR_YELLOW = 33;
|
|
|
+
|
|
|
static void
|
|
|
check (GError *error)
|
|
|
{
|
|
@@ -54,36 +58,61 @@ next_power_of_two (guint32 x)
|
|
|
return x + 1;
|
|
|
}
|
|
|
|
|
|
+static void
|
|
|
+colored_print (gint color, const gchar *fmt, va_list args)
|
|
|
+{
|
|
|
+ gchar *s;
|
|
|
+
|
|
|
+ s = g_strdup_vprintf (fmt, args);
|
|
|
+ g_print ("%c[%d;%dm%s%c[%dm", 0x1B, 1, color, s, 0x1b, 0);
|
|
|
+ g_free (s);
|
|
|
+}
|
|
|
+
|
|
|
+static void
|
|
|
+warn (const gchar *fmt, ...)
|
|
|
+{
|
|
|
+ va_list args;
|
|
|
+ va_start (args, fmt);
|
|
|
+ colored_print (COLOR_YELLOW, fmt, args);
|
|
|
+ va_end (args);
|
|
|
+}
|
|
|
+
|
|
|
+static void
|
|
|
+err (const gchar *fmt, ...)
|
|
|
+{
|
|
|
+ va_list args;
|
|
|
+ va_start (args, fmt);
|
|
|
+ colored_print (COLOR_RED, fmt, args);
|
|
|
+ va_end (args);
|
|
|
+}
|
|
|
+
|
|
|
static void
|
|
|
run_reconstruction (Params *params)
|
|
|
{
|
|
|
- UfoPluginManager *pm;
|
|
|
- UfoTaskGraph *graph;
|
|
|
- UfoBaseScheduler *sched;
|
|
|
- UfoTaskNode *radio_reader;
|
|
|
- UfoTaskNode *dark_reader;
|
|
|
- UfoTaskNode *flat_reader;
|
|
|
- UfoTaskNode *ffc;
|
|
|
- UfoTaskNode *pad;
|
|
|
- UfoTaskNode *ramp;
|
|
|
- UfoTaskNode *fft1;
|
|
|
- UfoTaskNode *fft2;
|
|
|
- UfoTaskNode *ifft;
|
|
|
- UfoTaskNode *conv;
|
|
|
- UfoTaskNode *reco;
|
|
|
- UfoTaskNode *writer;
|
|
|
+ guint xl, xr, yt, yb;
|
|
|
guint padded_width;
|
|
|
guint padded_height;
|
|
|
- guint xl, xr, yt, yb;
|
|
|
+ UfoPluginManager *pm = NULL;
|
|
|
+ UfoTaskGraph *graph = NULL;
|
|
|
+ UfoBaseScheduler *sched = NULL;
|
|
|
+ UfoTaskNode *radio_reader = NULL;
|
|
|
+ UfoTaskNode *dark_reader = NULL;
|
|
|
+ UfoTaskNode *flat_reader = NULL;
|
|
|
+ UfoTaskNode *ffc = NULL;
|
|
|
+ UfoTaskNode *pad = NULL;
|
|
|
+ UfoTaskNode *ramp = NULL;
|
|
|
+ UfoTaskNode *fft1 = NULL;
|
|
|
+ UfoTaskNode *fft2 = NULL;
|
|
|
+ UfoTaskNode *ifft = NULL;
|
|
|
+ UfoTaskNode *conv = NULL;
|
|
|
+ UfoTaskNode *reco = NULL;
|
|
|
+ UfoTaskNode *writer = NULL;
|
|
|
GError *error = NULL;
|
|
|
|
|
|
pm = ufo_plugin_manager_new (NULL);
|
|
|
graph = UFO_TASK_GRAPH (ufo_task_graph_new ());
|
|
|
|
|
|
radio_reader = make_task (pm, "reader");
|
|
|
- flat_reader = make_task (pm, "reader");
|
|
|
- dark_reader = make_task (pm, "reader");
|
|
|
- ffc = make_task (pm, "flat-field-correction");
|
|
|
pad = make_task (pm, "padding-2d");
|
|
|
ramp = make_task (pm, "lamino-ramp");
|
|
|
fft1 = make_task (pm, "fft");
|
|
@@ -98,9 +127,6 @@ run_reconstruction (Params *params)
|
|
|
"end", params->num_radios - 1,
|
|
|
NULL);
|
|
|
|
|
|
- g_object_set (flat_reader, "path", params->flats, NULL);
|
|
|
- g_object_set (dark_reader, "path", params->darks, NULL);
|
|
|
-
|
|
|
g_object_set (ffc, "num-darks", params->num_darks, NULL);
|
|
|
g_object_set (fft1, "dimensions", 2, NULL);
|
|
|
g_object_set (fft2, "dimensions", 2, NULL);
|
|
@@ -144,13 +170,27 @@ run_reconstruction (Params *params)
|
|
|
NULL);
|
|
|
|
|
|
g_object_set (writer,
|
|
|
- "filename", "/data/visitor/ma2183/id19/volume-%i.tif",
|
|
|
+ "filename", params->output,
|
|
|
NULL);
|
|
|
|
|
|
- ufo_task_graph_connect_nodes_full (graph, radio_reader, ffc, 0);
|
|
|
- ufo_task_graph_connect_nodes_full (graph, dark_reader, ffc, 1);
|
|
|
- ufo_task_graph_connect_nodes_full (graph, flat_reader, ffc, 2);
|
|
|
- ufo_task_graph_connect_nodes (graph, ffc, pad);
|
|
|
+ if (params->darks == NULL || params->flats == NULL) {
|
|
|
+ flat_reader = make_task (pm, "reader");
|
|
|
+ dark_reader = make_task (pm, "reader");
|
|
|
+ ffc = make_task (pm, "flat-field-correction");
|
|
|
+
|
|
|
+ g_object_set (flat_reader, "path", params->flats, NULL);
|
|
|
+ g_object_set (dark_reader, "path", params->darks, NULL);
|
|
|
+
|
|
|
+ ufo_task_graph_connect_nodes_full (graph, radio_reader, ffc, 0);
|
|
|
+ ufo_task_graph_connect_nodes_full (graph, dark_reader, ffc, 1);
|
|
|
+ ufo_task_graph_connect_nodes_full (graph, flat_reader, ffc, 2);
|
|
|
+ ufo_task_graph_connect_nodes (graph, ffc, pad);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ warn ("Reconstructing without flat/dark field correction\n");
|
|
|
+ ufo_task_graph_connect_nodes (graph, radio_reader, pad);
|
|
|
+ }
|
|
|
+
|
|
|
ufo_task_graph_connect_nodes (graph, pad, fft1);
|
|
|
ufo_task_graph_connect_nodes (graph, ramp, fft2);
|
|
|
ufo_task_graph_connect_nodes_full (graph, fft1, conv, 0);
|
|
@@ -168,8 +208,6 @@ run_reconstruction (Params *params)
|
|
|
g_object_unref (sched);
|
|
|
|
|
|
g_object_unref (radio_reader);
|
|
|
- g_object_unref (flat_reader);
|
|
|
- g_object_unref (dark_reader);
|
|
|
g_object_unref (ffc);
|
|
|
g_object_unref (pad);
|
|
|
g_object_unref (fft1);
|
|
@@ -177,6 +215,11 @@ run_reconstruction (Params *params)
|
|
|
g_object_unref (conv);
|
|
|
g_object_unref (reco);
|
|
|
g_object_unref (writer);
|
|
|
+
|
|
|
+ if (params->darks != NULL && params->flats != NULL) {
|
|
|
+ g_object_unref (flat_reader);
|
|
|
+ g_object_unref (dark_reader);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
static void
|
|
@@ -217,23 +260,17 @@ parse_params (Params *params, int argc, char **argv)
|
|
|
}
|
|
|
|
|
|
if (params->width == 0 || params->height == 0 || params->num_radios == 0 ||
|
|
|
- !params->radios || !params->darks || !params->flats ||
|
|
|
+ params->radios == NULL ||
|
|
|
params->theta == G_MAXDOUBLE ||
|
|
|
params->px == G_MAXDOUBLE || params->py == G_MAXDOUBLE) {
|
|
|
- g_printerr ("Error: Parameters missing.\n\n%s",
|
|
|
- g_option_context_get_help (context, TRUE, NULL));
|
|
|
-
|
|
|
+ err ("Parameters missing.\n\n");
|
|
|
+ g_print ("%s\n", g_option_context_get_help (context, TRUE, NULL));
|
|
|
exit (1);
|
|
|
}
|
|
|
|
|
|
g_option_context_free (context);
|
|
|
}
|
|
|
|
|
|
-static void
|
|
|
-check_params (Params *params)
|
|
|
-{
|
|
|
-}
|
|
|
-
|
|
|
int
|
|
|
main (int argc, char **argv)
|
|
|
{
|
|
@@ -260,7 +297,6 @@ main (int argc, char **argv)
|
|
|
#endif
|
|
|
|
|
|
parse_params (¶ms, argc, argv);
|
|
|
- check_params (¶ms);
|
|
|
run_reconstruction (¶ms);
|
|
|
|
|
|
return 0;
|