## 3 Methodology
### Fuzzy Image Classification
#### 3.2.1 Shadow  
In satellite images, it is very likely that shadows will be mistaken for roads, since they both are narrow elongated objects. Hence, it is necessary to label shadow segments in advance. In addition, shadows can help in defining elevated objects [9]. In this research, 2 parameters are used for shadow detection: Brightness and Density, which are explained in this section.  
**Brightness**: Brightness is the mean of gray values of all bands for each pixel/segment given in  
Equation (3).  
\[\text{Brightness} =\frac{\texttt{Red+Green+Blue+NIR}}{4} \tag{3}\]  
Since shadows tend to have low brightness values, here, in order to specify the parameters of the fuzzy function associated with _low brightness_ in the image, an unsupervised image classification method called the fuzzy k-means method is used to find the darkest cluster. The fuzzy k-means clustering method is applied on the image to generate 15 clusters. (Generally, the number of the clusters in the unsupervised classification methods should be between 3 and 5 times of the number of actual classes in the image [29]). Then, the mean and standard deviation of the darkest cluster, amongst all clusters, are used to define the fuzzy function for Shadow brightness. The fuzzy function used in this process is presented in Figure 4a.  
**Figure 4. (a) fuzzy function for Brightness: M is the mean of the darkest cluster and sigma is the associated standard deviation; (b) fuzzy function for Density.**The upper threshold is considered to be mean of the darkest cluster plus three times the associated standard deviation; statistically speaking, in normal distribution, the probability of 99% is given by M + 3\(\sigma\) and that is why in this study the upper threshold equals M + 3\(\sigma\). It is aimed to cover 99% of the shadows, but the membership probability is the least value in this threshold.  
**Density**: Density is a feature presented in eCognition software, which describes the distribution of the pixels of an image object in space [28].  
\[density=\frac{\sqrt{\#P_{\
u}}}{1+\sqrt{\sigma_{X}^{2}+\sigma_{Y}^{2}}} \tag{4}\]  
where, \(\sqrt{\#P_{\
u}}\) is the diameter of a square object with \(\#P_{\
u}\) pixels and \(\sqrt{\sigma_{X}^{2}+\sigma_{Y}^{2}}\) is the diameter of the fitted ellipse to the segment.  
The more the object is like a square, the higher the value of density. Consequently, filament shaped objects have low values of density, which is consistent with the shape of shadows looked for in this study. Here, we look for shadows to help in finding buildings. In this project the majority of shadows had a density less than 1. There are also shadows as well as some other objects with density between 1 and 1.2, which means this range is the fuzzy range of shadow classification. Thus, the membership degree for those segments with the density less than 1 is 100% (the membership degree equals one) and those in between 1 and 1.2 are in the fuzzy range with membership degree ranging from 1 to 0 (Figure 4b). Equations (5) and (6) show the formula for _low_ brightness and density that are associated with Figure 4. In other projects, density of shadows might be slightly different than the mentioned numbers.  
\[\mu_{B}(x)=\begin{cases}1,&\text{for }x{<}M\\ 1-\frac{x-M}{3\sigma},&\text{for }0\leq x-M\leq 3\sigma\\ 0,&\text{otherwise}\end{cases} \tag{5}\]  
\[\mu_{D}(x)=\begin{cases}1,&\text{for }x{<}1\\ 1-\frac{x-1}{0.2},&\text{for }0\leq x-1\leq 0.2\\ 0,&\text{otherwise}\end{cases} \tag{6}\]  
The fuzzy rule used for shadow detection is:  
If **Brightness** is _low_ and **Density** is _low_ then segment is _Shadow_.