Edible mushroom measuring method and system based on image recognition technology
Through the method based on image recognition technology, automated measurement of edible mushrooms is realized, solving the problems of low efficiency and poor reliability of traditional manual measurement, and improving measurement accuracy and efficiency.
Patent Information
- Application Number
- CN202510559166.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-30
- Publication Date
- 2025-06-03
- Estimated Expiration
- 2045-04-30
AI Technical Summary
The existing measurement of edible mushrooms mainly relies on manual operation, which is inefficient and can easily lead to sample damage and data recording errors, affecting the reliability of the measurement results.
Using measurement methods based on image recognition technology, automatic measurement of edible mushrooms is achieved through steps such as image acquisition, preprocessing, contour recognition and skeleton positioning segmentation.
Fully automatic and high-precision measurement of edible mushroom morphological parameters is realized, which improves measurement efficiency and reliability of results, and avoids sample damage and manual recording errors.
Smart Images

Figure CN120088248A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and particularly to a method and system for measuring edible fungi based on image recognition technology. Background Art
[0002] Currently, the phenotypic measurement of edible mushroom fruiting bodies mainly relies on manual operation. After picking, calipers are used to measure indicators such as the width of the mushroom cap and the length of the mushroom stalk one by one. However, manual measurement is inefficient, consuming a large amount of manpower and having a slow measurement speed; moreover, the samples are easily physically damaged during the picking and segmentation process, affecting subsequent analysis; in addition, manual data recording is prone to sample confusion or marking errors, resulting in a decline in the reliability of the measurement results. Summary of the Invention
[0003] The purpose of this application is to overcome the defects of the prior art and provide a method and system for measuring edible fungi based on image recognition technology.
[0004] In the first aspect, this application provides a method for measuring edible fungi based on image recognition technology, including the following steps: Collect images of sample edible fungi; Preprocess the sample edible fungi image to obtain a preprocessing configuration file; Preprocess the image of the edible fungi to be measured according to the preprocessing configuration file to obtain the contour of the edible fungi to be measured, and the area formed by the contour of the edible fungi to be measured corresponds to the region of interest; Use the skeleton location segmentation method to segment the region of interest to obtain the mushroom cap region and the mushroom stalk region, and use the minimum bounding rectangle algorithm to measure the mushroom cap region and the mushroom stalk region to achieve the measurement of the edible fungi to be measured.
[0005] Optionally, the preprocessing of the sample edible fungi image to obtain a preprocessing configuration file includes: Use a filter to smooth the sample edible fungi image to obtain a denoised sample edible fungi image; Perform morphological transformation on the denoised sample edible fungi image; Perform gradient detection on the sample edible fungi image after morphological transformation; Threshold the sample edible fungi image after gradient detection to obtain a binary image; Perform edge detection on the binary image to obtain points with significant brightness changes in the binary image; Obtain continuous edge points in the binary image through contour detection to obtain the contour of the sample edible fungi in the binary image; Organize and save the parameters in the above steps to obtain a preprocessing configuration file.
[0006] Optionally, the method of using skeleton positioning segmentation to segment the region of interest to obtain the cap region and the stalk region, and using the minimum bounding rectangle algorithm to measure the cap region and the stalk region to achieve the measurement of the edible mushroom to be measured includes: Refine the region of interest through iterative morphological transformation to obtain the skeleton of the region of interest; Use a convolution kernel to detect the skeleton, determine the two endpoints with the farthest distance on the skeleton, and determine the direction vector of the two endpoints as the main growth direction; Traverse all the points on the contour of the edible mushroom to be measured, calculate the distance from each point on the contour of the edible mushroom to be measured to the main growth direction, determine the point on the contour of the edible mushroom to be measured with the largest distance to the main growth direction, and obtain the demarcation point of the cap expansion; Take the demarcation point of the cap expansion as the foot of the perpendicular, draw a perpendicular line to the main growth direction, and obtain the demarcation line; Based on the demarcation line, determine the cap region and the stalk region, and use the minimum bounding rectangle algorithm to measure the cap region and the stalk region to achieve the measurement of the edible mushroom to be measured.
[0007] Optionally, the refining the region of interest through iterative morphological transformation to obtain the skeleton of the region of interest includes: Perform morphological transformation on the region of interest to remove edge pixels; Repeat the above steps until there are no pixels to be deleted, and obtain the skeleton of the central axis of the region of interest.
[0008] Optionally, the morphological transformation includes erosion and dilation.
[0009] As an example, the using a convolution kernel to detect the skeleton, determining the two endpoints with the farthest distance on the skeleton, and determining the direction vector of the two endpoints as the main growth direction includes: Use a convolution kernel to traverse the skeleton, count the number of adjacent pixels of each pixel on the skeleton, and obtain the pixel points with only one adjacent pixel, that is, the endpoints; Calculate the distance between every two endpoints to obtain the two endpoints with the farthest distance; Calculate the coordinate difference of the two endpoints with the farthest distance to obtain the direction vector, and take the direction vector as the main growth direction.
[0010] Optionally, the based on the demarcation line to determine the cap region and the stalk region, and using the minimum bounding rectangle algorithm to measure the cap region and the stalk region to achieve the measurement of the edible mushroom to be measured includes: Determine the cap region and the stalk region based on the dividing line. The first side of the dividing line is the cap region, and the second side of the dividing line is the stalk region; Use the minimum bounding rectangle algorithm to construct rectangles for the cap region and the stalk region respectively. The rectangles respectively contain all the points on the contour of the to-be-measured edible mushroom and have the minimum area.
[0011] Optionally, the rectangles include: a cap region rectangle and a stalk region rectangle; determine the length of the cap region rectangle as the cap diameter, and determine the width of the cap region rectangle as the cap thickness; set the length of the stalk region rectangle as the stalk length, and set the width of the stalk region rectangle as the stalk width to realize the measurement of the to-be-measured edible mushroom.
[0012] Optionally, the collecting the sample edible mushroom images includes: placing the edible mushrooms at intervals on a dark background and taking pictures with a fixed camera position to obtain sample edible mushroom images under the same ambient light and similar backgrounds.
[0013] In a second aspect, the present application also provides a measurement system for edible mushrooms based on image recognition technology, including: An image acquisition module for acquiring sample edible mushroom images; A preprocessing module for preprocessing the sample edible mushroom images to obtain a preprocessing configuration file; A contour recognition module for preprocessing the to-be-measured edible mushroom images according to the preprocessing configuration file to obtain the contour of the to-be-measured edible mushroom. The region formed by the contour of the to-be-measured edible mushroom corresponds to the region of interest; A measurement and analysis module for detecting the region of interest by using the skeleton positioning and segmentation method to obtain the cap region and the stalk region, and measuring the cap region and the stalk region by using the minimum bounding rectangle algorithm to realize the measurement of the to-be-measured edible mushroom.
[0014] The present application provides a measurement method and system for edible mushrooms based on image recognition technology. By establishing a standardized image acquisition process, constructing a multi-stage preprocessing configuration file, and combining the innovative skeleton positioning and segmentation method with the minimum bounding rectangle cap and stalk separation algorithm, the automatic and high-precision measurement of the morphological parameters of edible mushrooms can be realized; the dynamic generation mechanism of the preprocessing configuration file can solve the image adaptability problem under different lighting conditions; the skeleton positioning and segmentation method can effectively distinguish the morphological boundaries between the cap and the stalk, and the minimum bounding rectangle algorithm can accurately quantify the cap diameter and the stalk length. The present application breaks through the limitations of subjectivity and low efficiency of traditional manual measurement, provides a real-time and non-destructive phenotypic analysis tool for the variety breeding, growth cycle monitoring and factory production of edible mushrooms, and has significant application value.
[0015] To make the above features and advantages of the invention more obvious and understandable, specific embodiments are given below and described in detail in conjunction with the accompanying drawings. Description of the Drawings
[0016] To more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following will briefly introduce the drawings required for use in the description of the embodiments or related technologies. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0017] Figure 1 It is a flowchart of a measurement method for edible fungi based on image recognition technology provided in an embodiment of the present application.
[0018] Figure 2 It is an image of a sample edible fungus collected in a measurement method for edible fungi based on image recognition technology provided in an embodiment of the present application.
[0019] Figure 3 It is a flowchart of step S20 in a measurement method for edible fungi based on image recognition technology provided in an embodiment of the present application.
[0020] Figure 4 It is a contour map of a sample edible fungus obtained by preprocessing in a measurement method for edible fungi based on image recognition technology provided in an embodiment of the present application.
[0021] Figure 5 It is a schematic diagram of the region of interest of an edible fungus to be measured in a measurement method for edible fungi based on image recognition technology provided in an embodiment of the present application.
[0022] Figure 6 It is a flowchart of step S40 in a measurement method for edible fungi based on image recognition technology provided in an embodiment of the present application.
[0023] Figure 7 It is a schematic diagram of the fruiting body skeleton of an edible fungus in a measurement method for edible fungi based on image recognition technology provided in an embodiment of the present application.
[0024] Figure 8 It is a schematic diagram of the cap region and the stipe region of an edible fungus in a measurement method for edible fungi based on image recognition technology provided in an embodiment of the present application.
[0025] Figure 9 It is a schematic structural diagram of a measurement system for edible fungi based on image recognition technology provided in another embodiment of the present application. Detailed Embodiments
[0026] To make the objectives and technical solutions of the embodiments of this application clearer, the following will clearly and completely describe the technical solutions of the embodiments of this application in conjunction with the accompanying drawings of the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, rather than all of them. Based on the described embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of this application.
[0027] In one embodiment, please refer to Figure 1 , this application provides a measurement method for edible fungi based on image recognition technology. The measurement method for edible fungi based on image recognition technology may include the following steps: S10 to S40.
[0028] S10: Collect images of sample edible fungi.
[0029] S20: Preprocess the images of sample edible fungi to obtain a preprocessing configuration file.
[0030] S30: Preprocess the images of the edible fungi to be measured according to the preprocessing configuration file to obtain the contour of the edible fungi to be measured. The area formed by the contour of the edible fungi to be measured corresponds to the region of interest.
[0031] S40: Use the skeleton positioning segmentation method to segment the region of interest to obtain the cap region and the stalk region, and use the minimum bounding rectangle algorithm to measure the cap region and the stalk region, so as to realize the measurement of the edible fungi to be measured.
[0032] In the measurement method for edible fungi based on image recognition technology of this application, by constructing a preprocessing configuration file, the standardized processing process of the sample and the image to be measured is realized, which can effectively eliminate the influence of external factors such as light and background interference on image analysis; by using the skeleton positioning segmentation method to accurately segment the cap and stalk regions, and combining the minimum bounding rectangle algorithm to realize the quantitative measurement of morphological parameters, the key phenotypic indicators such as cap diameter and stalk height can be accurately obtained; the non-contact image acquisition method avoids the damage to the sample caused by traditional manual measurement, is suitable for continuous dynamic monitoring of living samples, and has the significant advantages of high efficiency, objectivity and repeatability; through automatic contour extraction and multi-algorithm fusion analysis, this application can quickly evaluate the growth status of edible fungi and provide data support for variety breeding and cultivation optimization.
[0033] In step S10, please refer to Figure 1 the S10 step in
[0034] As an example, edible mushroom samples are harvested, and the harvested edible mushroom samples are scattered and placed against a dark background without overlapping between the samples. A fixed-position camera is used to take pictures to obtain a number of sample edible mushroom images with the same ambient light and similar background, such as Figure 2 shown.
[0035] As an example, the edible mushrooms may include: Hericium coralloides.
[0036] In one example, Hericium coralloides is used as the edible mushroom sample, and the edible mushroom sample may be the Hericium coralloides strain provided by the Institute of Edible Fungi, Shanghai Academy of Agricultural Sciences.
[0037] As an example, the cultivation formula of the Hericium coralloides strain may include: 29% wood chips, 22% rice bran, 15% cottonseed hulls, 11% corn cobs, 10% soybean dregs, 8% corn flour, 5% wheat bran, 63%-65% water content, pH 8.0-8.2.
[0038] As an example, the cultivation method of the Hericium coralloides strain may include: Each cultivation bottle (1100 mL) is filled with (660±10) g (wet weight) of the cultivation medium for the cultivated species, sterilized at 121°C under high-pressure steam for 2 h, placed in a cooling room, and when the central temperature of the cultivation medium in the cultivation bottle is lower than 22°C, inoculated with an automatic inoculator, and the inoculation amount is 30 mL / bottle to 40 mL / bottle; placed in a 22°C cultivation room for dark cultivation, the temperature between the cultivation bottles is maintained at 20-25°C, the relative air humidity is 65% to 75%, and the CO 2 mass concentration ≤ 3500 mg / kg, and after culturing for 45 d, the mycelium is scratched; the temperature in the fruiting room is 15-18°C, and the CO 2 mass concentration is 2500-3500 mg / kg, and the lights are turned on appropriately according to the fruiting situation, and harvested after 22-25 d.
[0039] As an example, a Hikvision industrial camera MV-CA013-20GC can be used for image capture.
[0040] In step S20, please refer to Figure 1 step S20 in, and preprocess the sample edible mushroom images to obtain a preprocessing configuration file.
[0041] As an example, please refer to Figure 3 , step S20 may include the following steps: S201~S207.
[0042] S201: Use a filter to smooth the sample edible mushroom images to obtain the denoised sample edible mushroom images.
[0043] S202: Perform morphological transformation on the denoised sample edible mushroom images.
[0044] S203: Perform gradient detection on the sample edible mushroom image after morphological transformation.
[0045] S204: Threshold the sample edible mushroom image after gradient detection to obtain a binary image.
[0046] S205: Perform edge detection on the binary image to obtain points with significant brightness changes in the binary image.
[0047] S206: Obtain continuous edge points in the binary image through contour detection to get the contour of the sample edible mushroom in the binary image.
[0048] S207: Organize and save the parameters in steps S201 to S206 to obtain a preprocessing configuration file.
[0049] As an example, in order to clearly separate the edible mushroom target from the background, a series of image preprocessing operations need to be performed on the sample edible mushroom image. First, decompose the color sample edible mushroom image into three channels: red (R), green (G), and blue (B). Use the grayscale conversion formula for weighted calculation, synthesize the information of the three channels, avoid detail loss caused by a single channel, and convert the calculation result to a grayscale value range of 0 - 255 to form a single-channel grayscale image. The grayscale conversion formula is as follows:
[0050] where, Gray is the grayscale channel, R is the red channel, G is the green channel, B is the blue channel. By converting the color sample edible mushroom image into a grayscale sample edible mushroom image, it provides a stable grayscale background for subsequent parameter measurement, effectively reduces analysis errors caused by color interference, and ensures that the boundary between the mushroom cap and the stalk is clearer during subsequent contour extraction.
[0051] Furthermore, in step S201, use a filter to smooth the grayscale sample edible mushroom image to obtain a denoised sample edible mushroom image. Specifically, slide the filter on the grayscale sample edible mushroom image, perform element multiplication and summation for each position to achieve convolution, and modify the pixel value at each position according to the surrounding pixel values to obtain a new pixel value, so as to reduce the noise and details in the grayscale sample edible mushroom image and make the grayscale sample edible mushroom image look softer.
[0052] As an example, the filter may include: Gaussian filter, mean filter, median filter.
[0053] As an example, the Gaussian filter calculates pixel values based on Gaussian distribution weights, and the expression is as follows:
[0054] Among them, is a Gaussian filter, is the standard deviation of the Gaussian distribution, which controls the shape of the Gaussian function. The larger it is, the smoother the image; and are the coordinates relative to the center point.
[0055] As an example, the mean filter constructs a convolution kernel of all 1s, replaces the gray value of each pixel with the average value of all pixels in its neighborhood, and eliminates noise by reducing the contrast between pixels. The expression of the convolution kernel M is as follows:
[0056] where k is the size of the convolution kernel.
[0057] As an example, the median filter sorts the pixel values in the neighborhood of each pixel of the image and takes the median value as the output. The expression is as follows:
[0058] Among them, is the pixel at the coordinate (x, y) of the image after median processing, is the pixel at the coordinate (x + i, y + i) of the gray sample edible mushroom image, is the neighborhood radius.
[0059] Furthermore, in step S202, morphological transformation is performed on the denoised sample edible mushroom image. The morphological transformation includes two basic operations: erosion and dilation. Among them, erosion will reduce the size of the foreground object, and dilation will expand the size of the foreground object. More complex transformations such as opening operation (erosion first and then dilation) and closing operation (dilation first and then erosion) can be achieved by combining morphological transformations to eliminate spots and extract structural features in the image, such as boundaries, connected components, etc.
[0060] Furthermore, in step S203, gradient detection is performed on the sample edible mushroom image after morphological transformation. The gradients in the horizontal and vertical directions are obtained through the gradient operator, and the edges are located by calculating the derivative of the image brightness. The gradient operator can include: Sobel operator, Prewitt operator, and Roberts operator.
[0061] Further, in step S204, the sample edible mushroom image after gradient detection is thresholded, and each pixel is compared with the threshold. When the pixel value is greater than the threshold, it is set to 255, and when the pixel is less than the threshold, it is set to 0, thereby converting the grayscale image into a binary image to simplify the image data for further processing. The expression of the thresholding operation is as follows:
[0062] where, is the threshold, is the pixel value of the image at the coordinate (x, y) after over-thresholding processing, is the grayscale value of the pixel of the original image at the coordinate (x, y).
[0063] Further, in step S205, an edge detection algorithm is used to perform edge detection on the binary image, identify the regions with significant brightness changes in the image, and obtain the points with significant brightness changes in the binary image, that is, the gray gradient mutation points, to locate the contour or boundary of the object.
[0064] As an example, the edge detection algorithm may include: Canny edge detection, Sobel edge detection, and Laplacian edge detection.
[0065] Further, in step S206, continuous edge points are searched in the binary image through the contour to obtain the contour of the sample edible mushroom in the binary image, that is, a set of continuous points with the same color or intensity. The contour of the sample edible mushroom in the obtained binary image is as Figure 4 .
[0066] As an example, the findContours function in OpenCV can be used for contour detection to obtain the contour of the sample edible mushroom in the binary image.
[0067] Further, in step S207, the parameters in steps S201 to S206 are adjusted to obtain a clear contour of the sample edible mushroom (as shown in Figure 4 ). The parameters are sorted and saved to obtain a preprocessing configuration file, and the preprocessing configuration file is saved as an ini file for reuse by other images in the same batch. The parameters saved in the preprocessing configuration file are shown in Table 1.
[0068] Table 1 Parameters saved in the preprocessing configuration file
[0069] Continued Table 1 Parameters saved in the preprocessing configuration file
[0070] As an example, grayscale conversion uses the default formula; the filter type for smoothing can be a mean filter (kind = 0), and the filter kernel size can be 3 (ksize = 3); the morphological method can be opening (op = 2), the shape can be square (ksharpe = 0), and the kernel size can be 3 (ksize = 3) to connect broken edges; the morphological method can be further set to erosion (op = 1), the shape can be square (ksharpe = 0), and the kernel size can be 3 (ksize = 3) to further shrink the boundary; the gradient algorithm can be the Sobel operator (kind = 0), and the kernel size can be 7 (ksize = 7); edge detection can be the Canny algorithm (thresh1 = 80, thresh2 = 200); the contour retrieval mode can be only external contours (mode = 0) to separate individual edible mushrooms, and the contour approximation method can be to compress redundant points (method = 1) to reduce the data volume.
[0071] In step S30, refer to Figure 1 step S30 in, and preprocess the image of the edible mushroom to be measured according to the preprocessing configuration file to obtain the contour of the edible mushroom to be measured, and the area formed by the contour of the edible mushroom to be measured corresponds to the region of interest.
[0072] As an example, preprocess the image of the edible mushroom to be measured with the preprocessing configuration file to obtain the contour of the edible mushroom to be measured in the image of the edible mushroom to be measured, and the area formed by the contour of the edible mushroom to be measured is the region of interest (ROI region). The region of interest of the image of the edible mushroom to be measured is as Figure 5 shown. It can also be to traverse the contour of the edible mushroom to be measured to obtain the region of interest.
[0073] In step S40, refer to Figure 1 step S40 in, and segment the region of interest by using the skeleton positioning segmentation method to obtain the cap region and the stalk region, and use the minimum bounding rectangle algorithm to measure the cap region and the stalk region to realize the measurement of the edible mushroom to be measured.
[0074] As an example, refer to Figure 6 , step S40 may include the following steps: S401~S405.
[0075] S401: Refine the region of interest through iterative morphological transformation to obtain the skeleton of the region of interest.
[0076] S402: Detect the skeleton using a convolution kernel, determine the two endpoints on the skeleton that are the farthest apart, and determine the direction vector of the two endpoints as the main growth direction.
[0077] S403: Traverse all the points on the contour of the edible mushroom to be measured, calculate the distance from each point on the contour of the edible mushroom to be measured to the main growth direction, determine the point on the contour of the edible mushroom to be measured with the maximum distance to the main growth direction, and obtain the demarcation point of the cap expansion.
[0078] S404: Take the demarcation point of the cap expansion as the foot of the perpendicular, and draw a perpendicular line to the main growth direction to obtain the demarcation line.
[0079] S405: Determine the cap area and the stalk area based on the demarcation line, and use the minimum bounding rectangle algorithm to measure the cap area and the stalk area to realize the measurement of the edible mushroom to be measured.
[0080] As an example, in step S401, a structural element is constructed, and the structural element is convolved with the ROI. If the structural element is completely contained within the ROI area, the pixel value at that position is set to 1, otherwise it is set to 0, eroding the edge pixels, isolated pixels, discontinuous lines, etc., so that the ROI area shrinks uniformly by one layer, that is, the boundary indents inward; repeat the above steps until there are no pixels to be deleted. Through multiple iterations of erosion, the ROI area gradually shrinks from the outside to the inside, and the edges of the cap and the stalk will gradually become thinner until the skeleton of the central axis of the region of interest is obtained, as Figure 7 shown.
[0081] As an example, after each erosion operation, it is necessary to determine which pixels can be deleted without changing the connectivity of the object. For example, after deleting a certain pixel, the object will not be divided into multiple parts.
[0082] As an example, the structural element can adopt a 3×3 cross-shaped structural element.
[0083] Further, in step S402, use the convolution kernel to traverse the skeleton, count the number of adjacent pixels of each pixel on the skeleton, obtain the pixel points with only one adjacent pixel, that is, the end points; calculate the distance between every two end points, obtain the two end points with the farthest distance; calculate the coordinate difference between the two end points with the farthest distance to obtain the direction vector, and use the direction vector as the main growth direction.
[0084] Specifically, use the convolution kernel to traverse the skeleton, count the number of adjacent pixels of each pixel on the skeleton, obtain the end points of the skeleton, and the number of adjacent pixels around the end points of the skeleton is 1; calculate the Euclidean distance between any two end points, determine the two end points with the maximum distance, and denote them as end point A and end point .
[0085] Further, end point A can be used as the starting point and end point B as the ending point, and calculate the coordinate difference between the two to obtain the direction vector , that is, the main growth direction, represents the main extension direction of the edible mushroom to be measured.
[0086] Further, in step S403, all points on the contour of the edible mushroom to be measured are traversed, the distances from each point on the contour of the edible mushroom to be measured to the main growth direction are calculated, the point on the contour of the edible mushroom to be measured with the maximum distance to the main growth direction is determined, and the demarcation point of the cap unfolding is obtained.
[0087] As an example, the set of all points on the contour of the edible mushroom to be measured , where is the coordinate of the i-th point on the contour of the edible mushroom to be measured. Any point on the contour of the edible mushroom to be measured to the distance of the straight line corresponding to the main growth direction is , and the expression is:
[0088] where , are the abscissa and ordinate of endpoint A respectively, , are the abscissa and ordinate of endpoint B respectively, , are the abscissa and ordinate of any point on the contour of the edible mushroom to be measured.
[0089] As an example, for the fruiting body of Hericium coralloides, since the cap is semi-flat spherical, the point with the maximum lateral expansion (i.e., the widest part of the cap) must be the point farthest from the main growth direction.
[0090] Further, let the initial maximum distance from the contour of the edible mushroom to be measured to the straight line corresponding to the main growth direction, traverse all points on the contour of the edible mushroom to be measured, calculate the distance from each point to the straight line corresponding to the main growth direction as , if , then update the maximum distance , and the point corresponding to the maximum distance is the demarcation point O , that is, the demarcation point of the cap unfolding.
[0091] As an example, if there are multiple points with the same maximum distance (such as two symmetric points), the point on one side of the main growth direction (such as the side where the cap faces upward) can be taken as the final demarcation point, or the midpoint can be taken to ensure the uniqueness of the dividing line.
[0092] Further, in step S404, taking the demarcation point O as the foot of the perpendicular, draw a perpendicular to the straight line corresponding to the main growth direction, and this perpendicular is the dividing line between the cap and the stipe.
[0093] Further, in step S405, the cap area and the stalk area are determined based on the dividing line. The first side of the dividing line is the cap area, and the second side of the dividing line is the stalk area. The minimum bounding rectangle algorithm is used to construct rectangles for the cap area and the stalk area respectively. The rectangles respectively contain all the points on the contour of the to-be-measured edible mushroom and have the minimum area. The length of the rectangle of the cap area is determined as the cap diameter, and the width of the rectangle of the cap area is determined as the cap thickness. The length of the rectangle of the stalk area is set as the stalk length, and the width of the rectangle of the stalk area is set as the stalk width, so as to realize the measurement of the to-be-measured edible mushroom.
[0094] Specifically, the set of all the points on the contour of the cap area of the to-be-measured edible mushroom is , with the main growth direction as the axis and the dividing line as the axis, a local coordinate system is established, and the points in the set are converted into local coordinates . In the direction (perpendicular to the main growth direction), the minimum value and the maximum value are found, then the width is ; in the direction (perpendicular to the main growth direction), the minimum value and the maximum value are found, then the length is .
[0095] Further, with and as the diagonal vertices, a rectangle parallel to the local coordinate system is constructed to ensure that it contains all the cap contour points and has the minimum area (since the cap is oblate and the maximum width is in the direction perpendicular to the main growth direction).
[0096] Specifically, the set of all the points on the contour of the cap area of the to-be-measured edible mushroom is , and the minimum bounding rectangle algorithm is used to construct a rectangle to ensure a tight fit to the cylindrical structure. The specific method for constructing the rectangle of the stalk area can refer to the specific method for constructing the rectangle of the cap area, which will not be elaborated here.
[0097] Further, the width of the rectangle of the cap area is determined as the cap diameter, the length of the rectangle of the cap area is determined as the cap thickness, the length of the rectangle of the stalk area is set as the stalk length, and the width of the rectangle of the stalk area is set as the stalk width, so as to realize the measurement of the to-be-measured edible mushroom. The measurement results obtained by the minimum bounding rectangle algorithm are as Figure 8 shown.
[0098] In the measurement method of edible fungi based on image recognition technology of the present application, the sample is photographed with a fixed camera position and a dark background to reduce the interference of light and background. Through preprocessing operations, a preprocessing configuration file is constructed, integrating parameters such as smoothing processing and morphological transformation to form a standardized processing flow, eliminating the influence of external factors on image analysis. According to the preprocessing configuration file, the image of the edible fungi to be measured is processed to accurately extract the contour and region of interest (ROI). The cap and stalk regions are segmented by the skeleton positioning segmentation method, and the combination of the minimum bounding rectangle algorithm for quantitative measurement can avoid the regional division error caused by the irregular shape of the traditional segmentation method, ensuring that the boundaries of the cap and stalk conform to the actual shape. The present application can accurately analyze the growth status of edible fungi, help to judge the quality of edible fungi, realize the efficiency, objectivity and repeatability of the morphological analysis of edible fungi, provide accurate data support for variety breeding and cultivation optimization, and can effectively improve the accuracy and practicality of the analysis.
[0099] It should be understood that although the steps in the flowchart of the accompanying drawings are shown in sequence according to the indication of the arrows, these steps do not necessarily have to be executed in the order indicated by the arrows. Unless there is a clear indication in this article, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, at least a part of the steps in the accompanying drawings may include multiple sub-steps or multiple stages. These sub-steps or stages do not necessarily have to be completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages does not necessarily have to be sequential, but can be executed alternately or alternately with at least a part of other steps or sub-steps or stages of other steps.
[0100] In another embodiment, please refer to Figure 9 , the present application also provides a measurement system for edible fungi based on image recognition technology, which may include: an image acquisition module 1, a preprocessing module 2, a contour recognition module 3, and a measurement analysis module 4. Among them, the image acquisition module 1 is used to acquire the image of the sample edible fungi; the preprocessing module 2 is used to preprocess the image of the sample edible fungi to obtain a preprocessing configuration file; the contour recognition module 3 is used to preprocess the image of the edible fungi to be measured according to the preprocessing configuration file to obtain the contour of the edible fungi to be measured, and the region formed by the contour of the edible fungi to be measured corresponds to the region of interest; the measurement analysis module 4 is used to segment the region of interest by the skeleton positioning segmentation method to obtain the cap region and the stalk region, and use the minimum bounding rectangle algorithm to measure the cap region and the stalk region.
[0101] In the above measurement system for edible fungi based on image recognition technology, the image acquisition module 1 standardizes the acquisition process to ensure the basic quality of the images; the preprocessing module 2 generates a preprocessing configuration file to provide a parameter basis for the standardized processing of the images and eliminate the influence of environmental interference on the analysis; the contour recognition module 3 constructs contours and regions of interest based on the configuration file to ensure the consistency of the preprocessing of the images to be measured; the measurement and analysis module 4 accurately segments the cap and stipe regions and quantitatively measures them through the skeleton positioning segmentation method and the minimum circumscribed rectangle algorithm, and quickly outputs core phenotypic data such as the cap diameter and stipe length. This application can achieve an automated closed-loop from image acquisition to analysis, which not only improves the efficiency of the phenotypic analysis of edible fungi, but also ensures the accuracy and repeatability of the results, providing an efficient and reliable technical support for the variety breeding and cultivation management of edible fungi.
[0102] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope recorded in this specification.
[0103] Although this application has been disclosed above by way of examples, it is not intended to limit this application. Any person with ordinary knowledge in the technical field to which this application pertains may make some modifications and refinements without departing from the spirit and scope of this application. Therefore, the protection scope of this application shall be subject to that defined by the appended patent application scope.
Claims
1. A method for measuring edible mushrooms based on image recognition technology, characterized in that: The following steps are involved: Collect sample edible mushroom images; Preprocessing the sample edible mushroom image to obtain a preprocessing configuration file; Preprocessing the image of the edible mushroom to be tested according to the preprocessing configuration file to obtain the outline of the edible mushroom to be tested, wherein the area formed by the outline of the edible mushroom to be tested corresponds to the region of interest; The region of interest is segmented by using a skeleton positioning segmentation method to obtain a cap region and a stipe region, and the cap region and the stipe region are measured using a minimum circumscribed rectangle algorithm to achieve measurement of the edible mushroom to be measured.
2. The method for measuring edible mushrooms based on image recognition technology according to claim 1, characterized in that: The sample edible mushroom image is preprocessed to obtain a preprocessing configuration file, including: Using a filter to smooth the sample edible mushroom image to obtain a denoised sample edible mushroom image; Performing morphological transformation on the denoised sample edible mushroom image; Perform gradient detection on the sample edible mushroom image after morphological transformation; Thresholding the sample edible mushroom image after gradient detection to obtain a binary image; Performing edge detection on the binary image to obtain points with significant brightness changes in the binary image; Obtaining continuous edge points in the binary image by contour detection, and obtaining the contour of the sample edible mushroom in the binary image; Arrange and save the parameters in the above steps to obtain a preprocessing configuration file.
3. The method for measuring edible mushrooms based on image recognition technology according to claim 1, characterized in that: The method of segmenting the region of interest by using a skeleton positioning segmentation method to obtain a cap region and a stipe region, and measuring the cap region and the stipe region by using a minimum circumscribed rectangle algorithm to achieve measurement of the edible mushroom to be measured includes: Refining the region of interest by iterative morphological transformation to obtain a skeleton of the region of interest; Use the convolution kernel to detect the skeleton, determine the two endpoints on the skeleton that are farthest apart, and determine the direction vectors of the two endpoints as the main growth direction; Traversing all points on the contour of the edible mushroom to be tested, calculating the distance from each point on the contour of the edible mushroom to be tested to the main growth direction, determining the point on the contour of the edible mushroom to be tested with the largest distance from the main growth direction, and obtaining the demarcation point of the cap expansion; The demarcation point where the cap is unfolded is used as the foot of the vertical line, and the vertical line of the main growth direction is used to obtain the demarcation line; The cap region and the stipe region are determined based on the dividing line, and the cap region and the stipe region are measured using a minimum circumscribed rectangle algorithm to achieve measurement of the edible mushroom to be measured.
4. The method for measuring edible mushrooms based on image recognition technology according to claim 3, characterized in that: The step of refining the region of interest by iterative morphological transformation to obtain a skeleton of the region of interest includes: Perform morphological transformation on the region of interest to remove edge pixels; Repeat the above steps until there are no pixels that can be deleted, and obtain the skeleton of the central axis of the region of interest.
5. The method for measuring edible mushrooms based on image recognition technology according to claim 4, characterized in that: The morphological transformation includes erosion and dilation.
6. The method for measuring edible mushrooms based on image recognition technology according to claim 3, characterized in that: The method of using a convolution kernel to detect the skeleton, determining two endpoints on the skeleton that are farthest apart, and determining the direction vectors of the two endpoints as the main growth direction includes: Use the convolution kernel to traverse the skeleton, count the number of adjacent pixels of each pixel on the skeleton, and obtain the pixel point with only one adjacent pixel, that is, the endpoint; Calculate the distance between every two endpoints and get the two endpoints with the farthest distance; The coordinate difference between the two endpoints that are farthest apart is calculated to obtain a direction vector, and the direction vector is used as the main growth direction.
7. The method for measuring edible mushrooms based on image recognition technology according to claim 3, characterized in that: The method of determining the cap region and the stipe region based on the boundary line, and measuring the cap region and the stipe region using a minimum circumscribed rectangle algorithm to achieve measurement of the edible mushroom to be measured includes: Determine the cap region and the stipe region based on a dividing line, wherein a first side of the dividing line is the cap region, and a second side of the dividing line is the stipe region; A minimum circumscribed rectangle algorithm is used to construct rectangles for the cap region and the stipe region, respectively. The rectangles respectively contain all points on the contour of the edible mushroom to be tested and have the smallest area.
8. The method for measuring edible mushrooms based on image recognition technology according to claim 7, characterized in that: The rectangle includes: a cap area rectangle and a stipe area rectangle; the length of the cap area rectangle is determined as the cap diameter, and the width of the cap area rectangle is determined as the cap thickness; the length of the stipe area rectangle is set as the stipe length, and the width of the stipe area rectangle is set as the stipe width, so as to achieve measurement of the edible mushrooms to be measured.
9. The method for measuring edible mushrooms based on image recognition technology according to claim 1, characterized in that: The method of collecting sample edible mushroom images includes placing the edible mushrooms at intervals against a dark background, taking photos using a fixed camera, and obtaining sample edible mushroom images under the same ambient lighting and similar background.
10. A measurement system for edible mushrooms based on image recognition technology, characterized in that: The edible mushroom measurement system based on image recognition technology includes: An image acquisition module, used to acquire images of sample edible mushrooms; A preprocessing module, used for preprocessing the sample edible mushroom image to obtain a preprocessing configuration file; A contour recognition module, used for preprocessing the image of the edible mushroom to be tested according to the preprocessing configuration file to obtain the contour of the edible mushroom to be tested, wherein the area formed by the contour of the edible mushroom to be tested corresponds to the region of interest; The measurement and analysis module is used to segment the region of interest using a skeleton positioning segmentation method to obtain a cap region and a stipe region, and to measure the cap region and the stipe region using a minimum circumscribed rectangle algorithm.
Citation Information
Patent Citations
Method for cultivating ornamental lucid ganoderma by using waste fungus for producing pleurotus eryngii in industrialized manner
CN103460999A
Portabella pileus region vision online measurement method based on depth camera
CN110084799A
Crop included angle measurement method based on image recognition and application thereof
CN115393352A
Mushroom form data acquisition method and system, storage medium and equipment
CN118397028A
Edible mushroom phenotype parameter acquisition method and system
CN119540950A
Cited By
Indoor cultivation method and system for edible mushrooms and storage medium
CN120982350A
Lucid ganoderma image analysis method, device and system
CN121600008A