Deer Body Adaptive Threshold Segmentation Algorithm Based on Colour Space

In large-scale deer farming image analysis, K-means or maximum betweenclass variance (Otsu) algorithms can be used to distinguish the deer from the background. However, in an actual breeding environment, the barbed wire or chain-link fencing has a certain isolating effect on the deer which greatly interferes with the identification of the individual deer. Also, when the target and background grey values are similar, the multiple background targets cannot be completely separated. To better identify the posture and behaviour of deer in a deer shed, we used digital image processing to separate the deer from the background. To address the problems mentioned above, this paper proposes an adaptive threshold segmentation algorithm based on color space. First, the original image is pre-processed and optimized. On this basis, the data are enhanced and contrasted. Next, color space is used to extract the several backgrounds through various color channels, then the adaptive space segmentation of the extracted part of the color space is performed. Based on the segmentation effect of the traditional Otsu algorithm, we designed a comparative experiment that divided the four postures of turning, getting up, lying, and standing, and successfully separated multiple target deer from the background. Experimental results show that compared with K-means, Otsu and hue saturation value (HSV)+K-means, this method is better in performance and accuracy for adaptive segmentation of deer in artificial breeding scenes and can be used to separate artificially cultivated deer from their backgrounds. Both the subjective and objective aspects achieved good segmentation results. This article lays a foundation for the effective identification of abnormal behaviour in sika deer. 1 College of Information Technology, Jilin Agricultural University, Changchun, 130118, China. 2 Jilin Province Agricultural Internet of Things Technology Collaborative Innovation Center, Changchun, 130118, China. 3 Jilin Province Intelligent Environmental Engineering Research Center, Changchun, 130118, China. 4 Jilin Province Colleges and Universities and the 13th Five-Year Engineering Research Center, Changchun, 130118, China. 5 Wuhan Maritime Communication Research Institute, Wuhan, 430205, China. 6 Fruit Research and Extension Center, Department of Agricultural and Biological Engineering, Penn State University, PA, USA. * Corresponding Author: Ye Mu. Email: muye@jlau.edu.cn. Received: 07 March 2020; Accepted: 21 April 2020. 1318 CMC, vol.64, no.2, pp.1317-1328, 2020


Introduction
The Otsu algorithm proposed by Nobuyuki Otsu is widely regarded as a simple and effective adaptive threshold segmentation method that uses brute force to search for the optimal threshold and improves the interclass variance of image segmentation [Merzban and Elbayoumi (2019); Sharma, Kumar and Singh (2019); Guo, Liu, Ni et al. (2019); Jia, Peng, Song et al. (2019)]. Fu et al. [Fu, Xu, Zhang et al. (2019)] proposed a new antinoise superpixel segmentation algorithm that was robust against noise interference. Qin et al. [Qin, Shen, Mei et al. (2019)] improved the traditional ant colony algorithm to increase its convergence speed and applied it to the Otsu multi-threshold segmentation algorithm. To solve the defective single objective function to implement image segmentation, Liu et al. [Liu, Xiang, Song et al. (2019)] came up with a new image segmentation method based on a multi-objective particle swarm optimization (PSO) clustering algorithm. Mohanapriya et al. [Mohanapriya and Kalaavathi (2019)] proposes a new blend of Particle Swarm Optimization (PSO) and Accelerated Particle Swarm Optimization (APSO) called Hybrid Partial Swarm Optimization (HPSO) to enhance medical images. Kanchana [Kanchana (2019)] proposed an Otsu segmentation method based on the neural retinal edge. Wang et al. [Wang and Pan (2019)] conceived of an optimal threshold for image segmentation based on a niche PSO algorithm to improve the accuracy and speed of somatic segmentation of milk images and adjusted the requirements for rapid detection. Currently, in various fields, Otsu and K-means algorithms are used for color image segmentation, and many improvements have been proposed. To overcome the shortcomings of a single evaluation criterion for an objective function in the traditional clustering algorithm, Liu et al. [Liu, Xiang, Song et al. (2019)] proposed an unsupervised image segmentation method based on the PSO clustering algorithm and adopted two objective functions for clustering. Bhandari et al. [Bhandari, Kumar, Chaudhary et al. (2016)] invented an artificial bee colony optimization algorithm to compare the performances of different objective functions. Du et al. [Du, Chen and Xi (2019)] used a modulation level histogram instead of a grey histogram to calculate the threshold. To accelerate the segmentation of images by the traditional Otsu threshold method, Bhandari et al. [Bhandari, Kumar and Srinivas (2019)] proposed a 3-D Otsu threshold method based on the Cuttlefish algorithm. Yang et al. [Yang, Liu, Wu et al. (2019)] formulated a K-means algorithm and a hue, saturation, and value (HSV) color segmentation algorithm to segment aerial rapeseed images to distinguish flowers from non-flowering areas. Hrosik et al. [Hrosik, Tuba, Dolicanin et al. (2019)] produced an image segmentation method based on a rey algorithm, where the Otsu criterion was used as the degree function, and the K-means clustering algorithm was implemented to improve it. One drawback to image segmentation is that when parts of the background are light and dark, the segmentation effect is greatly reduced. To solve this problem, we propose an adaptive threshold segmentation algorithm based on color space. Using HSV color space to extract different backgrounds through different color channels, we explored adaptive threshold segmentation on the HSV extracted parts [Kiziltas, Uzun and Yılmaz (2019) (2010)]. Therefore, to aid the study of artificial deer breeding environments, this study tested the accuracy of the segmentation effect by comparing the traditional Otsu algorithm with the Otsu algorithm based on color space extraction.

Algorithms proposed in this paper
In the equations of the Otsu threshold segmentation algorithm, w0 is the proportion of the former attractions, w1 is the proportion of the background points, u0 is the foreground grey mean, u1 is the background grey mean, u is the global grey mean, and g is the objective function. Our goal was to maximize g, so that t would provide a good threshold to achieve the best segmentation.

Experimental process 3.1 Experimental steps
The experiments in this study followed these steps: (1) Image sampling. The sampled data were classified according to the various deer postures with the same background.
(2) Improve image quality. The color and darkness of the image were improved by adjusting the image contrast.
(3) Image segmentation. The target object was segmented from the background using a method based on image segmentation in the color space.
(4) Extracting features. Information was acquired about each of the divided image features by comparing the total pixel segmentation image with the total pixel error. (5) Verification. This phase guaranteed the accuracy of the feature extraction. We verified that the adaptive threshold segmentation algorithm using color space could effectively separate the deer from the background. In this paper, the improved HSV+K-means segmentation algorithm and the proposed algorithm are compared to determine which was better at optimally segmenting the color image with different backgrounds and light and dark effects. For this comparison, we used K-means, Otsu, and HSV+K-means algorithms.

Quantitative assessment
The extent that noise influenced the target in the segmentation was determined using a 3-D scatter plot. However, subjective analysis alone was not enough to prove that the proposed method was superior to other methods. Therefore, we used accuracy rate and Dice coefficients to quantitatively analyze the proposed algorithm. The Dice coefficient is one of many indicators that measure the spatial overlap of two images. It is typically used to report the performance of splits, with values ranging from 0, indicating no overlap, to 1, indicating complete consistency.

Image segmentation
The behaviour of deer in a shed is different from their behaviour behind a chain-link fence. We processed these objects with the traditional Otsu algorithm and the proposed algorithm. The results are shown in Figs. 1-4. In Figs. 1-4, the left side image is the original digital image, the centre image was processed by the Otsu algorithm and the right side image from the proposed algorithm. The comparison shows that the proposed algorithm could eliminate the noise caused by the chain-link fence. We calculated the proportion of the target pixels in a result graph (not shown) following the traditional Otsu algorithm and the segmentation result of the proposed algorithm. Image segmentation separates a target object from its background. The image segmentation method we used was based on color space. A comparison of other algorithm result graphs and 3-D scatter plots follows. The 3-D scatter diagrams in Figs. 5-10 show intuitively that the result of the proposed algorithm was closest to that of the manual segmentation effect, and its background segmentation was more thorough than those of the other algorithms.   Fig. 17 shows the ratios and differences between the black pixels and the total pixels of the conventional Otsu algorithm and the proposed algorithm in Figs. 1-4. The average difference between the black pixels and the total pixels of the two algorithms was 13.684%. Tab. 1 shows that the accuracy rates of the proposed algorithm were 57. 108%,24.824%,30.267%,respectively. The average accuracy rate improvement was 32.79%. Tab. 2 shows that the target ratio of the artificial segmentation comparison chart in Figs. 5-10 was 20.585%, the C of the proposed algorithm was 95.295%, and the accuracies of the K-means, Otsu, and HSV+K-means algorithms were 22.631%, 47.879%, and 23.306%, respectively. The Dice value of the proposed algorithm was 95.183%. The Dice values of the K-means, Otsu, and HSV+K-means algorithms were 74.482%, 58.654%, and 44.512%, respectively.

Analysis of results
This paper proposed a color space-based adaptive threshold segmentation algorithm for segmenting images of caged sika deer. This method can be used to segment a color image that is affected by a plurality of background parts, lightness and darkness of the target object, and background grey values. The color images were threshold-optimized using an improved Otsu threshold segmentation color space algorithm. To verify the validity and accuracy of the algorithm, the method was tested on images of various sika deer behaviors and actions on similar background images and grey values. A 3-D point map was used to visually depict the results. Accuracy and Dice coefficients were used to objectively evaluate the segmentation quality. The experimental results showed that the accuracy and Dice values were superior in this method to those of other comparative methods for color images with various grey values when the background and the light and dark sections were processed. The proposed algorithm has a good segmentation effect in regions with similar grey values and is easy to implement.

Conclusion and future work
Quantitative and visual analyses showed that the proposed algorithm is superior to the traditional segmentation method. Therefore, the effective segmentation of sika deer images in this paper lays the foundation for recognizing abnormal behaviour of sika deer in captivity. The algorithm can be further optimized in future work to achieve faster target segmentation.