1. A method for generating a high dynamic range (HDR) image from a set of M images at different exposure levels, implemented in one or more processors, comprising: (a) for each image m of the set of M images, where m=1, 2,. .. M, the one or more processors generating N level-n median threshold bitmap (MTB) for n=1, 2,. .. N, where N denotes a highest level, each level-n MTB being a gray-scale image having the same size as the image m and 2 n gray levels, generated from the image m by mapping the pixel value of each image pixel of the image m to one of the 2 n gray levels, wherein the pixel value mapping maps pixel values falling within each of 2 n non-overlapping ranges to a gray level, wherein the 2 n ranges collectively span a total pixel value range of the image m, and wherein an approximately equal number of pixels of the image m is mapped to each gray level; (b) for each level n, the one or more processors comparing the M level-n MTBs corresponding to the M images to generate a level-n ghost map for each image m, each level-n ghost map being a binary map having a size equal to the size of the corresponding image m and having pixel values indicating whether the corresponding pixels of the corresponding image are ghost or not; (c) for each image m, the one or more processors combining the N level-n ghost maps using pixel-wise OR to generate a combined ghost map, where the combined ghost map has pixel values indicating whether the corresponding pixels of the image m are ghost or not; and (d) the one or more processors generating the HDR image using the set of M images and the corresponding combined ghost maps.