The addition of heavy rare earth elements to sintered Nd–Fe–B magnets through grain boundary diffusion techniques can significantly improve the coercivity of magnets with minimal reduction in remanence. The diffusion depth and distribution of the diffusion source are critical metrics for evaluating the efficiency of the diffusion process. Glow discharge mass spectrometry can sequentially strip layers of the magnet within a limited region to measure the concentration of the diffusion source at various depths. However, the accuracy is compromised by the multiphase nature of the base magnet material and the inhomogeneous distribution of the diffusion source. In contrast, electron probe microanalysis enables direct observation of the diffusion depth and distribution by analyzing diffusion cross-sections of the magnet. Coupled with digital image processing techniques, electron probe microanalysis allows high-throughput analysis of images to calculate concentration across depth intervals, establish depth-concentration relationships, and predict the concentration of heavy rare-earth elements at specific depths. Describing the distribution of diffusion sources presents a significant challenge. In this work, a probabilistic denoising diffusion model is proposed for the first time to quantify the distribution of the diffusion source. EPMA images were segmented into 3,700 distinct positions for model training. The trained model can generate diffusion images with the same distribution of heavy rare-earth elements at any position. By training on microscopic images of various magnets, the model establishes a profound correlation between magnet performance and microstructure, providing practical guidance for optimizing magnets or diffusion sources.