## 4 Diatom Handcrafted Feature Descriptors
### Local Binary Patterns  
The Local Binary Pattern (LBP) operator is based on the idea that textural properties within homogeneous regions can be represented as patterns [28; 29; 30; 31]. These patterns represent micro-features. It analyzes a \"texture spectrum\", e.g., using a \(3\times 3\) mask and comparing their values with the central pixel. The pixels with a lower value than the central one are labeled with \"0\", otherwise with \"1\". A linear combination is applied where the labeled pixels are multiplied by a fixed weighting function and summed to obtain a label: \(LBP(g_{c})=\sum_{p=0}^{7}s(g_{p}-g_{c})2^{p}\), where \(\{g_{p}|p=0,\ldots,7\}\) are the neighbors of \(g_{c}\), and the comparison function is defined as: \(s(x)=\left\{\begin{array}{ll}1&\text{ if }x\geq 0\\ 0&\text{ otherwise.}\end{array}\right.\)  
\begin{table}
\begin{tabular}{l l} \hline _Energy_ & \(\sum_{i=0}^{H-1}\sum_{j=0}^{H-1}c(i,j)^{2}\) \\ _Variance_ & \(\sum_{i=0}^{H-1}\sum_{j=0}^{H-1}c(i-\mu)^{2}\cdot c(i,j)\) \\ _Contrast_ & \(\sum_{i=0}^{H-1}u^{2}\left(\sum_{i=0}^{H-1}\sum_{j=0}^{H-1}c(i,j)\right)\), \(|i-j|=n\) \\ _Dissimilarity_ & \(\sum_{i=0}^{H-1}\sum_{j=0}^{H-1}|i-j|\cdot c(i,j)\) \\ _Correlation_ & \(\frac{1}{\sigma(g_{c})}\sum_{i=0}^{H-1}\sum_{j=0}^{H-1}i\cdot j\cdot c(i,j)- \mu_{x}u_{y}\) \\ _Autocorrelation_ & \(\sum_{i=0}^{H-1}\sum_{j=0}^{H-1}i\cdot j\cdot c(i,j)\) \\ _Entropy_ & \(T=-\sum_{i=0}^{H-1}\sum_{j=0}^{H-1}c(i,j)\cdot log(c(i,j))\) \\ _Measure of Correlation 1_ & \(\frac{T-HXYI}{max(H,H,H)}\) \\ _Measure of Correlation 2_ & \((1-exp^{2}\cdot(HXY2-T))^{0.5}\) \\ _Cluster Shade_ & \(\sum_{i=0}^{H-1}\sum_{j=0}^{H-1}(i+j-\mu_{x}-\mu_{y})^{3}\cdot c(i,j)\) \\ _Cluster Prominence_ & \(\sum_{i=0}^{H-1}\sum_{j=0}^{H-1}(i+j-\mu_{x}-\mu_{y})^{4}\cdot c(i,j)\) \\ _Maximum Probability_ & \(max(c(i,j))\), \(i=[0..H-1],j=[0..H-1]\) \\ _Sum Average_ & \(\sum_{i=0}^{H-1}i\cdot c_{x+y}(i)\) \\ _Sum Entropy_ & \(\sum_{i=0}^{H-1}c_{x+y}(i)\cdot log(c_{x+y}(i,j))\) \\ _Sum Variance_ & \(-\sum_{i=0}^{H-1}(i-SumEntropy)^{2}\cdot c_{x+y}(i)\) \\ _Difference Entropy_ & \(-\sum_{i=0}^{H-1}c_{x-y}(i)\cdot log(c_{x-y}(i,j))\) \\ _Difference Variance_ & \(\sum_{i=0}^{H-1}l^{2}\cdot c_{x-y}(i)\) \\ _Homogeneity 1_ & \(\sum_{i=0}^{H-1}\sum_{j=0}^{H-1}\frac{c(i,j)}{1+|i-j|^{2}}\) \\ _Homogeneity 2_ & \(\sum_{i=0}^{H-1}\sum_{j=0}^{H-1}\frac{c(i,j)}{1+|i-j|^{2}}\) \\ \hline \(H\) bins number, \(HX\) and \(HY\) entropy of \(p_{x}\) and \(p_{y}\). \\ \(\mu_{x}=\sum_{i=0}^{H-1}\sum_{j=0}^{H-1}i\cdot c(i,j)\); & \(\mu_{y}=\sum_{i=0}^{H-1}\sum_{j=0}^{H-1}j\cdot c(i,j)\) \\ \(c_{x}(i)=\sum_{j=0}^{H-1}c(i,j)\); & \(c_{y}  
The mask may be defined using a circular neighborhood [32], denoted by \((P,R)\), where \(P\) is the number of sampling points and \(R\) is the radius of the neighborhood. [PERSON] et al. [32] observed that over 90% of patterns can be described with few LBP patterns, so they introduced a uniformity measure \(U(LBP_{P,R}(g_{c}))=|s(g_{P-1}-g_{c})-s(g_{0}-g_{c})|+\sum_{p=1}^{P-1}|s(g_{p}- g_{c})-s(g_{p-1}-g_{c})|\), which corresponds to the number of transitions \((0/1)\) in the labeled LBP.  
In this way, the uniform-LBP (\(LBP_{P,R}^{uni}\)) can be obtained as:  
\[LBP_{P,R}^{uni}\left(g_{c}\right)=\left\{\begin{array}{ll}\sum_{p=0}^{P-1}s \left(g_{p}-g_{c}\right)&\text{if }U\left(LBP_{P,R}\left(g_{c}\right)\right)\leq 2\\ P+1&\text{otherwise}\end{array}\right. \tag{6}\]  
After the LPB operator, a labeled image is obtained. Once this process is completed, the pixel-wise information from the labeled image is encoded as a histogram, so that it can be interpreted as a fingerprint of the analyzed diatom area. \(LBP_{P,R}^{uni}\) produces \((P+2)\)-bin histograms [33] where the statistical descriptors are computed. As far as the authors know, LBP has never been tested before for diatom classification. Figure 5 shows some examples of LBP corresponding to some diatom species.