## 4 Feature Extraction
### Granulometry-Based Descriptors (GBD)
: _A granulometry [4; 5] is a family of openings \(\Gamma=\{\gamma_{\lambda}:\lambda\geq 0\}\), which has the following property:_  
\[\forall\mu\geq 0,\ \gamma_{\lambda}(\gamma_{\mu})=\gamma_{\mu}(\gamma_{\lambda})= \gamma_{\max\{\lambda,\mu\}}. \tag{13}\]  
**Definition 8** (Anti-granulometry). : _An anti-granulometry is given by a family of closings \(\Phi=\{\varphi_{\lambda}:\lambda\geq 0\}\), such that_  
\[\forall\mu\geq 0,\ \varphi_{\lambda}(\varphi_{\mu})=\varphi_{\mu}(\varphi_{ \lambda})=\varphi_{\max\{\lambda,\mu\}}. \tag{14}\]  
(In this paper, for simplicity, all granularometries and anti-granulometries will be called _granulometry_.) Let \(\Psi=\{\varphi_{\lambda}:\lambda\geq 0\}\) be a granululometry. In the granulometric analysis, the amount of sieved structures by \(\psi_{\lambda}\) is computed for each increment of \(\lambda\). Let \(\Omega(\Psi)\) be the _size distribution_ of \(\Psi\) such that \(\forall\lambda\geq 0\), \(\Omega(\Psi)(\lambda)\) is the amount of sieved structures by \(\psi_{\lambda}\)[5]. Note that since \(\Omega(\Psi)(\lambda)\) increases as \(\lambda\) is incremented, \(\Omega(\Psi)\) is an increasing function. **Definition 9** (Opening Top-Hat). : _Let \(f\) be an image. The opening top-hat is given by_  
\[th(\gamma)(f)=f-\tau(f).\]  
**Definition 10** (Closing Top-Hat). : _Let \(f\) be an image. The closing top-hat is given by_  
\[th(\varphi)(f)=\varphi(f)-f.\]  
Note that the opening top-hat and closing top-hat are residual operators, which gives the sieved structures (the residue) by application of their respective morphological filters. \[\gamma_{B,B_{c}}^{\mathtt{rec}}(f)=\delta_{B_{c}}^{\mathtt{rec}}(\epsilon_{B }(f),f), \tag{8}\]0 Pixels affected by application of a opening by reconstruction and of a closing by reconstruction, using a disk structuring element with radius one. Let \(\Psi=\{\psi_{\lambda}:\lambda\geq 0\}\) be a granulometry. Let \(\sum f=\sum_{x}f(x)\) be the sum of all intensities \(f(x)\) from an image \(f\). The size distribution of \(\Psi\) is given by, \(\forall\lambda\geq 0\),  
\[\gamma_{B,B_{c}}^{\mathtt{rec}}(f)=\delta_{B_{c}}^{\mathtt{rec}}(\epsilon_{B }(f),f), \tag{8}\]1  
In this measurement, \(\Omega(\Psi)(\lambda)\) gives the sum of the volumes of all structures sieved by \(\psi_{\lambda}\). Let \(\beta(f)\) be the binarization function, which is given by  
\[\beta(f)(x)= \begin{cases}1&\text{if }f(x)>0\\ 0&\text{otherwise.}\end{cases} \]  
Let \(\Psi=\{\psi_{\lambda}:\lambda\geq 0\}\) be a granulometry. The _binary size distribution_\(\Omega_{\beta}(\Psi)\) is given by \(\forall\lambda\geq 0\),  
\[\Omega_{\beta}(\Psi)(\lambda)=\sum\beta(th(\psi_{\lambda})). \tag{16}\]  
In this measurement, \(\Omega_{\beta}(\Psi)(\lambda)\) gives the number of pixels of all structures sieved by \(\psi_{\lambda}\). Each one of the GBD assessed in this work is built as described in Algorithm 2. ```
Input:\(img\): Color image under the RGB color space model, binary: Boolean value: TRUE for binary granulometry; FALSE for gray level granulometry Output:\(\Psi=\{\psi_{\lambda}:1\leq\lambda\leq 50\}\): Feature vector with 50 elements. \(img_{r}\gets img\) red band \(img_{g}\gets img\) green band \(img_{b}\gets img\) blue band \(f\gets img_{r}+img_{g}+img_{b}\) ifbinuarythen forach\(\lambda\in[1,\cdots,50]\)do \(\Omega(\Psi)(\lambda)\leftarrow\sum\beta(th(\psi_{\lambda})(f))\) else forach\(\lambda\in[1,\cdots,50]\)do \(\Omega_{\beta}(\Psi)(\lambda)\leftarrow\sum th(\psi_{\lambda})(f)\)
```  
**Algorithm 2**Pseudocode for Granulometry-Based Descriptors. Table 2 summarizes the set of twelve GBD tested in this work. Figure 4 illustrates the construction of a size distribution \(\Omega(\Gamma)\) from a granululometry given by a family of openings by reconstruction. For each \(\lambda\), a disk structuring element \(B_{\lambda}\) of radius \(\lambda\) was used by the filter \(\gamma^{\text{rec}}_{B_{\lambda},B_{\lambda}}\). The residue of such a filter is summed and taken as the \(\lambda\)-th component of the feature vector.