## 3 Material and Method
### Proposed Leaf Vein-Seg Architecture  
The second step after preprocessing is the proposed leaf vein-seg architecture. The powder-like, purplish-white fungi growing mainly on the leaves that makes the plants dry and brown is called powdery mildew [34]. The honey-dew-like insect secretions that form a brownish layer on the leaf of mango plants are called sooty mold. The proposed architecture is a stepwise process that extracts the veins of the leaf. The extracted veins are helpful in further processing and in the classification of diseases of the mango plant. First, the RGB input image is converted to a binary image. The binary image is then converted to a gray-scale image to extract a single channel from the image. CLAHE is applied to it, which improves the quality of the image by improving its contrast. CLAHE operates on small regions of an image called tiles and takes care of the over amplification of contrast in an image [35]. Bilinear interpolation is used to remove artificial boundaries by combining the neighboring tiles. An average filter of 9 \(\times\) 9 is then applied to the output gray-scale image to exclude its background. A mean or average filter smooths the image by reducing the intensity variation among the neighbor pixels. This filter works by replacing the original value of a pixel with the average value of its own and neighboring pixels. It moves pixel-by-pixel through the whole image. An average 9 \(\times\) 9 filter is shown in matrix form below. Mathematically, it can be represented by Equation (1). \[I_{new(x,y)}=\sum_{j=-1}^{1}\sum_{i=-1}^{1}1\times I_{old}(x+i,y+j) \tag{1}\]  
The output is then normalized to make the image pixel values between 0 and 255 as given in Equation (2). \[I_{new(x,y)}^{normalized}=\frac{1}{\sum_{j=-1}^{1}\sum_{i=-1}^{1}1}\sum_{j=-1}^{ 1}\sum_{i=-1}^{1}1\times I_{old}(x+i,y+j) \tag{2}\]  
The edges of the image are detected, and noise is removed by sharpening the image. In the next step, the difference is calculated from the images obtained in the previous two steps: the gray-scale images and the images obtained after the application of the average filer along with its normalization, as the images should be the same size. This step is performed to compare the images and correct uneven luminance. Its mathematical representation is shown in Equation (3):  
\[D(x,y)=I_{1}(x,y)-I_{new(x,y)}^{normalized} \tag{3}\]  
where the output of the gray-scale image is \(I_{1}(x,y)\) and \(I_{new(x,y)}^{normalized}\) is the output after the application of the average filter and its normalization. The threshold is then applied to the obtained images as \(D(x,y)\). A method was designed to perform this task. The global image threshold is computed by setting a threshold level to \(D(x,y)\), obtained in Equation (3). The computed global threshold level is used to convert the intensity image to a binary image. Standardized intensity values lie between 0 and 1. The histogram is segmented into two parts to normalize the image by using a starting threshold value that should be half of the maximum dynamic range. \[H=2B-1 \tag{4}\]  
Foreground and background values are computed by using the sample mean values. Mean values associated with the foreground are (mf, 0), and the gray values associated with the background are (mb, 0). In this way, threshold value 1 is computed and this process is repeated until the threshold value does not change any more. The image obtained is converted to a binary image. The next step is to take the complement of binary image D. All zeros became one and all ones became zero. Mathematically, it can be represented in Equation (5). \[D=D^{\prime} \tag{5}\]Another method was designed to obtain the final segmented output in the form of edges and veins that is used to detect the diseased leaf of the mango plant. It takes as input the binary image obtained in Equation (5) to produce a mask of indicated colors for the output image while using a \(1\times 3\) size vector with values between 0 and 1 for the color.