Mushroom Image Data Acquisition and Preprocessing Method, Device and Storage Medium
Through the Hough circle finding algorithm combined with edge detection and fitting degree calculation, the problem of overfitting mushroom image collection is solved, and the automatic collection and preprocessing of mushroom image data set is realized, which improves the accuracy of mushroom cap contour recognition and simplifies the use process of the data set.
Patent Information
- Application Number
- CN202210427178.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-22
- Publication Date
- 2025-07-18
- Estimated Expiration
- 2042-04-22
AI Technical Summary
In the prior art, mushroom image data is difficult to collect, manual operation is difficult and the recognition accuracy is low. In particular, the circular recognition of mushroom caps is easy to overfit, resulting in inaccurate recognition.
The Hough circle finding algorithm combined with edge detection is used to calculate the fit of the circle and eliminate the overfitting circle. The mushroom image acquisition and preprocessing are realized through automated devices, and the image quality is improved by using fill lights. The circle with appropriate fit is screened by calculating the average distance and deviation between the center and edge points.
It improves the accuracy of mushroom cap contour recognition, realizes automatic collection and preprocessing of mushroom image data sets, simplifies the use process of subsequent data sets, and saves manpower and material resources.
Smart Images

Figure CN114742805B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of machine vision, and particularly relates to a method, a device and a storage medium for preprocessing mushroom image data collection. Background Art
[0002] Currently, for the collection work of mushroom image datasets, manual shooting is generally used for operation. The space between the upper and lower layers of the twin mushroom beds is small, the span on both sides is large, and the environment where they are located is dark. Manual shooting operation is difficult, and it is impossible to completely collect the image data of the entire mushroom bed. If high-efficiency dataset collection work is required, a device that can automatically perform image collection work is needed. At the same time, when using the mushroom image dataset, it is necessary to index the mushroom caps in the images. Although most mushroom caps are circular, they are not absolutely regular circles. Directly using the existing circle-finding algorithm may identify non-existent circles due to overfitting, and the recognition accuracy needs to be improved. Summary of the Invention
[0003] Object of the Invention: The object of the present invention is to propose a method for preprocessing mushroom image data collection, which uses the Hough circle-finding algorithm to identify the mushroom caps according to the mushroom contours recognized in the images, and eliminates the non-existent circles recognized due to overfitting by calculating the fitting degree between the recognized circles and the corresponding contour point sets, thereby improving the recognition accuracy.
[0004] Another object of the present invention is to propose a device for preprocessing mushroom image data collection that can implement the above method, and a storage medium storing a computer program instantiating the above method, which can realize the automatic mushroom image collection and preprocessing of the seedbed, facilitate the subsequent model establishment and algorithm training, and simplify the subsequent dataset usage process.
[0005] Technical Solution: The method for preprocessing mushroom image data collection according to the present invention includes the following steps:
[0006] S1: Control the image acquisition device to move from one end of the seedbed to the other end, and at the same time turn on the fill light and take pictures of the seedbed until the number of obtained mushroom images reaches a set value;
[0007] S2: Perform edge detection on the mushroom images to construct an edge point set A{(X n , Y n ), n = 1, 2, 3...;
[0008] S3: Use the edge point set A to perform Hough circle-finding on the mushroom images to obtain a circle coordinate set C;
[0009] S4: Calculate the average distance D between each center P in the set of circle coordinates C and each point in the corresponding set of edge points A, and the average deviation S between the distance from each center P to each point in the corresponding set of edge points A and the average distance D;
[0010] S5: Calculate the fitting degree of each circle in the set of circle coordinates C Remove the circles whose fitting degree R does not meet the fitting degree threshold from the set of circle coordinates C, and draw the circles that meet the fitting degree threshold in the image;
[0011] S6: Repeat steps S2 to S5 until all the collected mushroom images are traversed, number the processed mushroom images and store them in a storage medium after packing.
[0012] Furthermore, the step S2 includes the steps:
[0013] The step S1 includes the steps:
[0014] S1.1: Initialize the image acquisition device, set the image color category to grayscale, the pixel format to 8bit, and the resolution to QVGA;
[0015] S1.2: Control the image acquisition device to move from one end of the seedbed to the other end, and at the same time turn on the fill light to take pictures of the seedbed;
[0016] S1.3: Perform frame skipping processing, skip the rated pictures, omit the blurred frames, wait for the photosensitive element of the image acquisition device to stabilize, and then officially collect mushroom images until the number of collected mushroom images reaches the set value.
[0017] Furthermore, the step S3 includes the steps:
[0018] S3.1: Define the formula of the circle as:
[0019] (X - a n ) 2 +(Y - b n ) 2 =r n 2
[0020] where a n , b n and r n are the horizontal and vertical coordinates of the center of the circle and the radius respectively;
[0021] S3.2: Rewrite the formula of the circle into the following form:
[0022] b n =Y - r n sin(θ * π / 180)
[0023] a n= X - r n cos(θ * π / 180)
[0024] Successively substitute the points in the edge point set A into the rewritten formula of the circle, traverse from θ = 0° until 360°, and obtain the circle coordinate set B{(a n , b n , r n ), where n = 1, 2, 3..., and r n satisfies r max > r n > r min , r max and r min are the maximum detection radius and the minimum detection radius of the mushroom respectively;
[0025] S3.3: Count all the same points in the circle coordinate set B respectively, and use the circle coordinates with the count value reaching the local maximum as the circle coordinate points corresponding to the edge point set A and add them to the circle coordinate set C;
[0026] S3.4: Repeat steps S3.2 to S3.3 until all points in all edge point sets A are traversed.
[0027] The mushroom image data acquisition and preprocessing device of the present invention includes a track erected on the seedbed, a vehicle frame arranged on the track, a processor and a memory. A plurality of image acquisition devices and fill lights are arranged at intervals on the cross beam of the vehicle frame. The vehicle frame can move uniformly from one end of the seedbed to the other end along the track. The processor is used to control the movement of the vehicle frame, control the image acquisition device to acquire mushroom images, and preprocess the acquired mushroom images, and number and package the preprocessed mushroom images and store them in the memory.
[0028] Further, the vehicle frame includes a first vehicle frame and a second vehicle frame. Rollers are provided at the bottoms of the first vehicle frame and the second vehicle frame. A winch is provided on the cross beam of the first vehicle frame. The first vehicle frame is arranged at one end of the seedbed. The image acquisition device and the fill light are arranged on the second vehicle frame. A hanging ring for hanging the traction rope of the winch is provided on the second vehicle frame.
[0029] Further, the processor includes a control module, a circle recognition module and a circle screening module. The control module is used to control the vehicle frame, the image acquisition device and the fill light to work. The circle recognition module is used to recognize circles in the mushroom images. The circle screening module is used to eliminate non-existent circles obtained due to overfitting among the circles recognized by the circle recognition module.
[0030] The storage medium of the present invention stores a computer program, and the computer program is set to implement the above-mentioned mushroom image data acquisition and preprocessing method when running.
[0031] Beneficial effects: Compared with the prior art, the present invention has the following advantages: 1. It improves the accuracy of identifying the outline of the circular cap of mushrooms. 2. It can realize the automatic collection and preprocessing of mushroom images in the seedbed, facilitate the establishment of mushroom image data sets, and provide convenience for the subsequent use of mushroom data sets. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 A flowchart of a mushroom image data collection and preprocessing method according to an embodiment of the present invention;
[0033] Figure 2 It is a structural diagram of a mushroom image data acquisition and preprocessing device according to an embodiment of the present invention;
[0034] Figure 3 This is a schematic diagram of the structure of the seedbed. DETAILED DESCRIPTION
[0035] The technical solution of the present invention is further described below in conjunction with the accompanying drawings.
[0036] Reference Figure 1 , according to the mushroom image data acquisition preprocessing method of the embodiment of the present invention, comprises the following steps:
[0037] S1: Control the image acquisition device 302 to move from one end of the seedbed 100 to the other end of the seedbed 100, and simultaneously turn on the fill light 301 and take photos of the seedbed 100 until the number of mushroom images acquired reaches a set value;
[0038] S2: Perform edge detection on the mushroom image and construct the edge point set A{(X n , Y n )}, n=1, 2, 3, ...;
[0039] S3: Use the edge point set A to perform Hough circle search on the mushroom image to obtain the circle coordinate set C;
[0040] S4: Calculate the average distance D between each circle center P in the circle coordinate set C and each point in the corresponding edge point set A, and the average deviation S between the distance between each circle center P and each point in the corresponding edge point set A and the average distance D;
[0041] S5: Calculate the fit of each circle in the circular coordinate set C Eliminate circles whose fitting degree R does not meet the fitting degree threshold from the circle coordinate set C, and draw circles that meet the fitting degree threshold in the image;
[0042] S6: Repeat steps S2 to S5 until all collected mushroom images are traversed, and the processed mushroom images are numbered, packaged and stored in a storage medium.
[0043] According to the above technical solution of the mushroom image data acquisition and preprocessing method, the fitting degree R of the recognized circle is calculated, and it is determined whether the recognized circle is an actually non-existent circle determined by overfitting based on whether R is within a preset threshold range, which improves the accuracy of circle recognition, that is, improves the indexing accuracy of the mushroom cap contour in the mushroom image, facilitating the subsequent use of the data set. The closer the value of R is to 1, the smaller the ratio of the average distance D to the average deviation S, indicating that the detected object is closer to a circle. Therefore, the general judgment threshold is 1 > R > T, and the value of T varies according to different mushroom varieties. In this embodiment, taking Agaricus bisporus as an example, after statistics, when the value of R is 1 > R > 0.6, the circle closest to the actual contour of the cap of Agaricus bisporus is obtained.
[0044] To ensure the clarity of the image captured by the image acquisition device 302 and improve the accuracy of the initially recognized circle, the image acquisition device 302 needs to be initialized before acquisition. In this embodiment, the captured image needs to be set as a grayscale image, the pixel format is 8bit, and the resolution is set to QVGA. And frame skipping processing is performed after starting to shoot, omitting blurred images, and starting to take pictures after the photosensitive element of the image acquisition device 302 is stable.
[0045] Among them, the specific steps of the Hough circle finding in step S3 include:
[0046] First, define the corresponding coordinates C1(a1, b1, r1), C2(a2, b2, r2)... C n (a n , b n , r n ) of the circles that may exist in the image. Among them, (a1, b1), (a2, b2)... (a n , b n ) are the centers of each circle, and r1, r2... r n are the radii of each circle. The circle corresponding to each circle coordinate can be represented by formula (1):
[0047] (X - a n ) 2 + (Y - b n ) 2 =r n 2 (1)
[0048] The points in the edge point set A are the points through which the circle to be found passes. Therefore, by substituting the points in the edge point set A into formula (1), the circle coordinate set B{(a n , b n , r n )} that may be the circle to be found can be obtained.
[0049] For the convenience of calculation, the formula (1) is rewritten as follows:
[0050] b n = Y - r n sin*(θ*PI / 180) (2)
[0051] a n = X - r n cos*(θ*PI / 180) (3)
[0052] Substitute the points in the edge point set A into the formula (2) and formula (3), and search from 0° to 360° for the points that satisfy r max > r n > r min where r max and r min are the maximum detection radius and minimum detection radius of the mushroom respectively. In this embodiment, taking Agaricus bisporus as an example, after statistics, the value of the maximum detection radius is 8 cm, and the value of the minimum detection radius is 3 cm, that is, 8 > r n > 3. By traversing all the points in the edge point set A through the above steps, the circle coordinate set B can be obtained.
[0053] There will be the same circle coordinates in the circle coordinate set B, indicating that the edge points that solve the same circle coordinates are on the same circumference. Therefore, the more times the circle coordinate value appears, the higher the degree of contour fitting formed by it and the edge point set A, and the more likely it is to be the circle to be found. So, a counter α and a local maximum value β are set. The counter α counts the same values in the circle coordinate set B. When the number of a certain circle coordinate value in B reaches the local maximum value β, it is added to the circle coordinate set C. After traversing all the edge point sets A of the contours in the image, the coordinate set C of all the circles that may need to be found in the image can be obtained.
[0054] Since the mushroom is not a standard circle, there are still circles that actually do not exist due to overfitting in the circle coordinate set. Therefore, it is necessary to calculate the fitting degree between each circle in the circle coordinate set C and the corresponding edge point set A. The average distance D between the center P of any circle in the circle coordinate set C and each point in the corresponding edge point set A is:
[0055]
[0056] The average deviation S between the distance from the center P to each point in the corresponding edge point set A and the average distance D is:
[0057]
[0058] The fitting degree between each circle in the circle coordinate set C and the corresponding edge point set can be calculated from the average distance D and the average deviation S. The higher the fitting degree, the closer it is to a circle. By screening the circles with a fitting degree above a certain threshold, circles that are overfitted and actually do not exist can be excluded, improving the accuracy of circle recognition, and further improving the accuracy of indexing the contour of the mushroom cap.
[0059] Referring to Figure 3 , in practice, the seedbeds 100 for cultivating mushrooms are mostly multi-layer structures. The space between layers is narrow, making it difficult to take manual photos, and the light environment is poor. Therefore, to solve the problem of automatic acquisition of mushroom image data and save time, manpower and material resources, the mushroom image data acquisition and preprocessing device according to the embodiments of the present invention is as Figure 2 shown, and includes a track 200 installed on the seedbed 100, a vehicle frame arranged on the track 200, a processor 400 and a memory 500. A number of image acquisition devices 302 and fill light lamps 301 are arranged at intervals on the cross beam of the vehicle frame. The vehicle frame can move uniformly from one end of the seedbed 100 to the other end along the track 200. The processor 400 is used to control the movement of the vehicle frame, control the image acquisition device 302 to acquire mushroom images, and preprocess the acquired mushroom images, and number and package the preprocessed mushroom images and store them in the memory 500.
[0060] In the above technical solution, the vehicle frame is convenient for moving between the layers of the seedbed 100, realizing automatic acquisition of images of mushrooms in the seedbed 100. At the same time, the fill light lamp 301 on the vehicle frame can also solve the problem of poor light environment between the layers of the seedbed 100. The images acquired by the vehicle frame can be preprocessed in the processor 400, and the processed images are packaged and stored in the memory 500, which is convenient for use when establishing a subsequent model, and can save a large amount of manpower and material resources.
[0061] Referring to Figure 2, in this embodiment, for the convenience of frame erection, the frame includes a first frame 310 and a second frame 300. Four rollers 304 are provided at the bottoms of both the first frame 310 and the second frame 300. A winch 311 is provided on the first frame 310, and a hanging ring 303 for hanging the towing rope of the winch 311 is provided on the second frame 300. During use, the first frame 310 is arranged on the track 200 at one end of the seedbed 100, and the second frame 300 is erected on the track 200 at the other end of the seedbed 100. The rollers 304 of the first frame 310 are locked, and the towing rope of the winch 311 is pulled out and hung on the hanging ring 303 of the second frame 300. Starting the winch 311 can achieve uniform towing of the second frame 300. At the same time, starting the image acquisition device 302 and the supplementary light 301 on the second frame 300 can achieve automatic image acquisition of the seedbed 100. For the convenience of manufacturing, in this embodiment, the first frame 310 and the second frame 300 are frame structures built by profiles.
[0062] According to the storage medium of the embodiment of the present invention, a computer program instantiated by the above mushroom image data acquisition and preprocessing method is stored and set in the processor 400. The processor 400 includes a control module, a circle recognition module, and a circle screening module. Among them, the control module is used to control the frame, the image acquisition device 302, and the supplementary light 301 to work. The circle recognition module is used to recognize circles in the mushroom image, and the circle screening module is used to eliminate non-existent circles obtained due to overfitting among the circles recognized by the circle recognition module.
Claims
1. A method for preprocessing mushroom image data acquisition, characterized in that, It includes the following steps: S1: Control the image acquisition device to move from one end of the seedbed to the other end, and at the same time turn on the fill light and take pictures of the seedbed until the number of mushroom images obtained reaches the set value; S2: Perform edge detection on the mushroom image to construct an edge point set A{(X n , Y n ), where n = 1, 2, 3...; S3: Use the edge point set A to perform Hough circle finding on the mushroom image to obtain the circle coordinate set C; S4: Calculate the average distance D between each center P in the circle coordinate set C and each point in the corresponding edge point set A, and the average deviation S between the distance between each center P and each point in the corresponding edge point set A and the average distance D; S5: Calculate the fitness of each circle in the circle coordinate set C Remove the circles whose fitness R does not meet the fitness threshold from the circle coordinate set C, and draw the circles that meet the fitness threshold in the image; S6: Repeat steps S2 to S5 until all the collected mushroom images are traversed, number the processed mushroom images and package and store them in the storage medium.
2. The mushroom image data acquisition and preprocessing method according to claim 1, wherein The step S1 includes the steps: S1.1: Initialize the image acquisition device, set the image color category to grayscale, the pixel format to 8bit, and the resolution to QVGA; S1.2: Control the image acquisition device to move from one end of the seedbed to the other end, and at the same time turn on the fill light to take pictures of the seedbed; S1.3: Perform frame skipping processing, skip the rated pictures, omit the blurred frames, wait for the photosensitive element of the image acquisition device to stabilize, and then officially collect mushroom images until the number of collected mushroom images reaches the set value.
3. The mushroom image data acquisition and preprocessing method according to claim 1, wherein The step S3 includes the steps: S3.1: Define the formula of the circle as: (X - a n ) 2 +(Y - b n ) 2 = r n 2 where a n , b n and r n are the abscissa, ordinate of the center of the circle and the radius respectively; S3.2: Rewrite the formula of the circle into the following form: b n = Y - r n sin(θ * π / 180) a n = X - r n cos(θ*π / 180) Substitute the points in the edge point set A into the rewritten formula of the circle one by one, starting from θ = 0° and traversing until 360°, to obtain the circle coordinate set B{(a n , b n , r n ), where n = 1, 2, 3..., and r n satisfies r max > r n > r min , r max and r min are the maximum detection radius and the minimum detection radius of the mushroom respectively; S3.3: Count all the same points in the circle coordinate set B respectively, and use the circle coordinates with the count value reaching the local maximum as the circle coordinate points corresponding to the edge point set A and add them to the circle coordinate set C; S3.4: Repeat steps S3.2 to S3.3 until all the points in all the edge point sets A are traversed.
4. A mushroom image data acquisition and preprocessing device for implementing the mushroom image data acquisition and preprocessing method according to any one of claims 1 to 3, characterized in that, It includes a track erected on the seedbed, a vehicle frame arranged on the track, a processor and a memory. A plurality of image acquisition devices and fill lights are arranged at intervals on the cross beam of the vehicle frame. The vehicle frame can move uniformly from one end of the seedbed to the other end along the track. The processor is used to control the movement of the vehicle frame, control the image acquisition device to collect mushroom images, and perform preprocessing on the collected mushroom images, and number and package the preprocessed mushroom images and store them in the memory.
5. The mushroom image data acquisition and preprocessing device according to claim 4, characterized in that The vehicle frame includes a first vehicle frame and a second vehicle frame. The bottoms of the first vehicle frame and the second vehicle frame are provided with rollers. A winch is arranged on the cross beam of the first vehicle frame. The first vehicle frame is arranged at one end of the seedbed. The image acquisition device and the fill light are arranged on the second vehicle frame. A hanging ring for hanging the towing rope of the winch is arranged on the second vehicle frame.
6. The mushroom image data acquisition and preprocessing device according to claim 4, characterized in that, The processor includes a control module, a circle recognition module and a circle screening module. The control module is used to control the vehicle frame, the image acquisition device and the fill light to work. The circle recognition module is used to recognize the circles in the mushroom images. The circle screening module is used to eliminate the non-existent circles obtained due to overfitting among the circles recognized by the circle recognition module.
7. A storage medium stores a computer program, characterized in that, The computer program is set to implement the mushroom image data acquisition and preprocessing method according to any one of claims 1 to 3 when running.
Citation Information
Patent Citations
Data acquisition method based on deep learning and multi-view vision in digital twin environment
CN110334701A
Mushroom detection method based on laser and machine vision
CN111862043A