Ghosting artifact exists in Neural Network nonuniformity correction(NN-NUC) algorithm. The cause of ghosting artifact is analyzed, and an adaptive nonuniformity correction algorithm is proposed. First, an edge-preserving and denoising filter combinated by Gaussian low-pass filter and trilateral filter is designed. Then, the spatial average filter of NN-NUC is replaced by the proposed filter. To a large degree, the estimating errors of edge pixels are reduced and the ghosting artifact is removed. Finally, a simulation and a real infrared image sequence testing are carried out. The results show that the proposed algorithm effectively mitigates the ghosting artifact and yields a good nonuniformity correction effect.