A method and device for measuring the width and uniformity of a grain ridge

CN116740163BActive Publication Date: 2026-09-11KWEICHOW MOUTAI COMPANY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310480408.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-28
Publication Date
2026-09-11
Estimated Expiration
2043-04-28

AI Technical Summary

Technical Problem

[0004]目前,采用人工测量的方式存在测量点位少、误记以及漏记等问题,不仅耗费人力资源,还导致粮埂的宽度和宽度均匀度测量结果准确度较低

Benefits of technology

[0016]The method and apparatus for measuring the width and uniformity of grain ridges, the method comprising: generating at least one grain ridge mask image to be measured; for each grain ridge mask image to be measured, adding a central axis and segmenting the central axis to obtain at least two sub-central axes; for each sub-central axis, generating a second straight line perpendicular to a first straight line, wherein the first straight line is used to indicate the straight line formed by connecting the two ends of the sub-central axis; obtaining the sub-pixel width of the portion of the grain ridge mask image to be measured corresponding to the sub-central axis based on the intersection line segment of the second straight line and the grain ridge mask image to be measured; obtaining the average pixel width and pixel width uniformity of the grain ridge mask image to be measured based on the sub-pixel widths of the various portions of the grain ridge mask image to be measured in the same grain ridge mask image; and converting the average pixel width and pixel width uniformity of the same grain ridge mask image to obtain the actual width and actual width uniformity of the grain ridge to be measured corresponding to the grain ridge mask image to be measured. As can be seen, this application calculates the sub-pixel width of each part of the grain ridge mask image to be measured using the micro-element method, calculates the average pixel width and pixel width uniformity of the entire grain ridge mask image to be measured, and finally converts the average pixel width and pixel width uniformity into the actual width and actual width uniformity of the grain ridge to be measured, respectively. This method realizes the automatic measurement of the width and width uniformity of the grain ridge, which not only improves the problem of human resource consumption in the prior art, but also meets the accuracy and reliability of the measurement results, thereby promoting workers to operate according to process requirements and ensuring the quality of wine production.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116740163B_ABST
    Figure CN116740163B_ABST
Patent Text Reader

Abstract

The application relates to a kind of grain ridge width and width uniformity measurement method and device.The method comprises: generating at least one grain ridge mask to be measured; adding a center axis in the grain ridge mask to be measured, and the center axis is segmented to obtain at least two sub-center axes; a second straight line perpendicular to the first straight line is generated, wherein the first straight line is used to indicate the straight line formed by connecting the two ends of the sub-center axis; according to the intersection line segment of the second straight line and the grain ridge mask to be measured, the sub-pixel width of the part of the grain ridge mask to be measured corresponding to the sub-center axis is obtained; according to the sub-pixel width of each part of the grain ridge mask to be measured, the average pixel width and the pixel width uniformity of the grain ridge mask to be measured are obtained; the average pixel width and the pixel width uniformity are converted to obtain the actual width and the actual width uniformity of the grain ridge to be measured. The method can improve the problem of human resource consumption in the prior art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of automated detection technology in the brewing industry, and in particular to a method and apparatus for measuring the width and uniformity of grain ridges. Background Technology

[0002] A grain mound refers to a strip-shaped mound formed by spreading the steamed grain mash evenly, cooling it to a suitable temperature, and then gathering it together. The main purpose of gathering the grain mash into strip-shaped mounds is to facilitate the subsequent thorough mixing of the tail liquor, koji (fermented starter), and grain mash, thereby increasing the moisture and aroma of the grain mash and inoculating it with microorganisms.

[0003] The width of the grain ridges varies, affecting the uniformity of mixing the tail liquor, koji (fermentation starter), and grain mash. Furthermore, the degree of width variation within the same grain ridge in different areas (i.e., the uniformity of grain ridge width) influences the mixing ratio of tail liquor, koji, and grain mash from different regions, thus impacting the quality of the produced liquor. Therefore, the width and uniformity of the grain ridges are relatively important indicators. Monitoring the width and uniformity of the grain ridges helps encourage workers to operate according to process requirements, ensuring the quality of the produced liquor.

[0004] Currently, manual measurement methods suffer from problems such as a limited number of measurement points, misrecording, and omissions. This not only wastes human resources but also results in low accuracy of the measurement results for the width and uniformity of the grain ridges. Summary of the Invention

[0005] Based on this, a method and apparatus for measuring the width and uniformity of grain ridges are provided to automatically measure the width and uniformity of grain ridges, thereby improving the problem of high human resource consumption in the prior art.

[0006] Firstly, a method for measuring the width and uniformity of grain ridges is provided, the method comprising: Generate at least one mask image of the grain ridge to be measured; Add a central axis to the mask diagram of the grain ridge to be measured, and divide the central axis into segments to obtain at least two sub-central axes; Generate a second straight line perpendicular to the first straight line, wherein the first straight line is used to indicate the straight line formed by connecting the two ends of the sub-center axis; The sub-pixel width of the portion of the grain ridge mask to be measured corresponding to the sub-central axis is obtained based on the intersection line segment of the second straight line and the grain ridge mask to be measured. Based on the sub-pixel width of the portion of the grain ridge mask image to be measured corresponding to each of the sub-center axes, the average pixel width and pixel width uniformity of the grain ridge mask image to be measured are obtained. The average pixel width and the pixel width uniformity are converted to obtain the actual width and actual width uniformity of the grain ridge to be measured corresponding to the mask image of the grain ridge to be measured.

[0007] In conjunction with the first aspect, in a first possible implementation of the first aspect, prior to the step of generating at least one mask image of the grain ridge to be measured, the method further includes: Acquire at least one sample panoramic image, wherein the sample panoramic image includes at least one sample grain ridge; A mask image of the actual grain ridge area of ​​the sample grain ridge is obtained based on the panoramic image of the sample. The sample panoramic image is predicted by the semantic segmentation model to be trained, and the predicted grain ridge region mask map of the sample grain ridge is obtained. Pixel loss is calculated based on the predicted grain ridge area mask and the actual grain ridge area mask; The semantic segmentation model to be trained is iteratively trained based on the pixel loss to obtain the trained semantic segmentation model; The trained semantic segmentation model is used to generate a mask map of the grain ridge region to be measured based on the acquired panoramic image to be measured, and the mask map of the grain ridge region to be measured is used to generate at least one mask map of the grain ridge to be measured.

[0008] In a second possible implementation of the first aspect, in conjunction with the first possible implementation of the first aspect, the step of calculating pixel loss based on the predicted grain ridge region mask and the actual grain ridge region mask includes: Obtain the real pixels of each pixel in the real grain ridge area mask image, and the predicted pixels of each pixel in the predicted grain ridge area mask image; Based on the actual pixels and predicted pixels of each pixel, the pixel loss is calculated, wherein the mathematical expression for calculating the pixel loss includes: ; For the pixel loss, The row coordinates of the pixels in the actual grain ridge area mask or the predicted grain ridge area mask. The column coordinates of the pixels in the actual grain ridge area mask or the predicted grain ridge area mask. The width of the sample panoramic image, The height of the sample panoramic image, To be located in the mask diagram of the actual grain ridge area line, number The actual pixels of the column's pixels. To be located in the mask map of the predicted grain ridge area line, number The predicted pixels of the column's pixels.

[0009] In conjunction with the first possible implementation of the first aspect, in the third possible implementation of the first aspect, after the step of predicting the sample panoramic image through the semantic segmentation model to be trained to obtain the predicted grain ridge region mask map, the method further includes: Based on the actual grain ridge area mask, calculate the actual pixel mean and actual pixel variance; Based on the predicted grain ridge area mask, calculate the predicted pixel mean and predicted pixel variance; The region similarity loss is calculated based on the mean of the real pixels, the variance of the real pixels, the mean of the predicted pixels, and the variance of the predicted pixels. The semantic segmentation model to be trained is iteratively trained based on the region similarity loss to obtain the trained semantic segmentation model.

[0010] In conjunction with the third possible implementation of the first aspect, in the fourth possible implementation of the first aspect, the step of calculating the region similarity loss based on the true pixel mean, the true pixel variance, the predicted pixel mean, and the predicted pixel variance includes: Obtain the preset first and second coefficients; Calculate the pixel covariance based on the mean of the actual pixels, the mean of the predicted pixels, the variance of the actual pixels, and the variance of the predicted pixels; The region similarity loss is calculated based on the true pixel mean, the true pixel variance, the predicted pixel mean, the predicted pixel variance, the first coefficient, the second coefficient, and the pixel covariance. The mathematical expression for calculating the region similarity loss includes: ; The region similarity loss is... The predicted pixel mean, The average value of the actual pixels. For the first coefficient, Let the pixel covariance be... The second coefficient, Let Variance be the predicted pixel variance. Let be the variance of the actual pixels.

[0011] In conjunction with the first possible implementation of the first aspect, in the fifth possible implementation of the first aspect, after the step of predicting the sample panoramic image through the semantic segmentation model to be trained to obtain the predicted grain ridge region mask map, the method further includes: The image overlap loss is calculated based on the predicted grain ridge region mask and the actual grain ridge region mask, wherein the mathematical expression for calculating the image overlap loss includes: ; The image overlap loss is... The row coordinates of the pixels in the actual grain ridge area mask or the predicted grain ridge area mask. The column coordinates of the pixels in the actual grain ridge area mask or the predicted grain ridge area mask. The width of the sample panoramic image, The height of the sample panoramic image, To be located in the mask diagram of the actual grain ridge area line, number The actual pixels of the column's pixels. To be located in the mask map of the predicted grain ridge area line, number The predicted pixels of the column's pixels; The semantic segmentation model to be trained is iteratively trained based on the image overlap loss to obtain the trained semantic segmentation model.

[0012] In conjunction with the first aspect, in a sixth possible implementation of the first aspect, the step of adding a central axis to the masked image of the grain ridge to be measured includes: Extract the skeleton of the mask image of the grain ridge to be measured, and generate the coordinates of the skeleton point set of the skeleton; Based on the coordinates of each skeleton point in the skeleton point set, calculate the interval distance between each pair of adjacent skeleton points; Obtain a preset distance threshold, filter out the skeleton point pairs whose interval distance is greater than the distance threshold, and obtain the filtered skeleton point set; Based on the filtered skeleton point set, taking one of the skeleton points located at the end as a reference point, the remaining skeleton points other than the reference point are connected in series to obtain the central axis.

[0013] In conjunction with the first aspect, in a seventh possible implementation of the first aspect, the step of generating a second straight line perpendicular to the first straight line includes: Connect the two ends of the sub-central axis to generate the first straight line; Obtain the first coordinates and the second coordinates located at both ends of the sub-central axis, and the third coordinate located between the two ends of the sub-central axis; Calculate the first slope of the first straight line based on the first coordinate and the second coordinate; Based on the first slope, calculate the second slope of the second line perpendicular to the first line; The second straight line is generated based on the second slope and the third coordinate.

[0014] In conjunction with the first aspect, in the eighth possible implementation of the first aspect, the step of obtaining the sub-pixel width of the portion of the grain ridge mask image corresponding to the sub-centerline based on the intersection line segment of the second straight line and the grain ridge mask image to be measured includes: Obtain the pixel height of the panoramic image to be measured, which is used to generate the mask image of the grain ridge to be measured, and generate the intersection line segment of the second straight line and the mask image of the grain ridge to be measured; By setting the ordinate of the mathematical expression corresponding to the second straight line to zero and the value indicated by the pixel height, the coordinates of the first intersection point and the second intersection point of the intersecting line segments are obtained; Based on the coordinates of the first intersection point and the second intersection point, the sub-pixel width of the portion of the grain ridge mask image to be measured corresponding to the sub-central axis is obtained.

[0015] Secondly, a measuring device for the width and uniformity of grain ridges is provided, the device comprising: The image segmentation module is used to generate at least one mask image of the grain ridge to be measured based on the acquired panoramic image to be measured. The first image processing module is used to add a central axis to the mask image of the grain ridge to be measured, and to segment the central axis to obtain at least two sub-central axes; The second image processing module is used to generate a second straight line perpendicular to the first straight line, wherein the first straight line is used to indicate the straight line formed by connecting the two ends of the sub-central axis; The first parameter calculation module is used to obtain the sub-pixel width of the portion of the grain ridge mask image to be measured corresponding to the sub-central axis based on the intersection line segment of the second straight line and the grain ridge mask image to be measured. The second parameter calculation module is used to obtain the average pixel width and pixel width uniformity of the grain ridge mask image to be measured based on the sub-pixel width of the portion of the grain ridge mask image to be measured corresponding to each of the sub-center axes. The parameter conversion module is used to convert the average pixel width and the pixel width uniformity to obtain the actual width and actual width uniformity of the grain ridge to be measured corresponding to the grain ridge mask image to be measured.

[0016] The method and apparatus for measuring the width and uniformity of grain ridges, the method comprising: generating at least one grain ridge mask image to be measured; for each grain ridge mask image to be measured, adding a central axis and segmenting the central axis to obtain at least two sub-central axes; for each sub-central axis, generating a second straight line perpendicular to a first straight line, wherein the first straight line is used to indicate the straight line formed by connecting the two ends of the sub-central axis; obtaining the sub-pixel width of the portion of the grain ridge mask image to be measured corresponding to the sub-central axis based on the intersection line segment of the second straight line and the grain ridge mask image to be measured; obtaining the average pixel width and pixel width uniformity of the grain ridge mask image to be measured based on the sub-pixel widths of the various portions of the grain ridge mask image to be measured in the same grain ridge mask image; and converting the average pixel width and pixel width uniformity of the same grain ridge mask image to obtain the actual width and actual width uniformity of the grain ridge to be measured corresponding to the grain ridge mask image to be measured. As can be seen, this application calculates the sub-pixel width of each part of the grain ridge mask image to be measured using the micro-element method, calculates the average pixel width and pixel width uniformity of the entire grain ridge mask image to be measured, and finally converts the average pixel width and pixel width uniformity into the actual width and actual width uniformity of the grain ridge to be measured, respectively. This method realizes the automatic measurement of the width and width uniformity of the grain ridge, which not only improves the problem of human resource consumption in the prior art, but also meets the accuracy and reliability of the measurement results, thereby promoting workers to operate according to process requirements and ensuring the quality of wine production. Attached Figure Description

[0017] Figure 1 This is a flowchart illustrating a method for measuring the width and uniformity of grain ridges in one embodiment. Figure 2 This is a structural block diagram of a device for measuring the width and uniformity of grain ridges in one embodiment; Figure 3 This is a system architecture diagram illustrating the training process of a semantic segmentation model in one embodiment. Figure 4 This is a neural network architecture diagram of a semantic segmentation model in one embodiment. Detailed Implementation

[0018] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0019] It should be noted that the illustrations provided in this embodiment are only schematic representations of the basic concept of this application. Therefore, the drawings only show the components related to this application and are not drawn according to the number, shape and size of the components in actual implementation. In actual implementation, the form, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.

[0020] The structures, proportions, sizes, etc., shown in the accompanying drawings of this specification are only for the purpose of assisting those skilled in the art in understanding and reading the content disclosed in the specification, and are not intended to limit the implementation conditions of this application. Therefore, they have no substantial technical significance. Any modifications to the structure, changes in the proportions, or adjustments to the size should still fall within the scope of the technical content disclosed in this application, provided that they do not affect the effects and purposes that this application can produce.

[0021] The orientations or positional relationships indicated by terms such as "upper," "lower," "left," "right," "middle," "longitudinal," "lateral," "horizontal," "inner," "outer," "radial," and "circumferential" used in this specification are based on the orientations or positional relationships shown in the accompanying drawings and are used only for the purpose of simplifying the description. They do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as limiting this application. Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.

[0022] Because the width of the grain ridges varies, affecting the uniformity of mixing the tail liquor, koji (fermentation starter), and mash, and the degree of width variation of the same grain ridge in different areas (i.e., the uniformity of grain ridge width), it also affects the mixing ratio of tail liquor, koji, and mash from different areas, thus impacting the quality of the brewed liquor. Therefore, the width and uniformity of the grain ridges are relatively important indicators for the brewing process, and testing their width and uniformity can encourage workers to operate according to relatively standardized process requirements, thereby ensuring the quality of the brewed liquor. However, the current method of manually measuring the width and uniformity of the grain ridges is not only labor-intensive but also prone to errors.

[0023] To address this issue, this application proposes a method and apparatus for measuring the width and uniformity of grain ridges. This application calculates the sub-pixel width of each part of the grain ridge mask image to be measured using the infinitesimal method, calculates the average pixel width and pixel width uniformity of the entire grain ridge mask image, and finally converts the average pixel width and pixel width uniformity into the actual width and actual width uniformity of the grain ridge to be measured, respectively. This method achieves automatic measurement of the width and uniformity of grain ridges, not only improving the problem of high human resource consumption in existing technologies but also ensuring the accuracy and reliability of the measurement results. This promotes workers to operate according to process requirements and guarantees the quality of wine production.

[0024] It should be noted that, for simplicity, the width uniformity described in this application refers to the width difference of the same grain ridge in different regions. For example, pixel width uniformity refers to the degree of difference in pixel width of the same grain ridge in different regions of the same grain ridge to be measured in the same grain ridge mask image. As another example, actual width uniformity refers to the degree of difference in the actual width of the grain ridge to be measured in different regions of the same grain ridge to be measured, obtained by converting the pixel width uniformity of the same grain ridge in the same grain ridge mask image. Next, the method and apparatus for measuring the width and width uniformity of the grain ridge of this application will be described in detail through the following embodiments.

[0025] In one embodiment, such as Figure 1 As shown, a method for measuring the width and uniformity of grain ridges is provided. Taking the measuring device for measuring the width and uniformity of grain ridges as the main body for executing this method as an example, the method includes the following steps: S1: Generate at least one mask image of the grain ridge to be measured.

[0026] In one feasible approach, the measurement grain ridge mask can be obtained by: training a semantic segmentation model to obtain a trained semantic segmentation model; acquiring a panoramic image of the brewery to be measured, wherein the panoramic image includes at least one measurement grain ridge; inputting the panoramic image into the trained semantic segmentation model, and after processing by the trained semantic segmentation model, outputting at least one measurement grain ridge region mask, wherein each measurement grain ridge region mask is used to indicate the area where at least one measurement grain ridge is located and the background area image; generating at least one measurement grain ridge mask based on the measurement grain ridge region mask using image processing technology, wherein each measurement grain ridge mask corresponds to one measurement grain ridge, and the number of measurement grain ridge masks is consistent with the number of measurement grain ridges in the measurement grain ridge region mask.

[0027] Specifically, the steps of training the semantic segmentation model to be trained may include: acquiring at least one sample panoramic image, wherein the sample panoramic image includes at least one sample grain ridge; obtaining a real grain ridge region mask based on the sample panoramic image; predicting the sample panoramic image using the semantic segmentation model to be trained to obtain a predicted grain ridge region mask; calculating pixel loss based on the predicted grain ridge region mask and the real grain ridge region mask; iteratively training the semantic segmentation model to be trained based on the pixel loss to obtain a trained semantic segmentation model; wherein the trained semantic segmentation model is used to generate a grain ridge region mask to be measured based on the acquired panoramic image to be measured, the grain ridge region mask to be measured is used to indicate the area where at least one grain ridge to be measured is located and the background area image, and the grain ridge region mask to be measured is used to generate at least one grain ridge mask to be measured.

[0028] Because the shapes of the grain ridges being spread out to dry vary greatly, and the brewing process is often affected by factors such as light, shading, and human interference, this application adopts a semantic segmentation model based on deep learning, which can more accurately and robustly identify the area where the grain ridges are located and the shape of the grain ridges, compared to traditional image recognition methods. Examples include Fully Convolutional Networks (FCN), DeepLabV3, UNet, and U2Net.

[0029] It should be noted that the sample panoramic image can be obtained by capturing it using at least one camera. Due to the large area of ​​the brewery and the lack of clear area constraints on the grain-drying ridges, coupled with the limited field of view of a single camera making it difficult to capture a panoramic view of the grain-drying ridges, multiple cameras need to be arranged side-by-side at a fixed distance from a top-down angle. Each camera captures images of the brewery in real time, and then these images are stitched together using image stitching technology to form a panoramic image. Specifically, a matrix mapping transformation can be used to map the images captured by each camera to the same feature space. Since there are overlapping fields of view between the images captured by adjacent cameras, the overlapping fields of view are stitched together to obtain a panoramic image of the brewery. Both the sample panoramic image and the panoramic image to be measured described in this application can be obtained using the above method, which will not be elaborated upon further below.

[0030] After obtaining at least one sample panoramic image, it is copied to obtain a copy of the sample panoramic image. Between the original sample panoramic image and its copy, one is used to obtain the real grain ridge region mask, and the other is used to obtain the predicted grain ridge region mask. Taking the example of using the original sample panoramic image to obtain the real grain ridge region mask and the copy of the sample panoramic image to obtain the predicted grain ridge region mask, the steps of obtaining the real grain ridge region mask of the sample grain ridge from the sample panoramic image may include: using an image segmentation and annotation tool to annotate the region where the sample grain ridge is located in the sample panoramic image with polygonal borders, thereby generating an annotation file in "json" format for each sample panoramic image; converting the annotation file into the real grain ridge region mask of the sample grain ridge required for training, so that each sample panoramic image corresponds to one real grain ridge region mask.

[0031] It should be noted that in the masked images of the actual grain ridge area, the predicted grain ridge area, and the grain ridge to be measured, the areas where the sample grain ridge or the grain ridge to be measured is located (i.e., the foreground) and the background area are labeled differently. For example, the areas where the sample grain ridge is located in the masked image of the actual grain ridge area, the masked image of the predicted grain ridge area, and the masked image of the grain ridge to be measured are located can be labeled as "1", and the background area can be labeled as "0", thereby distinguishing the foreground and the background. Other labeling methods can also be used in other embodiments, which will not be listed here.

[0032] By predicting the pixel loss between the mask image of the grain ridge area and the actual grain ridge area mask image, the semantic segmentation model to be trained is iteratively trained until the loss value of the model is lower than a preset threshold. Training is stopped and the best model weight file is saved to obtain the trained semantic segmentation model. Then, in the process of measuring the width and width uniformity of the grain ridge, the trained semantic segmentation model is used to process the acquired panoramic image to be measured to generate at least one mask image of the grain ridge area to be measured.

[0033] As a specific implementation, the step of calculating pixel loss based on the predicted grain ridge region mask and the actual grain ridge region mask includes: obtaining the actual pixels of each pixel in the actual grain ridge region mask and the predicted pixels of each pixel in the predicted grain ridge region mask; calculating the pixel loss based on the actual pixels and predicted pixels of each pixel, wherein the mathematical expression for calculating the pixel loss includes: ; For the pixel loss, The row coordinates of the pixels in the actual grain ridge area mask or the predicted grain ridge area mask. The column coordinates of the pixels in the actual grain ridge area mask or the predicted grain ridge area mask. The width of the sample panoramic image, The height of the sample panoramic image, To be located in the mask diagram of the actual grain ridge area line, number The actual pixels of the column's pixels. To be located in the mask map of the predicted grain ridge area line, number The predicted pixels of the column's pixels.

[0034] It should be noted that the width and height of the sample panoramic image are parameters generated after stitching together the images captured by each camera. When calculating pixel loss, for the same pixel, its actual pixel value in the real grain ridge area mask and its predicted pixel value in the predicted grain ridge area mask are obtained. By obtaining the actual and predicted pixels of all pixels, the pixel loss is calculated using the mathematical expression described above. Taking the above annotation method for foreground and background as an example, the values ​​of actual and predicted pixels are "1" or "0". That is, if a pixel is a point in the sample grain ridge area in the real or predicted grain ridge area mask, its corresponding actual or predicted pixel value is "1"; conversely, if a pixel is a point in the background area in the real or predicted grain ridge area mask, its corresponding actual or predicted pixel value is "0".

[0035] In a preferred embodiment, since the loss generated by each pixel is related to its local region, in addition to training the semantic segmentation model to be trained through pixel loss, a step of training the semantic segmentation model to be trained through region-level structural similarity loss can be added. This makes the trained semantic segmentation model pay more attention to the edge information of the grain ridge, improves the accuracy of the semantic segmentation model in generating the mask map of the grain ridge region to be measured based on the panoramic image to be measured, and thus improves the measurement accuracy of the actual width and the uniformity of the actual width of the grain ridge to be measured.

[0036] Specifically, after the step of predicting the sample panoramic image using the semantic segmentation model to be trained to obtain a predicted grain ridge region mask, the method further includes: calculating the mean and variance of real pixels based on the real grain ridge region mask; calculating the mean and variance of predicted pixels based on the predicted grain ridge region mask; calculating a region similarity loss based on the mean, variance, mean, and variance of predicted pixels; and iteratively training the semantic segmentation model to be trained based on the region similarity loss to obtain a trained semantic segmentation model. The semantic segmentation model to be trained is iteratively trained using the region similarity loss between the predicted grain ridge region mask and the real grain ridge region mask until the model's loss value is lower than a preset threshold, at which point training stops, and the optimal model weight file is saved to obtain the trained semantic segmentation model.

[0037] It should be noted that the steps of calculating the mean and variance of real pixels based on the real grain ridge region mask image, and calculating the mean and variance of predicted pixels based on the predicted grain ridge region mask image, refer to: obtaining the real pixels of all pixels in the real grain ridge region mask image and the predicted pixels of all pixels in the predicted grain ridge region mask image; calculating the mean and variance of real pixels based on the real pixels of each pixel; and calculating the mean and variance of predicted pixels based on the predicted pixels of each pixel. The method of obtaining each real pixel and each predicted pixel is similar to the relevant steps in training the semantic segmentation model to be trained using pixel loss, as described above, and will not be repeated here.

[0038] Furthermore, the step of calculating the region similarity loss based on the true pixel mean, the true pixel variance, the predicted pixel mean, and the predicted pixel variance includes: obtaining preset first coefficients and second coefficients; calculating pixel covariance based on the true pixel mean, the predicted pixel mean, the true pixel variance, and the predicted pixel variance; and calculating the region similarity loss based on the true pixel mean, the true pixel variance, the predicted pixel mean, the predicted pixel variance, the first coefficient, the second coefficient, and the pixel covariance, wherein the mathematical expression for calculating the region similarity loss includes: ; The region similarity loss is... The predicted pixel mean, The average value of the actual pixels. For the first coefficient, Let the pixel covariance be... The second coefficient, Let Variance be the predicted pixel variance. Let be the variance of the actual pixels. For example, the first coefficient can be set to 0.01. 2 The second coefficient can be set to 0.03. 2 .

[0039] It should be noted that, Used to indicate the set of predicted pixels for all pixels in the mask image of the predicted grain ridge area. This is used to indicate the set of real pixels in the mask image of the actual grain ridge area. The predicted pixel mean is obtained by calculating the mean of the predicted pixels of all pixels. Then, based on the predicted pixels and the predicted pixel mean for each pixel, the predicted pixel variance is calculated using the variance calculation formula. Similarly, the real pixel mean is obtained by calculating the mean of the real pixels of all pixels. Then, based on the real pixels and the real pixel mean for each pixel, the real pixel variance is calculated using the variance calculation formula. The predicted pixel standard deviation is obtained by calculating the square root of the predicted pixel variance, and the real pixel standard deviation is obtained by calculating the square root of the real pixel variance. The pixel covariance is calculated based on the quotient of a first difference and a first product, where the first difference is the difference between the predicted pixel mean and the real pixel mean, and the first product is the product of the predicted pixel standard deviation and the real pixel standard deviation.

[0040] In a preferred embodiment, in addition to training the semantic segmentation model using pixel loss, a step can be added to train the semantic segmentation model using image-level intersection-union (IU) loss. This allows the trained semantic segmentation model to measure the IU of the predicted grain ridge region mask and the actual grain ridge region mask at the image level. This training enables the trained semantic segmentation model to pay more attention to the global shape features of the grain ridge region to be measured in the foreground region, further improving the accuracy of the semantic segmentation model in generating the grain ridge region mask based on the panoramic image to be measured, thereby improving the measurement accuracy of the width and width uniformity of the grain ridge.

[0041] Specifically, after the step of predicting the sample panoramic image using the semantic segmentation model to be trained to obtain a predicted grain ridge region mask, the method further includes: calculating an image overlap loss based on the predicted grain ridge region mask and the actual grain ridge region mask; and iteratively training the semantic segmentation model to be trained based on the image overlap loss to obtain a trained semantic segmentation model. The mathematical expression for calculating the image overlap loss includes: ; The image overlap loss is... The row coordinates of the pixels in the actual grain ridge area mask or the predicted grain ridge area mask. The column coordinates of the pixels in the actual grain ridge area mask or the predicted grain ridge area mask. The width of the sample panoramic image, The height of the sample panoramic image, To be located in the mask diagram of the actual grain ridge area line, number The actual pixels of the column's pixels. To be located in the mask map of the predicted grain ridge area line, number The predicted pixels of the column's pixels.

[0042] By predicting the image overlap loss between the mask image of the grain ridge region and the actual grain ridge region mask image, the semantic segmentation model to be trained is iteratively trained until the loss value of the model is lower than a preset threshold. The training stops when the model weight file is saved, and the trained semantic segmentation model is obtained.

[0043] It should be noted that when calculating the image overlap loss, for the same pixel, its real pixel in the real grain ridge region mask and its predicted pixel in the predicted grain ridge region mask are obtained. By obtaining the real and predicted pixels of all pixels, the image overlap loss is calculated based on the real and predicted pixels of all pixels using the mathematical expression described above. The method of obtaining each real pixel and each predicted pixel is similar to the relevant steps in training the semantic segmentation model to be trained using pixel loss, and the relevant descriptions are provided above and will not be repeated here.

[0044] In another preferred embodiment, the three training methods described above can be superimposed to minimize the loss of the trained semantic segmentation model at the pixel, region similarity, and image overlap levels. Training stops when the model's loss value falls below a preset threshold, and the optimal model weight file is saved, resulting in the trained semantic segmentation model. This further improves the image processing accuracy and reliability of the trained semantic segmentation model. During training, reasonable training iterations and learning rates can be set. The weights and other parameters of the neural network nodes in the semantic segmentation model are updated through iterative training. The performance of the semantic segmentation model is measured by accuracy, recall, or F1 score to obtain an optimized semantic segmentation model.

[0045] S2: Add a central axis to the mask diagram of the grain ridge to be measured, and divide the central axis into segments to obtain at least two sub-central axes.

[0046] The panoramic image to be measured is input into the semantic segmentation model trained above to obtain a mask image of the grain ridge region to be measured, which includes an image of the foreground region (the region where at least one grain ridge to be measured is located) and the background region. In one embodiment, morphological operators, such as opening / closing operations, can also be used to fill the foreground region and refine the edges to obtain an optimized mask image of the grain ridge region to be measured. Then, at least one mask image of the grain ridge to be measured is generated based on the optimized mask image.

[0047] Taking the above annotation method for foreground and background as an example, in the mask image of the grain ridge area to be measured, the area where the grain ridge to be measured is located is marked as "1", and the background area is marked as "0". Using the mask image of the grain ridge area to be measured as input, the image contour extraction function is called, such as the "cv2.findContours" operator in the OpenCV-Python library, to calculate the closure polygon of all the grain ridges to be measured, that is, to calculate the closure polygon of the area marked as "1". Then, the polygon filling function, such as the "cv2.fillPoly" operator, is called on the closure polygon of each grain ridge to be measured to generate at least one mask image of the grain ridge to be measured. Each mask image of the grain ridge to be measured corresponds to one grain ridge to be measured, and the number of mask images of the grain ridge to be measured is the same as the number of grain ridges to be measured in the mask image of the grain ridge area to be measured.

[0048] In one specific implementation, the step of adding a central axis to the masked grain ridge to be measured includes: extracting the skeleton of the masked grain ridge to be measured and generating the coordinates of the skeleton point set; calculating the interval distance between each pair of adjacent skeleton points based on the coordinates of each skeleton point in the skeleton point set; obtaining a preset distance threshold, filtering the skeleton point pairs whose interval distance is greater than the distance threshold to obtain a filtered skeleton point set; and based on the filtered skeleton point set, using one of the skeleton points located at the end as a reference point, concatenating the remaining skeleton points other than the reference point to obtain the central axis.

[0049] It should be noted that the mask image of the grain ridge to be measured is used as input, and a skeleton extraction function, such as the "morphology.medial_axis" operator in the Skimage library, is called to calculate the skeleton point set and its coordinates of the grain ridge to be measured. Since the skeleton point set obtained by the skeleton extraction function is unordered, it needs to be reordered along the extension direction of the grain ridge to be measured. Theoretically, skeleton points located at both ends of the grain ridge to be measured have only one adjacent skeleton point. Therefore, after filtering out skeleton point pairs with an interval greater than a distance threshold, the skeleton point located at any end is used as a reference point, and the remaining skeleton points are concatenated along the extension direction of the grain ridge to be measured, thereby obtaining the central axis of the grain ridge to be measured. The central axis is segmented to obtain at least two sub-central axes because the grain ridge to be measured is considered as a combination of at least two segments. Using each sub-central axis as a reference, the width and width uniformity of the entire grain ridge are calculated by measuring the width of the segment corresponding to each sub-central axis. This method, known as the infinitesimal method, improves the accuracy of measuring the width and width uniformity of the grain ridge. Furthermore, for even more precise results, the central axis can be divided into dozens or even hundreds of sub-central axes.

[0050] S3: Generate a second straight line perpendicular to the first straight line, wherein the first straight line is used to indicate the straight line formed by connecting the two ends of the sub-center axis.

[0051] In one specific implementation, the step of generating a second straight line perpendicular to the first straight line includes: connecting the two ends of the sub-central axis to generate the first straight line; obtaining a first coordinate, a second coordinate located at the two ends of the sub-central axis, and a third coordinate located between the two ends of the sub-central axis; calculating a first slope of the first straight line based on the first coordinate and the second coordinate; calculating a second slope of the second straight line perpendicular to the first straight line based on the first slope; and generating the second straight line based on the second slope and the third coordinate.

[0052] It should be noted that the first, second, and third coordinates are parameters output when adding the sub-center axis; and preferably, the third coordinate can be selected as the coordinate of the skeleton point located at the midpoint between the two ends of the sub-center axis, ensuring the measurement accuracy of the sub-pixel width of the portion of the grain ridge mask image to be measured with the third coordinate as the observation point, thereby ensuring the measurement accuracy of the pixel width of the entire grain ridge mask image to be measured. For example, assuming the first coordinate is ( The second coordinate is ( The third coordinate is ( If the first slope is ), then the first slope is The second slope is The mathematical expression for the second straight line is: A second straight line can be drawn on the grain ridge mask image to be measured by calling a line drawing function, such as the "cv2.line" operator in the OpenCV-Python library. The length of the intersection line segment between the second straight line and the grain ridge mask image to be measured can then be calculated and used as the sub-pixel width of a portion of the grain ridge mask image to be measured.

[0053] S4: Based on the intersection line segment of the second straight line and the grain ridge mask image to be measured, obtain the sub-pixel width of the portion of the grain ridge mask image to be measured corresponding to the sub-central axis.

[0054] In one specific implementation, the step of obtaining the sub-pixel width of the portion of the grain ridge mask corresponding to the sub-central axis based on the intersection line segment of the second straight line and the grain ridge mask to be measured includes: obtaining the pixel height of the panoramic image to be measured used to generate the grain ridge mask, and generating the intersection line segment of the second straight line and the grain ridge mask to be measured; setting the ordinate of the mathematical expression corresponding to the second straight line to zero and the value indicated by the pixel height to obtain the first intersection point coordinates and the second intersection point coordinates of the intersection line segment; and obtaining the sub-pixel width of the portion of the grain ridge mask corresponding to the sub-central axis based on the first intersection point coordinates and the second intersection point coordinates.

[0055] It should be noted that when calculating the length of the intersection segment between the second straight line and the grain ridge mask image to be measured, it can be done by calculating the coordinates of the first and second intersection points of the second straight line and the grain ridge mask image to be measured. Then, based on the coordinates of the first and second intersection points, the distance between the first and second intersection points can be obtained using the Euclidean distance formula, which is the sub-pixel width of the portion of the grain ridge mask image to be measured corresponding to the sub-center axis. Specifically, when calculating the coordinates of the first and second intersection points, the ordinate of the mathematical expression of the second straight line is set to 0, and the value indicated by the pixel height of the panoramic image to be measured is set to 0, respectively. The mathematical expression of the second straight line obtained using the first, second, and third coordinates is used as an example for illustration. ,but ,get That is, the coordinates of the first intersection point are ( );make ,but ,get That is, the coordinates of the second intersection point are [ ].

[0056] S5: Based on the sub-pixel width of the portion of the grain ridge mask image to be measured corresponding to each of the sub-center axes, obtain the average pixel width and pixel width uniformity of the grain ridge mask image to be measured.

[0057] For each sub-centerline, the steps of calculating the second straight line and the intersection line segment of the second straight line and the grain ridge mask image to be measured are performed to obtain the sub-pixel width of the portion of the grain ridge mask image to be measured corresponding to each sub-centerline; then, for each portion of the grain ridge mask image to be measured, the average value of the sub-pixel widths of the grain ridge mask image to be measured is calculated to obtain the average pixel width of the grain ridge mask image to be measured; based on all the sub-pixel widths and the average pixel width of the same grain ridge mask image to be measured, the pixel width uniformity of the grain ridge mask image to be measured is calculated using the standard deviation formula.

[0058] S6: Convert the average pixel width and the pixel width uniformity to obtain the actual width and actual width uniformity of the grain ridge to be measured corresponding to the grain ridge mask image to be measured.

[0059] Since the panoramic image to be measured is obtained by following the mapping relationship between the image and the real world, when measuring the width and uniformity of the grain ridge to be measured, this mapping relationship can be used to convert the average pixel width of the grain ridge mask to be measured into the actual width of the grain ridge to be measured, and to convert the pixel width uniformity of the grain ridge mask to be measured into the actual width uniformity of the grain ridge to be measured. For example, the mapping relationship between the panoramic image to be measured and the real world can be: 1 pixel in the panoramic image to be measured corresponds to 1 cm in the real world.

[0060] In summary, this application calculates the sub-pixel width of each part of the grain ridge mask image to be measured using the infinitesimal method, calculates the average pixel width and pixel width uniformity of the entire grain ridge mask image to be measured, and finally converts the average pixel width and pixel width uniformity into the actual width and actual width uniformity of the grain ridge to be measured, respectively. This method realizes the automatic measurement of the width and width uniformity of the grain ridge, which not only improves the problem of human resource consumption in the prior art, but also meets the accuracy and reliability of the measurement results, thereby promoting workers to operate according to process requirements and ensuring brewing output and quality.

[0061] It should be understood that, although Figure 1 The steps in the flowchart are shown sequentially as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order in which these steps are executed, and they can be performed in other orders. Figure 1 At least some of the steps in the process may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least some of the sub-steps or stages of other steps.

[0062] In one embodiment, such as Figure 2 As shown, a measuring device for the width and uniformity of grain ridges is provided, comprising: an image segmentation module, a first image processing module, a second image processing module, a first parameter calculation module, a second parameter calculation module, and a parameter conversion module, wherein: An image segmentation module is used to generate at least one mask image of the grain ridge to be measured; The first image processing module is used to add a central axis to the mask image of the grain ridge to be measured, and to segment the central axis to obtain at least two sub-central axes; The second image processing module is used to generate a second straight line perpendicular to the first straight line, wherein the first straight line is used to indicate the straight line formed by connecting the two ends of the sub-central axis; The first parameter calculation module is used to obtain the sub-pixel width of the portion of the grain ridge mask image to be measured corresponding to the sub-central axis based on the intersection line segment of the second straight line and the grain ridge mask image to be measured. The second parameter calculation module is used to obtain the average pixel width and pixel width uniformity of the grain ridge mask image to be measured based on the sub-pixel width of the portion of the grain ridge mask image to be measured corresponding to each of the sub-center axes. The parameter conversion module is used to convert the average pixel width and the pixel width uniformity to obtain the actual width and actual width uniformity of the grain ridge to be measured corresponding to the grain ridge mask image to be measured.

[0063] Specifically, before performing the step of generating at least one mask image of the grain ridge to be measured, the image segmentation module is further configured to: acquire at least one sample panoramic image, wherein the sample panoramic image includes at least one sample grain ridge; obtain a real grain ridge region mask image of the sample grain ridge based on the sample panoramic image; predict the sample panoramic image using a semantic segmentation model to be trained to obtain a predicted grain ridge region mask image of the sample grain ridge; calculate pixel loss based on the predicted grain ridge region mask image and the real grain ridge region mask image; iteratively train the semantic segmentation model to be trained based on the pixel loss to obtain a trained semantic segmentation model; wherein the trained semantic segmentation model is used to generate a mask image of the grain ridge to be measured based on the acquired panoramic image to be measured, and the mask image of the grain ridge to be measured is used to generate at least one mask image of the grain ridge to be measured.

[0064] Specifically, the image segmentation module performs the step of calculating pixel loss based on the predicted grain ridge region mask and the actual grain ridge region mask, including: obtaining the actual pixels of each pixel in the actual grain ridge region mask and the predicted pixels of each pixel in the predicted grain ridge region mask; calculating the pixel loss based on the actual pixels and predicted pixels of each pixel, wherein the mathematical expression for calculating the pixel loss includes: ; For the pixel loss, The row coordinates of the pixels in the actual grain ridge area mask or the predicted grain ridge area mask. The column coordinates of the pixels in the actual grain ridge area mask or the predicted grain ridge area mask. The width of the sample panoramic image, The height of the sample panoramic image, To be located in the mask diagram of the actual grain ridge area line, number The actual pixels of the column's pixels. To be located in the mask map of the predicted grain ridge area line, number The predicted pixels of the column's pixels.

[0065] Specifically, before performing the step of generating at least one grain ridge mask image to be measured, the image segmentation module is further configured to: calculate the mean and variance of real pixels based on the real grain ridge region mask image; calculate the mean and variance of predicted pixels based on the predicted grain ridge region mask image; calculate the region similarity loss based on the mean, variance, mean, and variance of real pixels; and iteratively train the semantic segmentation model to be trained based on the region similarity loss to obtain the trained semantic segmentation model.

[0066] Specifically, the image segmentation module performs the step of calculating the region similarity loss based on the true pixel mean, the true pixel variance, the predicted pixel mean, and the predicted pixel variance, including: obtaining preset first coefficients and second coefficients; calculating pixel covariance based on the true pixel mean, the predicted pixel mean, the true pixel variance, and the predicted pixel variance; and calculating the region similarity loss based on the true pixel mean, the true pixel variance, the predicted pixel mean, the predicted pixel variance, the first coefficient, the second coefficient, and the pixel covariance, wherein the mathematical expression for calculating the region similarity loss includes: ; The region similarity loss is... The predicted pixel mean, The average value of the actual pixels. For the first coefficient, Let the pixel covariance be... The second coefficient, Let Variance be the predicted pixel variance. Let be the variance of the actual pixels.

[0067] Specifically, before performing the step of generating at least one mask image of the grain ridge to be measured, the image segmentation module is further configured to: calculate the image overlap loss based on the predicted grain ridge region mask image and the real grain ridge region mask image; and iteratively train the semantic segmentation model to be trained based on the image overlap loss to obtain the trained semantic segmentation model. The mathematical expression for calculating the image overlap loss includes: ; The image overlap loss is... The row coordinates of the pixels in the actual grain ridge area mask or the predicted grain ridge area mask. The column coordinates of the pixels in the actual grain ridge area mask or the predicted grain ridge area mask. The width of the sample panoramic image, The height of the sample panoramic image, To be located in the mask diagram of the actual grain ridge area line, number The actual pixels of the column's pixels. To be located in the mask map of the predicted grain ridge area line, number The predicted pixels of the column's pixels.

[0068] Specifically, the first image processing module performs the step of adding a central axis to the mask image of the grain ridge to be measured, including: extracting the skeleton of the mask image of the grain ridge to be measured and generating the coordinates of the skeleton point set of the skeleton; calculating the interval distance between each pair of adjacent skeleton points according to the coordinates of each skeleton point in the skeleton point set; obtaining a preset distance threshold, filtering the skeleton point pairs corresponding to the interval distance being greater than the distance threshold to obtain a filtered skeleton point set; based on the filtered skeleton point set, taking one of the skeleton points located at the end as a reference point, concatenating the remaining skeleton points other than the reference point to obtain the central axis.

[0069] Specifically, the second image processing module performs the step of generating a second straight line perpendicular to the first straight line, including: connecting the two ends of the sub-central axis to generate the first straight line; obtaining a first coordinate, a second coordinate located at the two ends of the sub-central axis, and a third coordinate located between the two ends of the sub-central axis; calculating a first slope of the first straight line based on the first coordinate and the second coordinate; calculating a second slope of the second straight line perpendicular to the first straight line based on the first slope; and generating the second straight line based on the second slope and the third coordinate.

[0070] Specifically, the first parameter calculation module performs the step of obtaining the sub-pixel width of the portion of the grain ridge mask corresponding to the sub-central axis based on the intersection line segment of the second straight line and the grain ridge mask to be measured. This includes: obtaining the pixel height of the panoramic image to be measured used to generate the grain ridge mask, and generating the intersection line segment of the second straight line and the grain ridge mask to be measured; setting the ordinate of the mathematical expression corresponding to the second straight line to zero and the value indicated by the pixel height to obtain the first intersection point coordinates and the second intersection point coordinates of the intersection line segment; and obtaining the sub-pixel width of the portion of the grain ridge mask corresponding to the sub-central axis based on the first intersection point coordinates and the second intersection point coordinates.

[0071] Specific limitations regarding the measuring device for the width and uniformity of grain ridges can be found in the limitations on the measurement method for the width and uniformity of grain ridges mentioned above, and will not be repeated here. Each module in the aforementioned measuring device for the width and uniformity of grain ridges can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the corresponding operations of each module.

[0072] As exemplarily illustrated, the system architecture used in the training process of the semantic segmentation model provided in this application can be as follows: Figure 3 As shown, the system architecture 700 includes a data acquisition device 701, a database 702, a training device 703, and a semantic segmentation model 704. In this system architecture 700, the data acquisition device 701 can acquire sample data, including panoramic images of sample areas and mask images of real grain ridge areas. After acquiring the sample data, the data acquisition device 701 stores the sample data in the database 702. The training device 703 trains the semantic segmentation model 704 based on the sample data maintained in the database 702.

[0073] It should be noted that in practical applications, the sample data maintained in database 702 may not all come from data acquisition device 701; it may also be received from other devices. Furthermore, it should be noted that training device 703 may not necessarily train the semantic segmentation model entirely based on the sample data maintained in database 702; it may also acquire sample data from the cloud or other sources for model training. The above description should not be construed as limiting the embodiments of this application. The semantic segmentation model 704 trained by training device 703 can be applied to different systems or devices.

[0074] The semantic segmentation model 704 in this embodiment can specifically be a neural network, such as... Figure 4 As shown, the neural network architecture 800 includes an input layer 801, at least one hidden layer 802, and an output layer 803. In the training method of the semantic segmentation model, sample data is input from the input layer 801. The hidden layer 802 predicts the panoramic image of the sample data to obtain a predicted grain ridge region mask, which is then output to the output layer 803. The output layer 803 has a loss function, specifically used to calculate the pixel loss, region similarity loss, and image overlap loss based on the predicted grain ridge region mask and the real grain ridge region mask in the sample data. Once the forward propagation of the neural network (as shown in Figure 8, the propagation from the input layer 801 to the output layer 803 is forward propagation) is completed, the backward propagation (as shown in Figure 8, the propagation from the output layer 803 to the input layer 801 is backward propagation) will begin to update the weight values ​​and biases of each layer to reduce pixel loss, or pixel and region similarity loss, or pixel and image overlap loss, or pixel, region similarity and image overlap loss, as well as reduce the error between the predicted grain ridge region mask map output by the output layer and the ideal grain ridge region mask map.

[0075] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM).

[0076] The technical features of the above embodiments can be combined in any way. For the sake of brevity, 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.

[0077] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.

Claims

1. A method of measuring the width and width uniformity of a grain ridge, characterized by, include: At least one mask image of the grain ridge to be measured is generated based on the panoramic image to be measured; wherein, the panoramic image to be measured is acquired by at least one camera; Add a central axis to the mask diagram of the grain ridge to be measured, and divide the central axis into segments to obtain at least two sub-central axes; The step of adding a centerline to the masked image of the grain ridge to be measured includes: Extract the skeleton of the mask image of the grain ridge to be measured, and generate the coordinates of the skeleton point set of the skeleton; Based on the coordinates of each skeleton point in the skeleton point set, calculate the interval distance between each pair of adjacent skeleton points; Obtain a preset distance threshold, filter out the skeleton point pairs whose interval distance is greater than the distance threshold, and obtain the filtered skeleton point set; Based on the filtered skeleton point set, taking one of the skeleton points located at the end as a reference point, the remaining skeleton points other than the reference point are connected in series along the extension direction of the grain ridge to be measured corresponding to the mask image of the grain ridge to be measured, to obtain the central axis. Generate a second straight line perpendicular to the first straight line, wherein the first straight line is used to indicate the straight line formed by connecting the two ends of the sub-center axis; The sub-pixel width of the portion of the grain ridge mask to be measured corresponding to the sub-central axis is obtained based on the intersection line segment of the second straight line and the grain ridge mask to be measured. Based on the sub-pixel width of the portion of the grain ridge mask image to be measured corresponding to each of the sub-center axes, the average pixel width and pixel width uniformity of the grain ridge mask image to be measured are obtained. The process of obtaining the average pixel width and pixel width uniformity of the grain ridge mask image to be measured based on the sub-pixel width of the portion of the mask image to be measured corresponding to each of the sub-center axes includes: Based on the sub-pixel width of the portion of the grain ridge mask image to be measured corresponding to each of the sub-central axes, the average pixel width of the grain ridge mask image to be measured is calculated. Based on the sub-pixel width of the portion of the grain ridge mask image to be measured corresponding to each of the sub-center axes and the average pixel width, the pixel width uniformity of the grain ridge mask image to be measured is calculated using the standard deviation formula. The average pixel width and the pixel width uniformity are converted to obtain the actual width and actual width uniformity of the grain ridge to be measured corresponding to the mask image of the grain ridge to be measured.

2. The method of measuring the width of a grain ridge and the uniformity of the width according to claim 1, wherein Prior to the step of generating at least one mask image of the grain ridge to be measured, the method further includes: Acquire at least one sample panoramic image, wherein the sample panoramic image includes at least one sample grain ridge; A mask image of the actual grain ridge area of ​​the sample grain ridge is obtained based on the panoramic image of the sample. The sample panoramic image is predicted by the semantic segmentation model to be trained, and the predicted grain ridge region mask map of the sample grain ridge is obtained. Pixel loss is calculated based on the predicted grain ridge area mask and the actual grain ridge area mask; The semantic segmentation model to be trained is iteratively trained based on the pixel loss to obtain the trained semantic segmentation model; The trained semantic segmentation model is used to generate a mask map of the grain ridge region to be measured based on the acquired panoramic image to be measured, and the mask map of the grain ridge region to be measured is used to generate at least one mask map of the grain ridge to be measured.

3. The method of claim 2, wherein the width of the berm and the uniformity of the width of the berm are measured by a laser line sensor. The step of calculating pixel loss based on the predicted grain ridge region mask and the actual grain ridge region mask includes: Obtain the real pixels of each pixel in the real grain ridge area mask image, and the predicted pixels of each pixel in the predicted grain ridge area mask image; Based on the actual pixels and predicted pixels of each pixel, the pixel loss is calculated, wherein the mathematical expression for calculating the pixel loss includes: ; For the pixel loss, The row coordinates of the pixels in the actual grain ridge area mask or the predicted grain ridge area mask. The column coordinates of the pixels in the actual grain ridge area mask or the predicted grain ridge area mask. The width of the sample panoramic image, The height of the sample panoramic image, To be located in the masked image of the actual grain ridge area line, number The actual pixels of the column's pixels. To be located in the mask map of the predicted grain ridge area line, number The predicted pixels of the column's pixels.

4. The method for measuring the width and uniformity of grain ridges according to claim 2, characterized in that, After the step of predicting the sample panoramic image using the semantic segmentation model to be trained to obtain the predicted grain ridge region mask, the method further includes: Based on the actual grain ridge area mask, calculate the actual pixel mean and actual pixel variance; Based on the predicted grain ridge area mask, calculate the predicted pixel mean and predicted pixel variance; The region similarity loss is calculated based on the mean of the real pixels, the variance of the real pixels, the mean of the predicted pixels, and the variance of the predicted pixels. The semantic segmentation model to be trained is iteratively trained based on the region similarity loss to obtain the trained semantic segmentation model.

5. The method for measuring the width and uniformity of grain ridges according to claim 4, characterized in that, The step of calculating the region similarity loss based on the true pixel mean, the true pixel variance, the predicted pixel mean, and the predicted pixel variance includes: Obtain the preset first and second coefficients; Calculate the pixel covariance based on the mean of the actual pixels, the mean of the predicted pixels, the variance of the actual pixels, and the variance of the predicted pixels; The region similarity loss is calculated based on the true pixel mean, the true pixel variance, the predicted pixel mean, the predicted pixel variance, the first coefficient, the second coefficient, and the pixel covariance. The mathematical expression for calculating the region similarity loss includes: ; The region similarity loss is... The predicted pixel mean, The average value of the actual pixels. For the first coefficient, Let the pixel covariance be... The second coefficient, Let Variance be the predicted pixel variance. Let be the variance of the actual pixels.

6. The method of measuring the width of a grain ridge and the uniformity of the width according to claim 2, wherein After the step of predicting the sample panoramic image using the semantic segmentation model to be trained to obtain the predicted grain ridge region mask, the method further includes: The image overlap loss is calculated based on the predicted grain ridge region mask and the actual grain ridge region mask, wherein the mathematical expression for calculating the image overlap loss includes: ; The image overlap loss is... The row coordinates of the pixels in the actual grain ridge area mask or the predicted grain ridge area mask. The column coordinates of the pixels in the actual grain ridge area mask or the predicted grain ridge area mask. The width of the sample panoramic image, The height of the sample panoramic image, To be located in the mask image of the actual grain ridge area line, number The actual pixels of the column's pixels. To be located in the mask map of the predicted grain ridge area line, number The predicted pixels of the column's pixels; The semantic segmentation model to be trained is iteratively trained based on the image overlap loss to obtain the trained semantic segmentation model.

7. The method of measuring the width of a berm and the uniformity of the width of a berm of claim 1, wherein, The step of generating a second line perpendicular to the first line includes: Connect the two ends of the sub-central axis to generate the first straight line; Obtain the first coordinates and the second coordinates located at both ends of the sub-central axis, and the third coordinate located between the two ends of the sub-central axis; Calculate the first slope of the first straight line based on the first coordinate and the second coordinate; Based on the first slope, calculate the second slope of the second line perpendicular to the first line; The second straight line is generated based on the second slope and the third coordinate.

8. The method of measuring the width of a grain ridge and the uniformity of the width according to claim 1, wherein The step of obtaining the sub-pixel width of the portion of the grain ridge mask image corresponding to the sub-central axis based on the intersection line segment of the second straight line and the grain ridge mask image to be measured includes: Obtain the pixel height of the panoramic image to be measured, which is used to generate the mask image of the grain ridge to be measured, and generate the intersection line segment of the second straight line and the mask image of the grain ridge to be measured; By setting the ordinate of the mathematical expression corresponding to the second straight line to zero and the value indicated by the pixel height, the coordinates of the first intersection point and the second intersection point of the intersecting line segments are obtained; Based on the coordinates of the first intersection point and the second intersection point, the sub-pixel width of the portion of the grain ridge mask image to be measured corresponding to the sub-central axis is obtained.

9. A device for measuring the width of a grain ridge and the uniformity of the width, characterized in that The device includes: An image segmentation module is used to generate at least one mask image of the grain ridge to be measured based on the panoramic image to be measured; wherein the panoramic image to be measured is acquired by at least one camera; The first image processing module is used to add a central axis to the mask image of the grain ridge to be measured, and to segment the central axis to obtain at least two sub-central axes; The step of adding a centerline to the masked image of the grain ridge to be measured includes: Extract the skeleton of the mask image of the grain ridge to be measured, and generate the coordinates of the skeleton point set of the skeleton; Based on the coordinates of each skeleton point in the skeleton point set, calculate the interval distance between each pair of adjacent skeleton points; Obtain a preset distance threshold, filter out the skeleton point pairs whose interval distance is greater than the distance threshold, and obtain the filtered skeleton point set; Based on the filtered skeleton point set, taking one of the skeleton points located at the end as a reference point, the remaining skeleton points other than the reference point are connected in series along the extension direction of the grain ridge to be measured corresponding to the mask image of the grain ridge to be measured, to obtain the central axis. The second image processing module is used to generate a second straight line perpendicular to the first straight line, wherein the first straight line is used to indicate the straight line formed by connecting the two ends of the sub-central axis; The first parameter calculation module is used to obtain the sub-pixel width of the portion of the grain ridge mask image to be measured corresponding to the sub-central axis based on the intersection line segment of the second straight line and the grain ridge mask image to be measured. The second parameter calculation module is used to obtain the average pixel width and pixel width uniformity of the grain ridge mask image to be measured based on the sub-pixel width of the portion of the grain ridge mask image to be measured corresponding to each of the sub-center axes. The process of obtaining the average pixel width and pixel width uniformity of the grain ridge mask image to be measured based on the sub-pixel width of the portion of the mask image to be measured corresponding to each of the sub-center axes includes: Based on the sub-pixel width of the portion of the grain ridge mask image to be measured corresponding to each of the sub-central axes, the average pixel width of the grain ridge mask image to be measured is calculated. Based on the sub-pixel width of the portion of the grain ridge mask image to be measured corresponding to each of the sub-center axes and the average pixel width, the pixel width uniformity of the grain ridge mask image to be measured is calculated using the standard deviation formula. A parameter conversion module is configured to convert the average pixel width and the pixel width uniformity to obtain an actual width and an actual width uniformity of the grain line to be measured corresponding to the grain line mask image to be measured.

Citation Information

Patent Citations

  • Method for measuring diameter of fibers of textile materials based on phase information

    CN108305287A

  • Pavement pit and pond detection method based on machine vision in complex environment

    CN110717886A