A method, comprising: receiving a sequence of input images; selecting a candidate set of function parameter values for a mapping function from a plurality of candidate sets of function parameter values for the mapping function; dividing each input image into image blocks; determining, for each image block, a standard deviation of pixel values in that block; constructing a set of image blocks, from among said image blocks, having non-zero standard deviation in pixel values for at least one input image in the sequence of input images; generating mapped image blocks by applying the mapping function with the candidate set of function parameter values to the pixel values in the set of image blocks in the at least one input image; determining, for each mapped image block, a standard deviation of the pixel values in that block; constructing a subset of mapped image blocks from among the mapped image blocks, each mapped image block of said subset having a standard deviation larger than a predefined threshold value; determining whether a total number of mapped image blocks with non-zero standard deviations in said subset is equal to the number of image blocks in said set so that the candidate set of function parameter values is optimal for the mapping function to map the at least one input image; in response to determining that the candidate set of function parameter values is optimal for the mapping function to map the at least one input image, determining whether the candidate set of function parameter values should be used as an overall optimal set of function parameter values by the mapping function to map a plurality of input images that include the at least one input image; and in response to determining that the candidate set of function parameter values should be used as an overall optimal set of function parameter values by the mapping function to map the plurality of input images that include the at least one input image, generating a plurality of mapped images that correspond to the plurality of input images by applying the mapping function with the overall optimal set of function parameter values to the plurality of images. receiving a sequence of input images; selecting a candidate set of function parameter values for a mapping function from a plurality of candidate sets of function parameter values for the mapping function; dividing each input image into image blocks; determining, for each image block, a standard deviation of pixel values in that block; constructing a set of image blocks, from among said image blocks, having non-zero standard deviation in pixel values for at least one input image in the sequence of input images; generating mapped image blocks by applying the mapping function with the candidate set of function parameter values to the pixel values in the set of image blocks in the at least one input image; determining, for each mapped image block, a standard deviation of the pixel values in that block; constructing a subset of mapped image blocks from among the mapped image blocks, each mapped image block of said subset having a standard deviation larger than a predefined threshold value; determining whether a total number of mapped image blocks with non-zero standard deviations in said subset is equal to the number of image blocks in said set so that the candidate set of function parameter values is optimal for the mapping function to map the at least one input image; in response to determining that the candidate set of function parameter values is optimal for the mapping function to map the at least one input image, determining whether the candidate set of function parameter values should be used as an overall optimal set of function parameter values by the mapping function to map a plurality of input images that include the at least one input image; and in response to determining that the candidate set of function parameter values should be used as an overall optimal set of function parameter values by the mapping function to map the plurality of input images that include the at least one input image, generating a plurality of mapped images that correspond to the plurality of input images by applying the mapping function with the overall optimal set of function parameter values to the plurality of images.