diff options
-rw-r--r-- | doc/man/indexamajig.1 | 7 | ||||
-rw-r--r-- | libcrystfel/src/filters.c | 55 | ||||
-rw-r--r-- | src/dw-hdfsee.c | 5 | ||||
-rw-r--r-- | src/dw-hdfsee.h | 3 | ||||
-rw-r--r-- | src/hdfsee.c | 12 | ||||
-rw-r--r-- | src/indexamajig.c | 7 | ||||
-rw-r--r-- | src/process_image.c | 2 |
7 files changed, 11 insertions, 80 deletions
diff --git a/doc/man/indexamajig.1 b/doc/man/indexamajig.1 index 8a41e054..2b6bf36d 100644 --- a/doc/man/indexamajig.1 +++ b/doc/man/indexamajig.1 @@ -235,14 +235,15 @@ Set the tolerances for unit cell comparison. \fItol\fR takes the form \fIa\fR,\ The default is \fB--tolerance=5,5,5,1.5\fR. .PD 0 -.IP \fB--filter-cm\fR +.IP \fB--median-filter=\fR\fIn\fR .PD -Attempt to subtract common-mode noise from the image. The filtered image will be used for the final integration of the peaks (in contrast to \fB--filter-noise\fR. It is usually better to do a careful job of cleaning the images up before using indexamajig, so this option should not normally be used. +Apply a median filter with box "radius" \fIn\fR to the image. Each pixel will be set to the median of the values from a \fI(n+1)\fRx\fI(n+1)\fR square centered on the pixel. This might help with peak detection if the background is high and/or noisy. The \fIunfiltered\fR image will be used for the final integration of the peaks. If you also use \fB--noise-filter\fR, the median filter will be applied first. + .PD 0 .IP \fB--filter-noise\fR .PD -Apply a noise filter to the image with checks 3x3 squares of pixels and sets all of them to zero if any of the nine pixels have a negative value. This filter may help with peak detection under certain circumstances, and the \fIunfiltered\fR image will be used for the final integration of the peaks. It is usually better to do a careful job of cleaning the images up before using indexamajig, so this option should not normally be used. +Apply a noise filter to the image with checks 3x3 squares of pixels and sets all of them to zero if any of the nine pixels have a negative value. This filter may help with peak detection under certain circumstances. The \fIunfiltered\fR image will be used for the final integration of the peaks, because the filter is destroys a lot of information from the pattern. If you also use \fB--median-filter\fR, the median filter will be applied first. .PD 0 .IP \fB--no-sat-corr\fR diff --git a/libcrystfel/src/filters.c b/libcrystfel/src/filters.c index fc8738c8..2ce782d9 100644 --- a/libcrystfel/src/filters.c +++ b/libcrystfel/src/filters.c @@ -42,61 +42,6 @@ #include "image.h" -static int compare_vals(const void *ap, const void *bp) -{ - const signed int a = *(signed int *)ap; - const signed int b = *(signed int *)bp; - - if ( a > b ) return 1; - if ( a < b ) return -1; - return 0; -} - - -static void clean_panel(struct image *image, int sx, int sy) -{ - int x, y; - const int s = sizeof(signed int); - - for ( x=0; x<512; x++ ) { - - signed int vals[128]; - double m; - - for ( y=0; y<128; y++ ) { - vals[y] = image->data[(x+sx)+(y+sy)*image->width]; - } - - qsort(&vals[0], 128, s, compare_vals); - - m = gsl_stats_int_median_from_sorted_data(vals, 1, 128); - - for ( y=0; y<128; y++ ) { - image->data[(x+sx)+(y+sy)*image->width] -= m; - } - - } -} - - -/* Pre-processing to make life easier */ -void filter_cm(struct image *image) -{ - int px, py; - - if ( (image->width != 1024) || (image->height != 1024) ) return; - - for ( px=0; px<2; px++ ) { - for ( py=0; py<8; py++ ) { - - clean_panel(image, 512*px, 128*py); - - } - } - -} - - void filter_noise(struct image *image) { int x, y; diff --git a/src/dw-hdfsee.c b/src/dw-hdfsee.c index 8ad12a2a..ec90b87e 100644 --- a/src/dw-hdfsee.c +++ b/src/dw-hdfsee.c @@ -1529,8 +1529,6 @@ 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); } @@ -1795,7 +1793,7 @@ static gint displaywindow_press(GtkWidget *widget, GdkEventButton *event, DisplayWindow *displaywindow_open(const char *filename, const char *peaks, - double boost, int binning, int cmfilter, + double boost, int binning, int noisefilter, int colscale, const char *element, const char *geometry, int show_rings, double *ring_radii, @@ -1824,7 +1822,6 @@ DisplayWindow *displaywindow_open(const char *filename, const char *peaks, dw->scale = colscale; dw->binning = binning; dw->boostint = boost; - dw->cmfilter = cmfilter; dw->noisefilter = noisefilter; dw->not_ready_yet = 1; dw->surf = NULL; diff --git a/src/dw-hdfsee.h b/src/dw-hdfsee.h index 6bc2ae12..3e908947 100644 --- a/src/dw-hdfsee.h +++ b/src/dw-hdfsee.h @@ -100,7 +100,6 @@ typedef struct { int binning; double boostint; - int cmfilter; /* Use CM subtraction */ int noisefilter; /* Use aggressive noise filter */ int median_filter; int use_geom; @@ -119,7 +118,7 @@ typedef struct { /* Open an image display window showing the given filename, or NULL */ extern DisplayWindow *displaywindow_open(const char *filename, const char *peaks, double boost, - int binning, int cmfilter, + int binning, int noisefilter, int colscale, const char *element, const char *geometry, int show_rings, diff --git a/src/hdfsee.c b/src/hdfsee.c index 2db58f41..24d6d9cc 100644 --- a/src/hdfsee.c +++ b/src/hdfsee.c @@ -58,11 +58,10 @@ static void show_help(const char *s) " --ring-size=<n> Set the size for those circles.\n" " -i, --int-boost=<n> Multiply intensity by <n>.\n" " -b, --binning=<n> Set display binning to <n>.\n" -" --filter-cm Perform common-mode noise subtraction.\n" -" --filter-noise Apply an aggressive noise filter which\n" -" sets all pixels in each 3x3 region to\n" -" zero if any of them have negative\n" -" values.\n" +" --filter-noise Apply an aggressive noise filter to the\n" +" image data.\n" +" --median-filter=<n> Apply a median filter to the image data.\n" + " --show-rings Overlay rings that indicate resolution.\n" " --simple-rings=XX,YY,... Overlay rings at specified radii XX, YY, ...\n" " in pixel units.\n" @@ -113,7 +112,6 @@ int main(int argc, char *argv[]) char *peaks = NULL; double boost = 1.0; int binning = 2; - int config_cmfilter = 0; int config_noisefilter = 0; int config_showrings = 0; int colscale = SCALE_COLOUR; @@ -132,7 +130,6 @@ int main(int argc, char *argv[]) {"peak-overlay", 1, NULL, 'p'}, {"int-boost", 1, NULL, 'i'}, {"binning", 1, NULL, 'b'}, - {"filter-cm", 0, &config_cmfilter, 1}, {"filter-noise", 0, &config_noisefilter, 1}, {"colscale", 1, NULL, 'c'}, {"image", 1, NULL, 'e'}, @@ -264,7 +261,6 @@ int main(int argc, char *argv[]) for ( i=0; i<nfiles; i++ ) { main_window_list[i] = displaywindow_open(argv[optind+i], peaks, boost, binning, - config_cmfilter, config_noisefilter, colscale, element, geometry, diff --git a/src/indexamajig.c b/src/indexamajig.c index 27ec31fc..208c0ed0 100644 --- a/src/indexamajig.c +++ b/src/indexamajig.c @@ -104,9 +104,6 @@ static void show_help(const char *s) "For more control over the process, you might need:\n\n" " --tolerance=<tol> Set the tolerances for cell comparison.\n" " Default: 5,5,5,1.5.\n" -" --filter-cm Perform common-mode noise subtraction on images\n" -" before proceeding. Intensities will be extracted\n" -" from the image as it is after this processing.\n" " --filter-noise Apply an aggressive noise filter which sets all\n" " pixels in each 3x3 region to zero if any of them\n" " have negative values. Intensity measurement will\n" @@ -114,7 +111,7 @@ static void show_help(const char *s) " --median-filter=<n> Apply a median filter to the image data. Intensity\n" " measurement will be performed on the image as it\n" " was before this. The side length of the median\n" -" filter box will be <n>. Default: 0 (no filter).\n" +" filter box will be 2<n>+1. Default: 0 (no filter).\n" " --no-sat-corr Don't correct values of saturated peaks using a\n" " table included in the HDF5 file.\n" " --threshold=<n> Only accept peaks above <n> ADU. Default: 800.\n" @@ -185,7 +182,6 @@ int main(int argc, char *argv[]) /* Defaults */ iargs.cell = NULL; - iargs.cmfilter = 0; iargs.noisefilter = 0; iargs.median_filter = 0; iargs.satcorr = 1; @@ -239,7 +235,6 @@ int main(int argc, char *argv[]) {"image", 1, NULL, 'e'}, /* Long-only options with no arguments */ - {"filter-cm", 0, &iargs.cmfilter, 1}, {"filter-noise", 0, &iargs.noisefilter, 1}, {"no-sat-corr", 0, &iargs.satcorr, 0}, {"sat-corr", 0, &iargs.satcorr, 1}, diff --git a/src/process_image.c b/src/process_image.c index a8eeb663..ef673c84 100644 --- a/src/process_image.c +++ b/src/process_image.c @@ -134,8 +134,6 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, return; } - if ( iargs->cmfilter ) filter_cm(&image); - /* Take snapshot of image after CM subtraction but before applying * horrible noise filters to it */ data_size = image.width * image.height * sizeof(float); |