Spectral CT using a photon-counting x-ray detector (PCXD) can potentially increase accuracy of measuring tissue composition. However, PCXD spectral measurements suffer from distortion due to charge sharing, pulse pileup, and Kescape energy loss. This study proposes two novel artificial neural network (ANN)-based algorithms: one to model and compensate for the distortion, and another one to directly correct for the distortion. The ANN-based distortion model was obtained by training to learn the distortion from a set of projections with a calibration scan. The ANN distortion was then applied in the forward statistical model to compensate for distortion in the projection decomposition. ANN was also used to learn to correct distortions directly in projections. The resulting corrected projections were used for reconstructing the image, denoising via joint bilateral filtration, and decomposition into three-material basis functions: Compton scattering, the photoelectric effect, and iodine. The ANN-based distortion model proved to be more robust to noise and worked better compared to using an imperfect parametric distortion model. In the presence of noise, the mean relative errors in iodine concentration estimation were 11.82% (ANN distortion model) and 16.72% (parametric model). With distortion correction, the mean relative error in iodine concentration estimation was improved by 50% over direct decomposition from distorted data. With our joint bilateral filtration, the resulting material image quality and iodine detectability as defined by the contrast-to-noise ratio were greatly enhanced allowing iodine concentrations as low as 2 mg/ml to be detected. Future work will be dedicated to experimental evaluation of our ANN-based methods using 3D-printed phantoms.