Begin subroutine emask Determine maximum of exposure Multiply threshold parameters with exposure maximum Loop over image pixels Set pixels of detection mask to 1 if exposure is above cutoff and 0 otherwise. 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