Method and system for visually detecting outer surface defects of steamed stuffed buns
By constructing environmental disturbance response factors and local high-frequency abnormal response discrimination, the problem of identifying low-contrast defects on the surface of steamed buns was solved, achieving efficient detection under conditions of humidity and light variation, and improving detection accuracy and stability.
Patent Information
- Application Number
- CN202610061131.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-16
- Publication Date
- 2026-02-17
AI Technical Summary
Traditional visual inspection algorithms struggle to effectively identify low-contrast defects on the surface of steamed buns caused by changes in humidity and lighting, such as light-colored wrinkles and collapses. This is especially true in Chinese pastry production lines, where uneven lighting and humidity fluctuations affect the grayscale distribution of images, making it difficult for traditional algorithms to separate defective areas.
By employing image acquisition and preliminary preprocessing, regional grayscale fluctuation analysis, temperature and humidity mapping model construction, nonlinear brightness normalization mapping, local contrast enhancement and defect response modules, an environmental disturbance response factor is constructed, pixel-level dynamic adjustment and local high-frequency abnormal response discrimination are performed, a defect area mask is generated and graded judgment is made.
It effectively identifies minute defects on the surface of steamed buns in complex environments, improves the stability and accuracy of detection, avoids misjudgment in areas with abnormal lighting, enhances the perceptibility and recognition accuracy of fine structures, and adapts to image quality adjustments under different humidity conditions.
Smart Images

Figure CN121544607A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of defect visual inspection, in particular to a steamed bun outer surface defect visual inspection method and system. BACKGROUND
[0002] Image visual inspection technology is widely used in food appearance inspection, packaging consistency detection and other industrial scenes. In particular, in the production line of Chinese pastries, the outer surface defect detection of steamed foods such as steamed buns with flexible skin and complex wrinkle structure belongs to the sub-direction of the fusion of food intelligent perception and machine vision. This kind of detection task usually focuses on identifying the appearance defects such as collapse, damage and wrinkle abnormalities on the surface of steamed buns. The surface texture structure is subtle and the contrast is weak, which brings obvious challenges to conventional visual algorithms.
[0003] In the actual production environment, the steam of steamed buns is dispersed and the humidity fluctuates significantly, which easily leads to uneven illumination and contrast attenuation in the image, and then makes it difficult for traditional algorithms based on gray gradient or texture enhancement to effectively extract low-contrast defect features. For example, the light color wrinkle area often tends to be the same as the surrounding normal area in brightness under high humidity environment, and cannot be separated out by simple enhancement means.
[0004] The above detection deficiencies are mainly caused by two aspects: one is that the micro water mist formed by the steam escape of steamed buns in the camera area causes uneven illumination attenuation, producing regional low-contrast image regions; the other is that the change of environmental humidity causes the change of the water retention degree of the steamed bun skin, and then affects its local light reflection characteristics. These factors together cause the nonlinear drift of the local gray scale distribution of the image, making the light color collapse, depression or not fully closed wrinkle area visually close to the background, which is difficult to be perceived by traditional algorithms. SUMMARY
[0005] In view of the deficiencies of the prior art, the present application provides a steamed bun outer surface defect visual inspection method and system, which solves the problems mentioned in the background art.
[0006] To achieve the above purpose, the present application is realized by the following technical scheme: a steamed bun outer surface defect visual inspection system, comprising an image acquisition and preliminary preprocessing module, a regional gray scale fluctuation analysis module, a temperature and humidity mapping model construction module, a nonlinear brightness normalization mapping module, a local contrast enhancement and defect response module, and a defect discrimination and visual output module; The image acquisition and preliminary preprocessing module acquires the steamed bun surface image I(x, y) through a camera device and performs preprocessing to obtain an enhanced image Ic(x, y); The regional gray scale fluctuation analysis module divides the enhanced image Ic(x, y) into fixed size blocks, calculates the gray scale mean μ(i, j) and the variation degree δ(i, j) of each block, and constructs a regional gray scale fluctuation index ΔG(i, j); The temperature and humidity mapping model construction module calculates the environmental disturbance response factor Ψ(i,j) for each image region using the regional grayscale fluctuation index ΔG(i,j). The nonlinear brightness normalization mapping module performs pixel-level dynamic adjustment on the enhanced image Ic(x,y) through the environmental disturbance response factor Ψ(i,j) to obtain the normalized image Ino(x,y); The local contrast enhancement and defect response module performs texture edge enhancement processing on the normalized image Ino(x,y) and calculates and obtains the local high-frequency anomaly response map Ef(x,y). The defect identification and visual output module performs intensity threshold judgment on the local high-frequency abnormal response map Ef(x,y), generates a defect region mask Mdef(x,y), obtains the defect proportion Dare, and performs hierarchical judgment.
[0007] Preferably, the image acquisition and preliminary preprocessing module includes an image acquisition and dynamic compensation unit and a structure-preserving brightness enhancement unit; The image acquisition and dynamic compensation unit acquires images of steamed buns through a camera, obtains the surface image I(x,y) of the steamed bun, and performs filtering and noise reduction cleaning to obtain the filtered image Imed(x,y); where (x,y) represents the pixel position; The filtering and denoising process is as follows: Taking the current pixel position as the center, a fixed-size neighborhood window is selected around it; then, the gray values of all pixels are read sequentially from the neighborhood window, and these gray values together constitute a local pixel set; this set completely reflects the brightness distribution of the area around the current pixel, which may contain abnormally bright or dark spots caused by vapor, reflection, or imaging noise. Next, the local pixel set is sorted and rearranged in ascending order of pixel gray values; after sorting, the pixel gray value located in the middle of the sorted sequence is selected as the representative value. Finally, the gray value at the middle position is used as the output for the current pixel position, replacing the original pixel value. Since this value-taking process is not directly affected by extremely bright or dark points, it can suppress isolated noise points while preserving the overall structural features of the image. Preferably, the structure-preserving brightness enhancement unit performs dynamic brightness enhancement on the filtered image Imed(x,y), including the construction of local histogram enhancement and structural edge suppression factors, to obtain the enhanced image Ic(x,y). The local histogram enhancement is in the following way: taking the region where the current pixel is located as a unit, the gray value of the brightest and darkest pixels in the region is counted, which is called maximum value and minimum value respectively; then, the gray value of the current pixel is used to subtract the minimum gray value of the region to obtain the relative brightness difference, and then divide by the entire brightness span, that is, the maximum value minus the minimum value, to obtain the brightness normalization value; then, the brightness normalization value is processed by a power function, square root processing, which can adjust the strength of the enhancement, strengthen the dark or bright details, finally, the nonlinear result is obtained, and then the nonlinear result is mapped back to the set target gray range, for example, stretched to 0 to 255, thereby forming the enhanced new gray value; The construction formula of the structure edge suppression factor is as follows: η (x, y) = exp (- |▽Imed (x, y) |); In the formula, η (x, y) represents the structure edge suppression factor, exp represents the exponential function, and |▽Imed (x, y) | represents the image gradient amplitude; The enhanced image Ic (x, y) is obtained by the following formula: Ic (x, y) = η (x, y) × Imed (x, y) + (1- η (x, y)) × Ieq (x, y); In the formula, Ieq (x, y) represents the enhanced new gray value.
[0008] Preferably, the regional gray level fluctuation analysis module comprises a region segmentation and basic gray level statistics unit and a regional variation degree construction and gray level fluctuation index generation unit. The region segmentation and basic gray level statistics unit divides the enhanced image Ic (x, y) into a plurality of non-overlapping fixed-size blocks, each block is denoted as Ω (i, j), wherein i and j represent the numbering of the region in the row direction and the column direction. For each block Ω (i, j), the gray level average of all pixels in the block is counted to obtain the gray mean value μ (i, j) of each block. The gray mean value μ (i, j) of the block is obtained by the following formula: ; The regional variation degree construction and gray level fluctuation index generation unit counts the variation degree δ (i, j) of all pixels in each block Ω (i, j), and combines it with the gray mean value μ (i, j) of the block to construct the regional gray level fluctuation index ΔG (i, j). The construction method of the variation degree δ (i, j) is as follows: Firstly, the deviation degree of each pixel in the block relative to the gray mean value μ (i, j) is calculated: the deviation degree is obtained by taking the absolute value of the difference between the enhanced image Ic (x, y) and the gray mean value μ (i, j); Then, the deviation values in the block are averaged to obtain the block gray deviation intensity D(i, j); The block gray deviation intensity D(i, j) is obtained by the following formula: ; In the formula, d(x, y) represents the deviation degree; Then, based on the block gray deviation intensity D(i, j) and the enhanced image Ic(x, y), the gray distribution skewness index S(i, j) and the structural complexity index C(i, j) are constructed; The gray distribution skewness index S(i, j) is obtained by the following formula: ; In the formula, dc represents a non-zero constant; The structural complexity index C(i, j) is obtained by the following formula: ; In the formula, represents the derivative symbol; The variation degree δ(i, j) is obtained by the following formula: δ(i, j) = D(i, j) x (1 + |S(i, j)|) + C(i, j); The regional gray fluctuation index ΔG(i, j) is obtained by the ratio of the variation degree δ(i, j) and the gray mean value μ(i, j) of the block.
[0009] Preferably, the temperature and humidity mapping model construction module comprises a regional gray perturbation decoupling analysis unit and an environmental disturbance response factor mapping generation unit; The regional gray fluctuation index ΔG(i, j) is compared with the average fluctuation level of the adjacent regions by the regional gray perturbation decoupling analysis unit, and the regional relative fluctuation ratio R(i, j) is constructed; The regional relative fluctuation ratio R(i, j) is obtained by the following formula: ; In the formula, N(i, j) represents the neighborhood set of the region (i, j), (p, q) represents any region coordinate in the neighborhood set, and qp represents a non-zero constant; The spatial consistency index U(i, j) is introduced to distinguish the environmental disturbance and the structural disturbance; The smaller the spatial consistency index U(i, j) is, the more likely it is that similar fluctuations occur in multiple regions at the same time, which is more consistent with the characteristics of environmental disturbance; the larger the spatial consistency index U(i, j) is, the more likely it is that the fluctuations have obvious locality, which is more likely to come from the surface structure difference of the package; The spatial consistency index U(i, j) is obtained by the following formula: ; In the formula, ΔG (p, q) represents the gray fluctuation index of the neighborhood region coordinate (p, q); The disturbance source tendency vector T (i, j) is obtained by comprehensively analyzing the region relative fluctuation ratio R (i, j) and the spatial consistency index U (i, j); The disturbance source tendency vector T (i, j) is obtained by the ratio of the region relative fluctuation ratio R (i, j) and the spatial consistency index U (i, j); The environmental disturbance response factor mapping generation unit calculates and obtains the environmental disturbance response factor Ψ (i, j) based on the disturbance source tendency vector T (i, j); The environmental disturbance response factor Ψ (i, j) is obtained by the following formula: ; In the formula, ln represents the logarithmic function, μ (i, j) represents the gray mean value of the region (i, j), M represents the total number of all regions in the image, and μ (k) represents the gray mean value of the kth region.
[0010] Preferably, the nonlinear brightness normalization mapping module includes a disturbance adaptive brightness compression unit and a logarithmic dynamic mapping enhancement unit. The disturbance adaptive brightness compression unit performs region-level compression on the brightness value of each pixel (x, y) in the enhanced image Ic (x, y) according to the environmental disturbance response factor Ψ (i, j) corresponding to the region, to obtain a compressed intermediate image Iadj (x, y); The compressed intermediate image Iadj (x, y) is obtained by taking the enhanced image Ic (x, y) as the numerator and the sum of the environmental disturbance response factor Ψ (i, j) raised to the power of α and 1 as the denominator, and then taking the ratio; Specifically, α is used to control the amplification degree or punishment intensity of the environmental disturbance response factor Ψ (i, j) in the normalization compression; The acquisition method is: automatically adjusting according to the statistical characteristics (such as mean value and standard deviation) of the environmental disturbance response factor Ψ (i, j) in the whole image or local region; if the standard deviation is large, it means that the disturbance distribution is uneven, and it is automatically adjusted to be high; The value range of the power of α: in the scene of uniform and light dispersion of steam, the value is 0.8-1.5; in the scene of local reflection or moderate fog interference, the value is 1.5-2.5; in the scene of severe uneven light and obvious background flash interference, the value is 2.5-4.0; The logarithmic dynamic mapping enhancement unit performs nonlinear logarithmic mapping on the compressed intermediate image Iadj (x, y) to obtain a normalized processing image Ino (x, y); The normalized processing image Ino (x, y) is obtained by the following formula: ; In the formula, log represents the logarithmic function, μG represents the global average brightness, and μ(i,j)(x,y) represents the average brightness of the region (i,j) where pixel (x,y) is located.
[0011] Preferably, the local contrast enhancement and defect response module includes a multi-dimensional texture edge enhancement unit and a multi-dimensional texture edge enhancement unit; The multidimensional texture edge enhancement unit performs edge direction enhancement processing on the normalized image Ino(x,y). Through composite gradient operation and Laplacian second-order differential operation, it amplifies the changes in fine texture edges, preserves the gradient response of local structural changes such as wrinkles, cracks and collapses, obtains the first-order gradient G1(x,y) in the x-direction, the first-order gradient G2(x,y) in the y-direction and the second-order Laplacian gradient G3(x,y) in the y-direction, and calculates and obtains the edge enhancement map Iedg(x,y). The method for obtaining the first-order gradient G1(x,y) of the image in the x direction is as follows: First, calculate the gray-level change rate of the pixel in the horizontal direction. Taking the pixel as the center, take the difference between the gray-level values of the left and right adjacent pixels and divide it by the distance between the pixels to calculate the brightness gradient of the pixel in the horizontal direction, and then take the absolute value to obtain it. The method for obtaining the first-order gradient G2(x,y) in the y-direction of the image is as follows: First, calculate the gray-level change rate of the pixel in the vertical direction. Taking the pixel as the center, take the difference in gray-level values between the upper and lower adjacent pixels and divide it by the distance between the pixels to calculate the brightness gradient of the pixel in the vertical direction, and then take the absolute value to obtain it. The second-order Laplacian gradient G3(x,y) of an image is obtained as follows: First, the second derivatives of the pixel in the x-axis and y-axis directions, i.e. the rate of change of edge changes, are calculated separately. The two second derivatives are summed to obtain the Laplacian response value of the pixel, and then the absolute value is taken to obtain the result. The edge enhancement map Iedg(x, y) is obtained using the following formula: Iedg(x,y)=e1×G1(x,y)+e2×G2(x,y)+e3×G3(x,y); In the formula, e1 represents the adjustment coefficient of horizontal texture, e2 represents the adjustment coefficient of vertical texture, and e3 represents the response sensitivity adjustment coefficient.
[0012] Specifically, the adjustment coefficient e1 for horizontal texture is set to a higher value when horizontal features are obvious (such as when horizontal creases are prone to occur); the normalization ratio is set after analyzing the mean and standard deviation of the image response of G1, and then scaled; the value range is 0.8 to 1.2. The adjustment coefficient e2 for longitudinal texture is suitable for buns placed in a fixed orientation on the production line (where vertical cracks are common); the priority dimension is automatically adjusted by combining the average gradient change of G2 with the ratio of G1; the value range is 0.8 to 1.2. The response sensitivity adjustment coefficient e2 is set according to whether the structural complexity in the image is drastic; if the overall variability or grayscale fluctuation index in the previous module is high → increase e3; if the image is flat, the edges are clear and there is no strong disturbance → decrease e3 to suppress the hypersensitive response; the value range is 0.5 to 1.0. Preferably, the high-frequency structural anomaly response extraction unit extracts the high-frequency response of the edge enhancement map Iedg(x,y), calculates and obtains the local high-frequency anomaly response map Ef(x,y), and compares it with the preset anomaly threshold Tef to determine the anomaly state; Specifically, the abnormal threshold Tef is obtained using the following formula: Tef = μEf + ke × σEf; In the formula, μEf is the mean of the structural response of the whole figure, σEf represents the standard deviation of the response intensity, and ke represents the adjustment coefficient, which ranges from 1.5 to 2.5. The local high-frequency anomaly response map Ef(x, y) is obtained using the following formula: ; In the formula, This represents the second derivative of Laplacian applied to the image based on the edge enhancement result. Represents partial derivatives; Abnormal states are obtained using the following formula: When the local high-frequency anomaly response map Ef(x,y) ≥ the anomaly threshold Tef, it indicates that the region is abnormal and located in the defect region. When the local high-frequency anomaly response map Ef(x,y) < the anomaly threshold Tef, it indicates that the region is normal.
[0013] Preferably, the defect identification and visual output module includes an abnormal response intensity identification unit and a defect proportion calculation and level determination output unit; The abnormal response intensity discrimination unit generates a defect region mask Mdef(x, y) based on the abnormal state of the region. When the region is abnormal, the defect region mask Mdef(x, y) = 1; When the region is normal, the defect region mask Mdef(x, y) = 0; The defect percentage calculation and grade determination output unit statistically analyzes the overlapping area between the defect mask and the bun outline mask, calculates the defect percentage (Dare), performs grade determination, and generates corresponding strategies. ; In the formula, Mobj(x, y) represents the outline mask of the bun; The method for obtaining the steamed bun outline mask Mobj(x,y) is as follows: Image grayscale binarization: Binarize the normalized image Ino(x,y) using a fixed or adaptive threshold, and extract the bright area, i.e., the steamed bun region: For example: set pixels whose gray values are greater than a certain multiple of the average value of the entire image to 1, and set the rest to 0, to obtain a preliminary binary image B(x, y). Connected component extraction: Extract all connected components from the initial binary graph B(x,y) and select the one with the largest area, denoted as Rmax; Generate a mask image: Set the pixel value corresponding to the region where Rmax is located to 1, and set the others to 0 to obtain the steamed bun outline mask Mobj(x,y). The methods for obtaining the classification criteria and corresponding strategies are as follows: When the defect percentage (Dare) is less than 0.01, it indicates the first risk level, with no significant defects; the handling strategy is to accept the product into the warehouse and treat it as a qualified product. When 0.01 ≤ Defect Ratio (Dare) < 0.05, it indicates the second risk level, a minor defect; handling strategy: mark it as a second-level product and send it to secondary sales and employee dining channels; When 0.05 ≤ Defect Ratio (Dare) < 0.15, it indicates the third risk level, a significant defect; handling strategy: sort and remove from the main production line, and enter the manual re-inspection station; determine whether it can be manually repaired, such as trimming or removal; When 0.15 ≤ Defect Ratio (Dare), it indicates the fourth risk level, a serious defect; the handling strategy is to remove and destroy the defect, classify it as a scrapped product, and record it in the quality traceability system.
[0014] A visual inspection method for defects on the outer surface of steamed buns includes the following steps: Step 1: The image acquisition and preliminary preprocessing module acquires the surface image I(x,y) of the bun through a camera device and performs preprocessing to obtain the enhanced image Ic(x,y). Step 2: The regional gray-level fluctuation analysis module divides the enhanced image Ic(x,y) into blocks of fixed size, calculates the mean gray level μ(i,j) and variability δ(i,j) of each block, and constructs the regional gray-level fluctuation index ΔG(i,j). Step 3: The temperature and humidity mapping model construction module calculates the environmental disturbance response factor Ψ(i,j) for each image region using the regional grayscale fluctuation index ΔG(i,j). Step 4: The nonlinear brightness normalization mapping module performs pixel-level dynamic adjustment on the enhanced image Ic(x,y) using the environmental disturbance response factor Ψ(i,j) to obtain the normalized image Ino(x,y). Step 5: The local contrast enhancement and defect response module performs texture edge enhancement processing on the normalized image Ino(x,y) and calculates and obtains the local high-frequency anomaly response map Ef(x,y). Step 6: The defect identification and visual output module performs intensity threshold judgment on the local high-frequency abnormal response map Ef(x,y), generates a defect area mask Mdef(x,y), obtains the defect proportion Dare, and performs hierarchical judgment.
[0015] This invention provides a method and system for visually inspecting defects on the outer surface of steamed buns, which has the following beneficial effects: (1) During system operation, the low-contrast areas are stretched to a higher grayscale space through regional mean logarithmic mapping, which enhances the overall image hierarchy and helps to reveal tiny defects hidden in the background of strong interference. By fusing the first-order gradient and two-dimensional Laplacian response in the horizontal and vertical directions, a composite response can be formed for structural changes such as depressions, cracks, and wrinkles on the surface of the bun in different directions. This makes the texture contours that are weakened under strong light, humidity, or compression areas stand out and solves the problem of blurred structural edges.
[0016] (2) By constructing the regional relative fluctuation ratio and spatial consistency index, this module can identify whether the grayscale change in the current region is caused by environmental humidity and heat fluctuations or by the natural structure of the bun surface, thus realizing the derivation and qualitative judgment of the disturbance source tendency. This mechanism significantly optimizes the discrimination basis in the subsequent brightness normalization processing, avoiding misjudging structurally normal regions as areas with abnormal lighting. Without the need for any additional temperature and humidity sensors, the environmental disturbance response factor that can be used for correction can be constructed solely through the spatial distribution and statistical characteristics of grayscale information in each region of the image, realizing the adaptive drive for nonlinear adjustment of image brightness under different humidity conditions. This design ensures the simplicity of the system structure while taking into account the real-time response capability of image quality under the dynamic conditions of humidity and heat in the actual production line, and improves the stable operation capability of the system under extreme conditions such as humidity and fog.
[0017] (3) By converting the high-frequency structural anomaly response discrimination results obtained in the previous module into defect region masks, binary annotation of defective areas in the bun image is achieved, effectively solving the difficulty of relying on global features and being unable to accurately locate local fine structural defects in traditional image analysis, and enhancing the system's perceptibility and recognition accuracy of real structural anomalies. The effective detection area is limited by the bun contour mask Mobj(x,y), and the abnormal response is limited to the product body for statistical analysis, avoiding misjudgment due to background interference, effectively improving the accuracy of area quantification, and making the defect proportion calculation results more physically corresponding and evaluation reference.
[0018] (4) By constructing a mapping mechanism between regional grayscale fluctuation index and environmental disturbance response factor, the brightness disturbance caused by external conditions such as temperature and humidity in the image area can be distinguished from the actual defect response, effectively suppressing unstructured artifact interference and improving the environmental robustness of the detection process. The pixel-level brightness dynamic compression and logarithmic mapping method based on the disturbance factor makes the brightness area distribution more balanced, enhances the ability of the image to present details in complex backgrounds, and is particularly suitable for steamed bun products with uneven surface texture or slight depressions, enhancing the sensitivity to early and small defects. Attached Figure Description
[0019] Figure 1 This is a schematic flowchart of a visual inspection system for defects on the outer surface of steamed buns according to the present invention. Figure 2 This is a schematic diagram illustrating the steps of a visual inspection method for defects on the outer surface of a steamed bun according to the present invention. Figure 3 This is a schematic diagram of the process for obtaining the local high-frequency anomaly response map according to the present invention; Figure 4 This is a trend chart of the environmental disturbance response factor of the present invention. Detailed Implementation
[0020] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0021] Example 1
[0022] This invention provides a visual inspection system for defects on the outer surface of steamed buns. Please refer to [link / reference]. Figures 1 to 4 It includes an image acquisition and preliminary preprocessing module, a regional grayscale fluctuation analysis module, a temperature and humidity mapping model construction module, a nonlinear brightness normalization mapping module, a local contrast enhancement and defect response module, and a defect discrimination and visual output module. The image acquisition and preliminary preprocessing module acquires the surface image I(x,y) of the bun through a camera device and performs preprocessing to obtain the enhanced image Ic(x,y). The regional grayscale fluctuation analysis module divides the enhanced image Ic(x,y) into blocks of fixed size, calculates the mean grayscale value μ(i,j) and variability δ(i,j) of each block, and constructs the regional grayscale fluctuation index ΔG(i,j). The temperature and humidity mapping model construction module calculates the environmental disturbance response factor Ψ(i,j) for each image region using the regional grayscale fluctuation index ΔG(i,j). The nonlinear brightness normalization mapping module performs pixel-level dynamic adjustment on the enhanced image Ic(x,y) through the environmental disturbance response factor Ψ(i,j) to obtain the normalized image Ino(x,y); The local contrast enhancement and defect response module performs texture edge enhancement processing on the normalized image Ino(x,y) and calculates and obtains the local high-frequency anomaly response map Ef(x,y). The defect identification and visual output module performs intensity threshold judgment on the local high-frequency abnormal response map Ef(x,y), generates a defect region mask Mdef(x,y), obtains the defect proportion Dare, and performs hierarchical judgment.
[0023] In this embodiment, by constructing a regional grayscale fluctuation index and further extracting environmental disturbance response factors, it is possible to indirectly estimate and characterize the impact of water vapor and humidity interference on local areas of an image without relying on physical temperature and humidity sensors, thus constructing a regional adaptive judgment mechanism under dynamic temperature and humidity changes. A nonlinear brightness normalization mechanism is introduced to dynamically adjust the brightness of each pixel-level image based on the spatial distribution characteristics of the environmental disturbance response factors. This solves the problem that traditional global normalization methods cannot cope with regional brightness fluctuations, and is particularly suitable for grayscale non-uniformity phenomena caused by local fog diffusion, residual moisture on the surface of buns, etc., helping to restore the true brightness structure that the image should present.
[0024] By performing local high-frequency detail enhancement processing on the normalized image, low-contrast defect areas such as light-colored wrinkles, local collapses, and edge indentations, which were originally visually blurred due to humidity or lighting interference, are enhanced in the response image. Furthermore, through defect response intensity judgment and mask generation mechanisms, the defect proportion is quantified and graded for output, meeting the needs of real-time classification and automated allocation of processing strategies on the production line. Temperature and humidity estimation and lighting normalization processing are performed using the image's own regional grayscale variation model, eliminating the need for additional external sensing components such as temperature and humidity sensors and illuminance monitoring equipment. This reduces system integration complexity, saves deployment costs, and minimizes failure risks while ensuring visual quality, demonstrating good versatility and engineering feasibility.
[0025] Example 2
[0026] This embodiment is an explanation based on Embodiment 1. Please refer to it. Figure 1 and Figure 3 Specifically: the image acquisition and preliminary preprocessing module includes an image acquisition and dynamic compensation unit and a structure-preserving brightness enhancement unit; The image acquisition and dynamic compensation unit acquires images of steamed buns through a camera, obtains the surface image I(x,y) of the steamed bun, and performs filtering and noise reduction cleaning to obtain the filtered image Imed(x,y); where (x,y) represents the pixel position; The filtering and noise reduction cleaning process is as follows: taking the current pixel position as the center, a neighborhood window of a fixed size is selected around it; then, the gray values of all pixels are read sequentially from the neighborhood window, and these gray values together form a local pixel set; next, the local pixel set is sorted and rearranged in order of pixel gray values from smallest to largest. Finally, the grayscale value at the middle position is used as the output result for the current pixel position to replace the original pixel value.
[0027] The structure-preserving brightness enhancement unit performs dynamic brightness enhancement on the filtered image Imed(x,y), including the construction of local histogram enhancement and structure edge suppression factor, to obtain the enhanced image Ic(x,y). The local histogram enhancement method is as follows: taking the region where the current pixel is located as a unit, the gray values of the brightest and darkest pixels in the region are counted, which are called the maximum and minimum values, respectively; then, the minimum gray value of the region is subtracted from the gray value of the current pixel to obtain the relative brightness difference, and then divided by the entire brightness span to obtain the brightness normalization value; next, the brightness normalization value is processed by a first power function, and finally, the non-linear result is obtained, and then the non-linear result is mapped back to the set target gray value range to form the enhanced new gray value; The formula for constructing the structural edge inhibition factor is as follows: η(x,y)=exp(-∣▽Imed(x,y)∣); In the formula, η(x,y) represents the structural edge suppression factor, exp represents the exponential function, and ▽Imed(x,y) represents the image gradient magnitude; The enhanced image Ic(x,y) is obtained using the following formula: Ic(x,y)=η(x,y)×Imed(x,y)+(1-η(x,y))×Ieq(x,y); In the formula, Ieq(x, y) represents the new grayscale value after enhancement.
[0028] In this embodiment, by introducing a median filtering mechanism, local pixel grayscale sorting and replacement are performed on the original image immediately after image acquisition. This effectively filters out unstructured high-frequency interference and isolated noise caused by steam, water vapor, oil stain reflection, etc., preserving the main structure and true brightness levels of the image, and avoiding image feature recognition shifts caused by strong local contrasts, thus providing a stable foundation for subsequent enhancement and defect identification. A local histogram brightness enhancement method is adopted, extracting extreme grayscale distributions on a per-image-region basis. Based on this, a normalized brightness difference and nonlinear power function adjustment mechanism are constructed. This allows defect areas such as light-colored wrinkles and skin collapses, which were originally similar in brightness to the background, to visually differentiate in terms of brightness and darkness, enhancing the subsequent response capability to low-grayscale contrast targets.
[0029] By introducing a structural edge suppression factor η and combining the gray-level enhancement value with the gradient magnitude of the original image for pixel-level fusion, a coupled strategy of brightness redistribution and edge suppression is constructed. While enhancing the brightness contrast of the image, it effectively suppresses side effects such as edge structure blurring and local morphological distortion that may be caused by the enhancement operation, maintains the integrity of key structures such as the surface outline of the bun and the edge of the crack, and ensures that the subsequent defect identification process is not misled.
[0030] It integrates the three-stage operation process of denoising, enhancement, and suppression, and establishes a dynamic adaptive chain from image acquisition to structural enhancement. It is particularly suitable for unstable scenarios such as frequent changes in lighting and severe water vapor interference in on-site production environments, improves the consistency of image quality, and provides highly reliable data input for the judgment and analysis of subsequent system modules.
[0031] Example 3 This embodiment is an explanation based on Embodiment 2. Please refer to it. Figure 3 and Figure 4 Specifically: the regional grayscale fluctuation analysis module includes a regional segmentation and basic grayscale statistics unit and a regional variability construction and grayscale fluctuation index generation unit; The region segmentation and basic gray-level statistics unit divides the enhanced image Ic(x,y) into several non-overlapping fixed-size blocks, each block is denoted as Ω(i,j), where i and j represent the region numbers in the row and column directions, respectively. For each block Ω(i,j), calculate the average gray level of all pixels within the block and obtain the average gray level μ(i,j) of each block. The average grayscale value μ(i,j) of the block is obtained using the following formula: ; The regional variability construction and grayscale fluctuation index generation unit calculates the variability δ(i,j) of all pixels in each block Ω(i,j) and combines it with the grayscale mean μ(i,j) of the block to construct the regional grayscale fluctuation index ΔG(i,j). The variability δ(i,j) is constructed as follows: First, calculate the degree of deviation of each pixel within the block relative to the gray-level mean μ(i,j): the degree of deviation is obtained by taking the absolute value of the difference between the enhanced image Ic(x,y) and the gray-level mean μ(i,j). Then, the average of all deviation values within the block is used to obtain the block grayscale deviation intensity D(i,j); The grayscale deviation intensity D(i,j) of the block is obtained by the following formula: ; In the formula, d(x, y) represents the degree of deviation; Next, based on the block gray-level deviation intensity D(i,j) and the enhanced image Ic(x,y), a gray-level distribution skewness index S(i,j) and a structural complexity index C(i,j) are constructed. The gray-level distribution skewness index S(i,j) is obtained by the following formula: ; In the formula, dc represents a non-zero constant; The structural complexity index C(i,j) is obtained using the following formula: ; In the formula, Indicates the sign of partial derivatives; The degree of variability δ(i,j) is obtained by the following formula: δ(i,j)=D(i,j)×(1+∣S(i,j)∣)+C(i,j); The regional grayscale fluctuation index ΔG(i,j) is obtained by the ratio of the variability δ(i,j) to the grayscale mean μ(i,j) of the block.
[0032] The temperature and humidity mapping model construction module includes a regional gray-scale disturbance decoupling analysis unit and an environmental disturbance response factor mapping generation unit; The regional gray-level disturbance decoupling analysis unit compares the regional gray-level fluctuation index ΔG(i,j) with the average fluctuation level of the neighboring regions to construct the regional relative fluctuation ratio R(i,j). The regional relative volatility ratio R(i,j) is obtained using the following formula: ; In the formula, N(i,j) represents the neighborhood set of region (i,j), (p,q) represents the coordinates of any region in the neighborhood set, and qp represents a non-zero constant; By introducing a spatial consistency index U(i,j), environmental disturbances and structural disturbances can be distinguished. The spatial consistency index U(i,j) is obtained through the following formula: ; In the formula, ΔG(p, q) represents the gray-level fluctuation index of the neighborhood region coordinates (p, q); By comprehensively analyzing the regional relative fluctuation ratio R(i,j) and the spatial consistency index U(i,j), the disturbance source tendency T(i,j) is obtained. The disturbance source tendency T(i,j) is obtained by the ratio of the regional relative volatility ratio R(i,j) to the spatial consistency index U(i,j); The environmental disturbance response factor mapping generation unit calculates and obtains the environmental disturbance response factor Ψ(i,j) based on the disturbance source tendency T(i,j). The environmental disturbance response factor Ψ(i,j) is obtained through the following formula: ; In the formula, ln represents the logarithmic function, μ(i,j) represents the mean gray value of region (i,j), M represents the total number of regions in the image, and μ(k) represents the mean gray value of the k-th region.
[0033] In this embodiment, by introducing block-based grayscale statistics, deviation intensity analysis, and coupled calculation of skewness and structural complexity, a regional grayscale fluctuation index system is established from multiple dimensions such as grayscale mean, fluctuation intensity, skewed distribution, and structural texture. This system can not only accurately capture the non-uniform distribution of brightness on the surface of the bun, but also respond to grayscale disturbances that may be caused by steam condensation, humidity retention, etc., thereby enhancing the system's ability to perceive subtle light interference.
[0034] By constructing regional relative fluctuation ratios and spatial consistency indices, this module can identify whether the grayscale changes in the current region originate from environmental humidity and heat fluctuations or from the natural structure of the bun's surface, thus deriving and qualitatively identifying the source of disturbance. This mechanism significantly optimizes the discrimination basis in subsequent brightness normalization processing, avoiding misclassification of structurally normalized regions as areas with abnormal lighting. Without the need for any additional temperature and humidity sensors, an environmental disturbance response factor that can be used for correction can be constructed solely based on the spatial distribution and statistical characteristics of grayscale information in each region of the image, enabling adaptive driving of nonlinear adjustment of image brightness under different humidity conditions. This design, while ensuring a simple system structure, also considers the real-time response capability to image quality under dynamic humidity and heat conditions in actual production lines, improving the system's stable operation under extreme conditions such as humidity and fog.
[0035] The perturbation factor generated by this module can effectively drive the subsequent nonlinear brightness normalization module, enabling the image to maintain clear details even in low-contrast environments. In particular, it enhances the ability to extract defects such as light-colored collapse and smooth depressions, providing a good base layer for subsequent defect identification.
[0036] Example 4
[0037] This embodiment is an explanation based on Embodiment 3. Please refer to it. Figure 1 Specifically: the nonlinear brightness normalization mapping module includes a perturbation adaptive brightness compression unit and a logarithmic dynamic mapping enhancement unit; The perturbation adaptive brightness compression unit performs region-level compression on the brightness value of each pixel (x, y) in the enhanced image Ic(x, y) according to the environmental perturbation response factor Ψ(i, j) corresponding to the region, and obtains the compressed intermediate image Iadj(x, y). The compressed intermediate image Iadj(x,y) is obtained by taking the enhanced image Ic(x,y) as the numerator, and the sum of the environmental disturbance response factor Ψ(i,j) raised to the power of α and 1 as the denominator. The logarithmic dynamic mapping enhancement unit performs nonlinear logarithmic mapping on the compressed intermediate image Iadj(x,y) to obtain the normalized image Ino(x,y). The normalized image Ino(x,y) is obtained using the following formula: ; In the formula, log represents the logarithmic function, μG represents the global average brightness, and μ(i,j)(x,y) represents the average brightness of the region (i,j) where pixel (x,y) is located.
[0038] The local contrast enhancement and defect response module includes a multi-dimensional texture edge enhancement unit and a multi-dimensional texture edge enhancement unit; The multidimensional texture edge enhancement unit performs edge direction enhancement processing on the normalized image Ino(x,y). Through composite gradient operation and Laplacian second-order differential operation, it amplifies the changes in fine texture edges, preserves the gradient response of local structural changes such as wrinkles, cracks and collapses, obtains the first-order gradient G1(x,y) in the x-direction, the first-order gradient G2(x,y) in the y-direction and the second-order Laplacian gradient G3(x,y) in the y-direction, and calculates and obtains the edge enhancement map Iedg(x,y). The method for obtaining the first-order gradient G1(x,y) of the image in the x direction is as follows: First, calculate the gray-level change rate of the pixel in the horizontal direction. Taking the pixel as the center, take the difference between the gray-level values of the left and right adjacent pixels and divide it by the distance between the pixels to calculate the brightness gradient of the pixel in the horizontal direction, and then take the absolute value to obtain it. The method for obtaining the first-order gradient G2(x,y) in the y-direction of the image is as follows: First, calculate the gray-level change rate of the pixel in the vertical direction. Taking the pixel as the center, take the difference in gray-level values between the upper and lower adjacent pixels and divide it by the distance between the pixels to calculate the brightness gradient of the pixel in the vertical direction, and then take the absolute value to obtain it. The second-order Laplacian gradient G3(x,y) of an image is obtained as follows: First, the second derivatives of the pixel in the x-axis and y-axis directions are calculated separately. The two second derivatives are summed to obtain the Laplacian response value of the pixel, and then the absolute value is taken. The edge enhancement map Iedg(x, y) is obtained using the following formula: Iedg(x,y)=e1×G1(x,y)+e2×G2(x,y)+e3×G3(x,y); In the formula, e1 represents the adjustment coefficient of horizontal texture, e2 represents the adjustment coefficient of vertical texture, and e3 represents the response sensitivity adjustment coefficient.
[0039] The high-frequency structural anomaly response extraction unit extracts the high-frequency response of the edge enhancement map Iedg(x,y), calculates and obtains the local high-frequency anomaly response map Ef(x,y), and compares it with the preset anomaly threshold Tef to determine the anomaly state. The local high-frequency anomaly response map Ef(x, y) is obtained using the following formula: ; In the formula, This represents the second derivative of Laplacian applied to the image based on the edge enhancement result. Represents partial derivatives; Abnormal states are obtained using the following formula: When the local high-frequency anomaly response map Ef(x,y) ≥ the anomaly threshold Tef, it indicates that the region is abnormal and located in the defect region. When the local high-frequency anomaly response map Ef(x,y) < the anomaly threshold Tef, it indicates that the region is normal.
[0040] In this embodiment, by applying the environmental disturbance response factor derived in the previous module to the pixel-level brightness compression operation, the image brightness value in areas of strong light, reflection, and water vapor condensation is effectively suppressed, thereby significantly reducing the impact of external disturbances on the brightness field and providing a more unified dynamic range basis for subsequent detail restoration.
[0041] This embodiment uses regional mean logarithmic mapping to stretch low-contrast areas to a higher grayscale space, enhancing the overall image's depth and helping to reveal minute defects hidden against strong interference backgrounds. By fusing the first-order gradients in the horizontal and vertical directions with the two-dimensional Laplacian response, a composite response can be generated for structural changes such as depressions, cracks, and wrinkles on the surface of the bun in different directions. This allows the texture contours that are weakened under strong light, humidity, or compression to be highlighted, solving the problem of blurred structural edges.
[0042] Based on the edge enhancement map, high-frequency abnormal response features are further extracted, which can accurately locate local abrupt change areas, such as the edges of wrinkles and cracks, and minor surface collapses. By setting clear thresholds to determine boundaries, false detections or missed detections caused by texture blurring are effectively avoided, improving the robustness and accuracy of overall detection and discrimination. Not only does it solve the problem of inconsistent brightness such as light spots, whitening, and reflections in high-humidity environments through a perturbation factor compression mechanism, but it also compensates and amplifies low-to-medium contrast defects at the detail level through logarithmic mapping and multi-dimensional gradient enhancement mechanisms. It takes into account both global normalization and differentiated control of local responses, providing more stable and identifiable image input for subsequent defect recognition.
[0043] Example 5
[0044] This embodiment is an explanation based on Embodiment 4. Please refer to it. Figure 1 and Figure 3 Specifically: the defect identification and visual output module includes an abnormal response intensity identification unit and a defect proportion calculation and level determination output unit; The abnormal response intensity discrimination unit generates a defect region mask Mdef(x, y) based on the abnormal state of the region. When the region is abnormal, the defect region mask Mdef(x, y) = 1; When the region is normal, the defect region mask Mdef(x, y) = 0; The defect percentage calculation and grade determination output unit statistically analyzes the overlapping area between the defect mask and the bun outline mask, calculates the defect percentage (Dare), performs grade determination, and generates corresponding strategies. ; In the formula, Mobj(x, y) represents the outline mask of the bun; The methods for obtaining the classification criteria and corresponding strategies are as follows: When the defect percentage (Dare) is less than 0.01, it indicates the first risk level, with no significant defects; the handling strategy is to accept the product into the warehouse and treat it as a qualified product. When 0.01 ≤ Defect Ratio (Dare) < 0.05, it indicates the second risk level, a minor defect; handling strategy: mark it as a second-level product and send it to secondary sales and employee dining channels; When 0.05 ≤ Defect Ratio (Dare) < 0.15, it indicates the third risk level, a significant defect; the handling strategy is to sort and remove it from the main production line and move it to the manual re-inspection station. When 0.15 ≤ Defect Ratio (Dare), it indicates the fourth risk level, a serious defect; the handling strategy is to remove and destroy the product, classifying it as a scrapped product.
[0045] In this embodiment, the high-frequency structural anomaly response discrimination results obtained in the previous module are converted into defect region masks to achieve binary annotation of defective areas in the steamed bun image. This effectively solves the difficulty of traditional image analysis, which relies on global features and cannot accurately locate local fine structural defects, thus enhancing the system's perceptibility and recognition accuracy of real structural anomalies. The steamed bun contour mask Mobj(x,y) is used to limit the effective detection area, restricting the statistical analysis of anomaly responses to the product body itself. This avoids misjudgments due to background interference, effectively improving the accuracy of area quantification and making the defect proportion calculation results more physically corresponding and reliable for evaluation.
[0046] Based on the ratio of defect area to the overall product area, a clear threshold is established, defining a four-level risk level system from no defects, minor flaws to serious defects. Each level corresponds to a specific processing channel, thereby replacing the traditional judgment method that relies on human experience and yields inconsistent results, and laying the foundation for automated grading and batch processing.
[0047] Example 6 A visual inspection method for defects on the outer surface of steamed buns, please refer to... Figure 2 Specifically, it includes the following steps: Step 1: The image acquisition and preliminary preprocessing module acquires the surface image I(x,y) of the bun through a camera device and performs preprocessing to obtain the enhanced image Ic(x,y). Step 2: The regional gray-level fluctuation analysis module divides the enhanced image Ic(x,y) into blocks of fixed size, calculates the mean gray level μ(i,j) and variability δ(i,j) of each block, and constructs the regional gray-level fluctuation index ΔG(i,j). Step 3: The temperature and humidity mapping model construction module calculates the environmental disturbance response factor Ψ(i,j) for each image region using the regional grayscale fluctuation index ΔG(i,j). Step 4: The nonlinear brightness normalization mapping module performs pixel-level dynamic adjustment on the enhanced image Ic(x,y) using the environmental disturbance response factor Ψ(i,j) to obtain the normalized image Ino(x,y). Step 5: The local contrast enhancement and defect response module performs texture edge enhancement processing on the normalized image Ino(x,y) and calculates and obtains the local high-frequency anomaly response map Ef(x,y). Step 6: The defect identification and visual output module performs intensity threshold judgment on the local high-frequency abnormal response map Ef(x,y), generates a defect area mask Mdef(x,y), obtains the defect proportion Dare, and performs hierarchical judgment.
[0048] In this embodiment, a mapping mechanism between regional grayscale fluctuation indices and environmental disturbance response factors is constructed to distinguish between brightness disturbances caused by external conditions such as temperature and humidity in the image region and actual defect responses. This effectively suppresses unstructured artifact interference and improves the environmental robustness of the detection process. The use of pixel-level dynamic brightness compression and logarithmic mapping based on disturbance factors results in a more balanced brightness distribution, enhancing the image's ability to reveal details against complex backgrounds. This is particularly suitable for steamed bun products with uneven surface textures or slight depressions, enhancing the sensitivity to early, minute defects.
[0049] By jointly processing normalized images using multi-dimensional edge operators, gradient changes caused by differences in microstructures such as wrinkles and cracks are preserved, resulting in a more sensitive and stable high-frequency anomaly response map. This enables refined enhancement of complex structural details, overcoming the limitation of traditional image sharpening methods in accurately identifying real defect areas. A masking mechanism is employed to accurately label detected anomaly regions, and the defect percentage is calculated by combining this with product contour information. This allows detection to go beyond simply determining the presence of defects; it also quantifies their severity, generating structured outputs with interpretability to meet the needs of quality control and traceability management.
[0050] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and variations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended technical solutions and their equivalents.
Claims
1. A visual inspection system for defects on the outer surface of steamed buns, characterized in that: It includes an image acquisition and preliminary preprocessing module, a regional grayscale fluctuation analysis module, a temperature and humidity mapping model construction module, a nonlinear brightness normalization mapping module, a local contrast enhancement and defect response module, and a defect discrimination and visual output module. The image acquisition and preliminary preprocessing module acquires the surface image I(x,y) of the bun through a camera device and performs preprocessing to obtain the enhanced image Ic(x,y). The regional grayscale fluctuation analysis module divides the enhanced image Ic(x,y) into blocks of fixed size, calculates the mean grayscale value μ(i,j) and variability δ(i,j) of each block, and constructs the regional grayscale fluctuation index ΔG(i,j). The temperature and humidity mapping model construction module calculates the environmental disturbance response factor Ψ(i,j) for each image region using the regional grayscale fluctuation index ΔG(i,j). The nonlinear brightness normalization mapping module performs pixel-level dynamic adjustment on the enhanced image Ic(x,y) through the environmental disturbance response factor Ψ(i,j) to obtain the normalized image Ino(x,y); The local contrast enhancement and defect response module performs texture edge enhancement processing on the normalized image Ino(x,y) and calculates and obtains the local high-frequency anomaly response map Ef(x,y). The defect identification and visual output module performs intensity threshold judgment on the local high-frequency abnormal response map Ef(x,y), generates a defect region mask Mdef(x,y), obtains the defect proportion Dare, and performs hierarchical judgment.
2. The visual inspection system for defects on the outer surface of steamed buns according to claim 1, characterized in that: The image acquisition and preliminary preprocessing module includes an image acquisition and dynamic compensation unit and a structure-preserving brightness enhancement unit; The image acquisition and dynamic compensation unit acquires images of steamed buns through a camera, obtains the surface image I(x,y) of the steamed bun, and performs filtering and noise reduction cleaning to obtain the filtered image Imed(x,y); where (x,y) represents the pixel position; The filtering and noise reduction cleaning process is as follows: taking the current pixel position as the center, a neighborhood window of a fixed size is selected around it; then, the gray values of all pixels are read sequentially from the neighborhood window, and these gray values together form a local pixel set; next, the local pixel set is sorted and rearranged in order of pixel gray values from smallest to largest. Finally, the grayscale value at the middle position is used as the output result for the current pixel position to replace the original pixel value.
3. The visual inspection system for defects on the outer surface of steamed buns according to claim 2, characterized in that: The structure-preserving brightness enhancement unit performs dynamic brightness enhancement on the filtered image Imed(x,y), including the construction of local histogram enhancement and structure edge suppression factor, to obtain the enhanced image Ic(x,y). The local histogram enhancement method is as follows: taking the region where the current pixel is located as a unit, the gray values of the brightest and darkest pixels in the region are counted, which are called the maximum and minimum values, respectively; then, the minimum gray value of the region is subtracted from the gray value of the current pixel to obtain the relative brightness difference, and then divided by the entire brightness span to obtain the brightness normalization value; next, the brightness normalization value is processed by a first power function, and finally, the non-linear result is obtained, and then the non-linear result is mapped back to the set target gray value range to form the enhanced new gray value; The formula for constructing the structural edge inhibition factor is as follows: η(x,y)=exp(-∣▽Imed(x,y)∣); In the formula, η(x,y) represents the structural edge suppression factor, exp represents the exponential function, and ▽Imed(x,y) represents the image gradient magnitude; The enhanced image Ic(x,y) is obtained using the following formula: Ic(x,y)=η(x,y)×Imed(x,y)+(1-η(x,y))×Ieq(x,y); In the formula, Ieq(x, y) represents the new grayscale value after enhancement.
4. The visual inspection system for defects on the outer surface of steamed buns according to claim 3, characterized in that: The regional grayscale fluctuation analysis module includes a regional segmentation and basic grayscale statistics unit and a regional variability construction and grayscale fluctuation index generation unit; The region segmentation and basic gray-level statistics unit divides the enhanced image Ic(x,y) into several non-overlapping fixed-size blocks, each block is denoted as Ω(i,j), where i and j represent the region numbers in the row and column directions, respectively. For each block Ω(i,j), calculate the average gray level of all pixels within the block and obtain the average gray level μ(i,j) of each block. The average grayscale value μ(i,j) of the block is obtained using the following formula: ; The regional variability construction and grayscale fluctuation index generation unit calculates the variability δ(i,j) of all pixels in each block Ω(i,j) and combines it with the grayscale mean μ(i,j) of the block to construct the regional grayscale fluctuation index ΔG(i,j). The variability δ(i,j) is constructed as follows: First, calculate the degree of deviation of each pixel within the block relative to the gray-level mean μ(i,j): the degree of deviation is obtained by taking the absolute value of the difference between the enhanced image Ic(x,y) and the gray-level mean μ(i,j). Then, the average of all deviation values within the block is used to obtain the block grayscale deviation intensity D(i,j); The grayscale deviation intensity D(i,j) of the block is obtained by the following formula: ; In the formula, d(x, y) represents the degree of deviation; Next, based on the block gray-level deviation intensity D(i,j) and the enhanced image Ic(x,y), a gray-level distribution skewness index S(i,j) and a structural complexity index C(i,j) are constructed. The gray-level distribution skewness index S(i,j) is obtained by the following formula: ; In the formula, dc represents a non-zero constant; The structural complexity index C(i,j) is obtained using the following formula: ; In the formula, Indicates the sign of partial derivatives; The degree of variability δ(i,j) is obtained by the following formula: δ(i,j)=D(i,j)×(1+∣S(i,j)∣)+C(i,j); The regional grayscale fluctuation index ΔG(i,j) is obtained by the ratio of the variability δ(i,j) to the grayscale mean μ(i,j) of the block.
5. The visual inspection system for defects on the outer surface of steamed buns according to claim 4, characterized in that: The temperature and humidity mapping model construction module includes a regional gray-scale disturbance decoupling analysis unit and an environmental disturbance response factor mapping generation unit; The regional gray-level disturbance decoupling analysis unit compares the regional gray-level fluctuation index ΔG(i,j) with the average fluctuation level of the neighboring regions to construct the regional relative fluctuation ratio R(i,j). The regional relative volatility ratio R(i,j) is obtained using the following formula: ; In the formula, N(i,j) represents the neighborhood set of region (i,j), (p,q) represents the coordinates of any region in the neighborhood set, and qp represents a non-zero constant; By introducing a spatial consistency index U(i,j), environmental disturbances and structural disturbances can be distinguished. The spatial consistency index U(i,j) is obtained through the following formula: ; In the formula, ΔG(p, q) represents the gray-level fluctuation index of the neighborhood region coordinates (p, q); By comprehensively analyzing the regional relative fluctuation ratio R(i,j) and the spatial consistency index U(i,j), the disturbance source tendency T(i,j) is obtained. The disturbance source tendency T(i,j) is obtained by the ratio of the regional relative volatility ratio R(i,j) to the spatial consistency index U(i,j); The environmental disturbance response factor mapping generation unit calculates and obtains the environmental disturbance response factor Ψ(i,j) based on the disturbance source tendency T(i,j). The environmental disturbance response factor Ψ(i,j) is obtained through the following formula: ; In the formula, ln represents the logarithmic function, μ(i,j) represents the mean gray value of region (i,j), M represents the total number of regions in the image, and μ(k) represents the mean gray value of the k-th region.
6. The visual inspection system for defects on the outer surface of a steamed bun according to claim 5, characterized in that: The nonlinear brightness normalization mapping module includes a perturbation adaptive brightness compression unit and a logarithmic dynamic mapping enhancement unit; The perturbation adaptive brightness compression unit performs region-level compression on the brightness value of each pixel (x, y) in the enhanced image Ic(x, y) according to the environmental perturbation response factor Ψ(i, j) corresponding to the region, and obtains the compressed intermediate image Iadj(x, y). The compressed intermediate image Iadj(x,y) is obtained by taking the enhanced image Ic(x,y) as the numerator, and the sum of the environmental disturbance response factor Ψ(i,j) raised to the power of α and 1 as the denominator. The logarithmic dynamic mapping enhancement unit performs nonlinear logarithmic mapping on the compressed intermediate image Iadj(x,y) to obtain the normalized image Ino(x,y). The normalized image Ino(x,y) is obtained using the following formula: ; In the formula, log represents the logarithmic function, μG represents the global average brightness, and μ(i,j)(x,y) represents the average brightness of the region (i,j) where pixel (x,y) is located.
7. The visual inspection system for defects on the outer surface of a steamed bun according to claim 6, characterized in that: The local contrast enhancement and defect response module includes a multi-dimensional texture edge enhancement unit and a multi-dimensional texture edge enhancement unit; The multidimensional texture edge enhancement unit performs edge direction enhancement processing on the normalized image Ino(x,y). Through composite gradient operation and Laplacian second-order differential operation, it amplifies the changes in fine texture edges, preserves the gradient response of local structural changes such as wrinkles, cracks and collapses, obtains the first-order gradient G1(x,y) in the x-direction, the first-order gradient G2(x,y) in the y-direction and the second-order Laplacian gradient G3(x,y) in the y-direction, and calculates and obtains the edge enhancement map Iedg(x,y). The method for obtaining the first-order gradient G1(x,y) of the image in the x direction is as follows: First, calculate the gray-level change rate of the pixel in the horizontal direction. Taking the pixel as the center, take the difference between the gray-level values of the left and right adjacent pixels and divide it by the distance between the pixels to calculate the brightness gradient of the pixel in the horizontal direction, and then take the absolute value to obtain it. The method for obtaining the first-order gradient G2(x,y) in the y-direction of the image is as follows: First, calculate the gray-level change rate of the pixel in the vertical direction. Taking the pixel as the center, take the difference in gray-level values between the upper and lower adjacent pixels and divide it by the distance between the pixels to calculate the brightness gradient of the pixel in the vertical direction, and then take the absolute value to obtain it. The second-order Laplacian gradient G3(x,y) of an image is obtained as follows: First, the second derivatives of the pixel in the x-axis and y-axis directions are calculated separately. The two second derivatives are summed to obtain the Laplacian response value of the pixel, and then the absolute value is taken. The edge enhancement map Iedg(x, y) is obtained using the following formula: Iedg(x,y)=e1×G1(x,y)+e2×G2(x,y)+e3×G3(x,y); In the formula, e1 represents the adjustment coefficient of horizontal texture, e2 represents the adjustment coefficient of vertical texture, and e3 represents the response sensitivity adjustment coefficient.
8. The visual inspection system for defects on the outer surface of a steamed bun according to claim 7, characterized in that: The high-frequency structural anomaly response extraction unit extracts the high-frequency response of the edge enhancement map Iedg(x,y), calculates and obtains the local high-frequency anomaly response map Ef(x,y), and compares it with the preset anomaly threshold Tef to determine the anomaly state. The local high-frequency anomaly response map Ef(x, y) is obtained using the following formula: ; In the formula, ∂ denotes the second Laplacian derivative performed on the image based on the edge enhancement result, and ∂ denotes the partial derivative; Abnormal states are obtained using the following formula: When the local high-frequency anomaly response map Ef(x,y) ≥ the anomaly threshold Tef, it indicates that the region is abnormal and located in the defect region. When the local high-frequency anomaly response map Ef(x,y) < the anomaly threshold Tef, it indicates that the region is normal.
9. A visual inspection system for defects on the outer surface of a steamed bun according to claim 8, characterized in that: The defect identification and visual output module includes an abnormal response intensity identification unit and a defect proportion calculation and level determination output unit; The abnormal response intensity discrimination unit generates a defect region mask Mdef(x, y) based on the abnormal state of the region. When the region is abnormal, the defect region mask Mdef(x, y) = 1; When the region is normal, the defect region mask Mdef(x, y) = 0; The defect percentage calculation and grade determination output unit statistically analyzes the overlapping area between the defect mask and the bun outline mask, calculates the defect percentage (Dare), performs grade determination, and generates corresponding strategies. ; In the formula, Mobj(x, y) represents the outline mask of the bun; The methods for obtaining the classification criteria and corresponding strategies are as follows: When the defect percentage (Dare) is less than 0.01, it indicates the first risk level, with no significant defects; the handling strategy is to accept the product into the warehouse and treat it as a qualified product. When 0.01 ≤ Defect percentage (Dare) < 0.05, it indicates the second risk level, a minor defect; Handling strategy: Mark as secondary product and send to secondary sales and employee dining channels; When 0.05 ≤ Defect Ratio (Dare) < 0.15, it indicates the third risk level, a significant defect; the handling strategy is to sort and remove it from the main production line and move it to the manual re-inspection station. When 0.15 ≤ Defect Ratio (Dare), it indicates the fourth risk level, a serious defect; the handling strategy is to remove and destroy the product, classifying it as a scrapped product.
10. A visual inspection method for defects on the outer surface of steamed buns, applied to the visual inspection system for defects on the outer surface of steamed buns as described in any one of claims 1 to 9, characterized in that: Includes the following steps: Step 1: The image acquisition and preliminary preprocessing module acquires the surface image I(x,y) of the bun through a camera device and performs preprocessing to obtain the enhanced image Ic(x,y). Step 2: The regional gray-level fluctuation analysis module divides the enhanced image Ic(x,y) into blocks of fixed size, calculates the mean gray level μ(i,j) and variability δ(i,j) of each block, and constructs the regional gray-level fluctuation index ΔG(i,j). Step 3: The temperature and humidity mapping model construction module calculates the environmental disturbance response factor Ψ(i,j) for each image region using the regional grayscale fluctuation index ΔG(i,j). Step 4: The nonlinear brightness normalization mapping module performs pixel-level dynamic adjustment on the enhanced image Ic(x,y) using the environmental disturbance response factor Ψ(i,j) to obtain the normalized image Ino(x,y). Step 5: The local contrast enhancement and defect response module performs texture edge enhancement processing on the normalized image Ino(x,y) and calculates and obtains the local high-frequency anomaly response map Ef(x,y). Step 6: The defect identification and visual output module performs intensity threshold judgment on the local high-frequency abnormal response map Ef(x,y), generates a defect area mask Mdef(x,y), obtains the defect proportion Dare, and performs hierarchical judgment.
Citation Information
Cited By
Lightweight convolutional neural network construction method and system for glue pudding defect detection
CN122089740A