aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dw-hdfsee.c24
-rw-r--r--src/dw-hdfsee.h4
-rw-r--r--src/hdfsee.c9
3 files changed, 34 insertions, 3 deletions
diff --git a/src/dw-hdfsee.c b/src/dw-hdfsee.c
index c4eabaf2..8ad12a2a 100644
--- a/src/dw-hdfsee.c
+++ b/src/dw-hdfsee.c
@@ -47,6 +47,7 @@
#include "hdfsee.h"
#include "utils.h"
#include "detector.h"
+#include "filters.h"
static void displaywindow_error(DisplayWindow *dw, const char *message)
@@ -1526,6 +1527,20 @@ static int geometry_fits(struct image *image, struct detector *geom)
}
+static void do_filters(DisplayWindow *dw)
+{
+ if ( dw->cmfilter ) filter_cm(dw->image);
+
+ if ( dw->median_filter > 0 ) {
+ filter_median(dw->image, dw->median_filter);
+ }
+
+ if ( dw->noisefilter ) {
+ filter_noise(dw->image);
+ }
+}
+
+
struct newhdf {
DisplayWindow *dw;
GtkWidget *widget;
@@ -1581,6 +1596,8 @@ static gint displaywindow_newhdf(GtkMenuItem *item, struct newhdf *nh)
nh->dw->image->det = nh->dw->simple_geom;
}
+ do_filters(nh->dw);
+
displaywindow_update(nh->dw);
return 0;
}
@@ -1782,7 +1799,8 @@ DisplayWindow *displaywindow_open(const char *filename, const char *peaks,
int noisefilter, int colscale,
const char *element, const char *geometry,
int show_rings, double *ring_radii,
- int n_rings, double ring_size)
+ int n_rings, double ring_size,
+ int median_filter)
{
DisplayWindow *dw;
char *title;
@@ -1813,6 +1831,7 @@ DisplayWindow *displaywindow_open(const char *filename, const char *peaks,
dw->ring_radius = ring_size;
dw->ring_radii = ring_radii;
dw->n_rings = n_rings;
+ dw->median_filter = median_filter;
/* Open the file, if any */
if ( filename != NULL ) {
@@ -1850,6 +1869,9 @@ DisplayWindow *displaywindow_open(const char *filename, const char *peaks,
dw->simple_geom = simple_geometry(dw->image);
dw->image->det = dw->simple_geom;
+ /* Filters need geometry */
+ do_filters(dw);
+
/* Peak list provided at startup? */
if ( peaks != NULL ) {
load_features_from_file(dw->image, peaks);
diff --git a/src/dw-hdfsee.h b/src/dw-hdfsee.h
index 84095a41..6bc2ae12 100644
--- a/src/dw-hdfsee.h
+++ b/src/dw-hdfsee.h
@@ -102,6 +102,7 @@ typedef struct {
double boostint;
int cmfilter; /* Use CM subtraction */
int noisefilter; /* Use aggressive noise filter */
+ int median_filter;
int use_geom;
int show_rings;
int show_peaks;
@@ -122,7 +123,8 @@ extern DisplayWindow *displaywindow_open(const char *filename,
int noisefilter, int colscale,
const char *element,
const char *geometry, int show_rings,
- double *ring_radii, int n_rings, double ring_size);
+ double *ring_radii, int n_rings,
+ double ring_size, int median_filter);
#endif /* DISPLAYWINDOW_H */
diff --git a/src/hdfsee.c b/src/hdfsee.c
index 36472e46..2db58f41 100644
--- a/src/hdfsee.c
+++ b/src/hdfsee.c
@@ -124,6 +124,7 @@ int main(int argc, char *argv[])
char *reslist = NULL;
double ring_radii[128];
int n_rings = -1;
+ int median_filter = 0;
/* Long options */
const struct option longopts[] = {
@@ -139,6 +140,7 @@ int main(int argc, char *argv[])
{"show-rings", 0, &config_showrings, 1},
{"ring-size", 1, NULL, 2},
{"simple-rings", 1, NULL, 'r'},
+ {"median-filter", 1, NULL, 3},
{0, 0, NULL, 0}
};
@@ -197,6 +199,10 @@ int main(int argc, char *argv[])
}
break;
+ case 3 :
+ median_filter = atoi(optarg);
+ break;
+
case 'r' :
config_showrings = 1;
reslist = strdup(optarg);
@@ -265,7 +271,8 @@ int main(int argc, char *argv[])
config_showrings,
ring_radii,
n_rings,
- ring_size);
+ ring_size,
+ median_filter);
if ( main_window_list[i] != NULL ) main_n_windows++;
}