Pixel detectors typically display pixel-to-pixel gain variation of a few percent which result in reduced spectroscopic performance. We have developed a calibration method which relies on cross-correlating histograms of many pixel pairs and obtaining large sets of relative shifts. These were subsequently used to calculate absolute pixel shifts and corresponding pixel gains. We demonstrate that this method yields stable gain calibration maps with an order of magnitude less statistics than required by typical approaches. Finally, we demonstrate the accuracy of the method by comparing with gain maps obtained with good statistics and monochromatic radiation at a synchrotron beamline.