improve gamma filtering: automatic threshold

Created by: yxqd

according to Hassina, gamma filtering only needs to be done for pixels with values larger than half of the maximum integer of the image data type.