Risk assessment and early warning method and system for microorganisms in food
By constructing pure colony images and matrices of food colony images, the problem of the inability to accurately assess the colony status on the food surface in existing technologies is solved, enabling precise assessment and automatic early warning of food microbial risks.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NINGXIA HUI AUTONOMOUS REGION FOOD TESTING RES INST
- Filing Date
- 2024-02-02
- Publication Date
- 2026-04-24
AI Technical Summary
Existing methods for assessing and warning about the risk of microorganisms in food fail to accurately analyze the bacterial colony situation on the food surface, resulting in an inability to accurately assess the risk of microorganisms in food.
By acquiring real-time images of food at multiple time points, removing impurity areas, constructing pure colony images of food microorganisms, establishing colony matrices and reference matrices, and calculating edible risk values, the risk assessment of food at each time point can be achieved.
To more accurately assess the risk level of food consumption, provide automatic early warnings, and ensure food safety.
Smart Images

Figure CN121921767A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of microbial monitoring technology, and in particular to a method and system for risk assessment and early warning of microorganisms in food. Background Technology
[0002] Currently, the food industry is one that involves the health and safety of all people in society. Food must meet food safety standards, especially the assessment of the presence of microorganisms in food. Obtaining potential microbial risk assessment results is of paramount importance. The main microorganisms in food include colonies of Escherichia coli, Salmonella, Staphylococcus aureus, and molds. Therefore, assessing these colonies is equivalent to assessing the microorganisms in food.
[0003] However, existing methods and systems for risk assessment and early warning of microorganisms in food only process food safety risk scores over a period of time within a target area to obtain food safety assessment results. They do not analyze the bacterial colony situation on the food surface during this process, making it impossible to more accurately assess and warn of microorganism risks in food. For example, the patent with publication number "CN113379189A" and patent name "Food Safety Risk Assessment Method" includes the following steps: S1. Collecting food safety risk scores for L months within a target area and fitting L risk fluctuation curves based on these scores; S2. Performing density-based spatial clustering on the L risk fluctuation curves and extracting risk fluctuation characteristics at different time scales; S3. Clustering the risk fluctuation characteristics at different time scales using a gravity search algorithm; S4. Calculating the clustering evaluation index CDI, where CDI is the cluster dispersion; S5. Repeating steps S3-S4, selecting the risk fluctuation curve corresponding to the minimum value of the CDI as the risk assessment result. By applying the embodiments of this invention, the safety risks of a target area can be accurately assessed, enabling timely alerts for videos exceeding abnormal ranges, thus facilitating accurate and effective supervision of food safety risks. However, this patent only processes the food safety risk score of the target area over a period of time to obtain the food safety assessment result. Throughout the process, it does not analyze the bacterial colony situation on the food surface, making it impossible to more accurately assess and warn of the risks posed by microorganisms in food.
[0004] Therefore, this invention proposes a risk assessment and early warning method and system for microorganisms in food, which can analyze the colony status on the surface of food at multiple time points and more accurately conduct risk assessment and early warning of microorganisms in food. Summary of the Invention
[0005] This invention provides a method and system for risk assessment and early warning of microorganisms in food. It aims to more accurately remove impurity regions from food colony images, obtaining pure colony images for each food colony image. This facilitates the subsequent construction of colony matrices and reference matrices for the food colony images. Based on the relevant data of all pure colony regions in the food colony images at each time point, a colony matrix for each time point is constructed. Similarly, based on the relevant data of all pure colony regions in the food colony images at all time points, a colony reference matrix is constructed. By using the colony matrix and reference matrix for each time point, the edibility risk value of the food at each time point can be obtained more accurately. Finally, by using the edibility risk value of the food at all time points, the degree of edibility risk of the food can be assessed more accurately.
[0006] This invention provides a method for risk assessment and early warning of microorganisms in food, comprising:
[0007] S1: Obtain real-time images of food at multiple time points, and obtain the standard pixel value of each real-time image at each pixel position. Based on the standard pixel value of each real-time image at all pixel positions, obtain the food colony image at each time point.
[0008] S2: Based on the food colony image at each time point, remove the impurity areas in the corresponding food colony image to obtain the pure colony image of the food colony image at each time point.
[0009] S3: Construct a colony matrix for the food colony image at each time point based on the pure colony image of the food colony image at each time point, and construct a colony reference matrix based on the food colony images at all time points.
[0010] S4: Based on the colony matrix and reference matrix of the food colony image at each time point, obtain the food consumption risk value at each time point. Based on the food consumption risk value at all time points, assess the degree of food consumption risk, obtain the risk assessment result, and issue an automatic warning based on the risk assessment result.
[0011] Preferably, the risk assessment and early warning method for microorganisms in food includes the following steps: S1: acquiring real-time images of the food at multiple time points, acquiring the standard pixel value of each real-time image at each pixel location, and obtaining the food colony image at each time point based on the standard pixel values of each real-time image at all pixel locations, including:
[0012] S101: Acquire real-time images of the food at a preset number of time points every unit of time before the current time, with the current time also being considered as a time point;
[0013] S102: Obtain the standard pixel value of each real-time image at each pixel location based on the three-channel pixel value of each real-time image at each pixel location, and obtain the food colony image at each time node based on the standard pixel value of each real-time image at all pixel locations.
[0014] Preferably, the risk assessment and early warning method for microorganisms in food, S102: Obtaining the standard pixel value of each real-time image at each pixel location based on the three-channel pixel values of each real-time image at each pixel location, and obtaining a food colony image at each time point based on the standard pixel values of each real-time image at all pixel locations, including:
[0015] S1021: Obtain the three-channel pixel value of each real-time image at each pixel position, and use the sum of the products of the three-channel pixel value at each pixel position and the corresponding preset channel coefficient as the standard pixel value at each pixel position to obtain the standard pixel value of each real-time image at each pixel position.
[0016] S1022: Based on the colony separation algorithm, the position of each pixel in each real-time image is determined to obtain the background area and colony area in each real-time image. The standard pixel value of the background area in each real-time image is assigned to 0, and the standard pixel value of the colony area is assigned to 1. Based on the assignment results of the background area and colony area in each real-time image, the food colony image at each time node is obtained.
[0017] Preferably, the risk assessment and early warning method for microorganisms in food determines the position of each pixel in each real-time image based on a colony separation algorithm, thereby obtaining the background area and colony area in each real-time image, including:
[0018] S10221: Set the separation pixel value to 1;
[0019] S10222: The region consisting of pixels whose standard pixel value is greater than the currently set separation pixel value in all pixels of each real-time image is taken as the hypothetical colony region in the real-time image, and the region consisting of pixels whose standard pixel value is not greater than the currently set separation pixel value in all pixels of each real-time image is taken as the hypothetical background region in the real-time image.
[0020] S10223: Calculate the feasibility value of the currently set separation pixel value based on the colony separation algorithm and the hypothetical colony region and hypothetical background region in the real-time image, including:
[0021]
[0022] Where δ is the feasibility value for setting the separated pixel value, n1 is the number of pixel positions in the hypothetical colony region in the real-time image, n2 is the number of pixel positions in the hypothetical background region in the real-time image, N is the total number of pixel positions in the real-time image, ln is the natural logarithm, and e is 2.718, ε1 is the mean of the standard pixel values of all pixel positions in the hypothetical colony region in the real-time image, and ε2 is the mean of the standard pixel values of all pixel positions in the hypothetical background region in the real-time image.
[0023] S10224: When the feasibility value of the currently set separation pixel value is greater than the preset threshold, it is determined that the currently set separation pixel value is feasible, and the hypothetical colony area and hypothetical background area in the real-time image are treated as the background area and colony area in the real-time image. Otherwise, the value of the currently set separation pixel value is incremented by 1 to obtain a newly set separation pixel value, and steps S10221 to S10223 are executed repeatedly based on the newly set separation pixel value until the feasibility value of the newly set separation pixel value is greater than the preset threshold. The hypothetical colony area and hypothetical background area in the real-time image are treated as the background area and colony area in the real-time image, respectively.
[0024] Preferably, the risk assessment and early warning method for microorganisms in food, S2: Based on the food colony image at each time point, impurity areas in the corresponding food colony image are removed to obtain a pure colony image of the food colony image at each time point, including:
[0025] Obtain all sub-regions in the food colony image at each time point, and determine the sub-regions in each food colony image whose number of boundary pixels is greater than the preset number of boundary pixels as pure colony regions;
[0026] In each food colony image, the sub-regions in which the number of boundary pixels is not greater than the preset number of boundary pixels are identified as impurity regions.
[0027] By setting the standard pixel value of all pixels in the sub-regions identified as impurity regions in the food colony image at each time point to 0, a pure colony image of the food colony image at each time point is obtained.
[0028] Preferably, the risk assessment and early warning method for microorganisms in food, S3: constructs a colony matrix of food colony images at each time point based on pure colony images of food colony images at each time point, and constructs a colony reference matrix based on food colony images at all time points, including:
[0029] S301: Construct a colony matrix for the food colony image at each time point based on the relevant data of each pure colony region in the pure colony image of the food colony image at each time point;
[0030] S302: Construct a colony reference matrix based on the correlation data of all pure colony regions in food colony images at all time points.
[0031] Preferably, the risk assessment and early warning method for microorganisms in food, S301: constructs a colony matrix for each time point of the food colony image based on the relevant data of each pure colony region in the pure colony image of the food colony image at each time point, including:
[0032] S3011: Obtain the number of all pixels and the number of boundary pixels contained in each pure colony region of the pure colony image of the food colony image at each time node, and use them as the relevant data of the corresponding pure colony region;
[0033] S3012: Sort all pure colony regions in each pure colony image ordinally starting from 1 according to the total number of pixels contained, to obtain the sorting result of the food colony images at each time point. Based on the sorting result of the food colony images at each time point, use the relevant data of each pure colony region of the pure colony image of the food colony image at each time point as matrix elements to construct the colony matrix of the food colony image at each time point, which is:
[0034]
[0035] Where E is the colony matrix of the food colony image, w1 is the number of boundary pixels of the pure colony region with ordinal number 1, r1 is the total number of pixels contained in the pure colony region with ordinal number 1, t1 is the quotient of the number of boundary pixels of the pure colony region with ordinal number 1 and the total number of pixels contained in the corresponding pure colony region, w2 is the number of boundary pixels of the pure colony region with ordinal number 2, r2 is the total number of pixels contained in the pure colony region with ordinal number 2, t2 is the quotient of the number of boundary pixels of the pure colony region with ordinal number 2 and the total number of pixels contained in the corresponding pure colony region, w i r is the number of boundary pixels of a pure colony region with ordinal number i. i Let t be the total number of pixels contained in the pure colony region of ordinal number i. i Let i be the quotient of the number of boundary pixels of the pure colony region with ordinal number i and the total number of pixels contained in the corresponding pure colony region, where i is the total number of pure colony regions in the food colony image.
[0036] Preferably, the risk assessment and early warning method for microorganisms in food, S302: constructs a colony reference matrix based on the relevant data of all pure colony regions in food colony images at all time points, including:
[0037] S3021: Obtain the relevant data of all pure colony regions in the food colony image at each time point, wherein the relevant data of all pure colony regions in each food colony image is the total number of all pixels contained in the pure colony region and the total number of boundary pixels of all pure colony regions.
[0038] S3022: Sort all food colony images sequentially by ordinal number starting from 1, and construct a colony reference matrix using the relevant data of all pure colony regions in all food colony images as matrix elements, as follows:
[0039]
[0040] Among them, E ° Let W1 be the total number of boundary pixels in all pure colony regions of the food colony image with ordinal number 1, R1 be the total number of pixel positions in all pure colony regions of the food colony image with ordinal number 1, T1 be the quotient of the number of boundary pixels in all pure colony regions of the food colony image with ordinal number 1 and the total number of pixels contained in the corresponding pure colony regions, W2 be the total number of boundary pixels in all pure colony regions of the food colony image with ordinal number 2, R2 be the total number of pixel positions in all pure colony regions of the food colony image with ordinal number 2, and T2 be the quotient of the number of boundary pixels in all pure colony regions of the food colony image with ordinal number 2 and the total number of pixels contained in the corresponding pure colony regions. I R is the total number of boundary pixel locations of all pure colony regions in a food colony image with ordinal number I. I T represents the total number of pixel locations in all pure colony regions of a food colony image with ordinal number I. I Let I be the quotient of the number of boundary pixels of all pure colony regions in the food colony image with ordinal number I and the number of all pixels contained in the corresponding pure colony regions, where I is the total number of time nodes.
[0041] Preferably, the risk assessment and early warning method for microorganisms in food obtains the food's edibility risk value at each time point based on the colony matrix and reference matrix of the food colony image at each time point, and assesses the degree of food edibility risk based on the food's edibility risk values at all time points to obtain a risk assessment result, including:
[0042] The quotient of the rank of the colony matrix of the food colony image at each time point and the rank of the reference matrix is taken as the food's consumption risk value at the corresponding time point.
[0043] The difference between the consumption risk values of food at two adjacent time points is taken as the adjacent consumption risk value. If the maximum value among all adjacent consumption risk values of food is greater than the preset risk value threshold, the consumption risk of food is determined to be high; otherwise, the consumption risk of food is determined to be low.
[0044] This invention provides a risk assessment and early warning system for microorganisms in food, used to execute any one of the risk assessment and early warning methods for microorganisms in food in Examples 1 to 9, comprising:
[0045] The food colony image module is used to acquire real-time images of food at multiple time points, and to acquire the standard pixel value of each real-time image at each pixel position. Based on the standard pixel value of each real-time image at all pixel positions, the food colony image at each time point is obtained.
[0046] The pure colony image module is used to remove impurity areas from the corresponding food colony image based on the food colony image at each time point, so as to obtain the pure colony image of the food colony image at each time point.
[0047] The matrix construction module is used to construct a colony matrix of food colony images at each time point based on the pure colony images of food colony images at each time point, and to construct a colony reference matrix based on food colony images at all time points.
[0048] The assessment module is used to obtain the food's edibility risk value at each time point based on the colony matrix and reference matrix of the food colony image at each time point, assess the degree of food edibility risk based on the food's edibility risk values at all time points, obtain the risk assessment result, and issue automatic warnings based on the risk assessment result.
[0049] The beneficial effects of this invention compared to the prior art are as follows: it more accurately removes impurity areas from food colony images, obtaining pure colony images for each food colony image, which facilitates the subsequent construction of colony matrices and colony reference matrices for food colony images. Based on the relevant data of all pure colony areas in the food colony images at each time point, a colony matrix for the food colony images at each time point is constructed. Based on the relevant data of all pure colony areas in the food colony images at all time points, a colony reference matrix is constructed. Based on the colony matrix and reference matrix of the food colony images at each time point, the edibility risk value of the food at each time point is obtained more accurately. Based on the edibility risk value of the food at all time points, a more precise assessment of the degree of edibility risk of the food is achieved.
[0050] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention may be realized and obtained by means of the structures particularly pointed out in the written documents of this application.
[0051] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description
[0052] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:
[0053] Figure 1 This is a flowchart of a risk assessment and early warning method for microorganisms in food according to an embodiment of the present invention;
[0054] Figure 2 This is a schematic diagram of a risk assessment and early warning system for microorganisms in food according to an embodiment of the present invention. Detailed Implementation
[0055] The preferred embodiments of the present invention will be described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit the present invention.
[0056] Example 1:
[0057] This invention provides a method for risk assessment and early warning of microorganisms in food, with reference to Figure 1 ,include:
[0058] S1: Acquire real-time images of food at multiple time points, and obtain the standard pixel value of each real-time image at each pixel position. Based on the standard pixel value of each real-time image at all pixel positions, obtain the food colony image at each time point.
[0059] S2: Based on the food colony image at each time point, remove the impurity areas in the corresponding food colony image to obtain the pure colony image of the food colony image at each time point.
[0060] S3: Construct a colony matrix for the food colony image at each time point based on the pure colony image of the food colony image at each time point, and construct a colony reference matrix based on the food colony images at all time points.
[0061] S4: Based on the colony matrix and reference matrix of the food colony image at each time point, obtain the food consumption risk value at each time point. Based on the food consumption risk value at all time points, assess the degree of food consumption risk, obtain the risk assessment result, and issue an automatic warning based on the risk assessment result.
[0062] In this embodiment, the time node is a preset number of time nodes that occur every unit of time before the current time for the food.
[0063] In this embodiment, the real-time image is an image containing details of the food surface acquired in real time at the corresponding time node.
[0064] In this embodiment, the standard pixel value is the pixel value at each pixel location obtained based on the three-channel pixel values at each pixel location in each real-time image.
[0065] In this embodiment, the food colony image is an image containing colony areas on the real-time image, obtained based on the standard pixel values at all pixel locations of the real-time image. Each real-time image corresponds to one food colony image.
[0066] In this embodiment, the impurity region is the image region of the impurity part in the food colony image, such as micro dust particles.
[0067] In this embodiment, the removal process involves assigning a standard pixel value of 0 to all pixel locations in the impurity region of the food colony image.
[0068] In this embodiment, the pure colony image is the image obtained after removing the impurity areas from the food colony image, and each food colony image corresponds to one pure colony image.
[0069] In this embodiment, the pure colony image is the area containing only pure colonies remaining after removing the impurity areas from the food colony image.
[0070] In this embodiment, the colony matrix of the food colony image is a matrix constructed using the relevant data of each pure colony region of the pure colony image of the food colony image at each time point as matrix elements, which represents the existence status of pure colonies in the food colony image at each time point.
[0071] In this embodiment, the colony reference matrix is a matrix constructed using relevant data of all pure colony regions in all food colony images as matrix elements, and is used to calculate the edible risk value at each time point.
[0072] In this embodiment, the edibility risk value at each time point represents the degree of risk that exists when the food is consumed at each time point. The higher the risk value, the greater the probability of danger occurring when consuming the food.
[0073] In this embodiment, the assessment is an evaluation and estimation of the degree of food's risk of consumption at the current moment based on the food's consumption risk value at all time points.
[0074] In this embodiment, the risk assessment results include high and low risk levels of food consumption.
[0075] In this embodiment, the automatic warning is to control the red indicator light to illuminate when the risk assessment result indicates that the food has a high risk of consumption; otherwise, the green indicator light will illuminate.
[0076] The beneficial effects of the above technology are as follows: it can more accurately remove impurity areas from food colony images, obtain pure colony images for each food colony image, facilitate the construction of subsequent colony matrices and colony reference matrices for food colony images, construct colony matrices for each time point based on the relevant data of all pure colony areas in food colony images at each time point, construct colony reference matrices based on the relevant data of all pure colony areas in food colony images at all time points, obtain the food's edibility risk value at each time point more accurately based on the colony matrix and reference matrix of food colony images at each time point, and achieve a more accurate assessment of the degree of food edibility risk based on the food's edibility risk value at all time points.
[0077] Example 2:
[0078] Based on Example 1, a risk assessment and early warning method for microorganisms in food, S1: acquiring real-time images of food at multiple time points, and acquiring the standard pixel value of each real-time image at each pixel location, obtaining a food colony image at each time point based on the standard pixel values of each real-time image at all pixel locations, including:
[0079] S101: Acquire real-time images of the food at a preset number of time points every unit of time before the current time, with the current time also being considered as a time point;
[0080] S102: Obtain the standard pixel value of each real-time image at each pixel location based on the three-channel pixel value of each real-time image at each pixel location, and obtain the food colony image at each time node based on the standard pixel value of each real-time image at all pixel locations.
[0081] In this embodiment, the unit time is, for example, 1 hour.
[0082] In this embodiment, the preset quantity is a pre-set quantity value used to determine the total number of time nodes, such as 10.
[0083] In this embodiment, the three-channel pixel values are the R-channel, G-channel, and B-channel components of the real-time image at each pixel location.
[0084] The beneficial effects of the above technology are as follows: based on the three-channel pixel values at each pixel position of the real-time image of the food, the standard pixel value at each pixel position of the real-time image is obtained more accurately; based on the standard pixel values at all pixel positions of the real-time image, the food colony image at each time node is obtained more accurately; this embodiment provides a method for determining the food colony image based on the standard pixel values at all pixel positions of the real-time image.
[0085] Example 3:
[0086] Based on Example 2, the risk assessment and early warning method for microorganisms in food, S102: Obtaining the standard pixel value of each real-time image at each pixel location based on the three-channel pixel values of each real-time image at each pixel location, and obtaining the food colony image at each time point based on the standard pixel values of each real-time image at all pixel locations, including:
[0087] S1021: Obtain the three-channel pixel value of each real-time image at each pixel location, and use the sum of the products of the three-channel pixel value at each pixel location and the corresponding preset channel coefficients as the standard pixel value at each pixel location (standard pixel value = R component × α1 + G component × α2 + B component × α3, where α1, α2, and α3 are the preset channel coefficients corresponding to the three channels, and their values are 0.2, 0.2, and 0.6 respectively), thus obtaining the standard pixel value of each real-time image at each pixel location;
[0088] S1022: Based on the colony separation algorithm, the position of each pixel in each real-time image is determined to obtain the background area and colony area in each real-time image. The standard pixel value of the background area in each real-time image is assigned to 0, and the standard pixel value of the colony area is assigned to 1. Based on the assignment results of the background area and colony area in each real-time image, the food colony image at each time node is obtained.
[0089] In this embodiment, the preset channel coefficient is a pre-set coefficient used to calculate the standard pixel value, and each channel corresponds to a preset channel coefficient.
[0090] In this embodiment, the colony separation algorithm is an algorithm that determines the position of each pixel in each real-time image to obtain the background area and colony area in each real-time image, specifically steps S10221 to S10224 in embodiment 4.
[0091] In this embodiment, the determination is the process of determining whether each pixel in the real-time image is a background area or a colony area.
[0092] In this embodiment, the colony area is the region in the real-time image where colonies and impurities exist.
[0093] In this embodiment, the background area is the area remaining in the real-time image excluding the bacterial colony area.
[0094] The beneficial effects of the above technology are as follows: based on the three-channel pixel values of each pixel position in the real-time image of the food, the standard pixel value of each real-time image at each pixel position is obtained more accurately; based on the colony separation algorithm, the position of each pixel in each real-time image is determined more accurately, so as to whether each pixel position in each real-time image is in the background area or the colony area, and the food colony image at each time point is obtained more accurately.
[0095] Example 4:
[0096] Based on Example 3, the risk assessment and early warning method for microorganisms in food determines the position of each pixel in each real-time image based on a colony separation algorithm, obtaining the background area and colony area in each real-time image, including:
[0097] S10221: Set the separation pixel value to 1;
[0098] S10222: The region consisting of pixels whose standard pixel value is greater than the currently set separation pixel value in all pixels of each real-time image is taken as the hypothetical colony region in the real-time image, and the region consisting of pixels whose standard pixel value is not greater than the currently set separation pixel value in all pixels of each real-time image is taken as the hypothetical background region in the real-time image.
[0099] S10223: Calculate the feasibility value of the currently set separation pixel value based on the colony separation algorithm and the hypothetical colony region and hypothetical background region in the real-time image, including:
[0100]
[0101] Where δ is the feasibility value for setting the separated pixel value, n1 is the number of pixel positions in the hypothetical colony region in the real-time image, n2 is the number of pixel positions in the hypothetical background region in the real-time image, N is the total number of pixel positions in the real-time image, ln is the natural logarithm, and e is 2.718, ε1 is the mean of the standard pixel values of all pixel positions in the hypothetical colony region in the real-time image, and ε2 is the mean of the standard pixel values of all pixel positions in the hypothetical background region in the real-time image.
[0102] S10224: When the feasibility value of the currently set separation pixel value is greater than the preset threshold, it is determined that the currently set separation pixel value is feasible, and the hypothetical colony area and hypothetical background area in the real-time image are treated as the background area and colony area in the real-time image. Otherwise, the value of the currently set separation pixel value is incremented by 1 to obtain a newly set separation pixel value, and steps S10221 to S10223 are executed repeatedly based on the newly set separation pixel value until the feasibility value of the newly set separation pixel value is greater than the preset threshold. The hypothetical colony area and hypothetical background area in the real-time image are treated as the background area and colony area in the real-time image, respectively.
[0103] In this embodiment, the separated pixel value is a set value used to compare with the standard pixel value of each pixel position in each real-time image and determine the pixel value of the corresponding pixel position belonging to the hypothetical background area or the hypothetical colony area.
[0104] In this embodiment, the feasibility value is a numerical value that reflects the feasibility of setting the separation pixel value, calculated based on the colony separation algorithm and the hypothetical colony area and hypothetical background area in the real-time image. The larger the feasibility value, the more feasible the setting of the separation pixel value is.
[0105] In this embodiment, the preset threshold is a pre-set feasibility value threshold used to determine whether the setting of the currently set separation pixel value is feasible.
[0106] In this embodiment, feasibility means that the currently set separation pixel value can separate the colony area and the background area in the real-time image.
[0107] The beneficial effects of the above technology are as follows: the feasibility value of the currently set separation pixel value is calculated based on the colony separation algorithm, and the calculated feasibility value is compared with the preset threshold, so as to obtain the background area and colony area in the real-time image more accurately, which facilitates the construction of the colony matrix and colony reference matrix of the subsequent food colony image.
[0108] Example 5:
[0109] Based on Example 1, the risk assessment and early warning method for microorganisms in food, S2: Based on the food colony image at each time point, impurity areas in the corresponding food colony image are removed to obtain a pure colony image of the food colony image at each time point, including:
[0110] Obtain all sub-regions in the food colony image at each time point, and determine the sub-regions in each food colony image whose number of boundary pixels is greater than the preset number of boundary pixels as pure colony regions;
[0111] In each food colony image, the sub-regions in which the number of boundary pixels is not greater than the preset number of boundary pixels are identified as impurity regions.
[0112] By setting the standard pixel value of all pixels in the sub-regions identified as impurity regions in the food colony image at each time point to 0, a pure colony image of the food colony image at each time point is obtained.
[0113] In this embodiment, the sub-region is a single connected region in the food colony image at each time point, and there is no overlap in pixel positions between different sub-regions.
[0114] In this embodiment, the number of boundary pixels is the total number of pixels at the boundary of the sub-region that constitutes the food colony image.
[0115] In this embodiment, the preset number of boundary pixels is a pre-set threshold for determining whether a sub-region is a pure colony region, such as 60.
[0116] In this embodiment, the pure colony area is the area in the food colony image where only colonies exist.
[0117] In this embodiment, the impurity region is the area in the food colony image where impurities (e.g., micro-dust) are present.
[0118] The beneficial effects of the above technology are: based on the number of boundary pixels of the sub-region in the food colony image at each time point, the impurity region in the corresponding food colony image is removed, and the pure colony image of the food colony image at each time point is obtained more accurately.
[0119] Example 6:
[0120] Based on Example 5, the risk assessment and early warning method for microorganisms in food, S3: Constructing a colony matrix of food colony images for each time point based on pure colony images of food colony images at each time point, and constructing a colony reference matrix based on food colony images at all time points, including:
[0121] S301: Construct a colony matrix for the food colony image at each time point based on the relevant data of each pure colony region in the pure colony image of the food colony image at each time point;
[0122] S302: Construct a colony reference matrix based on the correlation data of all pure colony regions in food colony images at all time points.
[0123] The beneficial effects of the above technology are as follows: a colony matrix of food colony images at each time point is constructed based on the pure colony images of food colony images at each time point, and a colony reference matrix is constructed based on the food colony images at all time points, which facilitates the calculation of subsequent food consumption risk values.
[0124] Example 7:
[0125] Based on Example 6, the risk assessment and early warning method for microorganisms in food, S301: constructing a colony matrix for the food colony image at each time point based on the relevant data of each pure colony region in the pure colony image of the food colony image at each time point, including:
[0126] S3011: Obtain the number of all pixels and the number of boundary pixels contained in each pure colony region of the pure colony image of the food colony image at each time node, and use them as the relevant data of the corresponding pure colony region;
[0127] S3012: Sort all pure colony regions in each pure colony image ordinally starting from 1 according to the total number of pixels contained, to obtain the sorting result of the food colony images at each time point. Based on the sorting result of the food colony images at each time point, use the relevant data of each pure colony region of the pure colony image of the food colony image at each time point as matrix elements to construct the colony matrix of the food colony image at each time point, which is:
[0128]
[0129] Where E is the colony matrix of the food colony image, w1 is the number of boundary pixels of the pure colony region with ordinal number 1, r1 is the total number of pixels contained in the pure colony region with ordinal number 1, t1 is the quotient of the number of boundary pixels of the pure colony region with ordinal number 1 and the total number of pixels contained in the corresponding pure colony region, w2 is the number of boundary pixels of the pure colony region with ordinal number 2, r2 is the total number of pixels contained in the pure colony region with ordinal number 2, t2 is the quotient of the number of boundary pixels of the pure colony region with ordinal number 2 and the total number of pixels contained in the corresponding pure colony region, w i r is the number of boundary pixels of a pure colony region with ordinal number i. i Let t be the total number of pixels contained in the pure colony region of ordinal number i. i Let i be the quotient of the number of boundary pixels of the pure colony region with ordinal number i and the total number of pixels contained in the corresponding pure colony region, where i is the total number of pure colony regions in the food colony image.
[0130] In this embodiment, the ordinal sorting of all pure colony regions in each pure colony image starting from 1 is based on the number of pixels contained in all pure colony regions, and the more pixels a pure colony region contains, the higher its ordinal sorting will be.
[0131] The beneficial effects of the above technology are as follows: a colony matrix of the food colony image at each time point is constructed based on the relevant data of all pure colony regions of the food colony image at each time point. This embodiment provides a method for constructing a colony matrix of a food colony image based on the relevant data of all pure colony regions of the food colony image.
[0132] Example 8:
[0133] Based on Example 6, the risk assessment and early warning method for microorganisms in food, S302: constructs a colony reference matrix based on the relevant data of all pure colony regions in food colony images at all time points, including:
[0134] S3021: Obtain the relevant data of all pure colony regions in the food colony image at each time point, wherein the relevant data of all pure colony regions in each food colony image is the total number of all pixels contained in the pure colony region and the total number of boundary pixels of all pure colony regions.
[0135] S3022: Sort all food colony images sequentially by ordinal number starting from 1, and construct a colony reference matrix using the relevant data of all pure colony regions in all food colony images as matrix elements, as follows:
[0136]
[0137] Among them, E ° Let W1 be the total number of boundary pixels in all pure colony regions of the food colony image with ordinal number 1, R1 be the total number of pixel positions in all pure colony regions of the food colony image with ordinal number 1, T1 be the quotient of the number of boundary pixels in all pure colony regions of the food colony image with ordinal number 1 and the total number of pixels contained in the corresponding pure colony regions, W2 be the total number of boundary pixels in all pure colony regions of the food colony image with ordinal number 2, R2 be the total number of pixel positions in all pure colony regions of the food colony image with ordinal number 2, and T2 be the quotient of the number of boundary pixels in all pure colony regions of the food colony image with ordinal number 2 and the total number of pixels contained in the corresponding pure colony regions. I R is the total number of boundary pixel locations of all pure colony regions in a food colony image with ordinal number I. IT represents the total number of pixel locations in all pure colony regions of a food colony image with ordinal number I. I Let I be the quotient of the number of boundary pixels of all pure colony regions in the food colony image with ordinal number I and the number of all pixels contained in the corresponding pure colony regions, where I is the total number of time nodes.
[0138] In this embodiment, all food colony images are sorted by ordinal number starting from 1 according to time sequence. The earlier the time node, the earlier the ordinal number.
[0139] The beneficial effects of the above technology are as follows: a colony reference matrix is constructed based on the relevant data of all pure colony regions in food colony images at all time points. This embodiment provides a method for constructing a colony reference matrix based on all pure colony regions in food colony images at all time points.
[0140] Example 9:
[0141] Based on Example 1, the risk assessment and early warning method for microorganisms in food obtains the edibility risk value of the food at each time point based on the colony matrix and reference matrix of the food colony image at each time point, and assesses the degree of edibility risk of the food based on the edibility risk values of the food at all time points to obtain the risk assessment result, including:
[0142] The quotient of the rank of the colony matrix of the food colony image at each time point and the rank of the reference matrix is taken as the food's consumption risk value at the corresponding time point.
[0143] The difference between the consumption risk values of food at two adjacent time points is taken as the adjacent consumption risk value. If the maximum value among all adjacent consumption risk values of food is greater than the preset risk value threshold, the consumption risk of food is determined to be high; otherwise, the consumption risk of food is determined to be low.
[0144] In this embodiment, the adjacent consumption risk value is the difference between the consumption risk values of food at two adjacent time points.
[0145] In this embodiment, the preset risk value threshold is a pre-set risk value threshold used to determine the degree of risk of consuming food, such as 2.
[0146] The beneficial effects of the above technology are: to obtain the food consumption risk value at each time point more accurately based on the colony matrix and reference matrix of the food colony image at each time point, and to achieve a more accurate assessment of the food consumption risk level based on the food consumption risk value at all time points.
[0147] Example 10:
[0148] This invention provides a risk assessment and early warning system for microorganisms in food, used to execute any one of the risk assessment and early warning methods for microorganisms in food in Examples 1 to 9, with reference to... Figure 2 ,include:
[0149] The food colony image module is used to acquire real-time images of food at multiple time points, and to acquire the standard pixel value of each real-time image at each pixel position. Based on the standard pixel value of each real-time image at all pixel positions, the food colony image at each time point is obtained.
[0150] The pure colony image module is used to remove impurity areas from the corresponding food colony image based on the food colony image at each time point, so as to obtain the pure colony image of the food colony image at each time point.
[0151] The matrix construction module is used to construct a colony matrix of food colony images at each time point based on the pure colony images of food colony images at each time point, and to construct a colony reference matrix based on food colony images at all time points.
[0152] The assessment module is used to obtain the food's edibility risk value at each time point based on the colony matrix and reference matrix of the food colony image at each time point, assess the degree of food edibility risk based on the food's edibility risk values at all time points, obtain the risk assessment result, and issue automatic warnings based on the risk assessment result.
[0153] The beneficial effects of the above technology are as follows: it can more accurately remove impurity areas from food colony images, obtain pure colony images for each food colony image, facilitate the construction of subsequent colony matrices and colony reference matrices for food colony images, construct colony matrices for each time point based on the relevant data of all pure colony areas in food colony images at each time point, construct colony reference matrices based on the relevant data of all pure colony areas in food colony images at all time points, obtain the food's edibility risk value at each time point more accurately based on the colony matrix and reference matrix of food colony images at each time point, and assess the degree of food's edibility risk more accurately based on the food's edibility risk value at all time points.
[0154] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
Claims
1. A method for risk assessment and early warning of microorganisms in food, characterized in that, include: S1: Obtain real-time images of food at multiple time points, and obtain the standard pixel value of each real-time image at each pixel position. Based on the standard pixel value of each real-time image at all pixel positions, obtain the food colony image at each time point. S2: Based on the food colony image at each time point, remove the impurity areas in the corresponding food colony image to obtain the pure colony image of the food colony image at each time point. S3: Construct a colony matrix for the food colony image at each time point based on the pure colony image of the food colony image at each time point, and construct a colony reference matrix based on the food colony images at all time points. S4: Based on the colony matrix and reference matrix of the food colony image at each time point, obtain the food consumption risk value at each time point. Based on the food consumption risk value at all time points, assess the degree of food consumption risk, obtain the risk assessment result, and issue an automatic warning based on the risk assessment result.
2. The method for risk assessment and early warning of microorganisms in food according to claim 1, characterized in that, S1: Acquire real-time images of the food at multiple time points, and obtain the standard pixel value of each real-time image at each pixel location. Based on the standard pixel values of each real-time image at all pixel locations, obtain the food colony image at each time point, including: S101: Acquire real-time images of the food at a preset number of time points every unit of time before the current time, with the current time also being considered as a time point; S102: Obtain the standard pixel value of each real-time image at each pixel location based on the three-channel pixel value of each real-time image at each pixel location, and obtain the food colony image at each time node based on the standard pixel value of each real-time image at all pixel locations.
3. The method for risk assessment and early warning of microorganisms in food according to claim 2, characterized in that, S102: Obtain the standard pixel value of each real-time image at each pixel location based on the three-channel pixel values of each real-time image at each pixel location, and obtain the food colony image at each time node based on the standard pixel values of each real-time image at all pixel locations, including: S1021: Obtain the three-channel pixel value of each real-time image at each pixel position, and use the sum of the products of the three-channel pixel value at each pixel position and the corresponding preset channel coefficient as the standard pixel value at each pixel position to obtain the standard pixel value of each real-time image at each pixel position. S1022: Based on the colony separation algorithm, the position of each pixel in each real-time image is determined to obtain the background area and colony area in each real-time image. The standard pixel value of the background area in each real-time image is assigned to 0, and the standard pixel value of the colony area is assigned to 1. Based on the assignment results of the background area and colony area in each real-time image, the food colony image at each time node is obtained.
4. The method for risk assessment and early warning of microorganisms in food according to claim 3, characterized in that, Based on the colony separation algorithm, the position of each pixel in each real-time image is determined to obtain the background region and colony region in each real-time image, including: S10221: Set the separation pixel value to 1; S10222: The region consisting of pixels whose standard pixel value is greater than the currently set separation pixel value in all pixels of each real-time image is taken as the hypothetical colony region in the real-time image, and the region consisting of pixels whose standard pixel value is not greater than the currently set separation pixel value in all pixels of each real-time image is taken as the hypothetical background region in the real-time image. S10223: Calculate the feasibility value of the currently set separation pixel value based on the colony separation algorithm and the hypothetical colony region and hypothetical background region in the real-time image, including: Where δ is the feasibility value for setting the separated pixel value, n1 is the number of pixel positions in the hypothetical colony region in the real-time image, n2 is the number of pixel positions in the hypothetical background region in the real-time image, N is the total number of pixel positions in the real-time image, ln is the natural logarithm, and e is 2.718, ε1 is the mean of the standard pixel values of all pixel positions in the hypothetical colony region in the real-time image, and ε2 is the mean of the standard pixel values of all pixel positions in the hypothetical background region in the real-time image. S10224: When the feasibility value of the currently set separation pixel value is greater than the preset threshold, it is determined that the currently set separation pixel value is feasible, and the hypothetical colony area and hypothetical background area in the real-time image are treated as the background area and colony area in the real-time image. Otherwise, the value of the currently set separation pixel value is incremented by 1 to obtain a newly set separation pixel value, and steps S10221 to S10223 are executed repeatedly based on the newly set separation pixel value until the feasibility value of the newly set separation pixel value is greater than the preset threshold. The hypothetical colony area and hypothetical background area in the real-time image are treated as the background area and colony area in the real-time image, respectively.
5. The method for risk assessment and early warning of microorganisms in food according to claim 1, characterized in that, S2: Based on the food colony image at each time point, remove impurity regions from the corresponding food colony image to obtain a pure colony image for each time point, including: Obtain all sub-regions in the food colony image at each time point, and determine the sub-regions in each food colony image whose number of boundary pixels is greater than the preset number of boundary pixels as pure colony regions; In each food colony image, the sub-regions in which the number of boundary pixels is not greater than the preset number of boundary pixels are identified as impurity regions. By setting the standard pixel value of all pixels in the sub-regions identified as impurity regions in the food colony image at each time point to 0, a pure colony image of the food colony image at each time point is obtained.
6. The method for risk assessment and early warning of microorganisms in food according to claim 5, characterized in that, S3: Construct a colony matrix for the food colony images at each time point based on the pure colony images of the food colony images at each time point, and construct a colony reference matrix based on the food colony images at all time points, including: S301: Construct a colony matrix for the food colony image at each time point based on the relevant data of each pure colony region in the pure colony image of the food colony image at each time point; S302: Construct a colony reference matrix based on the correlation data of all pure colony regions in food colony images at all time points.
7. The method for risk assessment and early warning of microorganisms in food according to claim 6, characterized in that, S301: Construct a colony matrix for the food colony image at each time point based on the relevant data of each pure colony region in the pure colony image of the food colony image at each time point, including: S3011: Obtain the number of all pixels and the number of boundary pixels contained in each pure colony region of the pure colony image of the food colony image at each time node, and use them as the relevant data of the corresponding pure colony region; S3012: Sort all pure colony regions in each pure colony image ordinally starting from 1 according to the total number of pixels contained, to obtain the sorting result of the food colony images at each time point. Based on the sorting result of the food colony images at each time point, use the relevant data of each pure colony region of the pure colony image of the food colony image at each time point as matrix elements to construct the colony matrix of the food colony image at each time point, which is: Where E is the colony matrix of the food colony image, w1 is the number of boundary pixels of the pure colony region with ordinal number 1, r1 is the total number of pixels contained in the pure colony region with ordinal number 1, t1 is the quotient of the number of boundary pixels of the pure colony region with ordinal number 1 and the total number of pixels contained in the corresponding pure colony region, w2 is the number of boundary pixels of the pure colony region with ordinal number 2, r2 is the total number of pixels contained in the pure colony region with ordinal number 2, t2 is the quotient of the number of boundary pixels of the pure colony region with ordinal number 2 and the total number of pixels contained in the corresponding pure colony region, w i r is the number of boundary pixels of a pure colony region with ordinal number i. i Let t be the total number of pixels contained in the pure colony region of ordinal number i. i Let i be the quotient of the number of boundary pixels of the pure colony region with ordinal number i and the total number of pixels contained in the corresponding pure colony region, where i is the total number of pure colony regions in the food colony image.
8. The method for risk assessment and early warning of microorganisms in food according to claim 6, characterized in that, S302: Construct a colony reference matrix based on the correlation data of all pure colony regions in food colony images at all time points, including: S3021: Obtain the relevant data of all pure colony regions in the food colony image at each time point, wherein the relevant data of all pure colony regions in each food colony image is the total number of all pixels contained in the pure colony region and the total number of boundary pixels of all pure colony regions. S3022: Sort all food colony images sequentially by ordinal number starting from 1, and construct a colony reference matrix using the relevant data of all pure colony regions in all food colony images as matrix elements, as follows: Among them, E ° Let W1 be the total number of boundary pixels in all pure colony regions of the food colony image with ordinal number 1, R1 be the total number of pixel positions in all pure colony regions of the food colony image with ordinal number 1, T1 be the quotient of the number of boundary pixels in all pure colony regions of the food colony image with ordinal number 1 and the total number of pixels contained in the corresponding pure colony regions, W2 be the total number of boundary pixels in all pure colony regions of the food colony image with ordinal number 2, R2 be the total number of pixel positions in all pure colony regions of the food colony image with ordinal number 2, and T2 be the quotient of the number of boundary pixels in all pure colony regions of the food colony image with ordinal number 2 and the total number of pixels contained in the corresponding pure colony regions. I R is the total number of boundary pixel locations of all pure colony regions in a food colony image with ordinal number I. I T represents the total number of pixel locations in all pure colony regions of a food colony image with ordinal number I. I Let I be the quotient of the number of boundary pixels of all pure colony regions in the food colony image with ordinal number I and the number of all pixels contained in the corresponding pure colony regions, where I is the total number of time nodes.
9. The method for risk assessment and early warning of microorganisms in food according to claim 1, characterized in that, Based on the colony matrix and reference matrix of the food colony image at each time point, the edibility risk value of the food at each time point is obtained. Based on the edibility risk values of the food at all time points, the degree of edibility risk of the food is assessed, and the risk assessment results are obtained, including: The quotient of the rank of the colony matrix of the food colony image at each time point and the rank of the reference matrix is taken as the food's consumption risk value at the corresponding time point. The difference between the consumption risk values of food at two adjacent time points is taken as the adjacent consumption risk value. If the maximum value among all adjacent consumption risk values of food is greater than the preset risk value threshold, the consumption risk of food is determined to be high; otherwise, the consumption risk of food is determined to be low.
10. A risk assessment and early warning system for microorganisms in food, characterized in that, A method for risk assessment and early warning of microorganisms in food according to any one of claims 1 to 9, comprising: The food colony image module is used to acquire real-time images of food at multiple time points, and to acquire the standard pixel value of each real-time image at each pixel position. Based on the standard pixel value of each real-time image at all pixel positions, the food colony image at each time point is obtained. The pure colony image module is used to remove impurity areas from the corresponding food colony image based on the food colony image at each time point, so as to obtain the pure colony image of the food colony image at each time point. The matrix construction module is used to construct a colony matrix of food colony images at each time point based on the pure colony images of food colony images at each time point, and to construct a colony reference matrix based on food colony images at all time points. The assessment module is used to obtain the food's edibility risk value at each time point based on the colony matrix and reference matrix of the food colony image at each time point, assess the degree of food edibility risk based on the food's edibility risk values at all time points, obtain the risk assessment result, and issue automatic warnings based on the risk assessment result.
Citation Information
Patent Citations
Food safety risk evaluation method
CN113379189A