The quality assessment of biomaterials in pathological anatomy is crucial for the optimal diagnosis and treatment of conditions like cancer. This is exemplified in the immunohistochemistry profiling of the human epidermal growth factor receptor 2 (HER2) in breast cancer. Therefore, it is relevant to understand how preanalytical processes, such as post-surgery handling and fixation quality, impact biomaterial quality and diagnostic accuracy. This study investigates first the influence of fixation steps on the performance of HER2 diagnosis. Then a quantitative and automated approach is proposed to correct these biases. This approach is derived from a previous supervised Machine Learning model. The method, which employs a high-performance logistic model, has been further enhanced with a compensation strategy based on tissue quality. This enhancement utilizes a correction derived from a Tissue Quality Index (TQI) to fine-tune the input parameters of the classification model (referred to as TQI-enhancer). Results, obtained from 60 quality control samples with Vimentin and 75 HER2 classification samples, first demonstrate that cold ischemia and fixation times lead to significant changes in immunoreactivity within a short period. Second, adjusting specific parameters quantified in HER2 samples through automated image analysis based on the TQI-Enhancer equation exhibits an improved correlation with the reference diagnosis. This adjustment significantly enhances the classification performance of the logistic classifier in ML-based diagnosis compared to uncompensated data with improved AUC values from 0.84 to 0.93. We anticipate that implementing similar strategies will enhance the performance of digital pathology techniques, ultimately leading to the development of robust diagnostic classifiers for cases of aggressive breast cancer. By analyzing the association between biomarkers like HER2 with patients' clinical outcomes, these classifiers are expected to provide invaluable insights.