## 2 Materials and Methods
### Measurements
#### 2.5.5 Optimization  
Resolution  
The characterizing value resolution can be modified. Higher resolutions provide better information about the colours of an image. Still, they need more data to work correctly because two almost identical colours will fall into different bins, with a consequent increase in the dimension of the \(x\)-values. Higher-resolution values would be necessary in the case of food with many tones of colour, such as meat. The appropriate amount of \(y\)-values characterizing a particular product ensures the correct oxidation pattern. Otherwise, the  
\begin{table}
\begin{tabular}{l} \hline \hline \multicolumn{1}{c}{**MATLAB Code**} \\ \hline _function testImages_ \\ _res = 4; \% Some resolution to calculate histogram at_ \\ _\% Load and process first image_ \\ _II = imread(’NAME1.jpg’); \% Load image and find distance from background colour_ \\ _D1 = sum((double(I1)-repmat(reshape[42 42 46],[I1 3]),[512 512 11])): 2,3);_ \\ _figure_(1); _imshow_(D1\(>\)5000); \% Check that this segments the image adequately_ \\ _C1 = reshape(I1,[512*512 3]); \% C1=C1(D1(:)\(>\)5000,); \% Pull out foreground pixel colours_ \\ _H1 = colourHist(C1,res); \% Compute colour histogram for image_ \\ _% Load and process second image_ \\ _I2 = imread(’NAME1.jpg’); \% Load image and find distance from background colour_ \\ _D2 = sum((double(I2)-repmat(reshape[42 42 46],[I1 3]),[512 512 11])): 2,3);_ \\ _figure_(2); _imshow_(D2\(>\)5000); \% Check that this segments the image adequately_ \\ _C2 = reshape(I2,[512*512 3]); C2=C2(D2(:)\(>\)5000,); \% Pull out foreground pixel colours_ \\ _H2 = colourHist(C2,res); \% Compute colour histogram for image_ \\ _% Show colour histogram of first image and second image together_ \\ _figure_(3); _plot_(1:length(H1),H1,’b-’,I:length(H2),H2,’r-’);_ \\ _function_ = colourHist(ColourVector,Res) \% compute a colour histogram with resolution Res on a vector_ \\ _function_ = colourHist(ColourVector,285)_ \\ _disc = ceil(double(ColourVector)/256*Res);_ \\ _bin = ones(size(ColourVector,I),I);_ \\ _for_ =1;3, _bin = bin + (disc(:,z)-1)*Res(’z-1); end;_ \\ _H = hist(bin,I:Res’3); H=H/sum(H);_ \\ \hline \hline \end{tabular}
\end{table}
Table 2: Developed MATLAB code used for colour quantification.  
grouping of similar samples will not be possible during PCA. In mushrooms, a resolution value of 4 was enough to generate an exact oxidation pattern.  
Background  
It is necessary to be aware of the changes in colour that characterize the analysed samples over time. In mushrooms, deteriorative oxidation causes browning of the fungi body, which significantly influences the applied background colour. The black colour of the background was chosen because it was not present among the analysed sample colours (from white to brown), and it would not be discarded as a part of a sample during segmentation.  
\(y\)-values  
The optimization of \(y\)-values was carried out using the Unscrambler software. It consisted of the rejection of all values that did not significantly affect the oxidation pattern. The values that differed from the others were also eliminated as interfering components of the oxidation pattern.