Method, system and storage medium for determining optimal image segmentation threshold of silkworm seat

By determining the optimal image segmentation threshold in the silkworm seat image, the problem of insufficient recognition accuracy of silkworms and mulberry branches in the existing technology is solved, and higher recognition accuracy and more accurate mulberry giving are achieved.

CN114529563BActive Publication Date: 2025-01-21JIANGSU UNIV OF SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210174784.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-24
Publication Date
2025-01-21
Estimated Expiration
2042-02-24

AI Technical Summary

Technical Problem

The existing image recognition technology still has room for improvement in the recognition accuracy of home silkworms, and it is difficult to effectively distinguish between home silkworms and mulberry branches in the silkworm images.

Method used

By collecting silkworm seat pictures, establishing a correction set and marking the pixels of silkworms and mulberry branches, using image segmentation algorithms (such as the maximum inter-class variance method and the maximum entropy threshold segmentation method) for segmentation, statistics of RGB values ​​and distribution images, and determining the best Image segmentation threshold to improve the recognition accuracy of silkworms and mulberry branches.

Benefits of technology

By determining the optimal image segmentation threshold, the recognition accuracy of silkworms and mulberry branches in silkworm seat images is improved, more accurate mulberry feeding is achieved, and the automation level in the silkworm raising process is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114529563B_ABST
    Figure CN114529563B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for determining the optimal image segmentation threshold of a silkworm seat, a method for identifying the silkworm area in a silkworm seat, a system and a storage medium. The determination method mainly performs binarization on each silkworm area and mulberry branch area with different segmentation thresholds on the R, G and B components respectively, identifies the silkworm pixels and mulberry branch pixels of the binarized silkworm area and mulberry branch area, calculates the recognition error rate of the binarized silkworm area and mulberry branch area, and draws a relationship curve between the recognition error rate and the segmentation threshold; the segmentation threshold corresponding to the intersection point of the relationship curve between the silkworm area and the mulberry branch area in the three components with the lowest recognition error rate is taken as the optimal segmentation threshold. Through the above method, the optimal image segmentation threshold that can achieve the lowest recognition error rate for both silkworms and mulberry branches is determined, thereby improving the accuracy of the calculation result of the silkworm area in the silkworm seat image, and achieving more accurate mulberry.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of image recognition, and in particular relates to a method, system and storage medium for determining an optimal silkworm seat image segmentation threshold. Background Art

[0002] my country is the birthplace of the world's sericulture industry, and the silk industry is still a traditional industry in my country with resource advantages and a dominant position in the international market. However, with the rapid development of social economy, especially the deepening of economic globalization, some problems in the development of my country's sericulture industry have become more prominent, such as single products, low efficiency, unstable industry, backward equipment, etc. At the same time, it is also facing increasingly fierce international competition from emerging sericulture countries. Therefore, we must avoid disorderly competition in the export market, promote major scientific and technological innovation and the implementation of brand strategy, so as to consolidate the foundation of industry development and lead the direction of industry development.

[0003] At present, image recognition technology has been used in silkworm breeding, such as the scientific paper "Study on the Silkworm Seat Position and Feeding Uniformity in Silkworm Breeding Based on Image Recognition" (Sericulture Science, May 2019, authors: He Yu; Shi Hongkang; Tian Yaya, etc.), which uses computer image processing technologies such as median filtering, binarization and edge detection to establish the principles and methods for machine determination of the silkworm seat position, mulberry planting uniformity and feeding amount in silkworm breeding. However, there is still room for improvement in the recognition accuracy of existing image recognition technology for silkworms. Summary of the invention

[0004] Purpose of the invention: The purpose of the present invention is to propose a method for determining the optimal image segmentation threshold of the silkworm seat, which can determine the optimal vector and threshold for processing the silkworm seat image segmentation, ensure that there is a large difference between the mulberry branch and the silkworm after segmentation, and improve the accuracy of identifying the silkworm and mulberry branch in the segmented image.

[0005] Another object of the present invention is to propose a method for identifying the area of ​​silkworms in a silkworm seat using the optimal image segmentation threshold determined by the above method, as well as a silkworm seat identification system that can implement the identification method, and a storage medium storing a computer program that instantiates the above determination method and the identification method.

[0006] Technical solution: The method for determining the optimal silkworm seat image segmentation threshold of the present invention comprises the following steps:

[0007] S1: Collect several pictures of silkworm seats after mulberry planting to establish a calibration set, and mark the silkworm pixels and mulberry branch pixels on each silkworm seat picture;

[0008] S2: Use image segmentation algorithm to segment the calibration set images, and crop and extract the silkworm and mulberry branch areas;

[0009] S3: respectively obtaining the RGB values ​​and distribution images of the silkworm area and the mulberry branch area, and counting the mean distribution of the number of occurrences of different values ​​on each component in the silkworm area and the mulberry branch area;

[0010] S4: binarizing each silkworm region and mulberry branch region with different segmentation thresholds on the R, G and B components respectively, identifying silkworm pixels and mulberry branch pixels in the binarized silkworm region and mulberry branch region, calculating the recognition error rate of the binarized silkworm region and mulberry branch region, and drawing a relationship curve between the recognition error rate and the segmentation threshold;

[0011] S5: The component with the lowest overlap in mean distribution between the silkworm region and the mulberry branch region is taken as the optimal component, and the segmentation threshold corresponding to the intersection of the relationship curve between the silkworm region and the mulberry branch region under the optimal component is taken as the optimal segmentation threshold.

[0012] Furthermore, the image segmentation algorithm in step S2 includes a maximum inter-class variance method and / or a maximum entropy threshold segmentation method.

[0013] Furthermore, in step S4, the recognition error rate is calculated by the following formula:

[0014] .

[0015] The method for identifying the area of ​​silkworms in a silkworm seat of the present invention comprises the following steps:

[0016] (1) Collecting silkworm seat images and segmenting the collected silkworm seat images using an image segmentation algorithm;

[0017] (2) Preprocess the segmented image;

[0018] (3) binarizing the preprocessed image at the optimal component using the optimal segmentation threshold, wherein the optimal component and the optimal segmentation threshold are determined by the method for determining the optimal image segmentation threshold of the silkworm seat according to any one of the above items;

[0019] (4) Calculate the ratio of the number of white pixels in the binarized image to the number of pixels in the entire image to obtain the area occupied by the silkworm.

[0020] Furthermore, the image segmentation algorithm in (1) includes a maximum inter-class variance method and / or a maximum entropy threshold segmentation method.

[0021] Furthermore, the preprocessing in (2) includes corrosion and expansion.

[0022] The silkworm seat identification system of the present invention comprises a control system, a camera and a camera driving system, wherein the camera and the camera driving system are arranged on the top of the silkworm seat, and the camera and the camera driving system are electrically connected to the control system, and the camera is driven by the camera driving system to collect a complete image of the silkworm seat, and the control system comprises an image segmentation threshold determination module and a silkworm area identification module, the image segmentation threshold determination module is used to determine the optimal image segmentation threshold by using the above-mentioned method for determining the optimal image segmentation threshold of the silkworm seat, and the silkworm area identification module uses the optimal image segmentation threshold to pre-process the collected image and identify the silkworm area ratio.

[0023] The storage medium of the present invention stores at least one computer program, wherein the first computer program is configured to implement the method for determining the optimal silkworm seat image segmentation threshold when running.

[0024] Furthermore, the second computer program is configured to implement the above-mentioned method for identifying the area of ​​silkworms in the silkworm seat when it is run.

[0025] Beneficial effect: Compared with the prior art, the present invention has the following advantages: by traversing the silkworm seat images after cutting with different thresholds under different components respectively, and identifying silkworms and mulberry branches in the images after cutting with different thresholds and calculating the recognition error rate, it is determined that the optimal image segmentation threshold with the lowest recognition error rate for both silkworms and mulberry branches can be achieved, thereby improving the accuracy of the calculation results of the silkworm area in the silkworm seat image and achieving more accurate mulberry identification. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 A flowchart of a method for determining an optimal silkworm seat image segmentation threshold according to an embodiment of the present invention;

[0027] Figure 2 This is a mean distribution diagram of the number of occurrences of different component values ​​of silkworms and mulberry branches in an embodiment of the present invention;

[0028] Figure 3 It is a curve diagram showing the relationship between the recognition error rate and the segmentation threshold value under different components of silkworm and mulberry branch in an embodiment of the present invention;

[0029] Figure 4 It is a flow chart of a method for identifying the area of ​​silkworms in a silkworm seat according to an embodiment of the present invention;

[0030] Figure 5 This is a curve diagram of the change in silkworm area within a period of time identified by the identification method of an embodiment of the present invention. DETAILED DESCRIPTION

[0031] The technical solution of the present invention is further described below in conjunction with the accompanying drawings.

[0032] Reference Figure 1 , the method for determining the optimal image segmentation threshold of the silkworm seat according to an embodiment of the present invention comprises the following steps:

[0033] S1: Collect several pictures of silkworm seats after mulberry planting to establish a calibration set, and mark the silkworm pixels and mulberry branch pixels on each silkworm seat picture;

[0034] S2: Use image segmentation algorithm to segment the calibration set images, and crop and extract the silkworm and mulberry branch areas;

[0035] S3: respectively obtaining the RGB values ​​and distribution images of the silkworm area and the mulberry branch area, and counting the mean distribution of the number of occurrences of different values ​​on each component in the silkworm area and the mulberry branch area;

[0036] S4: binarizing each silkworm region and mulberry branch region with different segmentation thresholds on the R, G and B components respectively, identifying silkworm pixels and mulberry branch pixels in the binarized silkworm region and mulberry branch region, calculating the recognition error rate of the binarized silkworm region and mulberry branch region, and drawing a relationship curve between the recognition error rate and the segmentation threshold;

[0037] S5: The component with the lowest overlap in mean distribution between the silkworm region and the mulberry branch region is taken as the optimal component, and the segmentation threshold corresponding to the intersection of the relationship curve between the silkworm region and the mulberry branch region under the optimal component is taken as the optimal segmentation threshold.

[0038] Since the silkworms entering the fifth instar are white and the mulberry branches are dark green, no matter under the R, G or B component, as the image segmentation threshold increases, the recognition error rate of the silkworm in the segmented image will increase, and the recognition error rate of the mulberry branch will decrease. By drawing the relationship curve between the recognition error rate of the silkworm and the segmentation threshold and the relationship curve between the recognition error rate of the mulberry branch and the segmentation threshold, the segmentation threshold corresponding to the intersection of the two curves is the segmentation threshold that can achieve the recognition error rate of the mulberry branch and the silkworm at a low level. At the same time, the mean distribution diagram of the number of occurrences of each value in the silkworm area and the mulberry branch area image under different components is observed. The lower the distribution overlap, the greater the difference between the silkworm and the mulberry branch under this component. The segmentation threshold determined by the intersection of the two relationship curves under this component, the recognition error rate of the silkworm and the mulberry branch in the segmented image is the lowest among the three components.

[0039] By using the image segmentation threshold determined by the above technical solution to perform binary segmentation on the collected images, it can be ensured that the recognition error rate of silkworms and mulberry branches is at a low level, thereby improving the accuracy of recognition, thereby improving the accuracy of silkworm area recognition and achieving more accurate mulberry planting.

[0040] The maximum inter-class variance method (Otsu method) focuses more on the uniformity of pixel grayscale, and is not suitable for situations where the area of ​​the target and background is very different; the maximum entropy threshold segmentation method focuses on the proportion of pixels of a certain grayscale level to the total pixels in its class, and is not sensitive to the size of the divided target and background. Therefore, in this embodiment, the maximum inter-class variance method and the maximum entropy threshold segmentation method are respectively used to obtain the silkworm area and the mulberry branch area.

[0041] In this embodiment, the calibration set is composed of 3 images captured every 1 hour after feeding mulberry leaves, a total of 105 images in PNG format with a resolution of 400 pixels × 525 pixels. Another 45 images of the process of feeding mulberry leaves until the mulberry leaves are eaten are taken as the test set.

[0042] 105 images were processed by the maximum entropy method and the Otsu method to obtain a binary image after removing most of the mulberry leaves. For fine segmentation of the target, the silkworm and a small part of the mulberry branch (including the veins) were obtained from the original image using this as a mask. The silkworm and mulberry branch areas were cropped and extracted respectively, and the effects of different segmentation thresholds on the silkworm and mulberry branch recognition error rates were explored on the R, G, and B components. The calculation method is shown in the following formula:

[0043]

[0044] The misidentified pixels are obtained by comparing the pixels of silkworm or mulberry branch identified after binarization with the manually marked pixels.

[0045] After the above processing, the 105 original images were counted and the number of occurrences of R, G, and B values ​​(expressed as mean) was calculated. The results are as follows: Figure 2 As shown. Figure 2 A and 2B show that the R component values ​​of silkworms are mainly concentrated in [140, 230], the R component values ​​of mulberry leaf veins are mainly concentrated in [140, 200], the G component values ​​of silkworms are mainly concentrated in [150, 220], and the G component values ​​of mulberry branches are mainly concentrated in [180, 220]. The two have serious overlap in R and G components. Figure 2 C shows that the B component of the silkworm is mainly concentrated in [110, 240], and the B component of the mulberry branch image is mainly concentrated in [80, 130], with only a small overlap between the two intervals. This reflects that there is a large difference in the B component between the silkworm and the mulberry branch.

[0046] Calculate and count according to the error rate formula, the results are as follows Figure 3 As shown. Figure 3In the figure, the black solid line represents the silkworm, and the gray solid line represents the mulberry leaf vein. As the values ​​of each component increase, the error rate of identifying the silkworm gradually increases, and the error rate of identifying the mulberry leaf vein gradually decreases. It shows that as the selected threshold increases, the more mulberry leaf veins are segmented, and the more silkworms are segmented at the same time, so the threshold should not be selected too large or too small. If the threshold is too large, the segmentation target will be incomplete, and if it is too small, the target and the background cannot be completely segmented. That is, the point where the two curves intersect in the figure is the threshold for the best segmentation on this component. When the R component takes a value of 181, the error rate is 51.1%; when the G component takes a value of 191, the error rate is 70.5%; when the B component takes a value of 129, the error rate is 5.5%. It can be seen that the recognition error rate of the B component is the lowest, and the value of 129 on the B component is the best image segmentation threshold in this embodiment.

[0047] like Figure 4 As shown, the method for identifying the area of ​​silkworms in a silkworm seat according to an embodiment of the present invention comprises the following steps:

[0048] (1) Collecting silkworm seat images and segmenting the collected silkworm seat images using an image segmentation algorithm;

[0049] (2) Preprocess the segmented image;

[0050] (3) Binarizing the preprocessed image with the optimal segmentation threshold on the optimal component. The optimal component and the optimal segmentation threshold are determined by the above-mentioned method for determining the optimal image segmentation threshold of the silkworm seat, which is 129 on the B component in this embodiment;

[0051] (4) Calculate the ratio of the number of white pixels in the binarized image to the number of pixels in the entire image to obtain the area occupied by the silkworm.

[0052] The 105 images were processed by binarization method to obtain the curve of the change of silkworm area over time after feeding mulberry. Figure 5 As shown in A, it can be seen that the overall trend of the area occupied by silkworms gradually increased after feeding mulberry, and the rate of increase was relatively fast within 6 hours, accounting for about 18% of the area. After that, the area no longer changed much, only fluctuated up and down or remained unchanged. The 45 images of the test set were processed in the same way, and the area occupied by silkworms in the silkworm seat was identified using the above method. The results are shown in Figure 5 As shown in B, the area increases rapidly within 5 hours, and the area no longer changes after the 6th hour. The area proportion is about 18%, which is the same as the calibration set, verifying the feasibility of the above method.

[0053] The silkworm seat identification system according to the embodiment of the present invention includes a control system, a camera and a camera driving system. The camera and the camera driving system are arranged on the top of the silkworm seat, and the camera and the camera driving system are electrically connected to the control system. The camera realizes the acquisition of the complete image of the silkworm seat under the drive of the camera driving system. The control system includes an image segmentation threshold determination module and a silkworm area identification module. The image segmentation threshold determination module is used to determine the optimal image segmentation threshold using the above-mentioned method for determining the optimal image segmentation threshold of the silkworm seat. The silkworm area identification module uses the optimal image segmentation threshold to pre-process the collected image and identify the proportion of the silkworm area.

[0054] In this embodiment, the control system uses Raspberry Pi 4B. The camera drive system includes a stepper motor, a motor drive board and an I-shaped guide rail. The camera is set on the slide of the I-shaped guide rail and is driven by the stepper motor to move along the guide rail. The stepper motor is electrically connected to the Raspberry Pi 4B through the motor drive board.

[0055] The storage medium according to the embodiment of the present invention stores a computer program that instantiates the above-mentioned method for determining the optimal image segmentation threshold of the silkworm seat and the method for identifying the area of ​​silkworms in the silkworm seat.

Claims

1. A method for determining the optimal image segmentation threshold of a silkworm seat, characterized in that: The steps include: S1: Collect several pictures of silkworm seats after mulberry planting to establish a calibration set, and mark the silkworm pixels and mulberry branch pixels on each silkworm seat picture; S2: Use image segmentation algorithm to segment the calibration set images, and crop and extract the silkworm and mulberry branch areas; S3: respectively obtaining the RGB values ​​and distribution images of the silkworm area and the mulberry branch area, and counting the mean distribution of the number of occurrences of different values ​​on each component in the silkworm area and the mulberry branch area; S4: Binarize each silkworm region and mulberry branch region with different segmentation thresholds on the R, G and B components respectively, identify the silkworm pixels and mulberry branch pixels in the binarized silkworm region and mulberry branch region, calculate the recognition error rate of the binarized silkworm region and mulberry branch region, and draw a relationship curve between the recognition error rate and the segmentation threshold; the recognition error rate is calculated by the following formula: ; S5: The component with the lowest overlap in mean distribution between the silkworm region and the mulberry branch region is taken as the optimal component, and the segmentation threshold corresponding to the intersection of the relationship curve between the silkworm region and the mulberry branch region under the optimal component is taken as the optimal segmentation threshold.

2. The method for determining the optimal silkworm seat image segmentation threshold according to claim 1, characterized in that: The image segmentation algorithm in step S2 includes a maximum inter-class variance method and / or a maximum entropy threshold segmentation method.

3. A method for identifying the area of ​​silkworms in a silkworm nest, characterized in that: The steps include: (1) Collecting silkworm seat images and segmenting the collected silkworm seat images using an image segmentation algorithm; (2) Preprocess the segmented image; (3) binarizing the preprocessed image at the optimal component using the optimal segmentation threshold, wherein the optimal component and the optimal segmentation threshold are determined by the method for determining the optimal image segmentation threshold of the silkworm seat according to any one of claims 1 to 2; (4) Calculate the ratio of the number of white pixels in the binarized image to the number of pixels in the entire image to obtain the area occupied by the silkworm.

4. The method for identifying the area of ​​silkworms in a silkworm bed according to claim 3, characterized in that: The image segmentation algorithm in (1) includes the maximum inter-class variance method and / or the maximum entropy threshold segmentation method.

5. The method for identifying the area of ​​silkworms in a silkworm bed according to claim 3, characterized in that: The preprocessing in (2) includes corrosion and expansion.

6. A silkworm seat identification system, characterized in that: It includes a control system, a camera and a camera driving system, wherein the camera and the camera driving system are arranged on the top of the silkworm seat, and the camera and the camera driving system are electrically connected to the control system. The camera can collect a complete image of the silkworm seat under the drive of the camera driving system. The control system includes an image segmentation threshold determination module and a silkworm area recognition module. The image segmentation threshold determination module is used to determine the optimal image segmentation threshold by using the method for determining the optimal image segmentation threshold of the silkworm seat according to any one of claims 1 to 2. The silkworm area recognition module uses the optimal image segmentation threshold to pre-process the collected image and identify the silkworm area proportion.

7. A storage medium storing at least one computer program, characterized in that: The computer program is configured to implement the method for determining the optimal silkworm seat image segmentation threshold according to any one of claims 1 to 2 when running.

8. A storage medium storing at least one computer program, characterized in that: The computer program is configured to implement the method for identifying the area of ​​silkworms in a silkworm seat according to any one of claims 3 to 5 when running.