MedSegDiffNCA: Diffusion Models With Neural Cellular Automata for Skin Lesion Segmentation Avni Mittal, John Kalkhof, Anirban Mukhopadhyay, Arnav Bhavsar Abstract Denoising Diffusion Models (DDMs) are widely used for high-quality image generation and medical image segmentation but often rely on Unet-based architectures, leading to high computational overhead, especially with high-resolution images. This work proposes three NCA-based improvements for diffusion-based medical image segmentation. First, Multi-MedSegDiffNCA uses a multilevel NCA framework to refine rough noise estimates generated by lower level NCA models. Second, CBAM-MedSegDiffNCA incorporates channel and spatial attention for improved segmentation. Third, MultiCBAM-MedSegDiffNCA combines these methods with a new RGB channel loss for semantic guidance. Evaluations on Lesion segmentation show that MultiCBAM-MedSegDiffNCA matches Unet-based model performance with dice score of 87.84% while using 60-110 times fewer parameters, offering a more efficient solution for low resource medical settings. † † address: ⋆ Indian Institute of Technology Mandi † Technische Universität Darmstadt 1 Introduction Denoising Diffusion Probabilistic Models (DDPMs) [ 1 , 2 ] have emerged as powerful tools for image processing and generation, showing particular promise in medical image segmentation [ 3 , 4 , 5 ] . Typically, DDPMs use the U-Net architecture [ 6 ] to capture multi-scale spatial dependencies, leveraging its encoder-decoder structure. However, U-Net’s large parameter count poses challenges due to the repeated use across multiple diffusion steps, leading to high computational costs. To overcome these limitations, Neural Cellular Automata (NCA) [ 7 ] offers a lightweight alternative, significantly reducing parameter counts. In NCAs, each pixel is treated as a cell with an internal state that evolves based on interactions with neighboring cells, controlled by a shared neural update function. This efficiency makes NCAs particularly suitable for resource-constrained environments, with their parallelism and simplicity enabling faster training and deployment. This work integrates NCA with DDPM for medical image segmentation and has the following salient features: 1. Model Architecture: We introduce three novel frameworks that target high segmentation accuracy while minimizing computational overhead. (a) Multi-MedSegDiffNCA: A multilevel NCA architecture that refines noise estimates iteratively during backward diffusion. (b) CBAM-MedSegDiffNCA: Enhances feature representation by incorporating global and spatial channel attention using the Convolutional Block Attention Module (CBAM) [ 8 ] , marking a first for applying global attention in NCA. (c) MultiCBAM-MedSegDiffNCA: Combines the benefits of multilevel NCA and CBAM, offering a more generalizable solution. 2. Efficiency: Our models achieve close to state-of-the-art performance while reducing model size by 60-110x, making them ideal for deployment in resource-limited settings. 3. RGB Channel Loss: A novel loss function based on RGB channels guides the diffusion process, leveraging image semantics for better segmentation results. 2 Related Work 2.1 Denoising Diffusion Probabilistic Models Denoising Diffusion Models (DDMs) [ 1 ] have advanced image generation, showing strong performance in inpainting [ 9 ] , segmentation [ 3 , 4 , 5 ] etc. Ho et al. [ 1 ] introduced a forward diffusion process that incrementally adds noise to an image x_{0} over T time steps, followed by a reverse process to reconstruct the original image: p_{\theta}(x_{0:T-1}|x_{T})=\prod_{t=1}^{T}p_{\theta}(x_{t-1}|x_{t})\quad\text{(1)} where p_{\theta}(x_{t-1}\mid x_{t}) represents the transition from step t to t-1 , allowing recovery of clean data from noisy inputs. SegDiff [ 3 ] first applied DDMs for segmentation by iteratively refining segmentation maps. MedSegDiff [ 4 ] enhanced this with a dynamic conditional encoding framework and an FF-Parser to filter out high-frequency noise. MedSegDiff-V2 [ 5 ] further improved segmentation by integrating a transformer encoder with attention mechanisms, allowing for better focus on critical features. 2.2 Neural Cellular Automata (NCA) Neural Cellular Automata (NCA) [ 7 ] integrate cellular automata principles with neural networks, offering a lightweight approach for image processing. NCA models treat image pixels as a grid of cells with internal states that evolve based on interactions with neighboring cells, governed by a shared update function learned by a neural network. This update function uses convolution operations to generate a perception vector, which is then processed to update cell states iteratively. Each update across the grid constitutes an NCA step, refining the image over multiple iterations while maintaining a low parameter count. NCAs have demonstrated effectiveness in image generation [ 10 , 11 ] , segmentation [ 12 , 13 ] , and inpainting [ 14 , 11 ] , offering computational efficiency through parameter sharing. However, their local update mechanism can limit global information propagation in high-dimensional images, as it depends on the number of NCA steps. Adaptations like MED-NCA and M3D-NCA [ 12 , 13 ] address this with multi-level architectures and patch-wise training, reducing VRAM usage. Integrating NCAs with DDPMs [ 15 ] show their potential as a Unet alternative. 2.3 Limitiations of current work State-of-the-art segmentation models, typically based on UNet, have high parameter counts which result in significant computational demands and longer processing times. This complexity can be a bottleneck, especially in resource-constrained settings requiring real-time processing. NCAs offer a promising alternative by drastically reducing parameter counts, from billions to a few hundred thousand [ 12 ] . This efficiency allows NCAs to operate on smaller computational devices, reducing both, training and inference time and easing integration across various platforms, making them suitable for a wider range of applications. 3 Methodology Figure 1 : Multi-MedSegDiffNCA single diffusion step While combining the basic NCA model [ 7 ] with a DDPM backend, there are challenges in efficiently propagating global context with limited NCA steps for higher-dimensional images. To address this, we explored two strategies: 1. Multilevel Pyramidal Architecture: Facilitates global information transfer across low-dimensional representations of images. 2. Guiding Generation with Global Attention: Uses attention mechanisms to ensure important global features are captured during map refinement. Based on these strategies, we introduce three novel NCA architectures: the Multi-MedSegDiffNCA, CBAM-MedSegDiffNCA, and MultiCBAM-MedSegDiffNCA, designed to improve segmentation quality for higher-dimensional images. 3.1 MedSegDiffNCA The MedSegDiffNCA architecture replaces the Basic NCA model as the backbone for noise estimate prediction in the DDPM backend. The NCA comprises c channels, all initialized to zero. The first channel computes diffusion noise loss, while the next three channels are initialized with the RGB channels of the conditional image I . The subsequent channel holds the noise-added segmentation map x_{t} at a specific diffusion time step, and the final channel contains the diffusion time step information t : \epsilon_{\theta}(x_{t},I,t)={NCA_{\theta}[\textbf{0},I,x_{t},...,t]}\quad\text{(2)} Here, \epsilon_{\theta}(x_{t},I,t) represents the noise generation function conditioned on the raw image I , diffusion time step t , and current noisy segmentation map x_{t} . The NCA model performs n iterations at each diffusion time step, with the first channel providing the predicted noise estimate for the reverse diffusion process. 3.2 Multi-MedSegDiffNCA To overcome the slow local propagation of information in NCA models for larger images, we propose Multi-MedSegDiffNCA, which features multiple levels of NCAs. The first level processes downsampled images to enhance global information propagation. As representations and noise estimates are progressively upscaled, the original higher-dimensional inputs replace the downsampled inputs, allowing higher-level NCAs to leverage global embeddings. Unlike MED-NCA [ 12 ] , which refines individual image patches, our approach refines the complete noise map for the backward diffusion process. The implementation features two levels: the original image is downsampled by a factor of 4 in the first level to produce an initial noise estimate. This estimate and the learned hidden channels are then upsampled for refinement in the second level. The refined noise estimate is used in the backward diffusion process as shown in Figure 1 . Figure 2 : CBAM-MedSegDiffNCA single diffusion step 3.3 CBAM-MedSegDiffNCA Basic NCA models [ 3.1 ] produce incomplete segmentations due to limited global image knowledge propagation. To address this, we propose integrating channel and spatial attention mechanisms into the NCA module. However, conventional attention methods like Query-Key-Value (QKV) [ 16 ] suffer from quadratic time complexity, causing significant computational overhead. While the ViTCA model [ 14 ] combines attention with cellular automata, its local-scale operation limits global context capture. To overcome these limitations, we incorporate the Convolutional Block Attention Module (CBAM) introduced by Woo et al. In our CBAM-MedSegDiffNCA model, the input is processed through CBAM before generating the perception vector, enabling the NCA to leverage both channel and spatial attention information while minimizing the computational costs. Figure 2 illustrates the single update rule, demonstrating how the CBAM module is integrated into the NCA model. 3.4 MultiCBAM-MedSegDiffNCA (a) MultiCBAM-MedSegDiffNCA Single diffusion step (b) Qualitative Comparison of Different Losses for Multi-MedSegDiffNCA The MultiCBAM-MedSegDiffNCA integrates the multilevel architecture of Multi-MedSegDiffNCA with the attention mechanisms of CBAM-MedSegDiffNCA, facilitating improved propagation of local information at downscaled levels while preserving global attention in segmentations. This architecture efficiently conveys global contextual understanding across multiple levels, enhancing segmentation quality by focusing on relevant features and spatial locations as illustrated in Figure 3(a) . 4 Experiments 4.1 Dataset For our experiments, we used the ISIC 2018 dataset [ 17 , 18 ] , which includes 2,594 dermoscopic lesion images and corresponding segmentation masks. The masks precisely delineate lesion areas, enabling the model to learn the distinctions between cancerous and healthy skin. The default train/validation/test split is used. 4.2 Loss We utilized two different loss functions in our study. Firstly, standard noise prediction loss L_{n} of DDPM [ 1 , 2 ] was used. L_{n}=\mathbb{E}_{x_{0},\hat{\epsilon},t}\left[\left\|\hat{\epsilon}-\epsilon_{\theta}\left(\sqrt{a_{t}}x_{0}+\sqrt{1-a_{t}}\epsilon,I,t\right)\right\|^{2}\right]\quad\text{(3)} To further guide the NCA model regarding the semantics of the image, we introduce an additional RGB channel loss, L_{RGB} . This loss is the sum of the mean squared error between the RGB channels of the conditional raw image I modified by the NCA model and the ground truth segmentation mask x_{0} . NCA[I(R)] , NCA[I(G)] and NCA[I(B)] are the RGB channels of the raw image I modified by the NCA model respectively \begin{split}L_{RGB}=\left\|NCA[I(R)]-(x_{0})\right\|^{2}+\left\|NCA[I(G)]-(x_{0})\right\|^{2}\\ +\left\|NCA[I(B)]-(x_{0})\right\|^{2}\quad\text{(4)}\end{split} By incorporating L_{RGB} , the NCA channels are trained to extract structural information from the image, generating a preliminary segmentation mask for NCA guidance. The combined loss L_{total} used for training is: L_{total}=L_{n}+L_{RGB}\quad\text{(5)} 4.3 Implementation Details We employed a standard NCA model with a hidden size of 512 in the fully connected layer and 64 channels. Asynchronous activation was simulated by randomly activating 50% of the cells. Input images were resized to 256x256 pixels, and each NCA model ran for 10 steps. The model was trained end-to-end using the AdamW optimizer with an initial learning rate of 1\times 10^{-4} , over 100 diffusion steps and a batch size of 8. For ensemble learning, it was run 10 times, with evaluation metrics including Dice score and Intersection over Union (IoU). 5 Results Table 1 compares the performance of various models. While MedSegDiff and MedSegDiff-v2 achieved Dice scores of 91.3% and IoU of 93.2% in their original papers, these models require significantly more parameters and training time—over five times that of NCA-based models. In our experiments, we reached only 72% Dice after training for five times longer on an NVIDIA V100 GPU, unlike [ 4 , 5 ] which used multiple A100 GPUs. Performance improved with extended training, but resource limitiations prevented full replication of the original results. The MedSegDiffNCA model, which incorporates a basic NCA into the diffusion process, achieved a Dice score of 63.73% and IoU of 51.19% with just 139k parameters. Incorporating the CBAM module into MedSegDiffNCA improved the performance to 68.53% Dice and 53.01% IoU, highlighting the benefits of attention mechanisms. While in the above two cases, the parameter count is significantly lower, the perfrmance is also not very high. However we achieve considerably better performance with Multi-MedSegDiffNCA, with only a small increase in the number of parameters to get a Dice score of 83.9% and an IoU of 74.5%. Table 1 : Comparison of SOTA diffusion-based medical image segmentation and proposed NCA-based architectures Algorithm Dice IoU Parameters MedSegDiff [ 4 ] * 91.3 84.1 25M MedSegDiff-v2 [ 5 ] * 93.2 85.3 46M MedSegDiffNCA 63.73 51.19 139k CBAM-MedSegDiffNCA 68.53 53.01 206k Multi-MedSegDiffNCA 83.90 74.55 410k MultiCBAM-MedSegDiffNCA 87.84 78.86 412k * Results from original paper. Figure 4 : Qualitative Comparison of Different Methods on skin lesion segmentation As image resolution increases, the linear propagation of information in the NCA model becomes a bottleneck, particularly with limited NCA time steps. The multilevel architecture addresses this by enabling efficient propagation of global information in lower dimensions, leading to the improved performance of Multi-MedSegDiffNCA over CBAM-MedSegDiffNCA. The combined MultiCBAM-MedSegDiffNCA model, which integrates the multilevel NCA architecture with the CBAM module, achieves the best performance, with a Dice score of 87.54% and an IoU of 78.86%, while maintaining a low parameter count of 412k—over 60-110 times smaller than the MedSegDiff models. Figure 4 shows a qualitative comparison of segmentations from different methods. The basic NCA model 3.1 produces incomplete and patchy results, while CBAM-MedSegDiffNCA improves segmentation by incorporating channel and spatial attention mechanisms. The use of multilevel architectures further enhances segmentation quality, with MultiCBAM-MedSegDiffNCA delivering the most accurate results. Figure 3(b) compares segmentations from Multi-MedSegDiffNCA trained with standard diffusion noise prediction loss L_{n} versus the combined loss L_{total}=L_{n}+L_{RGB} . Results show that L_{n} alone is insufficient for effective segmentation, while adding L_{RGB} significantly boosts model performance. 6 Conclusion This study integrates Neural Cellular Automata (NCA) with diffusion models for medical image segmentation, introducing the MultiCBAM-MedSegDiffNCA framework. This approach combines a multilevel architecture with a Convolutional Block Attention Module (CBAM) to enhance noise prediction. We propose an RGB channel loss that conditions the model on both the original image and noisy segmentation map, improving training efficacy. Our experiments achieve state-of-the-art performance while reducing model size by over 60-110 times and decreasing training convergence time by more than 5 times. These advancements make our model particularly suitable for resource-constrained medical imaging environments. 7 Compliance and Ethical Standards This research study was conducted retrospectively using human subject data made available in open access [ 17 , 18 ] . Ethical approval was not required as confirmed by the license attached with the open access data.