Diamond spot removal

This script is part of the TIMEleSS tools. It is meant to be used when cleaning up diamond anvil cell data

timelessDiamondSpotRemoval -h

Diamond spot removal for 3D-XRD in the DAC
This is part of the TIMEleSS project
http://timeless.texture.rocks

usage: usage: timelessDiamondSpotRemoval [options] todo

Usage:
 - timelessDiamondSpotRemoval [options] spots: test spot detection parameters
 - timelessDiamondSpotRemoval [options] plotMask: try to create a mask a plot an overlay of images and corresponding mask
 - timelessDiamondSpotRemoval  [options] clearMask: create a mask and display images with median and mask removed
 - timelessDiamondSpotRemoval  [options] save: save new images with median and mask removed in EDF

Basic examples:
 - timelessDiamondSpotRemoval -P Edf-P02-Ti-Close -n P02-Ti-02_ -m P02-Ti-02_m20100.edf -f 50 -l 65 spots
 - timelessDiamondSpotRemoval -P Edf-P02-Ti-Close -n P02-Ti-02_ -m P02-Ti-02_m20100.edf -f 50 -l 65 -s Edf-P02-Ti-Close-Filtered save

Complex example:
 - timelessDiamondSpotRemoval -P Edf-P02-Ti-Close -n P02-Ti-02_ -m P02-Ti-02_m20100.edf -f 50 -l 65 --growXY=25 --growXYO=2 --c_rawy=1097 --c_rawz=922 --radius=300 --filtersize=3 -t 1.5 -s Edf-P02-Ti-Close-Filtered/ save

Typically, you start by testing the spot parameters and improve you match by playing with the threshold and filtersize parameter, and you then try creating a mask.

This is part of the TIMEleSS project
http://timeless.texture.rocks

positional arguments:
  todo                  What shall we do? Options are spots, plotMask, clearMask, save

optional arguments:
  -h, --help            show this help message and exit
  -n STEM, --stem STEM  Stem for EDF image files (required)
  -f FIRST, --first FIRST
                        First image number (mendatory)
  -l LAST, --last LAST  First image number (mendatory)
  -m MEDIAN, --median MEDIAN
                        Name of median image (mendatory)
  -P PATH, --path PATH  Path to EDF images. Default is ./
  --newpath NEWPATH     Path to save the new EDF image. Default is ./
  -d DIGITS, --digits DIGITS
                        Number of digits for file number. Default is 4
  -e EXT, --ext EXT     Extension for EDF images. Default is edf
  --scale SCALE         X dimension to which the image will be reduced (in pixels, the image is assumed to be square, used to blur the image). Default is 400
  --filtersize FILTERSIZE
                        Width of median filter to ignore small spots in diamond detection (in pixels). Default is 4
  -t THRESHOLD, --threshold THRESHOLD
                        Threshold for diamond spot detection, in multiples of image mean intensity. Default is 2.0
  --growXY GROWXY       Number of pixels to grow the mask in X and Y (useless in spot detection). Default is 15
  --growXYO GROWXYO     Number of pixels to grow the mask in X, Y, and omega (useless in spot detection). Default is 2
  --c_rawy C_RAWY       Raw Y position of beam center (can be read directly in Fabian, plot your image with orientation 1 0 0 1, it is the first number displayed to locate the cursor). Used to ignore a disk at the center of the image. If you have large intensity spots which are not diamond in there.
  --c_rawz C_RAWZ       Raw Z position of beam center (can be read directly in Fabian, plot your image with orientation 1 0 0 1, it is the first number displayed to locate the cursor). Used to ignore a disk at the center of the image. If you have large intensity spots which are not diamond in there.
  --radius RADIUS       Radius of disk to ignore around the beam center (in pixels, optional). c_rawy and c_rawz are mendatory if you want to use this option. . Used to ignore a disk at the center of the image. If you have large intensity spots which are not diamond in there.
  --inpaint INPAINT     If set to True, fill diamond mask with inpainting. If not set, diamond mask is filled with median value.