Begin subroutine emask Determine maximum of exposure Multiply threshold parameters with exposure maximum Optionally read region file Loop over image pixels Set pixels of detection mask to 1 if exposure is above cutoff and 0 otherwise. Set pixels inside excluded regions to 0. END Loop Loop over image pixels Set pixels of detection mask to 0 if gradient of exposure is above threshold. END Loop End subroutine emask