fixed threshold (fraction of number of pixels), refactoring frameNumber