## 2 Materials and Methods
### Color Deconvolution  
The mammary gland slides stained for ESR and ERBB2 include diaminobenzidine (DAB) stain, which has a brown-dominating appearance and oftentimes significant background staining that makes it very distinct from all other stained slides. Therefore, the hereby proposed approach applies color deconvolution [30; 31] only to these slides to distinctly separate the color components of the original images into artificially reproduced _DAB-_, _FastRed-_, and _FastBlue_-stained slides. The intention of this deconvolution is to avoid potential mis-registrations and increase the ability to better assess the underlying tissue structure by lowering the brown-dominating background artefactual appearances from the DAB stain.  
An example of this process is shown in Figure 3, where this method was used to artificially reproduce and separate the individual contributions of the _DAB_, _FastRed_, and _FastBlue_ stains from the original image. Specifically, the optical density (OD) of the _DAB_, _FastRed_, and _FastBlue_ stains are decomposed in their red (R), green (G), and blue (B) channels. Each OD vector is then normalized by its total length, such that each stain forms a normalized RGB triplet. In our case, the OD matrix representing the set of triplets for _FastRed_, _FastBlue_, and _DAB_ stains is represented as  
\[\begin{array}{cccc}&R&G&B\\ FastRed&0.2140&0.8517&0.4782\\ FastBlue&0.7489&0.6062&0.2673\\ DAB&0.2681&0.5703&0.7764\\ \end{array} \tag{1}\]  
Figure 2: Example histologic images from the various anatomical sites included in the ANHIR dataset, i.e., (**A**) lung lesion, (**B**) kidney, (**C**) colon adenocarcinoma, (**D**) gastric, (**E**) mice kidney, (**F**) lung lobes, (**G**) breast, and (**H**) mammary gland.  
The color deconvolution matrix is the inverse of this OD matrix and, as detailed in [30], it expresses the mechanism to obtain the corrected contribution of each artificially reproduced stain to the overall image, as if the image was stained using all of them. Here, the color deconvolution matrix is calculated as  
\[\begin{array}{cccc}&R&G&B\\ FastRed&-1.3283&1.6219&0.2597\\ FastBlue&2.1280&-0.1584&-1.2561\\ DAB&-1.1044&-0.4437&2.1210\end{array} \tag{2}\]  
Each row of this matrix represents the factor of the relevant channel/column in the original image that best approximates the contribution of the relevant artificially reproduced stain to the overall image. Negative signs denote information getting subdued and positive signs denote amplification. For example, to obtain the contribution of the _FastBlue_ stain, we must subdue portions of the G and B channels by factors of \(-0.1584\) and \(-1.2561\), respectively, while amplifying the R channel by a factor of 2.1280.  
As shown in the example results of Figure 3, we observed that the contributions of the artificially reproduced _FastBlue_ stain (Figure 3C) retained all the tissue structure information while omitting the background brown-dominating artefact due to the DAB  
Figure 3: Example results of the applied color deconvolution in a diaminobenzzidine (_DAB_)-stained slide, illustrated in (**A**) color deconvolution artificially reproducing and separating the contributions of (**B**) _FastRed_, (**C**) _DAB_, and (**D**) _FastBlue_ stains.  
stain (Figure 3D). Therefore, we decided to keep the contribution of the _FastBlue_ stain to estimate the transformation between the given consecutive slides.