Studies on Automatic Image Segmentation Method for Canopy Density Measurement of Chinese Alligator ( Alligator sinensis ) Habitat

.


INTRODUCTION
T he Chinese alligator (Alligator sinensis) is a nationallevel protected animal endemic to China, mainly found around lakes, ponds, and swamps in the lower reaches of the Yangtze River. The construction of transportation networks, over-hunting, pesticide and fertilizer abuse, and climate change has greatly affected the habitat of the Chinese alligator over past half century, leading to further fragmentation of its habitat (Thorbjarnarson and Wang, 2010;Zhang et al., 2015). Although the government has made great efforts to protect the population of Chinese alligator in recent years, there are only about 200 individuals in the wild according to 2019 statistics, mainly distributed in counties of Xuanzhou, Jingxian, Guangde, Langxi, and Nanling. The distribution map is shown in Figure 1. The population of the Chinese alligator needs recovery. The expansion speed of wild Chinese alligator populations is strongly related to effective reproduction in the wild (Zhou, 2009). In the wild, the alligators use withered branches and leaves to build their nests. Sunlight and the decaying nesting material keep the nests warm for egg hatching. Therefore, temperature, humidity, and the canopy density of nesting location are important factors that affect the growth and reproduction of alligators (Zhang et al., 2006;Xia, 2009;Wang et al., 2011). The canopy density, cover ratio of vegetation to the ground,

O n l i n e F i r s t A r t i c l e
severely affect the temperature, humidity, and seclusion of the alligator habitat, thus greatly influencing the cycle of nest-building and the nest site selection. Please note that inappropriate canopy is not suitable for alligator to build nests and spawn, as the canopy density affects the photoperiod, relative humidity, and temperature of a field. A low nest temperature prevents the development of early embryos and female alligators delay the egg laying until suitable conditions are available (Wang and Xia, 2005). The hot and humid environment accelerates the metabolism and activity of alligators, which promotes the behavior of egg laying and nest building (Zeng and Fang, 2011). Therefore, the canopy density is a key parameter for studying the nest site selection of Chinese alligator and evaluating the habitat. In order to measure the canopy density quickly and accurately, this study aims to provide a new method for the measurement of canopy density of Chinese alligator habitat. However, there is no standardized method proposed for canopy density measurement. The measuring methods are limited by the study object and the technology level. In earlier years, the common measuring method for canopy density included visual inspection or spherical or vertical densitometry method (Fiala et al., 2006;Korhonen et al., 2006). After the availability of digital cameras, digital image based photographic methods are used for measuring the canopy density (Qi et al., 2009;Lang et al., 2010). As compared with non-photographic methods, the computer image-based photographic methods are convenient in terms of data acquisition, and advanced digital image analysis techniques can be used for computing the canopy density to achieve a higher accuracy. Based on the type of lens being used, the photogrammetric methods can be divided into conventional and hemispherical photogrammetric methods. The lens used in the conventional photogrammetric methods is aberration-free. On the other hand, in the hemispheric photogrammetric methods, 180° fisheye lens is used (Yamada et al., 2017;Smith and Ramsay, 2018). The images captured by the hemispheric photogrammetric method contain a wider range of environmental information. The canopy density measured with hemispheric photogrammetric method may be influenced by the shrubs (Smith and Ramsay, 2018). Based on the direction of photo shoot, the photogrammetric methods can be divided into top-down and bottom-up photogrammetric methods. The top-down photogrammetric methods use drones or remote sensing technology to acquire image data from above, whereas the bottom-up photogrammetric methods use digital cameras for acquiring image data from the surface (Chianucci et al., 2018;Bera et al., 2020;Chen et al., 2022). Considering that the Chinese alligator is a reptile and its visual range is closer to the bottom-up image shoot direction, the bottomup photogrammetric method is used commonly to measure the canopy density of the habitats of Chinese alligator (Yang et al., 2017;Wang et al., 2021a, b).
Due to its convenience, the photogrammetric method for canopy density measuring is widely used. The threshold segmentation method based on manual threshold selection is generally used to segment the canopy density images. This method can be used in image editing software, such as Adobe Photoshop, ImageJ, and GIMP (GNU Image Manipulation Program) (Stewart et al., 2007;Campillo et al., 2008;Smith and Ramsay, 2018). However, this method is time-consuming and laborious. In addition, it is greatly influenced by human subjectivity. In the study of Chinese alligator habitat, the canopy density image is usually segmented by an automatic pixel clustering method in Arc view GIS (Sun et al., 2005). However, the accuracy of this method is lower than the threshold segmentation method.
Automatic threshold segmentation is a common method used for image segmentation. This method is simple, has low computational complexity and is easily deployable. However, when the automatic threshold segmentation method is used for canopy density measurement, the automatic threshold selection becomes a key step, which directly affects the measurement results (Guo et al., 2015;Song et al., 2016). Currently, the well-known image threshold segmentation methods include the fixed threshold method, the bimodal method, the iterative method, and the Otsu's method (maximum interclass variance method) (Xu et al., 2011;Wang et al., 2017;Sharma, 2021). The fixed threshold method and the normal bimodal methods select the thresholds manually, and are unable to segment the images automatically. On the other hand, the iterative method and Otsu's method automatically search the best threshold value based on the variation relationship between the gray values of image pixels. However, since color of the sky and the vegetation in image varies with light intensity, cloud thickness, and vegetation type change, the segmentation threshold obtained using the iterative and Otsu's methods generally deviate from the optimal segmentation thresholds, leading to biased results in the measurement of canopy density. To the best of our knowledge, no reliable automatic threshold segmentation method has been reported for canopy density measurement based on photogrammetric method.
In this work, an adaptive bimodal threshold segmentation method is established for the photogrammetric method of canopy density measurement. The accuracy of the proposed method is compared with the accuracies of iterative method and Otsu's method. Then, the adaptability of the proposed method in different weather conditions and images containing different canopy O n l i n e

F i r s t A r t i c l e
density levels is evaluated.

Experimental materials
The images of canopy density are acquired in three protected areas, including Gaojingmiao Forestry Farm (119°17'E, 31°04'N), Wuhu Alligator Farm (118°43'E, 31°30'N), and Xuan Cheng Alligator Breeding Center (118°78'E, 30°90'N) in Anhui Province, China. Each image is captured from bottom to the top by digital cameras in BMP format. The resolution of each image is 3880 × 5184 pixels. The vegetation in these images includes trees, shrubs, and bamboos. In this experiment, 804 images of canopy density in the habitat of Chinese alligator are used to perform analysis. Among these images, 247 images are captured on cloudy days (without direct sunlight), 557 images are acquired on sunny days (with direct sunlight), 51 images are acquired in the environment of lower canopy density (0, 0.3), 246 images are acquired in the environment of medium canopy density (0.3, 0.7), and 507 images are acquired in the environment of high canopy density (0.7, 1).

Image segmentation and canopy density calculation
As shown in Figure 2a, image of canopy density contains sky area and vegetation area. Accurately segmenting the sky region is the key step in canopy density calculation by photogrammetric methods. The segmentation method selects a threshold T and transforms the gray image into binary image based on (1), where the white area denotes the sky area (pixel value is 1) and the black area denotes the vegetation area (pixel value is 0), as shown in Figure 2b. The ratio between the vegetation area and the total area of the image is calculated as the canopy density based on (2).
Where, x and y represent the horizontal and vertical coordinates of the image, respectively, f(x, y) represents the pixel value of the point (x, y), and T represents the segmentation threshold.
where, CD represents the canopy density, S 1 represents the number of pixels with value 0, and S represents the number of all pixels. The segmentation threshold T determines the size of the sky region segmented from the canopy density image and affects the accuracy of the canopy density calculation. Therefore, the correct threshold T is the key to obtain accurate canopy density.

Manual threshold selection method
At present, the manual methods of segmentation threshold selection are widely used in segmentation of canopy density image. This method selects the appropriate segmentation threshold based on human vision. Afterwards, it uses the threshold to segment the image for obtaining the binary image. Finally, it used (2) to calculate the canopy density.
The method of manual segmentation threshold is selected as follows. Adobe Photoshop 2021 software (Adobe Inc., USA) is used to read and process the canopy density image. The threshold tool is used to display the histogram of the B component of the image, and the threshold slider is manually dragged to adjust the segmentation threshold for appropriately segmented image. Thus, the optimal segmentation threshold is selected.

Otsu's method
The Otsu's method, also named as maximum interclass variance method, is an adaptive threshold selection method. The steps of this method are: (1) divide the gray value of the image into target area and background area repeatedly by using the segmentation threshold of 1 to 255; (2) calculate the inter class variance between the target and the background areas of each segmentation as the judgment basis; (3) select the segmentation threshold with the largest interclass variance as the threshold T.
The method for calculating the total average gray level of the image is presented in (3), and the method for calculating the interclass variance is presented in (4).
where, δ 0 is the proportion of target pixels in the total image pixels, μ 0 is the average gray level, δ 1 is the proportion Automatic Image Segmentation Method for Canopy Density Measurement of Chinese Alligator O n l i n e

F i r s t A r t i c l e
of background pixels in the total image pixels, μ 1 is the average gray level, μ is the total average gray level of the image, and f denotes the interclass variance.

Iterative threshold segmentation method
The iterative method updates the threshold for obtaining its appropriate value by minimizing the within-cluster variance. The steps of iterative threshold segmentation method are presented below: (1) Set the initial threshold T 0 as the average of the maximum and minimum gray values of the image, and set the iteration accuracy δ to 0.001.
(2) According to the threshold T 0 , the image is divided into the target area and the background area. Then, the average gray value μ 0 (0) of target area and the average gray value μ 1 (0) of the background area are calculated.
(3) Calculate the new threshold T 1 using (5) and use the threshold T 1 as the new initial threshold for the next iteration.
(4) The process continues until |T (k+1) -T (k) | < δ, where T (k) is the threshold calculated in k th iterative loop, T (k+1) is the threshold calculated in (k+1) th iterative loop, and δ is the iteration accuracy.

Automatic bimodal threshold segmentation method
If there is an obvious target area in the image, the gray histogram shows a bimodal shape, and the segmentation threshold generally appears in the position of the troughs. The bimodal method determines the segmentation threshold by searching the trough of the histogram, and selects the lowest gray value of the trough as the segmentation threshold. Figure 3 shows the gray histogram of the canopy density image. It is evident that there is an obvious trough in the histogram. However, the positions and quantities of peaks and troughs in each figure are different. At present, the bimodal method is achieved by manually searching the trough threshold. In this paper, a histogram traversal method is established to automatically search the peak and trough positions for determining the best threshold. The proposed algorithm is as follows: (1) Calculate the image gray histogram (Fig. 4a) by median filtering with a window width of 10 from 256 levels to 32 levels (Fig. 4b) for removing the miscellaneous peaks from the histogram (Fig. 4c).
(2) Traverse the gray value G = 0 till the end of the histogram and count F(g) as the number of pixels with gray value equal to g. A peak position is found when F(g +1) < F(g). Record the peak position as g +1. The starting point of the first peak is recorded as 0.
(3) Traverse from the gray value g+1 to the end of the histogram. The end point of this peak is obtained when F(g+1) > F(g) and the end point is recorded as g. g+1 is recorded as the starting point of the next peak.
(4) Repeat steps 2 and 3 to traverse the 64 levels of histogram for obtaining the position of all peaks in the histogram. Convert the position of the peaks into 256-level gray values. The gray value of the positions of the first two peaks is recorded as P 1 and P 2 . P 1 is the position of the peak of background and P 2 is the peak of the target.
(5) When P 1 and P 2 of the first two peaks are obtained, the best threshold must be between the positions of the two peaks. However, the distance between the two peak positions in the histogram is generally longer than 100 gray levels and the lowest gray value between the two peaks may not be the best segmentation threshold. Therefore, the optimal threshold T is calculated by using (6). where, t is the threshold position parameter. The value of t is determined by experiments.

Grayscale conversion of canopy density image
The color canopy density image is composed of three color components: red, green, and blue. Among these three components, the grayscale difference between the sky and vegetation-covered area is the largest in the blue component. So, the blue component of the image is taken as the gray image for threshold segmentation.

Accuracy evaluation of automatic image segmentation methods for canopy density calculation
The canopy density value calculated by the manual threshold selection method is used as the standard value. The canopy density value calculated by other automatic O n l i n e

F i r s t A r t i c l e
Automatic Image Segmentation Method for Canopy Density Measurement of Chinese Alligator 5 image segmentation methods is compared with the standard value. The average error, determination coefficient (R 2 ), root mean square error (RMSE), and the slope of linear regression model of the canopy density is calculated by using three automatic segmentation methods to evaluate the accuracy and practicability of these methods.

Determination of optimal threshold position parameter t
The optimal threshold position parameters t is respectively taken as 1/4, 1/3, 1/2, 2/3, 3/4, and the lowest gray value of the trough. The automatic bimodal threshold segmentation method is used to segment all the canopy density image samples with each t and the canopy density is calculated. The accuracy of canopy density measured by the automatic bimodal threshold segmentation method with different values of t is calculated. The value of t corresponding to the highest accuracy is selected as the optimal threshold position parameter.

Accuracy comparison of the self-adaptive bimodal threshold segmentation methods for canopy density measurement in different conditions
The practicability of self-adaptive bimodal threshold segmentation methods in different conditions is evaluated by using the images captured during cloudy days, sunny days, and the images with different canopy densities.
(1) The canopy density of 247 images captured on cloudy days and 557 images captured on sunny days is measured by using self-adaptive bimodal threshold segmentation methods, and the accuracy of the measurements is calculated and compared.
(2) The canopy density of 51 images with low canopy density [0-0.3), 246 images with medium canopy density [0.3-0.7), and 804 images with high canopy density [ 0.7-1) is measured by using self-adaptive bimodal threshold segmentation methods. The absolute error of the measurements is calculated and compared using (7).
where, ε is absolute error, x i is the canopy density measured by automatic threshold segmentation method, a i is the canopy density measured by manual threshold selection method, and i is the serial number of images.

RESULTS AND DISCUSSION
Determination of the optimal threshold position parameter t As shown in Figure 5, when the optimal threshold position parameter is 2/3 (0.667), the absolute error of canopy density measured by the self-adaptive bimodal threshold segmentation method is smallest, i.e., 0.018 ± 0.016. This value is less than that of using lowest gray value of the trough as the segmentation threshold. Therefore, in this paper, the optimal threshold position parameter is set to 0.667, when the self-adaptive bimodal threshold segmentation method is used for subsequent experiments.
The canopy images in this study are captured with a bottom-up direction. The trough between the two peaks in the gray histogram of the image is long and smooth. As a result, there is no obvious lowest point between the two peaks. Considering the lowest point as the segmentation threshold directly cannot be used to segment a clear vegetation profile. However, the segmentation threshold for the images captured from up-bottom direction is at the lowest point between two peaks in gray histogram as the two peaks are much closer (Coy et al., 2016).

Accuracy of different automatic threshold segmentation methods
As presented in Figure 6, the determination coefficient (R 2 ) of canopy density measurements obtained by using the self-adaptive bimodal threshold segmentation method, the Otsu's method, and the iterative method are 0.9874, 0.9561, and 0.7073, respectively. Among these three methods, the slope of linear regression model obtained using the selfadaptive bimodal threshold segmentation method is the closest to 1, and R 2 is the largest. As shown in Table I, the absolute error, maximum absolute error, and RMSE of the self-adaptive bimodal threshold segmentation method are the smallest and the average absolute error of selfadaptive bimodal threshold segmentation method is 0.018. It is evident that the measuring accuracy of self-adaptive bimodal threshold segmentation method is better than the other two methods. As compared with the measuring method based on ArcView GIS, which is widely used in O n l i n e

F i r s t A r t i c l e
K. Sun et al. the study of Chinese alligator habitat (Sun et al., 2005), this self-adaptive bimodal threshold segmentation method has higher measurement accuracy and can improve the measurement speed by using batch processing.

Influence of different weather on the measuring accuracy of self-adaptive bimodal threshold segmentation method
The weather conditions significantly influence the segmentation of canopy density image (Lang et al., 2010). As shown in Figure 7 and Table II, R 2 , RMSE, absolute error, and maximum absolute error of self-adaptive bimodal threshold segmentation method for the images captured on cloudy days are 0.9907, 0.019, 0.014 ± 0.012, and 0.062, respectively. The measurement accuracy of this method for the images captured on cloudy days is higher than that for the images captured on sunny days, which indicates that the self-adaptive bimodal threshold segmentation method is more suitable for canopy density images captured on cloudy days. This may be because that on sunny days, when an image is captured, the brightness of a certain area is higher as compared to other areas due to direct sunlight. This causes interference in the search for the optimal threshold of the self-adaptive bimodal threshold segmentation algorithm.

Effect of different canopy density range on accuracy of self-adaptive bimodal threshold segmentation method
As shown in Figure 8 and Table III, the determination coefficient (R 2 ) of the self-adaptive bimodal threshold segmentation method is the largest (0.9947), followed by the middle canopy density image (0.9541), and the high canopy density image (0.8179). In terms of absolute error, the maximum absolute error and RMSE of the low canopy density images are smallest, while high canopy density images have the largest value.

O n l i n e F i r s t A r t i c l e
Automatic Image Segmentation Method for Canopy Density Measurement of Chinese Alligator It is evident that the self-adaptive bimodal threshold segmentation method is suitable for images with low and medium density canopies. When the canopy density is high, the sky area in the image is small and cluttered, and the contours of the leaves are blurred. These factors greatly cause light diffraction, thus causing difficulty in finding a definite and standard segmentation threshold even in manual methods. In other cases, the sky area is small and partial with a relative long outline. So, the segmented area is easily affected by the change in segmentation threshold. As compared with hemispheric image segmentation method based on edge detection (Nobis and Hunzikar, 2005), the adaptive dual-mode threshold segmentation method achieves better segmentation accuracy for low canopy density images and is more suitable for images with medium and low canopy densities.
The average absolute error of the self-adaptive bimodal threshold segmentation method based on images with high canopy density proposed in this paper is about 0.02. This method satisfies the accuracy requirements of canopy density measurement in Chinese alligator habitat research as the canopy density of Chinese alligator habitat has a relatively wide range.

CONCLUSIONS
In this paper, a self-adaptive bimodal threshold segmentation method is established for the automatic measurement of canopy density. The optimal threshold position parameter of this method is optimized and set to 0.67. The accuracy (absolute error 0.018±0.016) of the proposed method is higher than that of the Otsu's method and the iteration method. The accuracy (absolute error 0.014±0.012) of canopy density images captured on cloudy days is higher than the images captured on sunny days (absolute error 0.020±0.017). The accuracy of images with low canopy density (canopy density 0-0.3) is highest (absolute error 0.006±0.004). The accuracy of images with high canopy density (canopy density 0.7-1) is lowest (absolute error 0.020±0.016). The self-adaptive bimodal threshold segmentation method satisfies the accuracy requirements of canopy density measurement in Chinese alligator habitat research.