## 3 Proposed Method  
### Color Matching Algorithm  
In this work, the main objective was to develop an approach for determining vitamin C based on the color change of the solution influenced by its concentration. Therefore, a crucial step in achieving a high-quality regression model was performing the color standardization procedure on the photographed vitamin C samples. The proposed color standardization algorithm was divided into two parts. In the first step, standard histogram matching was performed between a digital color template and a photograph of a printed template obtained under a given lighting condition. In the second step, histogram matching was performed between a photo of the solution (tested sample) taken under the same illumination as the pattern and the reference template. In the end, 512 smaller random squares were cut from the reconstructed image to obtain a sufficiently large dataset for the subsequent training of the regression neural network. The number of randomly selected small squares was optimized, as preliminary calculations showed that insufficient data resulted in lower model quality. It was also necessary to take an additional step of adapting the self-designed reference template to the appropriate value range. This operation resulted in the development of an adapted histogram-matching algorithm. Histogram matching is an operation in which the pixels of an input image are manipulated in a way that allows its histogram to match the histogram of the reference image. In this work, the RGB color space was chosen for the calculations. It is widely available and popular, as most cameras and image capture devices record data directly in RGB format, eliminating the need for additional color space transformations. The RGB space is also simple to implement, being intuitive and directly related to the physical properties of light, which simplifies algorithm development. Additionally, in our specific application, RGB has proven to give satisfactory results. Therefore, despite the advantages of other color spaces, RGB was the most suitable for practical and technical reasons. In the case of color images, each channel (RGB) was considered independently. In the context of image processing, this was a normalization task, associated with, for example, changing illumination (Figure 1). In mathematical terms, histogram matching can be represented as an image transformation such that the cumulative distribution function (CDF) of the values in each band corresponds to the CDF of bands in another image. To match the histograms of two images, it is necessary to equalize their histograms. After that, each pixel of the first image is modified and mapped to the second image. This operation was performed for each of the channels (R, G, B) of a photographed template under a given lighting condition (natural light and artificial light) and for the channels of a digital template. The whole process of picture color transformation is represented in Figure 2.  
In order to standardize the images of the tested chemical solutions, the correct range of RGB values was selected from the histograms of the photo of the tested sample. If the histogram value for a sample was greater than or equal to 1% of the maximum value of the chemical solution histogram, the histogram value was not modified, otherwise it was set to 0. The discrepancy in the number of pixels was neutralized by their uniform random distribution across the range of values. The final step in the standardization algorithm was to match the histograms of an image of a solution with the adapted template histograms. This was done in the same way as described in Figure 3, followed by the reconstruction of an image from the R, G, and B channels. Figure 1: Example of histogram matching for illustrative purposes. Figure 3: Vitamin C solutions (0, 4.54, 11.31, 18.05, 22.52, 33.63, 44.64, 66.37, and 87.72 \(\upmu\)g-mL\({}^{-1}\)) in the presence of double-distilled water, acetate buffer, ammonium iron(III) sulfate, and orthophenanthroline.