Context-Preserving Dermoscopic Editing: Mask-Guided Lesion-Aware Diffusion for Attribute Modification
Abstract
Precise manipulation of dermoscopic attributes is essential for augmenting long-tailed datasets and enhancing diagnostic interpretability. However, generic diffusion-based editing methods often induce global distortions or fail to preserve the peri-lesional context critical for diagnosis. To address these limitations, we propose Context-Preserving Dermoscopic Editing (CPDE), a framework tailored for lesion-aware attribute modification. CPDE introduces a dual-branch diffusion pipeline that disentangles lesion editing from background reconstruction. Attribute changes are predicted by a Spatial--channel Transformer at the U-Net bottleneck and are trained with a lesion-aware objective that enforces semantic directionality only inside pathology regions. On the ISIC 2017 and 2018 datasets, CPDE produces spatially localized, clinically coherent edits that preserve lesion extent and surrounding skin. Our method achieves superior image fidelity with an FID of 0.274, while significantly outperforming existing approaches in terms of semantic alignment and background preservation.