Edible mushroom measurement method and system based on image recognition technology
Automatically measure the cap and stem of edible mushrooms through image recognition technology, solving the problems of low manual measurement efficiency and poor reliability, and achieving efficient and accurate edible mushroom morphology analysis.
Patent Information
- Application Number
- CN202510559166.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-30
- Publication Date
- 2025-08-15
- Estimated Expiration
- 2045-04-30
AI Technical Summary
In the prior art, the phenotype measurement of fruiting mushrooms relies on manual operation, is inefficient, is susceptible to damage and has poor reliability in measurement results.
Using an image recognition technology method, the caps and stems of edible mushrooms are automatically measured through image acquisition, pre-processing, skeleton positioning and segmentation method and the minimum external rectangle algorithm, and the pre-processing configuration file is constructed to adapt to different lighting conditions.
Fully automatic and high-precision measurement of edible mushroom morphological parameters is realized, avoiding the subjectivity and damage of manual measurement, and providing real-time, non-destructive phenotypic analysis tools.
Smart Images

Figure CN120088248B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a method and system for measuring edible mushrooms based on image recognition technology. Background Art
[0002] Currently, phenotypic measurement of edible mushroom fruiting bodies relies primarily on manual labor, using calipers to measure cap width, stipe length, and other indicators after harvesting. However, manual measurement is inefficient, labor-intensive, and slow. Furthermore, samples are susceptible to physical damage during the harvesting and segmentation process, compromising subsequent analysis. Furthermore, manual data recording is prone to sample confusion and mislabeling, resulting in reduced reliability of measurement results. Summary of the Invention
[0003] The purpose of this application is to overcome the shortcomings of the existing technology and provide a method and system for measuring edible mushrooms based on image recognition technology.
[0004] In a first aspect, the present application provides a method for measuring edible mushrooms based on image recognition technology, comprising the following steps:
[0005] Collect sample edible mushroom images;
[0006] Preprocessing the sample edible mushroom image to obtain a preprocessing configuration file;
[0007] 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;
[0008] The region of interest is segmented 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.
[0009] Optionally, the preprocessing of the sample edible mushroom image to obtain a preprocessing configuration file includes:
[0010] Using a filter to smooth the sample edible mushroom image to obtain a denoised sample edible mushroom image;
[0011] performing morphological transformation on the denoised sample edible mushroom image;
[0012] Perform gradient detection on the sample edible mushroom image after morphological transformation;
[0013] Thresholding is performed on the sample edible mushroom image after gradient detection to obtain a binary image;
[0014] Performing edge detection on the binary image to obtain points with significant brightness changes in the binary image;
[0015] Obtaining continuous edge points in the binary image by contour detection to obtain the contour of the sample edible mushroom in the binary image;
[0016] Arrange and save the parameters in the above steps to obtain a preprocessing configuration file.
[0017] Optionally, the skeleton positioning segmentation method is used to segment the region of interest to obtain a cap region and a stipe region, and a minimum circumscribed rectangle algorithm is used to measure the cap region and the stipe region to achieve measurement of the edible mushroom to be measured, including:
[0018] Refining the region of interest by iterative morphological transformation to obtain a skeleton of the region of interest;
[0019] 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;
[0020] Traversing all points on the outline of the edible mushroom to be tested, calculating the distance between each point on the outline of the edible mushroom to be tested and the main growth direction, determining the point on the outline 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;
[0021] The dividing point where the cap is unfolded is used as the vertical foot, and a vertical line is drawn in the main growth direction to obtain the dividing line;
[0022] 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.
[0023] Optionally, the thinning the region of interest by iterative morphological transformation to obtain a skeleton of the region of interest includes:
[0024] Perform morphological transformation on the region of interest to remove edge pixels;
[0025] 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.
[0026] Optionally, the morphological transformation includes erosion and dilation.
[0027] As an example, the method of using a convolution kernel to detect a 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:
[0028] Use the 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;
[0029] Calculate the distance between each two endpoints and get the two endpoints with the farthest distance;
[0030] 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.
[0031] Optionally, determining the cap region and the stipe region based on the dividing 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:
[0032] 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;
[0033] A minimum bounding rectangle algorithm is used to construct rectangles for the cap region and the stipe region, respectively. The rectangles respectively contain all points on the outline of the edible mushroom to be tested and have the smallest area.
[0034] Optionally, 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 mushroom to be tested.
[0035] Optionally, collecting the sample edible mushroom images includes: placing the edible mushrooms at intervals on a dark background, and photographing them using a fixed camera to obtain the sample edible mushroom images under the same ambient lighting and similar background.
[0036] In a second aspect, the present application also provides a measurement system for edible mushrooms based on image recognition technology, comprising:
[0037] An image acquisition module, used for acquiring images of sample edible mushrooms;
[0038] A preprocessing module, configured to preprocess the sample edible mushroom image to obtain a preprocessing configuration file;
[0039] a contour recognition module, configured to pre-process the image of the edible mushroom to be tested according to the pre-processing 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;
[0040] The measurement and analysis module is used to detect the region of interest using a skeleton positioning and 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 to achieve measurement of the edible mushroom to be measured.
[0041] The present application provides a method and system for measuring edible mushrooms based on image recognition technology. By establishing a standardized image acquisition process, constructing a multi-stage preprocessing configuration file, and an innovative skeleton positioning and segmentation method combined with a minimum circumscribed rectangle cap and stipe separation algorithm, it is possible to achieve fully automatic and high-precision measurement of the morphological parameters of edible mushrooms; 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 of the cap and stipe, and the minimum circumscribed rectangle algorithm can accurately quantify the cap diameter and stipe length. The present application breaks through the subjectivity and low efficiency limitations of traditional manual measurement, and provides a real-time, non-destructive phenotypic analysis tool for edible mushroom variety selection, growth cycle monitoring, and factory production, with significant application value.
[0042] In order to make the above features and advantages of the present invention more clearly understood, embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0044] Figure 1 This is a flowchart of a method for measuring edible mushrooms based on image recognition technology provided in one embodiment of the present application.
[0045] Figure 2 This is a sample edible mushroom image collected in the edible mushroom measurement method based on image recognition technology provided in one embodiment of the present application.
[0046] Figure 3 This is a flowchart of step S20 in the method for measuring edible mushrooms based on image recognition technology provided in one embodiment of the present application.
[0047] Figure 4 This is a contour image of a sample edible mushroom obtained by preprocessing in the edible mushroom measurement method based on image recognition technology provided in one embodiment of the present application.
[0048] Figure 5This is a schematic diagram of the region of interest of the edible mushrooms to be measured in the edible mushroom measurement method based on image recognition technology provided in one embodiment of the present application.
[0049] Figure 6 This is a flowchart of step S40 in the method for measuring edible mushrooms based on image recognition technology provided in one embodiment of the present application.
[0050] Figure 7 This is a schematic diagram of the fruiting body skeleton of an edible mushroom in the edible mushroom measurement method based on image recognition technology provided in one embodiment of the present application.
[0051] Figure 8 This is a schematic diagram of the cap area and stipe area in the edible mushroom measurement method based on image recognition technology provided in one embodiment of the present application.
[0052] Figure 9 This is a schematic structural diagram of an edible mushroom measurement system based on image recognition technology provided in another embodiment of the present application. DETAILED DESCRIPTION
[0053] To make the purpose and technical solutions of the embodiments of the present application clearer, the technical solutions of the embodiments of the present application will be clearly and completely described below in conjunction with the drawings of the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the described embodiments of the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0054] In one embodiment, see Figure 1 The present application provides a method for measuring edible mushrooms based on image recognition technology. The method for measuring edible mushrooms based on image recognition technology may include the following steps: S10~S40.
[0055] S10: Collect sample edible mushroom images.
[0056] S20: Preprocessing the sample edible mushroom image to obtain a preprocessing configuration file.
[0057] S30: 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, and the area formed by the outline of the edible mushroom to be tested corresponds to the region of interest.
[0058] S40: Segmenting the region of interest using a skeleton positioning segmentation method to obtain a cap region and a stipe region, 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.
[0059] In the measurement method of edible mushrooms based on image recognition technology of the present application, a standardized processing flow of samples and images to be measured is realized by constructing a preprocessing configuration file, which can effectively eliminate the influence of external factors such as light and background interference on image analysis; the cap and stipe areas are accurately segmented by the skeleton positioning segmentation method, and the minimum circumscribed rectangle algorithm is combined to realize quantitative measurement of morphological parameters, which can accurately obtain key phenotypic indicators such as cap diameter and stipe height; the non-contact image acquisition method avoids the damage to the sample caused by traditional manual measurement, and is suitable for continuous dynamic monitoring of living samples, with significant advantages of high efficiency, objectivity and repeatability; the present application can realize rapid evaluation of the growth status of edible mushrooms through automated contour extraction and multi-algorithm fusion analysis, providing data support for variety selection and cultivation optimization.
[0060] In step S10, refer to Figure 1 In step S10, sample edible mushroom images are collected.
[0061] As an example, edible mushroom samples are harvested and scattered on a dark background. The samples do not overlap. A fixed-position camera is used to take photos to obtain several sample edible mushroom images with the same ambient lighting and similar background. For example, Figure 2 shown.
[0062] As an example, the edible mushrooms may include: velvet antler mushrooms.
[0063] In one example, Pleurotus ostreatus is used as the edible mushroom sample, and the edible mushroom sample can be a Pleurotus ostreatus strain provided by the Edible Fungi Research Institute of Shanghai Academy of Agricultural Sciences.
[0064] As an example, the cultivation formula of the Pleurotus ostreatus strain may include: 29% sawdust, 22% rice bran, 15% cottonseed hulls, 11% corn cobs, 10% bean dregs, 8% corn flour, 5% bran, 63%-65% moisture content, and pH 8.0-8.2.
[0065] As an example, the cultivation method of the velvet antler mushroom strain may include: each cultivation bottle (1100 mL) is filled with (660±10) g (wet weight) of cultivation culture medium, sterilized with high-pressure steam at 121°C for 2 h, placed in a cooling room, and inoculated using an automatic inoculator when the center temperature of the culture medium in the cultivation bottle is lower than 22°C, with an inoculation amount of 30 mL / bottle to 40 mL / bottle; placed in a 22°C culture room in the dark, with the temperature between the cultivation bottles maintained at 20-25°C, the relative humidity of the air at 65% to 75%, the CO2 mass concentration ≤ 3500 mg / kg, and scratching the fungi after 45 days of cultivation; the temperature in the fruiting room is 15-18°C, the CO2 mass concentration is 2500-3500 mg / kg, the lights are turned on appropriately according to the fruiting situation, and the mushrooms are harvested after 22 to 25 days.
[0066] As an example, a Hikvision industrial camera MV-CA013-20GC may be used for image capture.
[0067] In step S20, refer to Figure 1 In step S20, the sample edible mushroom image is preprocessed to obtain a preprocessing configuration file.
[0068] As an example, see Figure 3 , step S20 may include the following steps: S201~S207.
[0069] S201: Using a filter to smooth the sample edible mushroom image to obtain a denoised sample edible mushroom image.
[0070] S202: Performing morphological transformation on the denoised sample edible mushroom image.
[0071] S203: Performing gradient detection on the sample edible mushroom image after morphological transformation.
[0072] S204: Thresholding the sample edible mushroom image after gradient detection to obtain a binary image.
[0073] S205: Perform edge detection on the binary image to obtain points with significant brightness changes in the binary image.
[0074] S206: Obtain continuous edge points in the binary image through contour detection, and obtain the contour of the sample edible mushroom in the binary image.
[0075] S207: Arrange and save the parameters in steps S201 to S206 to obtain a preprocessing configuration file.
[0076] As an example, in order to clearly separate the edible mushroom target from the background, a series of image preprocessing operations are required for the sample edible mushroom image. First, the color sample edible mushroom image is decomposed into three channels: red (R), green (G), and blue (B). A grayscale conversion formula is used for weighted calculation, integrating the information of the three channels to avoid detail loss caused by a single channel. The calculation result is converted to a grayscale value range of 0-255 to form a single-channel grayscale image. The grayscale conversion formula is as follows:
[0077]
[0078] in, Gray is the grayscale channel, R For the red channel, G For the green channel, BBy converting color sample edible mushroom images into grayscale sample edible mushroom images, a stable grayscale background is provided for subsequent parameter measurements, effectively reducing analytical errors caused by color interference and ensuring a clearer boundary between the cap and stipe during subsequent contour extraction.
[0079] Furthermore, in step S201, a filter is used to smooth the grayscale sample edible mushroom image to obtain a denoised sample edible mushroom image. Specifically, the filter is slid across the grayscale sample edible mushroom image, and convolution is performed by element-wise multiplication and summing at each position. The pixel value at each position is modified based on the surrounding pixel values to obtain a new pixel value, thereby reducing noise and details in the grayscale sample edible mushroom image, making the grayscale sample edible mushroom image appear softer.
[0080] As an example, the filter may include: a Gaussian filter, a mean filter, and a median filter.
[0081] As an example, the Gaussian filter calculates pixel values based on Gaussian distribution weights, as expressed below:
[0082]
[0083] in, 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; 、 are coordinates relative to the center point.
[0084] As an example, the mean filter replaces the grayscale value of each pixel with the average value of all pixels in its neighborhood by constructing a convolution kernel of all 1s, thereby eliminating noise by reducing the contrast between pixels. The convolution kernel M is expressed as follows:
[0085]
[0086] Among them, k is the convolution kernel size.
[0087] As an example, the median filter sorts the pixel values in the neighborhood of each pixel in the image and takes the median value as the output. The expression is as follows:
[0088]
[0089] in, is the pixel at coordinate (x,y) of the median-processed image, is the pixel of the grayscale sample edible mushroom image at coordinate (x+i,y+i), is the area radius.
[0090] Furthermore, in step S202, a morphological transformation is performed on the denoised sample edible mushroom image. This morphological transformation includes two basic operations: erosion and dilation. Erosion reduces the size of foreground objects, while dilation expands them. Morphological transformations can be combined to achieve more complex transformations, such as opening (erosion followed by dilation) and closing (dilation followed by erosion), to eliminate speckles and extract structural features from the image, such as boundaries and connected components.
[0091] Furthermore, in step S203, gradient detection is performed on the sample edible mushroom image after morphological transformation, and edges are located by calculating the derivative of the image brightness using the gradient operator in the horizontal and vertical directions. The gradient operator may include: Sobel operator, Prewitt operator, and Roberts operator.
[0092] Furthermore, in step S204, the sample edible mushroom image after gradient detection is thresholded. 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 value is less than the threshold, it is set to 0, thereby converting the grayscale image into a binary image to simplify the image data and facilitate further processing. The expression of the thresholding operation is as follows:
[0093]
[0094] in, is the threshold, is the pixel value of the image at coordinate (x, y) after thresholding, is the grayscale value of the pixel at coordinate (x, y) in the original image.
[0095] Furthermore, in step S205, edge detection is performed on the binary image using an edge detection algorithm to identify areas in the image where brightness changes significantly, and points in the binary image where brightness changes significantly, i.e., grayscale gradient mutation points, are obtained to locate the outline or boundary of the object.
[0096] As an example, the edge detection algorithm may include: Canny edge detection, Sobel edge detection, and Laplacian edge detection.
[0097] Furthermore, in step S206, the contour of the sample edible mushroom in the binary image is found by searching for continuous edge points through the contour, and the contour of the sample edible mushroom in the binary image is obtained, that is, a set of continuous points with the same color or intensity. The contour of the sample edible mushroom in the binary image is obtained as follows: Figure 4 .
[0098] As an example, we can use the findContours function in OpenCV to perform contour detection and obtain the contours of sample edible mushrooms in a binary image.
[0099] Furthermore, in step S207, the parameters in steps S201 to S206 are adjusted to obtain a clear outline of the sample edible mushroom (e.g. Figure 4 The parameters are organized and saved to create a preprocessing configuration file. This preprocessing configuration file is saved as an ini file so that it can be reused with other images in the same batch. The parameters saved in the preprocessing configuration file are shown in Table 1.
[0100] Table 1 Parameters saved in the preprocessing configuration file
[0101]
[0102] Table 1 Parameters saved in the preprocessing configuration file
[0103]
[0104] As an example, the grayscale is converted to gray using the default formula. The smoothing filter type can be mean wave (kind=0), and the filter kernel size can be 3 (ksize=3). The morphological method can be opening operation (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 reduce the boundary. The gradient algorithm can be the Sobel operator (kind=0), and the kernel size can be 7 (ksize=7). The edge detection can be the Canny algorithm (thresh1=80, thresh2=200). The contour retrieval mode can be only the external contour (mode=0) to separate independent edible mushrooms, and the contour approximation method can be compressing redundant points (method=1) to reduce the amount of data.
[0105] In step S30, refer to Figure 1 In step S30, the image of the edible mushroom to be tested is preprocessed according to the preprocessing configuration file to obtain the outline of the edible mushroom to be tested, and the area formed by the outline of the edible mushroom to be tested corresponds to the region of interest.
[0106] As an example, the preprocessing configuration file is used to preprocess the image of the edible mushroom to be tested, and the outline of the edible mushroom to be tested in the image is obtained. The area formed by the outline of the edible mushroom to be tested is the region of interest (ROI area). Figure 5Alternatively, the outline of the edible mushroom to be tested may be traversed to obtain the region of interest.
[0107] In step S40, refer to Figure 1 In step S40, the region of interest is segmented 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.
[0108] As an example, see Figure 6 , step S40 may include the following steps: S401~S405.
[0109] S401: Refining the region of interest through iterative morphological transformation to obtain a skeleton of the region of interest.
[0110] S402: Use a 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.
[0111] S403: traverse all points on the outline of the edible mushroom to be tested, calculate the distance between each point on the outline of the edible mushroom to be tested and the main growth direction, determine the point on the outline of the edible mushroom to be tested with the largest distance to the main growth direction, and obtain the demarcation point of the cap expansion.
[0112] S404: The demarcation point where the cap is unfolded is used as a vertical foot, and a vertical line is drawn in the main growth direction to obtain a demarcation line.
[0113] S405: Determine the cap region and the stipe region based on the boundary line, and measure the cap region and the stipe region using a minimum circumscribed rectangle algorithm to achieve measurement of the edible mushroom to be measured.
[0114] As an example, in step S401, a structural element is constructed and convolved with the ROI. If the structural element is completely contained in the ROI area, the pixel value at that position is set to 1, otherwise it is set to 0. The edge pixels, isolated pixels, discontinuous lines, etc. are eroded to uniformly shrink the ROI area by one layer, that is, the boundary is indented inward. The above steps are repeated until there are no pixels that can be deleted. Through multiple iterative erosions, the ROI area is gradually reduced from the outside to the inside, and the edges of the cap and stipe will gradually become thinner until the skeleton of the central axis of the region of interest is obtained, as shown in FIG. Figure 7 shown.
[0115] As an example, after each erosion operation, we need 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 split into multiple parts.
[0116] As an example, the structure element may be a 3×3 cross-shaped structure element.
[0117] Furthermore, in step S402, the convolution kernel is used to traverse the skeleton, and the number of adjacent pixels of each pixel on the skeleton is counted to obtain pixel points with only one adjacent pixel, i.e., endpoints; the distance between each two endpoints is calculated to obtain the two endpoints with the farthest distance; the coordinate difference between the two endpoints with the farthest distance is calculated to obtain a direction vector, and the direction vector is used as the main growth direction.
[0118] Specifically, use the convolution kernel to traverse the skeleton, count the number of adjacent pixels of each pixel on the skeleton, and obtain the endpoints of the skeleton. The number of adjacent pixels around the endpoints of the skeleton is 1; calculate the Euclidean distance between any two endpoints, and determine the two endpoints with the largest distance, which are recorded as endpoint A. and endpoints .
[0119] Furthermore, we can use endpoint A as the starting point and endpoint B as the end point, and calculate the coordinate difference between the two to get the direction vector , i.e. the main growth direction, which indicates the main extension direction of the edible mushroom to be tested.
[0120] Furthermore, in step S403, all points on the outline of the edible mushroom to be tested are traversed, the distance between each point on the outline of the edible mushroom to be tested and the main growth direction is calculated, the point on the outline of the edible mushroom to be tested with the largest distance to the main growth direction is determined, and the dividing point of the cap expansion is obtained.
[0121] As an example, the set of all points on the contour of the edible mushroom to be tested ,in, is the coordinate of the i-th point on the contour of the edible mushroom to be tested. The distance to the straight line corresponding to the main growth direction is , the expression is:
[0122]
[0123] in, 、 are the abscissa and ordinate of endpoint A, 、 are the abscissa and ordinate of endpoint A, 、 are the horizontal and vertical coordinates of any point on the contour of the edible mushroom to be tested.
[0124] As an example, for the fruiting body of Pleurotus ostreatus, the cap is semi-oblate, and the point of its maximum lateral expansion (i.e. the widest part of the cap) must be the point farthest from the main growth direction.
[0125] Furthermore, let the initial maximum distance from the outline of the edible mushroom to the straight line corresponding to the main growth direction be , traverse all points on the contour of the edible mushroom to be tested, and calculate the distance from each point to the straight line corresponding to the main growth direction as ,like , then update the maximum distance , the point corresponding to the maximum distance is the dividing point O , which is the dividing point where the cap unfolds.
[0126] As an example, if there are multiple points with the same maximum distance (such as two symmetrical points), the point on the side of the main growth direction (such as the side with the cap facing upward) can be taken as the final dividing point, or the midpoint can be taken to ensure the uniqueness of the dividing line.
[0127] Furthermore, in step S404, the demarcation point O As the foot of the perpendicular, draw a perpendicular line to the straight line corresponding to the main growth direction, and this perpendicular line is the dividing line between the cap and the stipe.
[0128] Furthermore, in step S405, the cap area and the stipe 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 stipe area; a minimum circumscribed rectangle algorithm is used to construct rectangles for the cap area and the stipe area respectively, and the rectangles respectively contain all points on the outline of the edible mushroom to be measured and have the smallest area; 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 to the stipe length, and the width of the stipe area rectangle is set to the stipe width, thereby achieving measurement of the edible mushroom to be measured.
[0129] Specifically, the set of all points on the contour of the cap area of the edible mushroom to be tested is , with the main growth direction as axis, the dividing line is Axis, establish a local coordinate system, and set Convert the points in to local coordinates .exist direction (perpendicular to the main growth direction) to find the minimum , maximum value , then the width is ;exist direction (perpendicular to the main growth direction) to find the minimum , maximum value , then the length is .
[0130] Further, and For the diagonal vertices, a rectangle parallel to the local coordinate system is constructed to ensure that it contains all the contour points of the cap and has the smallest area (because the cap is an oblate spheroid, the maximum width is perpendicular to the main growth direction).
[0131] Furthermore, the set of all points on the contour of the cap area of the edible mushroom to be tested is , using the minimum enclosing rectangle algorithm to construct a rectangle, ensuring a close fit to the columnar structure. The specific method for constructing the rectangle of the stipe region can be referred to the specific method for constructing the rectangle of the cap region, and will not be repeated here.
[0132] Furthermore, the width of the cap area rectangle is determined as the cap diameter, the length 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, thereby achieving the measurement of the edible mushroom to be measured. The measurement results obtained by the minimum bounding rectangle algorithm are as follows: Figure 8 shown.
[0133] In the measurement method of edible mushrooms based on image recognition technology of the present application, samples are photographed with a fixed camera position and a dark background to reduce interference from light and background; a preprocessing configuration file is constructed through preprocessing operations, and parameters such as smoothing and morphological transformation are integrated to form a standardized processing flow to eliminate the influence of external factors on image analysis; the image of the edible mushroom to be measured is processed according to the preprocessing configuration file to accurately extract the contour and region of interest (ROI); the cap and stipe regions are segmented by the skeleton positioning segmentation method, and quantitative measurement combined with the minimum enclosing rectangle algorithm can avoid the regional division errors caused by irregular morphology of traditional segmentation methods, and ensure that the boundary definition of the cap and stipe conforms to the actual morphology. The present application can accurately analyze the growth status of edible mushrooms, help judge the quality of edible mushrooms, achieve high efficiency, objectivity and repeatability of morphological analysis of edible mushrooms, provide accurate data support for variety selection and cultivation optimization, and can effectively improve the accuracy and practicality of analysis.
[0134] It should be understood that although the steps in the flowcharts of the accompanying drawings are shown in sequence as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least some of the steps in the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The order of execution of these sub-steps or stages is not necessarily sequential, but can be executed in rotation or alternation with other steps or at least a portion of the sub-steps or stages of other steps.
[0135] In another embodiment, see Figure 9The present application also provides a measurement system for edible mushrooms 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 and analysis module 4. The image acquisition module 1 is used to acquire sample edible mushroom images; the preprocessing module 2 is used to preprocess the sample edible mushroom images to obtain a preprocessing configuration file; the contour recognition module 3 is used to 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; the measurement and analysis module 4 is used to segment the region of interest using a skeleton positioning segmentation method to obtain a cap region and a stipe region, and measure the cap region and the stipe region using a minimum enclosing rectangle algorithm.
[0136] In the above-mentioned measurement system of edible mushrooms based on image recognition technology, the image acquisition module 1 standardizes the acquisition process to ensure the basic quality of the image; the preprocessing module 2 generates a preprocessing configuration file to provide a parameter basis for image standardization processing and eliminate the influence of environmental interference on the analysis; the contour recognition module 3 constructs the contour and the region of interest based on the configuration file to ensure the consistency of the preprocessing of the image to be measured; the measurement and analysis module 4 uses the skeleton positioning segmentation method and the minimum circumscribed rectangle algorithm to accurately segment the cap and stipe areas and quantify the measurements, and quickly output the core phenotypic data such as the cap diameter and stipe length. The present application can realize an automated closed loop from image acquisition to analysis, which not only improves the efficiency of phenotypic analysis of edible mushrooms, but also ensures the accuracy and repeatability of the results, and provides efficient and reliable technical support for the selection and breeding of edible mushroom varieties, cultivation management, etc.
[0137] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, 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, they should be considered to be within the scope of this specification.
[0138] Although the present application has been disclosed above with reference to the embodiments, they are not intended to limit the present application. Anyone with ordinary knowledge in the technical field may make slight changes and modifications without departing from the spirit and scope of the present application. Therefore, the scope of protection of the present application shall be determined by the scope of the appended patent application.
Claims
1. A method for measuring edible mushrooms based on image recognition technology, characterized in that: The following steps are involved: Collecting sample edible mushroom images, wherein the sample edible mushroom images include color sample edible mushroom images; Decomposing the color sample edible mushroom image into three channels of red, green, and blue, performing weighted calculation using a grayscale conversion formula, and converting the calculation result into a grayscale value range of 0-255 to obtain a grayscale sample edible mushroom image; Preprocessing the grayscale 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 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, including: Refining the region of interest by iterative morphological transformation to obtain a skeleton of the region of interest, including: performing morphological transformation on the region of interest to remove edge pixels; repeating the above steps until there are no pixels that can be deleted, thereby obtaining a skeleton of the central axis 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 outline of the edible mushroom to be tested, calculating the distance between each point on the outline of the edible mushroom to be tested and the main growth direction, determining the point on the outline 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 dividing point where the cap is unfolded is used as the vertical foot, and a vertical line is drawn in the main growth direction to obtain the dividing 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.
2. The method for measuring edible mushrooms based on image recognition technology according to claim 1, characterized in that: Preprocessing the grayscale sample edible mushroom image to obtain a preprocessing configuration file, including: Using a filter to smooth the grayscale 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 is performed on 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 to obtain 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 morphological transformation includes erosion and dilation.
4. The method for measuring edible mushrooms based on image recognition technology according to claim 1, characterized in that: The method of using a convolution kernel to detect a 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 points with only one adjacent pixel, that is, the endpoints; Calculate the distance between each 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.
5. The method for measuring edible mushrooms based on image recognition technology according to claim 1, 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 bounding rectangle algorithm is used to construct rectangles for the cap region and the stipe region, respectively. The rectangles respectively contain all points on the outline of the edible mushroom to be tested and have the smallest area.
6. The method for measuring edible mushrooms based on image recognition technology according to claim 5, 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 realize the measurement of the edible mushroom to be measured.
7. 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, photographing the mushrooms using a fixed camera, and obtaining sample edible mushroom images under the same ambient lighting and similar background.
8. A measurement system for edible mushrooms based on image recognition technology, characterized in that: The edible mushroom measurement system based on image recognition technology is used to perform the edible mushroom measurement method based on image recognition technology according to any one of claims 1 to 7; The edible mushroom measurement system based on image recognition technology includes: An image acquisition module, used for acquiring images of sample edible mushrooms; A preprocessing module, configured to preprocess the sample edible mushroom image to obtain a preprocessing configuration file; a contour recognition module, configured to pre-process the image of the edible mushroom to be tested according to the pre-processing 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
Mushroom form data acquisition method and system, storage medium and equipment
CN118397028A