Machine vision-based baked food appearance quality detection system

By using a machine vision-based baking food appearance quality inspection system, which combines the inner contour line and thermal expansion deformation matrix with local texture information and gradient amplitude, the problem of misjudgment of appearance defects caused by thermal expansion and cracking in baked goods has been solved, and more accurate inspection results have been achieved.

CN122176697APending Publication Date: 2026-06-09XIAN YANG SHI XIN TE RUAN SHI PIN YOU XIAN GONG SI

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
XIAN YANG SHI XIN TE RUAN SHI PIN YOU XIAN GONG SI
Filing Date
2026-05-11
Publication Date
2026-06-09

AI Technical Summary

Technical Problem

Existing technologies cannot effectively distinguish between appearance defects and actual defects caused by anisotropic thermal expansion and natural surface cracking during the heating process of baked goods, leading to misjudgment and positioning failure.

Method used

By extracting the relative spatial margin between the baked goods and the inner contour line, and converting it into a dynamic reference anchor point, the thermal expansion deformation matrix is ​​obtained. Combined with the local texture information entropy and gradient magnitude, a comprehensive defect discrimination index is generated to weaken the interference of false differences and amplify the real defect signal.

Benefits of technology

It improves the accuracy of appearance quality inspection of baked goods, avoids misjudgments caused by positional deviation and thermal expansion, can distinguish between normal deformation and real defects, and ensures that the test results are consistent with reality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122176697A_ABST
    Figure CN122176697A_ABST
Patent Text Reader

Abstract

The present application belongs to the technical field of image processing, and particularly relates to a baked food appearance quality detection system based on machine vision, which comprises: an acquisition module, which acquires an original image containing a plastic inner holder and baked food, and constructs an edge redundancy sequence; an analysis module, which acquires a thermal expansion deformation matrix representing the outward expansion state of the product to be detected according to the edge redundancy sequence, acquires a difference feature map eliminating the influence of deformation based on the thermal expansion deformation matrix, and acquires a comprehensive defect discrimination index according to a basic appearance difference reference value of the difference feature map, local texture information entropy and local gradient amplitude; and an anomaly detection module, which determines an appearance quality determination result according to the comprehensive defect discrimination index. The present application can effectively eliminate the false difference interference caused by thermal expansion, and improve the accuracy of baked food appearance defect detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology. More specifically, this invention relates to a machine vision-based system for inspecting the appearance quality of baked goods. Background Technology

[0002] The appearance quality of baked goods directly affects market acceptance and consumer experience. During production, transportation, and baking, baked goods often experience surface damage, edge chipping, and over-baking leading to hardening. Therefore, reliable appearance defect detection is crucial for ensuring standardized production and overall quality of baked goods.

[0003] In related technologies, for example, Chinese patent application document with publication number CN121640473A discloses a quality inspection system for baked goods production. The system generates an idealized appearance layout template by acquiring customized information, uses an image acquisition module to acquire image data of baked goods, aligns the acquired images with a standard template, and uses edge detection and feature point detection algorithms to extract key feature points of decorative elements. Finally, by comparing the distance difference between the actual key points and the ideal layout in a two-dimensional coordinate system, the system determines whether the appearance and placement meet the requirements.

[0004] However, during the baking process, the uneven distribution of internal moisture and heat in the dough leads to anisotropic natural thermal expansion, causing irregular outward deformation at the edges of the finished product. Simultaneously, the crust on the surface of baked goods inevitably forms intricate natural cracks when heated. The aforementioned technique directly aligns an ideal layout template with the actual object being tested and compares the distances of feature points, failing to consider the physical expansion patterns of the dough under heat and the textural evolution characteristics of the natural cracking of the crust. This results in normal anisotropic thermal expansion and crust cracking being directly misjudged as morphological deviations or surface defects. Summary of the Invention

[0005] To address the technical problems of misjudgment and positioning failure of appearance defects caused by anisotropic thermal expansion, natural surface cracking, and mechanical transmission vibration deviation in baked goods, this invention provides a machine vision-based baking goods appearance quality inspection system. The system includes the following modules: an acquisition module, which uses the outermost closed edge of the original image containing the inner tray and the baked goods as the inner tray contour line, and the closed edge with the largest area within the inner tray contour line as the food boundary line; acquires the Euclidean distance from the food boundary line to the inner tray contour line along a preset ray direction, and combines it into an edge redundancy sequence; and an analysis module, which acquires the difference between the original image and the reference image at various positions on the edge redundancy sequence and decomposes it into spatial transformation vectors along various angular ray directions; and analyzes the difference between the original image and the reference image at various positions along the food boundary line. Pixels at each ray angle are used as deformation control points and assigned corresponding spatial transformation vectors. Based on the Euclidean distance from each pixel in the reference image to all deformation control points, inverse distance weighted interpolation is performed on the spatial transformation vectors to obtain the thermal expansion deformation matrix. The reference image is then subjected to bilinear interpolation based on the thermal expansion deformation matrix to obtain a stretched map. The absolute value of the phase subtraction between the original image and the stretched map is used to obtain a difference feature map. The mean value of the difference feature map within the sliding window is used to obtain the basic appearance difference benchmark value. The comprehensive defect discrimination index is obtained by calculating the basic appearance difference benchmark value, the local texture information entropy of the original image, and the local gradient magnitude. The anomaly detection module determines the appearance quality judgment result based on the number of regions where the comprehensive defect discrimination index is greater than the judgment threshold.

[0006] This invention extracts the relative spatial margin between the baked goods and the inner contour line, transforming the random product position shift caused by conveyor vibration on the production line into a distance parameter of a dynamic reference anchor point, thus avoiding the risk of positioning failure due to non-fixed position. By comparing the differences between the reference image and the image to be detected in various edge ray directions, the irregular deformation phenomenon caused by the thermal expansion of the baked dough is transformed into a spatial stretching weight in a two-dimensional plane. This weight is then used to reshape the standard reference image, ensuring that the texture distribution of the reference image matches the expansion trend of the product to be detected. This eliminates the false difference interference caused by normal size differences during subsequent image subtraction. Furthermore, this invention transforms the high-frequency complex texture formed by the thermal cracking of the pastry on the surface of baked goods and the low-frequency smooth tortuosity caused by burnt damage into local information entropy and gradient data. These are then fused with basic difference values, weakening the tendency of difference alarms caused by normal cracking while amplifying the response signal of real defects. This allows for the differentiation between normal thermal expansion and real production defects, making the detection of surface defects in baked goods more accurate.

[0007] Preferably, the step of using the outermost closed edge of the original image containing the inner tray and the baked goods as the inner tray contour line includes: extracting edge pixels of the image using an edge detection operator and connecting them to form a closed edge contour; calculating the internal area of ​​each closed edge contour and removing noise contours with an internal area less than a preset area threshold; and extracting the closed edge of the remaining closed edge contours that is located at the outermost layer and surrounds other contours as the inner tray contour line.

[0008] Preferably, the step of obtaining the Euclidean distance from the food boundary line to the inner tray contour line in a preset ray direction and combining them into an edge redundancy sequence includes: determining the center coordinates of the food boundary line and using the center coordinates as the origin of the polar coordinates; obtaining the Euclidean distance between the pixel point on the food boundary line and the corresponding pixel point on the inner tray contour line in each preset ray direction; and aggregating the Euclidean distances in each ray direction in ascending order of angle to obtain the edge redundancy sequence.

[0009] This invention transforms the irregular geometric contour of the baked food edge into a distance sequence parameter in a specific direction by emitting multi-angle rays outward from the center of the food as the origin of polar coordinates. It reconstructs the complex two-dimensional planar contour features into one-dimensional spatial data arranged in an orderly manner according to angles, reflecting the distribution law of physical gaps between the food edge and its inner support. This allows the outward expansion or contraction state of the local edge to be captured independently, providing data support for subsequent evaluation of the degree of thermal expansion of the food in various directions.

[0010] Preferably, the step of obtaining the difference between the original image and the reference image at each position on the edge redundancy sequence and decomposing it into spatial transformation vectors in the ray directions of each angle includes: combining the ray angles corresponding to the difference, using trigonometric functions to decompose the difference into horizontal and vertical stretching in a rectangular coordinate system; and combining the horizontal and vertical stretching into a spatial transformation vector.

[0011] This invention decomposes the edge distance difference in different ray directions using trigonometric relationships, transforming the physical quantity of thermal expansion displacement of baking dough in a single radial direction into mutually orthogonal horizontal and vertical stretching quantities in a Cartesian coordinate system. This transforms the scalar change that originally only existed in the ray direction into a vector that can act on the pixel grid of a two-dimensional image, so that the subsequent reshaping and deformation process of the reference image can synchronously correspond to the uneven expansion process of the dough in the baking pan.

[0012] Preferably, the step of performing inverse distance weighted interpolation on the spatial transformation vector based on the Euclidean distance from each pixel point inside the reference image to all deformation control points to obtain the thermal expansion deformation matrix includes: using all pixels inside the reference image as the target coordinate grid, calculating the Euclidean distance from each pixel point in the target coordinate grid to all deformation control points; based on the Euclidean distance, weighting and fusing the horizontal stretching amount in the spatial transformation vector contained in all deformation control points to obtain the horizontal stretching amount of each pixel point in the target coordinate grid, and weighting and fusing the vertical stretching amount in the spatial transformation vector contained in all deformation control points to obtain the vertical stretching amount of each pixel point in the target coordinate grid; and concatenating the horizontal stretching amount and vertical stretching amount of all pixels according to the original pixel spatial arrangement order of the reference image to obtain the thermal expansion deformation matrix.

[0013] Preferably, the step of obtaining a stretched map by bilinear interpolation of the reference image based on the thermal expansion deformation matrix includes: traversing the target pixel coordinates on a blank mapping canvas of the same size as the original image, extracting the corresponding horizontal and vertical stretching amounts from the thermal expansion deformation matrix; subtracting the corresponding horizontal and vertical stretching amounts from the target pixel coordinates to obtain floating-point source coordinates; locating four integer coordinate pixels adjacent to the floating-point source coordinates in the reference image, and assigning weights to the four integer coordinate pixels according to their relative distances; calculating the interpolated gray value by weighted summation of the gray values ​​of the four integer coordinate pixels based on the weights, and assigning the interpolated gray value to the corresponding target pixel coordinates on the blank mapping canvas to obtain the stretched map.

[0014] This invention extracts floating-point source coordinates and assigns weighted proportions based on their relative distances to surrounding integer coordinate pixels. This transforms the pixel holes and jagged tearing phenomena generated during the stretching process of the reference image into grayscale fusion parameters of adjacent real pixels. When the image undergoes horizontal and vertical stretching, the reshaped stretched map maintains a smooth texture transition through the transfer of spatial distance and weight allocation. This filters out artifact patches caused by deformation, making the appearance of the reference template closer to the state of the object to be inspected.

[0015] Preferably, the method for obtaining the local texture information entropy and local gradient magnitude of the original image includes: obtaining the local information entropy of the original image within the coverage area of ​​the sliding window, and linearly normalizing the local information entropy to obtain the local texture information entropy; extracting the maximum gradient magnitude of the original image within the coverage area of ​​the sliding window, and linearly normalizing the maximum gradient magnitude to obtain the local gradient magnitude.

[0016] Preferably, obtaining the basic appearance difference benchmark value based on the mean value of the difference feature map within the sliding window includes: calculating the mean value of all values ​​in the difference feature map within the sliding window; and dividing the mean value by a preset maximum possible difference value to obtain the basic appearance difference benchmark value.

[0017] Preferably, the comprehensive defect discrimination index satisfies the following relationship: In the formula, In the difference feature map, the first Line number The comprehensive defect discrimination index of the sliding window area centered on column pixels. In the difference feature map, the first Line number The baseline value for the appearance difference of the sliding window area centered on the column pixels. For the original image, the first Line number The local texture information entropy of the sliding window region centered on the column pixels. For the original image, the first Line number The local gradient magnitude of the sliding window region centered on the column pixel.

[0018] This invention transforms the physical phenomenon of normal cracking in pastry into a downward suppression weight for basic appearance differences by utilizing local texture information entropy, while simultaneously transforming contour mutations caused by food defects into an upward amplification weight. When the physical texture of a region is more chaotic, the tendency for difference alarms at that location is weakened; when a region has sharp faults, the defect response signal is corrected upwards, filtering out false defect interference caused by normal surface cracking and exposing smooth, hardened areas caused by burning and true defects.

[0019] Preferably, determining the appearance quality judgment result based on the number of regions with a comprehensive defect discrimination index greater than the judgment threshold includes: when the number of sliding window regions with a comprehensive defect discrimination index greater than the preset judgment threshold is greater than the preset quantity threshold, the appearance quality judgment result is determined to be unqualified; when the number of sliding window regions with a comprehensive defect discrimination index greater than the preset judgment threshold is less than or equal to the preset quantity threshold, the appearance quality judgment result is determined to be qualified.

[0020] The beneficial effects of this invention are as follows: Addressing the random positional shift of baked goods on packaging lines caused by mechanical vibration, this invention extracts the relative spatial margin between the food boundary line and the inner tray contour line, transforming the irregular shift into a distance parameter. This avoids the positioning errors caused by the non-fixed target position in conventional fixed-area feature extraction, providing basic data for subsequent morphological comparison with synchronized positional correspondence. Regarding the uneven deformation of baked dough during thermal expansion, this invention transforms the natural outward expansion trend of baked goods in specific ray directions into horizontal and vertical stretching amounts. Based on this, the reference image is reshaped to adaptively approximate the expanded state of the sample, thus offsetting contour artifact interference caused by normal individual differences in food size. When identifying specific appearance anomalies, this invention transforms the normal high-frequency complex textures formed by the natural cracking of the pastry on the surface of baked goods due to heat, as well as the smooth areas and contour changes caused by over-baking or collisions, into local texture information entropy and local gradient amplitude. This enables the appearance quality detection system to suppress the visual differences caused by normal pastry cracking, while transforming real edge physical damage into amplified defect response weights, making the appearance quality judgment results of baked goods more consistent with reality. Attached Figure Description

[0021] Figure 1 This is a schematic diagram illustrating the system framework of the machine vision-based baking food appearance quality inspection system of the present invention; Figure 2 This is a schematic diagram illustrating the framework of the analysis module in this invention; Figure 3 This is a schematic diagram illustrating the contour relative distance extraction in this invention. Detailed Implementation

[0022] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0023] The specific embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0024] This invention provides a machine vision-based system for inspecting the appearance quality of baked goods. For example... Figure 1 As shown, the machine vision-based baking food appearance quality inspection system includes an acquisition module 100, an analysis module 200, and an anomaly detection module 300, which are described in detail below.

[0025] The acquisition module 100 acquires the original image containing the edge of the plastic inner tray and the edge of the baked food, and constructs an edge redundancy sequence.

[0026] It should be noted that due to the vibration of mechanical transmission on the packaging line, the position of baked goods within the plastic tray may randomly shift. This shift can cause subsequent fixed-area feature extraction and positioning to fail. To eliminate the positioning error caused by random position shift, this invention uses the boundary of the plastic tray as a dynamic reference anchor point to extract the relative space allowance between the product and the packaging.

[0027] Specifically, the original image containing the plastic tray and baked goods is acquired. The Canny edge detection operator is used to process the original image to obtain an edge feature map. All closed edges are extracted from the edge feature map, and the spatial inclusion relationship between each closed edge is established, resulting in multiple sets of closed contours with inner and outer enclosure structures. The internal pixel area of ​​each closed contour in the set is calculated, and small contours with internal pixel areas smaller than a preset area threshold are removed to filter out interfering edges caused by packaging reflective wrinkles and random food debris. In the remaining set of closed contours, the outermost closed edge with the largest internal pixel area is determined as the tray contour line, and the closed edge with the largest internal pixel area within the tray contour line is taken as the food boundary line.

[0028] For example, the preset area threshold is 50 pixels. Implementers can determine the preset area threshold according to the actual situation. When the food crumbs are large, the parameter can be increased appropriately to prevent false contours from being mistaken for target boundaries. When the baked food itself is small in size and easily produces small crumbs, the parameter can be decreased appropriately to avoid filtering out the real food's tiny appendages.

[0029] Furthermore, the center coordinates of the food boundary line are determined. Using the geometric center coordinates as the origin of the polar coordinates, the Euclidean distance between the pixels on the food boundary line and the corresponding pixels on the inner contour line is obtained along multiple preset angular ray directions. The Euclidean distances in each angular ray direction are aggregated in ascending order of angle to obtain the edge redundancy sequence of the original image.

[0030] For example, the method for determining the preset multiple angle ray directions includes: taking the horizontal rightward direction as 0 degrees, taking the direction corresponding to 0 degrees as the first ray direction, rotating counterclockwise, and determining a ray direction every 45 degrees, for a total of eight ray directions. The Euclidean distance corresponding to the 0-degree direction is 12 pixels, the Euclidean distance corresponding to the 45-degree direction is 15 pixels, the Euclidean distance corresponding to the 90-degree direction is 8 pixels, the Euclidean distance corresponding to the 135-degree direction is 10 pixels, the Euclidean distance corresponding to the 180-degree direction is 11 pixels, the Euclidean distance corresponding to the 225-degree direction is 14 pixels, the Euclidean distance corresponding to the 270-degree direction is 9 pixels, and the Euclidean distance corresponding to the 315-degree direction is 13 pixels. Then the edge redundancy sequence is [12, 15, 8, 10, 11, 14, 9, 13].

[0031] Analysis module 200 is used to calculate the difference feature map and the comprehensive defect discrimination index.

[0032] like Figure 2 As shown, the analysis module includes an expansion deformation analysis submodule 201, a difference mapping submodule 202, and a defect index submodule 203, which are described in detail below: The expansion deformation analysis submodule 201 obtains the thermal expansion deformation matrix characterizing the outward expansion state of the sample under test based on the edge redundancy sequence.

[0033] It should be noted that the varying moisture content and heating conditions of different batches of baked dough result in uncertainties in the natural expansion and deformation of each product, making it easy to misjudge this normal thermal expansion as a product defect. Therefore, this invention utilizes the relative space between the plastic inner tray and the food to estimate the actual degree of expansion of the food, enabling adaptive capture of deformation caused by thermal expansion.

[0034] Specifically, a reference image of a standard baked sample with ideal shape is obtained. The edge redundancy sequence of the reference image is used as a reference sequence. The difference between the values ​​of each angle in the edge redundancy sequence of the original image and the corresponding angle values ​​in the reference sequence is calculated. Combined with the ray angle corresponding to the difference, the difference data is decomposed into horizontal and vertical stretching in a rectangular coordinate system using trigonometric functions. The horizontal and vertical stretching are then combined into a spatial transformation vector.

[0035] For example, the Euclidean distance corresponding to a 45° direction in the original image is 15 pixels, and the Euclidean distance corresponding to a 45° direction in the reference image is 20 pixels. The difference between the two is 5 pixels, then the horizontal axis stretch is... The longitudinal stretch is Then the spatial transformation vector corresponding to the 45° direction is [ If the size of the original image is The dimension of the thermal expansion deformation matrix is ​​then... .

[0036] For example, Figure 3 This is a schematic diagram of the contour relative distance extraction in this invention. As can be seen from the figure, this invention uses the geometric center of the target as the origin of polar coordinates and radiates outward along multiple preset angular ray directions. The length of the arrows in the figure represents the relative distance difference between the food boundary line of the reference image and the food boundary line of the original image in each corresponding ray direction. This multi-angle radial ranging method effectively decomposes the irregular edge deformation of baked food caused by anisotropy, accurately captures the degree of local expansion or stretching of the contour in different directions, and thus provides data support for the subsequent construction of thermal expansion deformation matrix and the elimination of normal expansion deformation interference.

[0037] Furthermore, pixels on the food boundary line of the reference image at various ray angles are designated as deformation control points, and spatial transformation vectors at corresponding angles are assigned to the respective deformation control points. Using all pixels within the reference image as the target coordinate grid, the Euclidean distance from each pixel in the target coordinate grid to all deformation control points is obtained. Based on this Euclidean distance, an inverse distance weighted interpolation algorithm is used to weight and fuse the spatial transformation vectors contained in all deformation control points, obtaining the horizontal and vertical stretching amounts of each pixel in the target coordinate grid. Following the original pixel spatial arrangement order of the reference image, the horizontal and vertical stretching amounts of all pixels are concatenated to obtain a thermal expansion deformation matrix with the same resolution as the reference image.

[0038] In one embodiment, the weighted fusion of the spatial transformation vectors contained in all deformation control points includes: first, weighting and fusing the horizontal stretching amount in the spatial transformation vectors contained in all deformation control points to obtain the horizontal stretching amount of each pixel in the target coordinate grid; and then weighting and fusing the horizontal stretching amount in the spatial transformation vectors contained in all deformation control points to obtain the vertical stretching amount of each pixel in the target coordinate grid.

[0039] It should be noted that the difference data only represents the scalar value of the expansion or contraction of the baked goods' edges in a specific ray direction. Since subsequent image deformation operations need to be performed independently on each pixel in the horizontal and vertical directions of the two-dimensional plane, the aforementioned spatial decomposition and inverse distance weighted interpolation operations aim to cover the entire target coordinate grid with sparse boundary ranging data, ensuring that each pixel in the reference image has both horizontal and vertical stretching. This process follows the pattern of drastic edge deformation and weak center deformation when baked dough expands due to heat, giving each pixel node within the image a gradually changing traction force. This allows the originally standard-shaped template to fit the thermal expansion trend of the tested object in various directions not only on the contour boundaries but also in the overall internal texture distribution.

[0040] The difference mapping submodule 202 is used to obtain the difference feature map after eliminating the effects of deformation.

[0041] It should be noted that, due to the anisotropic thermal expansion of baked dough, directly obtaining the grayscale difference between the original image and the reference image will produce a large number of artifact patches caused by normal expansion, which can easily lead to false detection of normal baked goods. In order to avoid the interference of thermal expansion on the judgment of local surface quality, this invention reshapes the reference image so that the reshaped reference image conforms to the state of the current product to be detected in terms of shape.

[0042] Specifically, a blank mapping canvas of the same size as the original image is constructed. Each target pixel on the blank mapping canvas is traversed, and the horizontal and vertical stretching amounts corresponding to the coordinate position are extracted from the thermal expansion deformation matrix. The corresponding horizontal and vertical stretching amounts are subtracted from the target pixel coordinates to obtain the floating-point source coordinates of the target pixel in the reference image. Four integer coordinate pixels adjacent to the floating-point source coordinates in the reference image are located, and weights are assigned based on the relative distances between the floating-point source coordinates and these four integer coordinate pixels in the horizontal and vertical directions, with closer integer coordinate pixels receiving greater weights. The grayscale values ​​of these four integer coordinate pixels are weighted and summed based on the weights to achieve bilinear interpolation based on the thermal expansion deformation matrix, resulting in smoothly transitioned interpolated grayscale values. These interpolated grayscale values ​​are then assigned to the corresponding target pixel coordinates on the blank mapping canvas, thus completing the stretching mapping of the reference image to obtain a stretched mapping map. The original image and the stretched mapping map are subtracted pixel by pixel, and the absolute value is taken to obtain a difference feature map.

[0043] It's important to note that digital images are presented as two-dimensional matrices composed of discrete pixels, with each pixel in the reference image corresponding to an integer coordinate. However, the source coordinates, derived inversely from the thermal expansion deformation matrix, are typically floating-point coordinates with decimal parts due to the stretching offset. In the two-dimensional image pixel coordinate system, any floating-point coordinate must fall within the smallest square unit grid bounded by the floor values ​​of its horizontal and vertical axes. The four vertices of this unit grid are the four nearest real pixels tightly enclosing the floating-point coordinate, corresponding to the upper left, upper right, lower left, and lower right directions, respectively. Since the location of this floating-point coordinate lies in the gaps between pixel grids, there are no actual pixel entities to directly read the grayscale value. Therefore, only these four adjacent integer coordinate pixels can be selected as known data source references, providing a basis for subsequently calculating smooth virtual grayscale values ​​through bilinear interpolation.

[0044] It should be further noted that the expansion of baked goods exhibits localized unevenness. Stretch mapping aims to simulate the actual stretching process of baking dough, treating the original standard reference image as an elastic film and stretching it in directions where the actual spatial margin decreases, while maintaining its original shape in areas where expansion is not significant. This eliminates spurious differences at the edges caused by variations in contour size, allowing the contrast to focus on the textural variations on the food surface.

[0045] The defect index submodule 203 is used to obtain the comprehensive defect discrimination index.

[0046] It should be noted that when the crust of baked goods cracks under heat, it forms intricate natural cracks, characterized by localized high-frequency texture complexity. In contrast, genuine manufacturing defects, such as large-area burning or breakage, often manifest as low-frequency smooth grayscale and obvious depth breaks. Therefore, this invention generates a basic appearance difference benchmark value based on the difference feature map, combines it with the local texture information entropy and local gradient amplitude of the image to be detected, obtains a comprehensive defect discrimination index, and determines the final appearance quality judgment result. This ensures that normal minor cracks are not amplified, and that true defects are highlighted.

[0047] Specifically, a sliding window of a preset size is constructed. This window is used to iterate through the difference feature map and the original image. The mean of all values ​​within the sliding window in the difference feature map is calculated, and this mean is divided by the preset maximum possible difference to obtain the baseline appearance difference value. The local entropy of the original image within the sliding window is obtained and linearly normalized to obtain the local texture entropy. The Sobel operator is used to extract the maximum gradient magnitude of the original image within the sliding window and linearly normalized to obtain the local gradient magnitude. Based on the baseline appearance difference value, the local texture entropy, and the local gradient magnitude, a comprehensive defect discrimination index is obtained.

[0048] Since the images captured by the industrial camera are in eight-bit grayscale format, the theoretical maximum grayscale value of a pixel is 255 and the theoretical minimum grayscale value is 0. Therefore, in this embodiment, the maximum possible difference is preset to be 255.

[0049] Specifically, the comprehensive defect discrimination index satisfies the following relationship: ; In the formula, In the difference feature map, the first Line number The comprehensive defect discrimination index of the sliding window area centered on column pixels. In the difference feature map, the first Line number The baseline value for the appearance difference of the sliding window area centered on the column pixels. For the original image, the first Line number The local texture information entropy of the sliding window region centered on the column pixels. For the original image, the first Line number The local gradient magnitude of the sliding window region centered on the column pixel.

[0050] in, This represents the degree of disorder in the physical texture of a local area. A higher value indicates a greater likelihood of localized variations caused by normal crust cracking, leading to... Approaching 0, this value suppresses the baseline difference in appearance, preventing high difference alarms caused by normal cracking. A smaller value indicates a higher likelihood of a smooth, hardened area due to burning, leading to... Approaching 1, thus preserving the differential mutations of real defects. This represents the degree of abrupt change in the local surface contour. The larger the value, the greater the possibility of surface dents or edge defects in baked goods, thus resulting in a larger overall defect discrimination index; the smaller the value, the less likely surface dents or edge defects are to occur, thus resulting in a smaller overall defect discrimination index.

[0051] Anomaly detection module 300 is used to determine the final appearance quality judgment result.

[0052] Specifically, if the number of sliding window regions with a comprehensive defect discrimination index greater than a preset judgment threshold is greater than a preset quantity threshold, the appearance quality of the baked goods is deemed unqualified; if the number of sliding window regions with a comprehensive defect discrimination index greater than the preset judgment threshold is less than or equal to the preset quantity threshold, the appearance quality of the baked goods is deemed qualified. In this embodiment, the preset judgment threshold is 0.65 and the quantity threshold is 20, which are set by the implementer according to the actual error tolerance.

Claims

1. A machine vision-based system for inspecting the appearance quality of baked goods, characterized in that, include: The acquisition module takes the outermost closed edge of the original image containing the inner tray and the baked food as the inner tray contour line, and takes the closed edge with the largest area inside the inner tray contour line as the food boundary line; it acquires the Euclidean distance from the food boundary line to the inner tray contour line in the preset ray direction and combines them into an edge redundancy sequence. The analysis module obtains the differences between the original image and the reference image at various positions on the edge redundancy sequence and decomposes them into spatial transformation vectors in the ray directions at various angles. Pixels on the food boundary line of the reference image at each ray angle are used as deformation control points and assigned corresponding spatial transformation vectors. Based on the Euclidean distance from each pixel in the reference image to all deformation control points, inverse distance weighted interpolation is performed on the spatial transformation vectors to obtain the thermal expansion deformation matrix. The reference image is then subjected to bilinear interpolation based on the thermal expansion deformation matrix to obtain a stretched mapping map. The absolute value of the phase subtraction between the original image and the stretched mapping map is used to obtain a difference feature map. The mean value of the difference feature map within the sliding window is used to obtain the basic appearance difference benchmark value. The comprehensive defect discrimination index is obtained by calculating the basic appearance difference benchmark value, the local texture information entropy of the original image, and the local gradient magnitude. The anomaly detection module determines the appearance quality judgment result based on the number of areas where the comprehensive defect discrimination index is greater than the judgment threshold.

2. The machine vision-based baking food appearance quality inspection system according to claim 1, characterized in that, The step of using the outermost closed edge of the original image containing the inner tray and baked goods as the inner tray contour line includes: extracting edge pixels of the image using an edge detection operator and connecting them to form a closed edge contour; calculating the internal area of ​​each closed edge contour and removing noise contours with an internal area less than a preset area threshold; and extracting the closed edge of the remaining closed edge contours that is located at the outermost layer and surrounds other contours as the inner tray contour line.

3. The machine vision-based baking food appearance quality inspection system according to claim 1, characterized in that, The step of obtaining the Euclidean distance from the food boundary line to the inner tray contour line in a preset ray direction and combining them into an edge redundancy sequence includes: determining the center coordinates of the food boundary line and using the center coordinates as the origin of the polar coordinates; obtaining the Euclidean distance between the pixel point on the food boundary line and the corresponding pixel point on the inner tray contour line in each preset ray direction; and aggregating the Euclidean distances in each ray direction in ascending order of angle to obtain the edge redundancy sequence.

4. The machine vision-based baking food appearance quality inspection system according to claim 1, characterized in that, The step of obtaining the difference between the original image and the reference image at various positions on the edge redundancy sequence and decomposing it into spatial transformation vectors in the ray directions of various angles includes: combining the ray angles corresponding to the difference, using trigonometric functions to decompose the difference into horizontal and vertical stretching in a rectangular coordinate system; and combining the horizontal and vertical stretching into a spatial transformation vector.

5. The machine vision-based baking food appearance quality inspection system according to claim 4, characterized in that, The step of performing inverse distance weighted interpolation on the spatial transformation vector based on the Euclidean distance from each pixel point inside the reference image to all deformation control points to obtain the thermal expansion deformation matrix includes: using all pixels inside the reference image as the target coordinate grid, calculating the Euclidean distance from each pixel point in the target coordinate grid to all deformation control points; based on the Euclidean distance, weighted fusing the horizontal stretching amount in the spatial transformation vector contained in all deformation control points to obtain the horizontal stretching amount of each pixel point in the target coordinate grid, and weighted fusing the vertical stretching amount in the spatial transformation vector contained in all deformation control points to obtain the vertical stretching amount of each pixel point in the target coordinate grid; and concatenating the horizontal and vertical stretching amounts of all pixels according to the original pixel spatial arrangement order of the reference image to obtain the thermal expansion deformation matrix.

6. The machine vision-based baking food appearance quality inspection system according to claim 5, characterized in that, The step of obtaining a stretched map by bilinear interpolation of the reference image based on the thermal expansion deformation matrix includes: traversing the target pixel coordinates on a blank mapping canvas of the same size as the original image, extracting the corresponding horizontal and vertical stretching amounts from the thermal expansion deformation matrix; subtracting the corresponding horizontal and vertical stretching amounts from the target pixel coordinates to obtain floating-point source coordinates; locating four integer coordinate pixels adjacent to the floating-point source coordinates in the reference image, and assigning weights to the four integer coordinate pixels according to their relative distances; calculating the interpolated gray values ​​by weighted summation of the gray values ​​of the four integer coordinate pixels based on the weights, and assigning the interpolated gray values ​​to the corresponding target pixel coordinates on the blank mapping canvas to obtain the stretched map.

7. The machine vision-based baking food appearance quality inspection system according to claim 1, characterized in that, The method for obtaining the local texture information entropy and local gradient magnitude of the original image includes: obtaining the local information entropy of the original image within the coverage area of ​​the sliding window, and linearly normalizing the local information entropy to obtain the local texture information entropy; extracting the maximum gradient magnitude of the original image within the coverage area of ​​the sliding window, and linearly normalizing the maximum gradient magnitude to obtain the local gradient magnitude.

8. The machine vision-based baking food appearance quality inspection system according to claim 1, characterized in that, The step of obtaining the basic appearance difference benchmark value based on the mean value of the difference feature map within the sliding window includes: calculating the mean value of all values ​​in the difference feature map within the sliding window; and dividing the mean value by a preset maximum possible difference value to obtain the basic appearance difference benchmark value.

9. The machine vision-based baking food appearance quality inspection system according to claim 7, characterized in that, The comprehensive defect discrimination index satisfies the following relationship: ; In the formula, In the difference feature map, the first Line number The comprehensive defect discrimination index of the sliding window area centered on column pixels. In the difference feature map, the first Line number The baseline value for the appearance difference of the sliding window area centered on the column pixels. For the original image, the first Line number The local texture information entropy of the sliding window region centered on the column pixels. For the original image, the first Line number The local gradient magnitude of the sliding window region centered on the column pixel.

10. The machine vision-based baking food appearance quality inspection system according to claim 1, characterized in that, The step of determining the appearance quality judgment result based on the number of regions with a comprehensive defect discrimination index greater than the judgment threshold includes: when the number of sliding window regions with a comprehensive defect discrimination index greater than the preset judgment threshold is greater than the preset quantity threshold, the appearance quality judgment result is determined to be unqualified; when the number of sliding window regions with a comprehensive defect discrimination index greater than the preset judgment threshold is less than or equal to the preset quantity threshold, the appearance quality judgment result is determined to be qualified.