## 3 Methodology
### Image Preprocessing  
In order to extract the GLH statistical parameters in later steps, the RGB image is firstly converted into a grayscale image using Equation (1),  
\[f(x,y)=a_{1}*R(x,y)+a_{2}*G(x,y)+a_{3}*B(x,y),\ \forall a_{1}+a_{2}+a_{3}=1, \tag{1}\]  
where \((x,y)\) is the location of a pixel in the pixel matrix of an image; \(f(x,y)\) is the grayscale value comprising a pixel intensity level between 0 and 255; \(R(x,y),\ G(x,y),\ B(x,y)\) represent the red, green and blue values of the pixel located in \((x,y)\), respectively; \(a_{1},a_{2}\) and \(a_{3}\) are weighting factors that are automatically adjusted according to the R, G, B values of a given image. An edge is defined as the abrupt change of gray levels in a grayscale image [44], providing indications of the physical extent of an object. In a continuous domain edge segment \(F(x,y)\), the continuous gradient \(G(x,y)\) is calculated along a certain direction. The edge is detected if the gradient \(G(x,y)\) is above a given threshold value. The gradient \(G(x,y)\) can be computed by Equation (2),  
\[G(x,y)=\frac{\partial F(x,y)}{\partial x}cos\varphi+\frac{\partial F(x,y)}{ \partial y}sin\varphi, \tag{2}\]  
where \(\varphi\) is the angle between \(F(x,y)\) and the horizontal axis. In a discrete grayscale image which is a \(M\times N\) pixel matrix with \(M\) rows and \(N\) columns of pixels, a row gradient \(G_{R}(j,k)\) and a column gradient \(G_{C}(j,k)\) can be calculated using Equation (3),  
\[\left\{ \begin{array}{l}G_{R}(j,k)=F(j,k)-F(j,k-1),\ j=0,1,\ldots,M-1;k=0,1, \ldots,N-1;\\ G_{C}(j,k)=F(j,k)-F(j+1,k),\ j=0,1,\ldots,M-1;k=0,1,\ldots,N-1;\end{array} \right., \tag{3}\]  
where \((j,k)\) is the coordinate of a pixel in the matrix, in which the coordinate of the first pixel (in the top-left corner) is (0,0). The row and column gradients \(G_{R}(j,k)\) and \(G_{C}(j,k)\) can be alternatively computed by using impulse response matrix, Equation (4):  
\[\left\{ \begin{array}{l}G_{R}(j,k)=F(j,k)\times H_{R}(j,k)\\ G_{C}(j,k)=F(j,k)\times H_{C}(j,k)\end{array} \right., \tag{4}\]  
where \(H_{R}(j,k)\) and \(H_{C}(j,k)\) are row- and column-impulse response matrix, respectively, which can be defined by given edge-detection operators: the Prewitt operator [45], the [PERSON] operator [46], the [PERSON] operator [47], and the Canny operator [48]. Among these operators, the Prewitt operator is distinguished by its capability of detecting the horizontal and vertical edges [49], defined by Equation (5) and Equation (6), respectively:  
\[H_{R}(j,k)=\frac{1}{3}\!\left[ \begin{array}{ccc}1&0&-1\\ 1&0&-1\\ 1&0&-1\end{array} \right] \tag{5}\]  
\[H_{C}(j,k)=\frac{1}{3}\!\left[ \begin{array}{ccc}-1&-1&-1\\ 0&0&0\\ 1&1&1\end{array} \right]\!\!. \tag{6}\]  
However, the edge-detection operator can only result in a discrete edge map composed of isolated boundary points without knowing which points lie on the same lines. Therefore, coupled with edge-detection operators, line-detection techniques should be used to extract lines from the discrete edge map. The Hough transform [50] is widely used for retrieving line information from edge maps, due to its powerful ability in dealing with pixels that are missing or spurious as a result of noise produced by image defects or edge-detector imperfections. In a discrete binary image, such as an edge map producedby the Prewitt operator, each non-zero point \((x,y)\) in the Cartesian coordinate space is transformed into a line in the polar coordinate space \((\rho,\theta)\) using Equation (7), where \(\rho\) is the perpendicular distance from the image's origin point to the line, restricted to [\(-\)D, D], with D being the half-diagonal size of the image; and \(\theta\) is the angle between the normal of the line and the x-axis of the image, restricted to [\(-90^{\circ},90^{\circ}\)]. After transformation, lines are quantized into cells A \((\rho,\theta)\) whose initial values are 0.