Feature extraction is a very important issue in pattern recognition and classification. Suitable and discriminative features can efficiently present different contents in the image and offer strong supports for final classification. A large number of features have been proposed, however, we introduce some important and effective features applied for representing the staining patterns in this section. Roughly, we introduce the features from two aspects, i.e., low-level features and mid-level features.
We define the features describe image content from the primitive level as low-level features. It is a relative concept to the mid-level features obtained by using Bag-of- Words (BoW) framework.
Local Binary Patterns
LBP  is initially proposed to describe textural features for a local region. It can be obtained by thresholding the gray value of the circularly symmetric neighbor pixels with that of the center pixel. The neighbors whose difference is positive are set as ‘1’ while others are set as ‘0’. Then, these binary values are converted to a decimal number.
Let I be a grayscale image and I (x, y) be a gray value at location (x, y) in I. Then LBP at location (x, y) is defined as
where I(xit yi) is the gray value of P equal spaced pixels on a circle of radius R around center pixel (x, y) and (xi, yi) is the location of neighbors given by (xi, yi) = (x + R cos(2ni/P), y + R sin(2ni/P))). If the neighbors do not fall in the center of pixels, their gray values should be estimated by interpolation . Figure2.11 illustrates the procedure to obtain LBPp,r value with different (P, R).
The LBPp,r produces 2P different output values, therefore we can calculate the LBPp,r value for each pixel of an image and build a histogram with 2P bins as the image descriptor. The original LBPp,r achieves invariance against any monotonic transformation and the scaling of the gray-scale.
To achieve rotation invariance, a unique identifier is assigned to each rotation invariant LBP , which is formulated by
Fig. 2.11 Local binary patterns with different (P, R)s: (4, 1), (8, 1) and (16, 2) where ROR(x, s) performs circle-right-shift on the binary number x s times. For example, LBPP,R values 10000100b,00100001b and01000010b all map to the unique value 00100001b.
Another extension of original LBP called “uniform” patterns . A uniformity measure U(LBPP,R) is introduced to denote the times of spatial transitions (bitwise 0/1 changes) in the LBPs. For instance, pattern 00000010b and 00111000b have U(LBPP,R) value of 2; pattern 01100010b have U(LBPP,R) value of 4. Uniform LBP assigns different label to each “uniform” pattern and gives a unique number to all the “non-uniform” patterns. The uniform LBP has P(P — 1) + 3 different values. Figure2.12 shows 58 different “uniform” patterns of (8, R) neighborhood. Each “uniform” pattern has an unique label from 1 to 58 and all “non-uniform” patterns (there are 198 patterns are “non-uniform”) are assigned the same label 59. Let UP (i, j) be the label for a “uniform” pattern, where i is the number of ‘1’ in the pattern (row number in Fig.2.12) and j is the rotation degree (column number in Fig. 2.12) The uniform LBP can be formulated as
The “uniform” patterns provide stronger ability of discrimination in comparison to including all patterns, because they have different statistical properties [40, 44]. Most of the LBPs in natural images are uniform. The proportion of “non-uniform” patterns is so small, therefore the estimation of their probabilities is unreliable. Meanwhile, “uniform” patterns are more stable and only considering “uniform” patterns makes the distribution estimation more reliable.
To improve the capability of rotation invariance and elevate the discrimination, some rotation invariant patterns with low occurrence frequencies, i.e., “non-uniform” patterns of rotation invariant LBPs, are eliminate. The improved rotation invariant texture feature can be defined as 
Each rotation invariant “uniform” pattern is assigned a unique label equal to the number of ‘1’ in the pattern, while all the “non-uniform” patterns are labeled by P + 1. Therefore, there are P + 2 different values for LBPrPuR and the final feature is the histogram of LBPrPR accumulated over the entire image.
Fig. 2.12 The different “uniform” patterns in the case of P = 8. The white circle denotes ‘1’ while the dark circle denotes ‘0’