## 2 Materials and Methods
### Feature Extraction  
The feature extraction is performed using local and global scales. The feature vector is created by extracting features from each different image partition (local and global). An example is shown in Figure 7. The original image (a) is divided into five partitions, (b) four local and one global (the same original image), as shown in Figure 4. The feature vector is obtained from each partition as shown in (c). Since BQMP is applied once, we obtain different values for two representative colors for each sub-image. As in the example shown in Figure 7c, the first representative color is brown with R1 = 78, G1 = 62, and B1 = 39. The other color is pink with R2 = 215, G2 = 80, B2 = 119. Through binarization, we know that brown represents 41% of the image and pink 59%; therefore, H1 = 0.41 and H2 = 0.59.  
To achieve the binarization, the three-dimensional RGB information was transformed in a four-dimensional quaternion. Those quaternions were used to obtain the moments of order 1, 2, and 3, and the moments were used to obtain the equations of momentum conservation, to obtain the representative colors (R1,G1,B1 and R2,G2,B2) and the representative histograms (H1 and H2), as Reference [6] described. The moments were computed using quaternion multiplication that is a four-dimensional operation. For example, in the case of two quaternions \(a=a_{1}+a_{2}i+a_{3}j+a_{4}k\) and \(b=b_{1}+b_{2}i+b_{3}j+b_{4}k\), the product will be equal to \(ab=(a_{1}b_{1}-a_{2}b_{2}-a_{3}b_{3}-a_{4}b_{4})+(a_{1}b_{2}+a_{2}b_{1}+a_{3}b _{4}-a_{4}b_{3})i+(a_{1}b_{3}-a_{2}b_{4}+a_{3}b_{1}+a_{4}b_{2})j+(a_{1}b_{4}+a_ {2}b_{3}-a_{3}b_{2}+a_{4}b_{1})k\). Therefore, even if \(a_{1}\) and \(b_{1}\) are equal to zero, the real part of the multiplication will not necessarily be zero. In the case of the example, this extra information is Q1 = -0.61 in the first color and Q2 = 0.43 in the second color.  
Then, we extracted the 13 Haralick features (explained in Section 2.3) in each sub-image and each color channel, obtaining \(13\times 5\times 3\) = 195 more features to concatenate into the final vector.  
In the texture of Figure 7, we performed only one BQMP iteration in an image from Brodatz database, obtaining only two color representatives. In general, the BQMP method generates \(2^{\text{n}}\) representatives from each image, when n iterations are used. In Figures 5 and 6, an example for a simple color pattern shows the representatives for two iterations, n = 2. In our preliminary experiments, the results did not improve significantly for n \(\geq\) 3, and computational time increased significantly. The feature extraction was performed in local and global scales, so that the representative colors would capture the diversity of the whole image in a local and global manner.  
In the case of more complex textures, it is possible to use more iterations of the BQMP method obtaining more representative colors, histograms, and quaternions. Figure 8 shows the feature extraction from one sample image from the Vistex database (Food0007) using one, two, or three iterations of the method.  
As in the example shown in Figure 8c, the first representative color is dark blue with R1 = 30, G1 = 32, and B1 = 69. The other color is cream with R2 = 217, G2 = 172, and B2 = 106. Through binarization, we know that dark blue represents 74% of the image and cream 26%; therefore, H1 = 0.74 and H2 = 0.26. Q1 and Q2 are 1.49 and \(-\)2.43, respectively. The Haralick features computed from Equations (1)-(13) for the first sub-image are the following: F1 = 1.09 \(\times\) 10\({}^{-4}\), F2 = 2.66 \(\times\) 10\({}^{3}\), F3 = 9.90 \(\times\) 10\({}^{8}\), F4 = 4.75 \(\times\) 10\({}^{3}\), F5 = 2.60 \(\times\) 10\({}^{-2}\), F6 = 1.24 \(\times\) 10\({}^{2}\), F7 = 1.65 \(\times\) 10\({}^{4}\), F8 = 5.28, F9 = 9.32, F10 = 2.43 \(\times\) 10\({}^{-5}\), F11 = 4.63, F12 = \(-\)6.37 \(\times\) 10\({}^{-2}\), and F13 = 6.78 \(\times\) 10\({}^{-1}\).