1. A non-transitory machine readable medium containing executable computer program instructions which when executed by a data processing system causes said system to perform a method to generate a first dynamic range image from a second dynamic range image, the method comprising: determining a mask showing one or more regions of the second dynamic range image containing pixels having values that are outside a first range and inside a second range; computing a weight distribution from the mask, wherein computing the weight distribution comprises blurring the mask to generate the weight distribution; and generating the first dynamic range image from the second dynamic range image using the weight distribution.