WorksComputer Science
SemaNorm: Stain Normalization via Semantic and Morphology Alignment for Robust Cross-Hospital Computational Pathology
Abstract
Stain variability remains a major source of domain shift in computational pathology, yet existing normalization methods largely optimize color consistency without explicitly preserving morphology or diagnostic semantics. We propose SemaNorm, a self-supervised stain canonicalization stain normalizer to recover clean patches from strongly perturbed inputs, avoiding paired transfer, adversarial instability, and identity collapse. It further combines a frozen pathology foundation-model consistency loss with a differentiable nuclei-structure loss to preserve semantic and cellular organization. SemaNorm is evaluated across Camelyon17-WILDS and NCT-CRC-HE-100K using cross-hospital tumor classification, cell-graph morphology metrics, and semantic stability measured with an independent held-out foundation encoder. SemaNorm improves out-of-distribution accuracy by 5.9% over the strongest normalization baseline and by 13.5% over no normalization, while achieving the best morphology preservation. Independent foundation-model and cell-graph analyses further confirm improved semantic and structural stability. These results establish morphology- and semantics-aware optimization as a principled alternative to color-only stain normalization.
Introduction
Hematoxylin and eosin (H&E) staining is most crucial in histopathology, yet the appearance of stained tissue varies substantially across hospital, laboratory, staining protocol, and scanner [1, 2]. Traditional Convolutional Neural Network (CNN) and transformer models trained on source distribution which routinely degrade when applied to slides from an unseen hospital imaging [3, 4, 5]. Addressing this cross-hospital gap is a prerequisite for clinically deployable computational pathology. Stain normalization is the most widely used mitigation. Classical methods such as Macenko [6] and Reinhard [7] match color statistics to a reference, while learned methods such as StainGAN [8] and StainNet [9] translate appearance with neural networks. Despite their diverse formulations, existing stain normalization methods share a common limitation, their optimization objectives are defined exclusively in pixel or color space. As a result, they provide no explicit guarantee of preserving tissue morphology which includes the size, shape, and spatial organization of nuclei and glands that form the basis of pathological diagnosis. Furthermore, tissue morphology correlate with disease grade and progression [10, 11, 12, 13]. While a normalizer can effectively align color distributions, the same optimization process may inadvertently introduce subtle changes in nuclear boundaries and local cellular topology, compromising the morphological structures required by downstream models. A second, more recent consideration further complicates this landscape. Pathology foundation models (FMs) such as UNI [14], Phikon [15], CONCH [16], and Virchow [17] are pretrained with extensive stain augmentation and consequently exhibit substantial stain invariance in their learned feature representations. Although pathology foundation models exhibit increasing robustness to stain variation [18], stain normalization remains an important component of computational pathology workflows. Many deployed systems, including quality control pipelines, segmentation models, and task-specific CNNs, continue to rely on image-level inputs and remain vulnerable to staining differences [19]. Furthermore, normalized images remain valuable for clinical interpretation and visual assessment by pathologists [20]. This motivates the development of normalization approaches that achieve stain consistency while preserving the morphological and semantic structures required for reliable analysis. To address this gaps, we propose SemaNorm stain normalization method that elevates morphology and semantics via explicit training objectives. SemaNorm couples a lightweight normalization network with two consistency terms, FMs embedding-consistency loss that pulls the normalized image toward the semantic representation of a frozen pathology FM, and a differentiable nuclei-structure-consistency loss that preserves cellular morphology. To overcome the instability of adversarial training and the tendency toward identity mapping, we formulate stain normalization as a canonicalization problem. The network is trained to recover the original appearance from aggressively perturbed stains, requiring genuine stain transformation while embedding and morphology constraints prevent content distortion. Our contributions are:
SemaNorm, a stain normalizer that treats diagnostic morphology and FM semantics as explicit, differentiable training objectives, trained via stain-augmentation canonicalization and thereby avoiding both the GAN-instability and identity-collapse failure modes.
A morphology- and semantics-aware evaluation protocol that augments downstream cross-hospital accuracy with cell-graph stability and foundation-model embedding stability measured across two independent encoders, guarding conclusions against single-model artifacts and exposing the structural damage that color-matching normalizers inflict.
Experiments on Camelyon17-WILDS and NCT-CRC-HE-100K showing that SemaNorm delivers the strongest cross-hospital generalization among the evaluated normalizers together with the best morphology preservation, with ablations that isolate the contribution of each component.
Related Work
Stain Normalization
The classical stain normalization matches color statistics between a source and a reference image. Reinhard [7] aligns per-channel mean and standard deviation in LAB space, while Macenko [6] estimates a stain matrix by stain-vector decomposition in optical-density space. Learned approaches cast normalization as image-to-image translation, StainGAN [8] adopts a CycleGAN formulation, and StainNet [9] distills a fast pointwise network. Augmentation-based strategies such as RandStainNA [21] and the analysis of take a complementary route, improving robustness by perturbing stain during training rather than normalizing at inference [3]. SemaNorm differs from all of these by treating morphology and semantic preservation as explicit optimization targets.
Pathology Foundation Models
Large-scale self-supervised histopathology encoders such as UNI [14], Phikon [15], CONCH [16], and Virchow [17] learn representations that are relatively robust to stain variation. We exploit this robustness both as a feature-consistency training signal and as a semantic-preservation probe. Nevertheless, pixel-level normalization remains important for the many conventional clinical and research pipelines that do not use foundation-model features.
Morphological and Graph-Based Tissue Representations
Nuclei segmentation methods such as HoVer-Net [22] and StarDist [23] enable explicit characterization of cellular architecture. Prior work has modeled tissue morphology through manifold- and graph-based representations for carcinoma classification [24], malignancy grading [2], [25], and manifold-constrained deep feature learning [12], [26]. Related studies using quantitative morphometry [1], [27], context aggregation [28], and capsule-based cell classification [29] further demonstrate the diagnostic importance of fine cellular organization. Cell graphs, in which nuclei form nodes and spatial relationships define edges, provide a compact representation of tissue topology [30]. Rather than using such graphs as model inputs, we employ them as a morphology-preservation metric.
Methodology
Overview
Let be an H&E patch and a normalization network producing . We seek a that (a) maps inputs of varying stain appearance toward a canonical appearance, (b) preserves the semantic content captured by a frozen pathology foundation model , and (c) preserves cellular morphology captured by a frozen, differentiable nuclei-structure extractor . Figure 1 summarizes the training pipeline.

Figure 1. Overview of SemaNorm. A lightweight U-Net normalizer (0.52 M parameters) maps a stain-perturbed patch to the canonical appearance of . Training combines pixel reconstruction , foundation-model embedding consistency , and differentiable morphology preservation computed from a frozen soft-hematoxylin structure map. Grey modules are frozen and receive no gradients.
Stain-Augmentation Canonicalization
A reconstruction objective alone permits the trivial identity solution, which minimizes input-output consistency without performing stain normalization. We avoid this degeneracy through self-supervised canonicalization. Given a clean patch , we generate a strongly perturbed view using stain-matrix jitter and color augmentation, and train to recover the canonical appearance:
Since the perturbed input differs from the target, the network must actively correct stain variation rather than copy the input. This removes the identity-collapse failure mode without requiring an adversarial discriminator, thereby avoiding the associated training instability. Figure 2 illustrates the proposed scheme.
Figure 2. Training dynamics of each loss term (log scale) over 30 epochs, for the full model and three ablations. The full SemaNorm objective converges stably on all three terms. Removing stain augmentation drives toward a degenerate low value (the identity mapping), while removing or leaves the corresponding term poorly optimized evidence that the terms are not redundant.
Foundation-Model Embedding Consistency
To preserve semantics, we require the normalized output to match the embedding of the clean patch under a frozen pathology FM :
Because is frozen, gradients update only . Unlike pixel-space objectives, this feature-space constraint promotes preservation of pathology-relevant semantics during normalization. We use one pathology foundation model for training and a separate held-out encoder for evaluation, ensuring that semantic-preservation results are not specific to the model providing supervision (Sec. IV).
Differentiable Nuclei-Structure Consistency
Cell-graph construction (segmentation, centroid extraction, -NN graph) is non-differentiable and cannot serve as a training loss. We therefore rely on a frozen, fully differentiable nuclei-structure extractor the soft nuclei probability map of a pretrained segmentation network and enforce structure consistency directly:
The hard cell graph is held back for evaluation (Sec. V-B), where it supplies an interpretable, non-differentiable audit of morphology preservation that is independent of the differentiable proxy used during training.
Training Objective
The full objective is a weighted sum:
We set , , and , selected on the out-of-distribution validation hospital. is a lightweight U-Net encoder-decoder (0.52M parameters); the full architecture and hyperparameters are given in Sec. IV-D.
Experimental Setup
Datasets
Camelyon17-WILDS [4, 5] contains H&E patches from multiple hospitals, providing a natural cross-site variation in staining and acquisition. We use the official OOD split: hospitals for training, hospital 1 for model selection, and hospital 2 for testing. NCT-CRC-HE-100K provides colorectal histology patches spanning nine tissue classes; its larger field of view and higher nuclear density make it suitable for cell-graph-based morphology analysis.
Baselines
We compare against no normalization (empirical risk minimization, ERM), Reinhard [7], and Macenko [6]. These span the identity, statistics-matching, and stain-decomposition families that dominate practical pipelines and serve as the reference points against which normalization quality is judged.
Evaluation Metrics
For downstream accuracy, we train a ResNet-18 from scratch on normalized patches and evaluate it on the OOD test hospital. A deliberately stain-sensitive backbone is used so that differences in normalization quality remain measurable rather than being masked by a stain-robust encoder. For morphology stability, we use StarDist nuclei and quantify structural preservation through the matched-nuclei fraction, median centroid displacement, and Wasserstein distance between -NN edge-length distributions before and after normalization. We report the cosine similarity between FM embeddings of original and normalized patches for semantic stability, computed independently for two encoders (UNI and Phikon) so that no single model can dominate the conclusion.
Implementation Details
is a U-Net encoder-decoder with 0.52 M parameters. We train with Adam, learning rate , batch size 128, for 30 epochs. The frozen FM used for supervision is Phikon; UNI (ViT-L/16) is held out purely for evaluation. The frozen structure extractor is a pretrained nuclei segmentation network. All experiments use 3 seeds and we report mean std. Downstream ResNet-18 training is identical across every normalization method to keep the comparison fair.
Experiments and Results
Cross-Hospital Tumor Classification
Table I summarizes OOD classification performance. SemaNorm achieves the best cross-hospital generalization, increasing OOD test accuracy by 5.9% over the strongest conventional normalization baseline, Macenko (85.7%91.6%), and by 13.5% compared with unnormalized images (78.1%91.6%). The consistent ranking on the OOD validation hospital further supports the robustness of the approach. Importantly, these gains indicate that incorporating morphology and semantic preservation into the normalization objective improves downstream performance beyond color alignment alone.
| Normalization | OOD Val (Hosp. 1) | OOD Test (Hosp. 2) |
| None (ERM) | 79.2 1.8 | 78.1 2.1 |
| Reinhard | 84.7 1.2 | 83.2 1.8 |
| Macenko | 86.8 1.2 | 85.7 1.4 |
| SemaNorm | 92.8 1.2 | 91.6 1.3 |
Table I. Cross-Hospital Tumor Classification on Camelyon17-WILDS. Accuracy (%), meanstd over 3 seeds.
| Norm. | Matched | Displace. (px) | Edge-Wass. |
| Reinhard | 0.84 | 5.1 | 1.18 |
| Macenko | 0.88 | 2.4 | 0.92 |
| SemaNorm | 0.94 | 1.7 | 0.58 |
Table II. Morphology Stability (NCT-CRC, StarDist nuclei). Arrows show the better direction.
Morphology Preservation
Table II reports cell-graph stability. SemaNorm best preserves nuclei correspondence (highest matched fraction, 0.94; lowest median displacement, 1.7 px) and local topology (lowest edge-length Wasserstein distance, 0.58). The improvement over the classical baselines is consistent across all three metrics, indicating that the downstream gain in Table I coincides with preserved morphology rather than with effect of optimal pixel coordination.
Semantic Stability Across Two Encoders
Table III reports FM embedding stability. Because the embedding-consistency loss is supervised only by Phikon, we additionally probe UNI an encoder never seen during training to verify that semantic preservation is a property of the normalized image rather than of the supervising model. SemaNorm attains the highest cosine similarity to the original embedding under both encoders, confirming that the color-matching baselines shift content, not only color, in FM space.
| Norm. | Phikon (train) | UNI (held-out) |
| Reinhard | 0.942 | 0.931 |
| Macenko | 0.964 | 0.952 |
| SemaNorm | 0.987 | 0.988 |
Table III. Semantic Stability: Cosine similarity between FM embeddings of original and normalized patches (higher is better). UNI is held out and never used for training supervision.
Ablation Study
Table IV reports component-wise ablations obtained by removing each objective in turn. Excluding embedding consistency reduces OOD accuracy by 3% (91.6% 88.6%), highlighting the contribution of semantic preservation. Removing morphology consistency lowers OOD accuracy by 2.4% and decreases the matched-nuclei fraction from 0.94 to 0.87, confirming its role in maintaining cellular structure. The largest degradation occurs without stain-augmentation canonicalization, for which OOD accuracy falls to 75.0%, below all genuine normalization baselines. Together, these results show that canonicalization, semantic consistency, and morphology preservation provide complementary constraints for robust stain normalization.
| Variant | OOD Test Acc. ↑ | Matched ↑ |
| SemaNorm (full) | 91.6 | 0.94 |
| w/o | 88.6 | 0.93 |
| w/o | 89.2 | 0.87 |
| w/o stain-aug (identity collapse) | 75.0 | 0.84 |
Table IV. Ablation on Camelyon17-WILDS OOD test.
Qualitative Results
In Figure 4 shows representative patches normalized by each method. SemaNorm reaches the canonical stain appearance while visibly preserving nuclei boundaries and glandular architecture, whereas the color-statistic baselines either under-correct the stain or flatten fine texture. In Figure 5 decomposes a single patch into its RGB output, hematoxylin and eosin optical-density channels, and soft nuclei-structure map: SemaNorm reproduces the target stain balance while keeping the nuclei-structure map closest to the original, consistent with the quantitative morphology results.

Figure 4. Qualitative comparison on three representative patches. From left: original, Reinhard, Macenko, and SemaNorm. SemaNorm reaches the canonical stain appearance while preserving nuclei boundaries and glandular structure; the color-statistic baselines either under-correct stain or blur fine detail.

Figure 5. Stain deconvolution [31] and structure analysis for one patch. Rows show the RGB output, the hematoxylin and eosin optical-density channels, and the soft nuclei-structure map. SemaNorm reproduces the target stain balance while keeping the nuclei-structure map closest to the original, whereas the baselines shift the hematoxylin/eosin balance and distort the structure map.

Figure 3. Training dynamics of each loss term (log scale) over 30 epochs, for the full model and three ablations. The full SemaNorm objective converges stably on all three terms. Removing stain augmentation drives toward a degenerate low value (the identity mapping), while removing or leaves the corresponding term poorly optimized evidence that the terms are not redundant.
Discussion and Limitations
Even stain-robust foundation models exhibit measurable embedding shifts after conventional normalization (Table III), suggesting that these methods may alter semantic content beyond color appearance. SemaNorm reduces this shift while improving downstream performance for stain-sensitive models. Cell-graph evaluation is more reliable on the larger NCT-CRC patches, as the Camelyon17-WILDS patches contain relatively sparse nuclei. Our semantic and morphology objectives also depend on the fidelity of the frozen encoders and nuclei segmenter, whose errors may propagate into the training signal. Finally, our evaluation covers identity, statistics-matching, stain-decomposition baselines, and two foundation models; future work will extend comparisons to learned normalizers such as StainGAN and StainNet and evaluate generalization across broader tissue acquisition domains.
Conclusion
We presented SemaNorm, a stain normalization method that makes morphology and foundation-model semantics explicit training objectives, trained via stain-augmentation canonicalization to avoid both adversarial instability and identity collapse. Across cross-hospital benchmarks SemaNorm delivered the strongest out-of-distribution accuracy among the evaluated normalizers together with the best morphology preservation, and ablations confirmed the role of each component. The results argue that morphology-preserving normalization remains valuable even as foundation models become the dominant representation in computational pathology.
References
- [1]D. Nawn, S. Pratiher, S. Chattoraj, D. Chakraborty, M. Pal, R. R. Paul, S. Dutta, and J. Chatterjee, “Multifractal alterations in oral sub-epithelial connective tissue during progression of pre-cancer and cancer,” IEEE Journal of Biomedical and Health Informatics, vol. 25, no. 1, pp. 152–162, 2021.
- [2]S. Pratiher, S. Chattoraj, S. K. Agarwal, and S. Bhattacharya, “Grading tumor malignancy via deep bidirectional LSTM on graph manifold encoded histopathological image,” in IEEE International Conference on Data Mining Workshops (ICDMW), 2018, pp. 674–681.DOI
- [3]D. Tellez, G. Litjens, P. Bándi, W. Bulten, J.-M. Bokhorst, F. Ciompi, and J. van der Laak, “Quantifying the effects of data augmentation and stain color normalization in convolutional neural networks for computational pathology,” Medical Image Analysis, vol. 58, p. 101544, 2019.DOI
- [4]P. Bándi et al., “From detection of individual metastases to classification of lymph node status at the patient level: the CAMELYON17 challenge,” IEEE Transactions on Medical Imaging, vol. 38, no. 2, pp. 550–560, 2018.DOI
- [5]W. P. Koh et al., “WILDS: A benchmark of in-the-wild distribution shifts,” in International Conference on Machine Learning (ICML), 2021, pp. 5637–5664.arxiv.org/abs/2012.07421
- [6]M. Macenko, M. Niethammer, J. S. Marron, D. Borland, J. T. Woosley, X. Guan, C. Schmitt, and N. E. Thomas, “A method for normalizing histology slides for quantitative analysis,” in IEEE International Symposium on Biomedical Imaging (ISBI), 2009, pp. 1107–1110.DOI
- [7]E. Reinhard, M. Adhikhmin, B. Gooch, and P. Shirley, “Color transfer between images,” IEEE Computer Graphics and Applications, vol. 21, no. 5, pp. 34–41, 2001.DOI
- [8]M. T. Shaban, C. Baun, R. Navab, and S. Albarqouni, “StainGAN: Stain style transfer for digital histological images,” in IEEE International Symposium on Biomedical Imaging (ISBI), 2019, pp. 953–956.arxiv.org/abs/1804.01601
- [9]H. Kang, D. Luo, W. Feng, S. Zeng, T. Quan, J. Hu, and X. Liu, “StainNet: A fast and robust stain normalization network,” Frontiers in Medicine, vol. 8, p. 746307, 2021.DOI
- [10]J. Abel and S. D. J. et.al., “Ai powered quantification of nuclear morphology in cancers enables prediction of genome instability and prognosis,” NPJ Precision Oncology, vol. 8, 2024.DOI
- [11]C. Lu, D. Romo-Bucheli, X. Wang, A. Janowczyk, S. Ganesan, H. Gilmore, D. L. Rimm, and A. Madabhushi, “Nuclear shape and orientation features from h&e images predict survival in early-stage estrogen receptor-positive breast cancers,” Laboratory investigation: a journal of technical methods and pathology, vol. 98, pp. 1438 – 1448, 2018.DOI
- [12]S. Chattoraj, S. Pratiher, R. Mukherjee, S. Ghosh, A. Chakraborty, K. Hazra, and S. Pratiher, “Efficacy of deep convolutional neural network features on histological manifold for robust breast carcinoma detection,” in SPIE/COS Photonics Asia, 2018.DOI
- [13]V. Subedi, S. N. K. Rajakaruna, P. Sarkar, S. Chattoraj, A. Khasa, S. Nandy, H. Farooq, A. Biswas, S. Chaudhuri, A. K. Dey, K. P. Joshi, C. Lenglet, and A. Chatterjee, “Data-driven techniques for translational neuroscience and personalized neuro-health,” 2026.arxiv.org/abs/2608.13749
- [14]R. J. Chen et al., “Towards a general-purpose foundation model for computational pathology,” Nature Medicine, vol. 30, pp. 850–862, 2024.DOI
- [15]A. Filiot, R. Ghermi, A. Olivier, P. Jacob, L. Fidon, A. Mac Kain, C. Saillard, and J.-B. Schiratti, “Scaling self-supervised learning for histopathology with masked image modeling,” medRxiv, 2023.DOI
- [16]M. Y. Lu et al., “A visual-language foundation model for computational pathology,” Nature Medicine, vol. 30, pp. 863–874, 2024.DOI
- [17]E. Vorontsov et al., “A foundation model for clinical-grade computational pathology and rare cancers detection,” Nature Medicine, vol. 30, pp. 2924–2935, 2024.DOI
- [18]D. Tellez, G. Litjens, P. Bult, J.-M. Bokhorst, F. Ciompi et al., “Quantifying the effects of data augmentation and stain color normalization in convolutional neural networks for computational pathology,” IEEE Transactions on Medical Imaging, vol. 38, no. 9, pp. 2242–2253, 2019.DOI
- [19]D. Komura and S. Ishikawa, “Machine learning methods for histopathological image analysis,” Computational and Structural Biotechnology Journal, vol. 16, pp. 34–42, 2018.
- [20]K. Bera, K. A. Schalper, D. L. Rimm, V. Velcheti, and A. Madabhushi, “Artificial intelligence in digital pathology—new tools for diagnosis and precision oncology,” Nature Reviews Clinical Oncology, vol. 16, pp. 703–715, 2019.DOI
- [21]Y. Shen, Y. Luo, D. Shen, and J. Ke, “RandStainNA: Learning stain-agnostic features from histology slides by bridging stain augmentation and normalization,” in Medical Image Computing and Computer Assisted Intervention (MICCAI), 2022, pp. 212–221.DOI
- [22]S. Graham, Q. D. Vu, S. E. A. Raza, A. Azam, Y. W. Tsang, J. T. Kwak, and N. Rajpoot, “Hover-net: Simultaneous segmentation and classification of nuclei in multi-tissue histology images,” Medical Image Analysis, vol. 58, p. 101563, 2019.DOI
- [23]U. Schmidt, M. Weigert, C. Broaddus, and G. Myers, “Cell detection with star-convex polygons,” in Medical Image Computing and Computer Assisted Intervention (MICCAI), 2018, pp. 265–273.DOI
- [24]S. Pratiher and S. Chattoraj, “Diving deep onto discriminative ensemble of histological hashing and class-specific manifold learning for multi-class breast carcinoma taxonomy,” in IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), 2019, pp. 1025–1029.arxiv.org/abs/1806.06876
- [25]R. Agrawal, M. Tadepalli, A. Mittal, A. Singh, S. Kiran, S. Chattoraj, S. Sathyamurthy, and P. Putha, “Performance of a deep-learning algorithm in detecting and discriminating nodules on chest radiographs,” CHEST, 2023.DOI
- [26]S. Chattoraj, S. Chatterjee, and K. P. Joshi, “Geometry-routed attention for multi-magnification histopathology fusion in oral squamous cell carcinoma,” Sep. 2026. [Online]. Available: https://doi.org/10.5281/zenodo.22945256
- [27]A. Govindarajan, A. Govindarajan, S. Tanamala, S. Chattoraj, B. Reddy, R. Agrawal, D. B. Iyer, A. Srivastava, P. Kumar, and P. Putha, “Role of an automated deep learning algorithm for reliable screening of abnormality in chest radiographs: A prospective multicenter quality improvement study,” Diagnostics, vol. 12, 2022.DOI
- [28]S. Pratiher, S. Chattoraj, D. Nawn, M. Pal, R. R. Paul, H. Konik, and J. Chatterjee, “A multi-scale context aggregation enriched MLP-mixer model for oral cancer screening from oral sub-epithelial connective tissues,” in European Signal Processing Conference (EUSIPCO), 2022, pp. 1323–1327.DOI
- [29]S. Chattoraj, A. Chakraborty, A. Gupta, Y. Vishwakarma, K. Vishwakarma, and J. Aparajeeta, “Deep phenotypic cell classification using capsule neural network,” in Annual International Conference of the IEEE Engineering in Medicine and Biology Society (EMBC), 2021, pp. 4031–4036.DOI
- [30]P. Pati et al., “Hierarchical graph representations in digital pathology,” Medical Image Analysis, vol. 75, p. 102264, 2022.arxiv.org/abs/2102.11057
- [31]A. C. Ruifrok and D. A. Johnston, “Quantification of histochemical staining by color deconvolution,” Analytical and Quantitative Cytology and Histology, vol. 23, no. 4, pp. 291–299, Aug. 2001.pubmed.ncbi.nlm.nih.gov/11531144