Rice processing precision detection method, equipment and storage medium
Through multi-angle image acquisition and pre-processing technology, the problem of low detection accuracy in existing rice processing technology is solved, efficient rice processing accuracy assessment is achieved, labor costs are reduced and production efficiency is improved.
Patent Information
- Application Number
- CN202011147481.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-23
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2040-10-23
AI Technical Summary
In the existing rice processing technology, the dyeing method to detect the skin retention has the problems of low accuracy and heavy workload, making it difficult to accurately identify the germ part of the rice grain.
Multi-angle image acquisition and pre-processing technology is used to calculate the images of rice grains at different angles for binarization processing and gradient value analysis to determine whether the rice grains are rice with germ and skin retained, and calculate its germ and skin retained parameters to evaluate Processing accuracy.
It improves the accuracy of rice processing precision detection, reduces labor costs, improves the production efficiency of the rice production line, and avoids dyeing of rice grains.
Smart Images

Figure CN114494099B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a method, a device and a storage medium for detecting rice processing accuracy. Background Art
[0002] As people's living standards improve, they have higher requirements for the nutritional value and appearance of edible rice. The State Administration for Market Regulation and the Standardization Administration of China issued a new rice standard GB / T 1354-2018 on October 10, 2018. The standard stipulates the calculation method of rice husk retention, which is equal to the sum of the germ area and the husk area divided by the total area of the rice grain. The husk retention can be used to determine the quality of rice, such as processing accuracy. Among them, the germ part can reflect the nutritional value of rice, and thus reflect the quality of rice.
[0003] In the related art, the rice husk retention is usually detected by dyeing method, which requires the preparation of chemical dyes in advance to soak the sample. However, the skin layer of the sample is easy to fall off during the soaking process, resulting in low accuracy in calculating the husk retention and a large workload for the staff. At the same time, the germ and the remaining rice husk on the rice grains will be dyed by the dyeing method, making it difficult to accurately identify the germ part. Summary of the invention
[0004] The present invention aims to solve one of the technical problems in the related art to at least a certain extent. To this end, the first object of the present invention is to provide a method for detecting rice processing accuracy, so as to classify the categories to which rice grains belong for a specific rice production and processing task, thereby judging the rice processing accuracy.
[0005] A second object of the present invention is to provide a computer-readable storage medium.
[0006] The third object of the present invention is to provide a detection device for rice processing accuracy.
[0007] To achieve the above-mentioned purpose, a first aspect of the present invention provides a method for detecting rice processing accuracy, the method comprising the following steps: acquiring images of rice grains at at least three angles by at least three image acquisition devices, and recording the images at least three angles as first images; preprocessing the first images to obtain second images; and calculating the processing accuracy of the rice grains based on the first images and the second images.
[0008] The rice processing accuracy detection method of the embodiment of the present invention uses at least three image acquisition devices to collect images of rice grains at at least three angles, and records the images at the three angles as first images; pre-processes the first image to obtain a second image, and then calculates the rice grain processing accuracy based on the first image and the second image. In this way, the detection accuracy can be improved, and the labor cost can be reduced, and the production efficiency of the rice production line can be improved.
[0009] In addition, the rice processing precision detection method of the present invention may also have the following additional technical features:
[0010] According to one embodiment of the present invention, calculating the processing accuracy of the rice grains based on the first image and the second image includes: determining whether the rice grains are rice with the germ and husk retained based on the first image and the second image; if the rice grains are rice with the germ and husk retained, calculating the germ-retaining parameters and husk-retaining parameters of the rice grains; and calculating the processing accuracy of the rice grains based on the germ-retaining parameters and the husk-retaining parameters.
[0011] According to one embodiment of the present invention, the preprocessing of the first image includes: binarizing the first image to obtain the second image, wherein the grayscale value of a pixel in the second image is a first grayscale value or a second grayscale value.
[0012] According to one embodiment of the present invention, determining whether the rice grain is embryo-retained rice based on the first image and the second image includes: obtaining a blue value B and a red value R of each pixel in the first image; setting the first gray value for the gray value of the pixel (i, j) satisfying the formula 100*(RB) / R>nRB to obtain a third image, wherein nRB is a second preset threshold; performing preset area division with each pixel in the third image having a gray value of the first gray value as the center; counting a first number of pixels in each preset area having a gray value of the first gray value, and when the first number is less than the first preset number, setting the gray value of the center point pixel of the corresponding preset area to the second gray value to obtain a fourth image; obtaining a connected area with the largest area in a connected domain having a gray value of the first gray value in the fourth image; and determining that the rice grain is embryo-retained rice based on the connected area with the largest area and the second image.
[0013] According to an embodiment of the present invention, determining that the rice grain is embryo-retained rice according to the connected region with the largest area and the second image includes: calculating the compactness of the connected region with the largest area according to the following formula:
[0014] fcompactness=nEdgeArea*nEdgeArea / nMaxArea,
[0015] Among them, fcompactness is the compactness, nEdgeArea is the contour perimeter of the connected area with the largest area, and nMaxArea is the area of the connected area with the largest area; if the compactness is greater than the second preset threshold, the first position of the centroid of the connected area with the largest area is obtained, and the second position of the centroid of the rice grain where the connected area with the largest area is located is obtained according to the second image; the distance between the first position and the second position is calculated; if the distance is greater than or equal to the third preset threshold, it is determined that the rice grain is embryo-retained rice.
[0016] According to an embodiment of the present invention, determining whether the rice grain is a rice grain with embryo and husk retained according to the first image and the second image includes: obtaining a blue value B of each pixel point in the first image; and calculating the gradient value of the pixel point (i, j) in multiple directions around it according to the following formula:
[0017] nT1(k)=smooth(i'(k),j'(k))-smooth(i,j),
[0018] Wherein, 4≤k≤K, k and K are both integers, K represents the number of directions, the gray value of the pixel point (i, j) in the second image is the first gray value, the blue value in the first image is less than or equal to the fourth preset threshold, nT1(k) is the gradient value of the pixel point (i, j) in the first image in the kth direction, smooth(i, j) is the blue value of the pixel point (i, j) in the first image, smooth(i'(k), j'(k)) is the blue value of the pixel point (i'(k), j'(k)) in the first image, and the distance between the pixel point (i'(k), j'(k)) and the pixel point (i, j) is the preset step size; when all K gradient values are greater than the fifth preset threshold, the gray value of the pixel point (i, j) in the second image is retained as the first gray value, otherwise the gray value of the pixel point (i, j) in the second image is set to the second gray value to obtain a fifth image; and whether the rice grain is embryo or husk rice is determined according to the fifth image.
[0019] According to one embodiment of the present invention, determining whether the rice grain is a rice with the embryo and pik retained based on the fifth image includes: obtaining a connected area in the fifth image whose area is less than a sixth preset threshold and greater than a seventh preset threshold, and deleting it to obtain a sixth image, wherein the sixth preset threshold is less than the seventh preset threshold; setting the grayscale value of the pixel point in the sixth image whose grayscale value is the first grayscale value and whose corresponding blue value in the first image is greater than the ninth preset threshold to the second grayscale value to obtain a seventh image; counting the diagonal length of the minimum circumscribed rectangle of all connected areas in the seventh image whose grayscale value is the first grayscale value; if there is a diagonal length greater than the ninth preset threshold, determining that the rice grain is a rice with the pik retained.
[0020] According to one embodiment of the present invention, the method for detecting rice processing accuracy also includes: the germ retention parameter is the germ retention area of the rice grain germ retention region, and the skin retention parameter is the skin retention area of the rice grain skin retention region, wherein the germ retention area is the area of the largest connected region in the connected domain with a grayscale value of the first grayscale value in the fourth image, and the skin retention area is the area of the connected region with all grayscale values of the first grayscale value in the seventh image.
[0021] According to one embodiment of the present invention, the method for detecting the rice processing accuracy further comprises: calculating the processing accuracy of the rice grains by the following formula:
[0022]
[0023] Among them, nRate is the processing accuracy, ∑nEmbroyArea is the embryo area, ∑nThinArea is the skin area, and ∑nArea is the area of the rice grain.
[0024] To achieve the above-mentioned purpose, a second aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the above-mentioned method for detecting rice processing accuracy is implemented.
[0025] The computer-readable storage medium of the embodiment of the present invention, when the computer program stored thereon is executed by a processor, can improve the detection accuracy of rice processing precision, reduce labor costs, and improve the production efficiency of the rice production line.
[0026] To achieve the above-mentioned purpose, a third aspect of the present invention provides a rice processing precision detection device, comprising a memory, a processor and a computer program stored in the memory, wherein when the computer program is executed by the processor, the above-mentioned rice processing precision detection method is implemented.
[0027] The rice processing precision detection device of the embodiment of the present invention can improve the detection accuracy of the rice processing precision, reduce labor costs, and improve the production efficiency of the rice production line by implementing the above-mentioned rice processing precision detection method.
[0028] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 is a flow chart of a method for detecting rice processing accuracy according to an embodiment of the present invention;
[0030] Figure 2 It is a flow chart of a method for detecting rice processing accuracy according to a specific embodiment of the present invention;
[0031] Figure 3 is a flow chart of a method for detecting rice processing accuracy according to another specific embodiment of the present invention;
[0032] Figure 4 is a schematic diagram of a rice processing accuracy detection device according to an example of the present invention;
[0033] Figure 5 is a schematic diagram of a rice grain according to a first example of the present invention;
[0034] Figure 6 is a schematic diagram of a rice grain according to a second example of the present invention;
[0035] Figure 7 is a schematic diagram of rice grains according to a third example of the present invention;
[0036] Figure 8 is a schematic diagram of rice grains according to a fourth example of the present invention;
[0037] Fig. 9 It is a schematic diagram of a rice processing precision test page of an example of the present invention;
[0038] Fig.10 It is a schematic diagram of a rice processing accuracy test page according to another example of the present invention. DETAILED DESCRIPTION
[0039] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present invention, and should not be construed as limiting the present invention.
[0040] Please refer to the following Figure 1-10The invention describes a method, a device and a storage medium for detecting rice processing accuracy according to an embodiment of the invention.
[0041] Figure 1 It is a flow chart of a method for detecting rice processing accuracy according to an embodiment of the present invention.
[0042] S11, collecting images of rice grains at at least three angles, and recording the images at at least three angles as first images.
[0043] The rice grains are processed rice grains, and the first image may be an RGB image.
[0044] Specifically, multiple image acquisition devices may be used to acquire images of rice grains at at least three angles, such as Figure 4 As shown, the number of image acquisition devices can be 3, which are respectively recorded as image acquisition devices 1, 2, and 3. Image acquisition devices 1, 2, and 3 simultaneously receive R, G, and B signals generated by white light LED light sources 4, 5, and 6 acting on the surface of rice grains. In order to obtain the above-mentioned RGB image, image acquisition devices 1, 2, and 3 simultaneously acquire images of rice grains at multiple angles, and then use images at multiple angles to recognize rice grains, recognize rice germs, and calculate the germ retention degree and skin retention degree.
[0045] Specifically, see Figure 4 , the three image acquisition devices can be located on the same plane at the same angle (i.e., the angles between the two are 120°), and can simultaneously collect all-round appearance features of the same rice grain. Three groups of white light LED light sources are distributed at the same angle on the same side of the three image acquisition devices, and the image acquisition devices can simultaneously receive R, G, and B value signals in the white light.
[0046] S12, preprocessing the first image to obtain a second image.
[0047] As an example, preprocessing the first image may include: binarizing the first image to obtain a second image, wherein the grayscale value of a pixel in the second image is a first grayscale value or a second grayscale value. The first grayscale value may be a grayscale value of 255, and the second grayscale value may be a grayscale value of 0.
[0048] For example, see Figure 5 , Figure 5 (a) shows a first image, and the second image obtained by the above-mentioned method of preprocessing the first image can be shown as Figure 5 As shown in (b).
[0049] It should be noted that due to the black background, the rice grain binary image in the second image may have internal holes, such as Figure 6Therefore, after preprocessing the first image to obtain the second image, it is necessary to perform edge detection on the second image to detect the edge of the rice grain binary image, and then fill the inside of the rice grain binary image to obtain Figure 6 The image shown in (b).
[0050] Optionally, a morphological erosion operation may be used to erode the image edge of the second image twice, thereby preventing the color distortion of edge pixels from affecting recognition.
[0051] S13, determining whether the rice grains are rice with the germ or husk retained according to the first image and the second image.
[0052] S14: If the rice grain is a rice grain with germ and husk retained, then the germ and husk retained parameters of the rice grain are calculated.
[0053] Among them, the above-mentioned germ-retaining parameter can be the germ-retaining area of the germ-retaining region of the rice grain, and the above-mentioned skin-retaining parameter can be the skin-retaining area of the skin-retaining region of the rice grain.
[0054] Specifically, if it is determined that the rice grain is a rice with both germ and husk retained, the germ retention parameter, husk retention parameter and area of the rice grain are calculated.
[0055] S15, calculating the processing accuracy of the rice grains according to the germ retention parameter and the husk retention parameter.
[0056] Specifically, the processing accuracy of rice grains can be calculated according to the following formula:
[0057]
[0058] Among them, nRate is the processing accuracy, ∑nEmbroyArea is the embryo area, ∑nThinArea is the skin area, ∑nArea is the area of the rice grain, and ∑nArea can be the area of the connected area in the second image (that is, the connected area of the pixel points with the first grayscale value).
[0059] Furthermore, the rice grains can be classified according to the processing accuracy, into fine grinding and suitable grinding, or into super fine grinding, fine grinding and suitable grinding. Specifically, a processing accuracy interval is pre-set for each category, and the rice grain category can be determined according to the calculated processing accuracy interval.
[0060] In some examples, such as Figure 2 As shown, determining whether the rice grains are rice with the germ and rind retained according to the first image and the second image may include:
[0061] S31, obtaining a blue value B and a red value R of each pixel in the first image.
[0062] S32, setting the grayscale value of the pixel point (i, j) satisfying the formula 100*(RB) / R>nRB to the first grayscale value, to obtain a third image, wherein nRB is a first preset threshold.
[0063] The first preset threshold may be between 10 and 35, for example, 13.5.
[0064] S33, performing preset area division with each pixel point with a grayscale value of the first grayscale value in the third image as the center.
[0065] In this example, the preset area may be a frame with M rows and N columns, for example, a frame with 5 rows and 7 columns.
[0066] S34, counting a first number of pixel points whose grayscale value is a first grayscale value in each preset area, and when the first number is less than the first preset number, setting the grayscale value of the central point pixel of the corresponding preset area to a second grayscale value to obtain a fourth image.
[0067] Specifically, when the first number is greater than or equal to the first preset number, the grayscale value of the center point pixel corresponding to the preset area is set to the first grayscale value; otherwise, the grayscale value of the center point pixel is set to the second grayscale value to obtain a fourth image.
[0068] Among them, the above-mentioned first preset number can be between 6 and 10, for example, it can be 8; the above-mentioned embryo-retaining area can be the area of the largest connected region in the connected domain with the first grayscale value in the fourth image.
[0069] S35, obtaining a connected region with the largest area in a connected domain whose grayscale value is the first grayscale value in the fourth image.
[0070] S36, determining that the rice grain is embryo-retained rice according to the connected region with the largest area and the second image.
[0071] Specifically, the connected region with the largest area in the fourth image is obtained, and the pixels of other connected regions are set to the second grayscale value, and then the compactness of the connected region with the largest area can be calculated according to the following formula:
[0072] fcompactness=nEdgeArea*nEdgeArea / nMaxArea
[0073] Among them, fcompactness is the compactness, nEdgeArea is the contour perimeter of the connected area, and nMaxArea is the area of the largest connected area.
[0074] Furthermore, if the compactness is greater than a second preset threshold, a first position of the centroid of the connected region with the largest area is obtained, and a second position of the centroid of the rice grain where the connected region with the largest area is located is obtained according to the second image; and a distance between the first position and the second position is calculated. If the distance is greater than or equal to a fourth preset threshold, the rice grain is determined to be embryonated rice.
[0075] The second preset threshold may be between 27 and 33, for example, 30. The third preset threshold may be between 8 and 12, for example, 10.
[0076] In this example, see Figure 7 , Figure 7 (a) shows the first image of embryo-free rice. Figure 7 The fourth image of embryo-retained rice is shown in (b).
[0077] In some examples, such as Figure 3 As shown, determining whether the rice grains are rice with the germ and rind retained according to the first image and the second image may include:
[0078] S41, obtaining the blue value B of each pixel in the first image.
[0079] S42, calculating the gradient values of the pixel point (i, j) in multiple directions around it.
[0080] Specifically, the gradient values of the pixel point (i, j) in multiple directions around it can be calculated according to the following formula:
[0081] nT1(k)=smooth(i'(k),j'(k))-smooth(i,j),
[0082] Wherein, 4≤k≤K, k and K are both integers, K represents the number of directions, the grayscale value of the pixel (i, j) in the second image is the first grayscale value, the blue value in the first image is less than or equal to the fourth preset threshold, nT1(k) is the gradient value of the pixel (i, j) in the first image in the kth direction, smooth(i, j) is the blue value of the pixel (i, j) in the first image, smooth(i'(k), j'(k)) is the blue value of the pixel (i'(k), j'(k)) in the first image, and the distance between the pixel (i'(k), j'(k)) and the pixel (i, j) is the preset step size. The above fourth preset threshold can be between 175 and 185, for example, it can be 180; the above preset step size can be between 8 and 12, for example, it can be 10.
[0083] In this example, the above K can take a value of 8, for example, four directions including up, down, left, and right, and the middle direction of the adjacent directions of these four directions, that is, the direction that is at an angle of 45 degrees to the adjacent direction, for a total of 8 directions.
[0084] S43, when the K gradient values are all greater than the fifth preset threshold, retain the grayscale value of the pixel point (i, j) in the second image as the first grayscale value, otherwise set the grayscale value of the pixel point (i, j) in the second image to the second grayscale value, and obtain the fifth image.
[0085] The fifth preset threshold may be between 23 and 27, for example, 25.
[0086] S44, determining whether the rice grains are rice with the germ and husk retained according to the fifth image.
[0087] Specifically, a connected region whose area is smaller than a sixth preset threshold and larger than a seventh preset threshold is obtained in the fifth image, and is deleted to obtain a sixth image, wherein the sixth preset threshold is smaller than the seventh preset threshold. The grayscale value of the pixel whose grayscale value in the sixth image is the first grayscale value and whose corresponding blue value in the first image is larger than the ninth preset threshold is set to the second grayscale value to obtain a seventh image.
[0088] Specifically, by setting the grayscale value of the pixel point corresponding to the blue value greater than the ninth preset threshold in the first image to the second grayscale value, it is possible to delete the misidentified area.
[0089] Furthermore, the diagonal lengths of the minimum circumscribed rectangles of all connected areas whose grayscale values in the seventh image are the first grayscale value are counted. If there is a diagonal length greater than a ninth preset threshold, it is determined that the rice grains are piked rice.
[0090] Among them, the above-mentioned sixth preset threshold value can be between 75 and 85, for example, it can be 80. The above-mentioned seventh preset threshold value can be between 500 and 520, for example, it can be 510. The above-mentioned ninth preset threshold value can be between 80 and 90, for example, it can be 85. The above-mentioned ninth preset threshold value can be between 27 and 33, for example, it can be 30. The above-mentioned skin-retaining area can be the area of the connected area with the gray value of the first gray value in the seventh image (that is, the connected area with a gray value of 255). Of course, the skin-retaining area can also be the area of all connected domains in the seventh image whose diagonal length is greater than the ninth preset threshold.
[0091] In this example, see Figure 8 , Figure 8 (a) shows the first image of the leuprorein, Figure 8 Middle (b) shows the seventh image of Leupik.
[0092] It should be noted that, since the judgment methods of rice with germ and rice with husk are different, the two judgment processes can be performed simultaneously; the judgment of rice with germ can be performed first, and then the judgment of rice with husk; the judgment of rice with husk can be performed first, and then the judgment of rice with germ. Among them, the parameters of rice with germ and husk can be calculated in the corresponding judgment process, and the area of rice grains can be directly calculated based on the second image.
[0093] In summary, the method for detecting rice processing precision in the embodiment of the present invention detects the surface features of rice grains based on multi-angle images of rice grains to determine the rice processing precision. The detection accuracy is high and there is no need to dye the rice grains. Therefore, labor costs can be reduced and the production efficiency of the rice production line can be improved.
[0094] Based on the above identification method, the test was carried out and the data shown in Table 1 was obtained:
[0095] Table 1
[0096] Rice Sample total Identify the number Recognition rate Germ rice 531 520 97.9%
[0097] It can be seen that the present invention can achieve a relatively good recognition effect, and the recognition rate of embryo-retained rice can reach 97.9%.
[0098] The test was conducted using a fine milled rice sample with a husk retention of 0.7% and a suitable milled rice sample with a husk retention of 3.2% according to the 2020 national standard. The fine milled rice sample and the suitable milled rice sample were provided by the government, specifically by the Grain Quality Inspection Center. The rice sample was an international rice sample produced by Suzhou Yuerui Grain and Oil Co., Ltd., which is suitable for calibrating the rice processing accuracy, rice grade identification and quality control of the rice processing production process. The husk retention is the processing accuracy in the present invention. The test results are shown in Table 2 below:
[0099] Table 2
[0100] Rice Sample National standard skin retention degree (%) This example tests the skin retention (%) Fine grinding 0.7 0.73 Suitable for grinding 3.2 3.26
[0101] During the specific test, the test interface generated is as follows Fig. 9 and Fig.10 As shown, see Fig. 9 For the official milled rice sample, the skin retention rate was 0.73%, which was judged to be milled rice; see Fig.10 For the rice sample suitable for milling provided by the government, the tested skin retention rate was 3.26%, which was judged to be suitable for milling. It can be seen that the calculation accuracy of the processing precision is relatively high.
[0102] Furthermore, the present invention provides a computer-readable storage medium.
[0103] In an embodiment of the present invention, a computer program is stored on a computer-readable storage medium, and when the computer program is executed by a processor, the above-mentioned method for detecting rice processing accuracy is implemented.
[0104] The computer-readable storage medium of the embodiment of the present invention can improve the detection accuracy of rice processing precision, reduce labor costs, and improve the production efficiency of the rice production line when the computer program stored thereon is executed by a processor.
[0105] Furthermore, the present invention provides a device for detecting rice processing accuracy.
[0106] In an embodiment of the present invention, a rice processing precision detection device includes a memory, a processor, and a computer program stored in the memory. When the computer program is executed by the processor, the above-mentioned rice processing precision detection method is implemented.
[0107] The rice processing precision detection device of the embodiment of the present invention can improve the detection accuracy of the rice processing precision by implementing the above-mentioned rice processing precision detection method, and can also reduce labor costs and improve the production efficiency of the rice production line.
[0108] It should be noted that the logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be specifically implemented in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection portion with one or more wirings (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.
[0109] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0110] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0111] In the description of the present invention, it is to be understood that the terms “center”, “longitudinal”, “lateral”, “length”, “width”, “thickness”, “up”, “down”, “front”, “back”, “left”, “right”, “vertical”, “horizontal”, “top”, “bottom”, “inside”, “outside”, “clockwise”, “counterclockwise”, “axial”, “radial”, “circumferential”, etc., indicating orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the referred device or element must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as limiting the present invention.
[0112] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0113] In the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements, unless otherwise clearly defined. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0114] In the present invention, unless otherwise clearly specified and limited, a first feature being "above" or "below" a second feature may mean that the first and second features are in direct contact, or the first and second features are in indirect contact through an intermediate medium. Moreover, a first feature being "above", "above" or "above" a second feature may mean that the first feature is directly above or obliquely above the second feature, or simply means that the first feature is higher in level than the second feature. A first feature being "below", "below" or "below" a second feature may mean that the first feature is directly below or obliquely below the second feature, or simply means that the first feature is lower in level than the second feature.
[0115] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.
Claims
1. A method for detecting rice processing accuracy, characterized in that, The following steps are involved: Collecting images of rice grains at at least three angles, and recording the images at the at least three angles as first images; Preprocessing the first image to obtain a second image; Determine whether the rice grain is a rice grain with embryo and husk retained according to the first image and the second image; If the rice grain is a rice grain with germ and husk retained, then calculating a germ and husk retention parameter of the rice grain; Calculating the processing accuracy of the rice grains according to the germ-retaining parameter and the skin-retaining parameter; The first image is an RGB image, and the preprocessing of the first image includes: Binarize the first image to obtain the second image, wherein the grayscale value of a pixel in the second image is a first grayscale value or a second grayscale value; The step of determining whether the rice grain is a rice grain with the germ and husk retained according to the first image and the second image comprises: Obtaining a blue value B and a red value R of each pixel in the first image; The grayscale value of the pixel point (i, j) satisfying the formula 100*(RB) / R>nRB is set to the first grayscale value to obtain a third image, wherein nRB is a first preset threshold; Performing preset area division with each pixel point whose grayscale value in the third image is the first grayscale value as the center; Counting a first number of pixel points in each preset area whose grayscale value is the first grayscale value, and when the first number is less than the first preset number, setting the grayscale value of the central point pixel of the corresponding preset area to the second grayscale value, to obtain a fourth image; Obtaining a connected region with the largest area in a connected domain whose grayscale value is the first grayscale value in the fourth image; The rice grain is determined to be embryo-retained rice according to the connected region with the largest area and the second image.
2. The method for detecting rice processing accuracy as claimed in claim 1, wherein: The step of determining that the rice grain is embryo-retained rice according to the connected region with the largest area and the second image comprises: The compactness of the connected region with the largest area is calculated according to the following formula: fcompactness=nEdgeArea*nEdgeArea / nMaxArea, Wherein, fcompactness is the compactness, nEdgeArea is the contour perimeter of the connected region with the largest area, and nMaxArea is the area of the connected region with the largest area; If the compactness is greater than a second preset threshold, obtaining a first position of the centroid of the connected region with the largest area, and obtaining a second position of the centroid of the rice grain where the connected region with the largest area is located according to the second image; calculating a distance between the first position and the second position; If the distance is greater than or equal to a third preset threshold, it is determined that the rice grain is embryonated rice.
3. The method for detecting rice processing accuracy as claimed in claim 1 or 2, characterized in that, The step of determining whether the rice grain is a rice grain with the germ and husk retained according to the first image and the second image comprises: Obtaining a blue value B of each pixel in the first image; The gradient value of the pixel point (i, j) in multiple directions around it is calculated according to the following formula: nT1(k)=smooth(i'(k),j'(k))-smooth(i,j), Wherein, 4≤k≤K, k and K are both integers, K represents the number of directions, the grayscale value of the pixel point (i, j) in the second image is the first grayscale value, the blue value in the first image is less than or equal to the fourth preset threshold, nT1(k) is the gradient value of the pixel point (i, j) in the first image in the kth direction, smooth(i, j) is the blue value of the pixel point (i, j) in the first image, smooth(i'(k), j'(k)) is the blue value of the pixel point (i'(k), j'(k)) in the first image, and the distance between the pixel point (i'(k), j'(k)) and the pixel point (i, j) is the preset step size; When all K gradient values are greater than a fifth preset threshold, retaining the grayscale value of the pixel point (i, j) in the second image as the first grayscale value; otherwise, setting the grayscale value of the pixel point (i, j) in the second image to the second grayscale value, to obtain a fifth image; Determine whether the rice grain is rice with the germ and rind retained according to the fifth image.
4. The method for detecting rice processing accuracy as claimed in claim 3, wherein: The step of determining whether the rice grain is a rice grain with germ and rind retained according to the fifth image comprises: Obtaining connected regions in the fifth image whose areas are smaller than a sixth preset threshold and larger than a seventh preset threshold, and deleting them to obtain a sixth image, wherein the sixth preset threshold is smaller than the seventh preset threshold; The grayscale value in the sixth image is the first grayscale value, and the grayscale value of the pixel corresponding to the blue value greater than the ninth preset threshold in the first image is set to the second grayscale value, to obtain a seventh image; Counting the diagonal length of the minimum circumscribed rectangle of all connected areas whose grayscale value is the first grayscale value in the seventh image; If there is a diagonal length greater than a ninth preset threshold, it is determined that the rice grains are piked rice.
5. The method for detecting rice processing accuracy as claimed in claim 4, characterized in that: The germ-retaining parameter is the germ-retaining area of the rice grain germ-retaining region, and the husk-retaining parameter is the husk-retaining area of the rice grain husk-retaining region, wherein the germ-retaining area is the area of the largest connected region in the connected domain with a grayscale value of the first grayscale value in the fourth image, and the husk-retaining area is the area of the connected region with all grayscale values of the first grayscale value in the seventh image.
6. The method for detecting rice processing accuracy as claimed in claim 5, characterized in that: The processing accuracy of the rice grains is calculated by the following formula: Among them, nRate is the processing accuracy, ∑nEmbroyArea is the embryo area, ∑nThinArea is the skin area, and ∑nArea is the area of the rice grain.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for detecting rice processing accuracy according to any one of claims 1 to 6 is implemented.
8. A rice processing precision detection device, comprising a memory, a processor and a computer program stored in the memory, characterized in that: When the computer program is executed by a processor, the method for detecting rice processing accuracy according to any one of claims 1 to 6 is implemented.
