1. A computer-implemented method for gain calibration comprising: sorting a plurality of pixel values obtained from a plurality of offset-corrected X-ray images at a given pixel location into a sequence based on pixel value for each pixel location; removing one or more pixel values on one end or both ends of the sequence for each pixel location; averaging the remaining pixel values within each respective sequence to obtain an average pixel value for each pixel location; and generating a gain map based on the average pixel value for each pixel location.