A dynamic attenuator improves spectral imaging with energy-discriminating, photon counting detectors