diff options
author | Thomas White <taw@physics.org> | 2021-10-28 09:59:02 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2021-10-28 10:12:41 +0200 |
commit | 86633959138c6ec528c8cf635c6f0d39d79b61cc (patch) | |
tree | 39a19b4f4ff7fb874363dad70883c55a8ba548b9 /libcrystfel/src/image.c | |
parent | ff0242d5efa8f52449b4e7a55c7db668bdca9ea5 (diff) |
Add 'mask_panel_edges' to geometry file
Closes: https://gitlab.desy.de/thomas.white/crystfel/-/issues/27
Diffstat (limited to 'libcrystfel/src/image.c')
-rw-r--r-- | libcrystfel/src/image.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/libcrystfel/src/image.c b/libcrystfel/src/image.c index d31e99b6..ce924b35 100644 --- a/libcrystfel/src/image.c +++ b/libcrystfel/src/image.c @@ -1027,6 +1027,29 @@ static int load_mask(struct panel_template *p, } +static void mask_panel_edges(int *bad, int p_w, int p_h, int edgew) +{ + int i; + + /* Silly values should not cause memory errors */ + if ( edgew > p_w ) edgew = p_w/2 + 1; + if ( edgew > p_h ) edgew = p_h/2 + 1; + if ( edgew < 0 ) return; + + for ( i=0; i<edgew; i++ ) { + int fs, ss; + for ( fs=i; fs<p_w-i; fs++ ) { + bad[fs+p_w*i] = 1; + bad[fs+p_w*(p_h-i-1)] = 1; + } + for ( ss=i; ss<p_h-i; ss++ ) { + bad[i+p_w*ss] = 1; + bad[(p_w-i-1)+p_w*ss] = 1; + } + } +} + + static int create_badmap(struct image *image, const DataTemplate *dtempl, int no_mask_data) @@ -1066,6 +1089,12 @@ static int create_badmap(struct image *image, image->bad[i]); } + /* Mask panel edges (skip if panel is bad anyway) */ + if ( (p->mask_edge_pixels > 0) && !p->bad ) { + mask_panel_edges(image->bad[i], p_w, p_h, + p->mask_edge_pixels); + } + /* Load masks (skip if panel is bad anyway) */ if ( (!no_mask_data) && (!p->bad) ) { |