A machine vision-based chemical fertilizer packaging bag breakage detection method and system

By combining dust concentration and image texture complexity for dust removal enhancement processing, and using frequency domain phase gradient and gray-level co-occurrence matrix models for adaptive weighted fusion, the problem of insufficient detection accuracy of fertilizer packaging bag detection system in dusty environment is solved, and high accuracy and robust damage identification are achieved.

CN121010598BActive Publication Date: 2026-01-27SHAANXI QINCHUAN FERTILIZER CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511538778.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-27
Publication Date
2026-01-27
Estimated Expiration
2045-10-27

AI Technical Summary

Technical Problem

In existing technologies, machine vision inspection systems for fertilizer packaging bags lack the ability to dynamically adapt to changes in the production environment, resulting in insufficient detection accuracy and robustness under dust interference. They are unable to effectively distinguish between minor damage and dust, thus affecting the accuracy of the inspection.

Method used

By acquiring dust concentration and image texture complexity, transmittance is calculated for dust removal and enhancement processing. Complementary detection is performed by combining frequency domain phase gradient model and gray-level co-occurrence matrix model. Adaptive weighted fusion of local texture intensity is adopted to achieve accurate identification of structural and non-structural defects.

Benefits of technology

It improves the accuracy and robustness of fertilizer packaging bag detection, and can effectively identify various types of damage in dusty and complex textured environments, reducing the false detection and missed detection rates.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121010598B_ABST
    Figure CN121010598B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of image data processing, and more particularly to a chemical fertilizer packaging bag damage detection method and system based on machine vision, which comprises the following steps: obtaining a packaging bag image and an ambient dust concentration, combining the image local texture complexity to calculate the transmittance, and using an atmospheric scattering model for dynamic dust removal enhancement; in parallel, using a frequency domain analysis first detection model for structural damage and a texture analysis second detection model for unstructured defects to complementarily detect the enhanced image; finally, according to the image local periodic texture intensity, adaptively weighting and fusing the double model results to obtain a final defect score and determine the damage. Through the whole process adaptive strategy from preprocessing, detection to fusion, the present application effectively overcomes the interference of dust and complex texture, and realizes accurate and robust detection of various damages.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image data processing technology, and in particular to a method and system for detecting damage to fertilizer packaging bags based on machine vision. Background Technology

[0002] In modern, highly automated production lines in the fertilizer industry, packaging is a core process for fertilizer production, requiring strict quality control over the surface of packaging bags, with damage being particularly critical. Packaging bags come into direct contact with granular or powdered fertilizer; damage to the bag directly compromises its seal, leading to significant fertilizer leakage, moisture absorption, and clumping, thus affecting product performance. Furthermore, damaged bags can cause fertilizer spillage, posing environmental and safety hazards.

[0003] Traditional packaging bag damage inspection mainly relies on manual visual inspection. This method requires a high level of experience and concentration from the inspectors, and prolonged work can easily lead to visual fatigue, resulting in missed detections and misjudgments. It is difficult to adapt to the needs of modern large-scale industrial production. Therefore, adopting machine vision systems to replace manual labor and improve the accuracy and efficiency of damage defect detection has become the mainstream trend in packaging quality inspection in the fertilizer industry.

[0004] Among related technologies, machine vision inspection technology for packaging bags still has significant shortcomings in damage detection: it lacks dynamic adaptability to changes in the production environment, making it difficult to guarantee actual detection accuracy and robustness. On the one hand, the dust concentration in fertilizer production environments is high, and dust easily adheres to the bag surface or disperses in the collection area, causing traditional algorithms that rely on fixed thresholds to fail, easily misjudging dust as damage or missing minor damage; on the other hand, when the packaging bag surface has complex textures or dust adhering to it, the ability to distinguish between minor damage and normal textures or dust is weak, making it impossible to determine the location of the damage, seriously affecting the accuracy of damage detection. Summary of the Invention

[0005] To address the technical problem of machine vision damage detection for packaging bags lacking dynamic adaptability to changes in the production environment and failing to adapt to image changes caused by bag surface texture, ultimately leading to false positives and false negatives, this invention provides solutions in the following aspects.

[0006] In a first aspect, the present invention provides a machine vision-based method for detecting damage to fertilizer packaging bags, the method comprising the steps of:

[0007] The process involves: acquiring an image of the packaging bag and the dust concentration in its environment; calculating the transmittance of each pixel in the packaging bag image based on the dust concentration and the texture complexity of the image; performing dust removal and enhancement processing on the packaging bag image using an atmospheric scattering model based on the transmittance to obtain an enhanced image; processing the enhanced image using a preset first detection model to obtain a first detection result representing structural damage; processing the enhanced image using a preset second detection model to obtain a second detection result representing unstructured defects; adaptively weighting and fusing the first and second detection results based on the local periodic texture intensity of the enhanced image to obtain a defect score for each pixel; and determining whether the packaging bag is damaged based on the defect score.

[0008] This invention achieves dynamic dust removal enhancement by acquiring dust concentration and combining it with image texture complexity, effectively solving the problem of image quality degradation caused by environmental dust interference. By employing two complementary detection models in parallel, one targeting structural damage and the other unstructured defects, it overcomes the limitation of a single model being unable to cover all defect types. Finally, based on local texture intensity, an adaptive weighted fusion strategy is designed to accurately determine which model detection results should be emphasized for different image regions. This invention possesses dynamic adaptability throughout the entire process from image preprocessing and defect detection to result fusion, improving the accuracy and robustness of detecting various types of damage to fertilizer packaging bags under harsh industrial conditions such as dust and complex textures.

[0009] Preferably, the step of processing the enhanced image using a preset first detection model to obtain a first detection result characterizing structural damage includes: processing the enhanced image using a sliding window, and performing the following operations on the image blocks within each sliding window: performing frequency domain analysis on the image blocks to obtain the phase gradient of each pixel within the image block; and nonlinearly amplifying and aggregating the difference between the phase gradient of each pixel and the average phase gradient of the image block in which the pixel is located to obtain the first detection result.

[0010] This invention detects structural damage by analyzing phase gradients in the frequency domain. Considering that phase information is extremely sensitive to structural abrupt changes, such as broken lines and cracks, this method can capture damage features more stably and reliably. In addition, by nonlinearly amplifying and aggregating gradient deviations, it can effectively suppress minor fluctuations caused by normal textures, while enhancing the dramatic gradient jumps caused by real damage. This achieves high signal-to-noise ratio extraction of defect signals and improves detection sensitivity and anti-interference ability.

[0011] Preferably, the nonlinear amplification and aggregation are achieved by calculating the first detection result, i.e., the phase gradient deviation index, which satisfies the following relationship:

[0012] ;

[0013] in, It is the first Phase gradient deviation index of an image patch; It is the first The total number of pixels in an image block; It is the first The coordinates of any pixel in an image block; It is the first A set of pixels within an image block; It is a preset non-linear penalty factor; It is the first Pixels within an image block The normalized squared magnitude of the deviation.

[0014] The exponential function relationship defined in this invention can effectively suppress minor deviations caused by normal textures or noise, while exponentially enhancing significant deviations caused by actual damage, thereby improving the signal-to-noise ratio of the defect signal and achieving high sensitivity detection of weak defects and strong robustness to background noise.

[0015] Preferably, obtaining the phase gradient of each pixel within the image block includes: performing a two-dimensional Fourier transform on the image block to obtain a spectrum; determining two orthogonal principal directions of the image block by detecting the energy peak positions in the spectrum; applying a filter along the two orthogonal principal directions to filter the spectrum to obtain a filtering result; and extracting the phase from the filtering result to obtain the phase gradient.

[0016] Preferably, the step of processing the enhanced image using a preset second detection model to obtain a second detection result characterizing unstructured defects includes: processing the enhanced image using a sliding window, and performing the following operations on the image blocks within each sliding window: performing gray-level co-occurrence matrix analysis on the image blocks to obtain contrast and entropy characterizing the texture properties of the image blocks, and multiplying the contrast with the entropy after logarithmic transformation to obtain the second detection result.

[0017] This invention uses gray-level co-occurrence matrix analysis and multiplies the contrast reflecting local gray-level jumps with the entropy reflecting local disorder after logarithmic transformation. This allows it to capture defect features that have both gray-level abrupt changes and randomness, effectively identifying unstructured anomalies such as stains and ink spots. It complements the first detection model and ensures coverage of various types of defects on the surface of packaging bags.

[0018] Preferably, the transmittance of each pixel in the packaging bag image satisfies the following relationship:

[0019] ;

[0020] in, It is the first Transmittance per pixel; It is the preset minimum transmittance; It is the first Local texture complexity per pixel; It is a preset texture complexity reference value; It is a preset attenuation rate control factor.

[0021] This invention combines minimum transmittance, representing the severity of the global environment, with texture complexity, representing the local detail of a pixel. This ensures a strong dust removal effect in smooth areas, while preserving more detail and reducing transmittance to close to 1 in textured areas. This strategy, based on a physical model and local adaptation, effectively removes the influence of dust while protecting the original texture details of the packaging bag, providing high-quality image input for subsequent accurate detection.

[0022] Preferably, obtaining the local texture complexity includes: calculating the local variance in the neighborhood of the pixel, and the horizontal gradient component and vertical gradient component of the pixel; weighting the horizontal gradient component and vertical gradient component using the local variance; and recording the magnitude of the weighted gradient vector as the local texture complexity.

[0023] Preferably, obtaining the preset texture complexity reference value includes: acquiring a reference image of a standard packaging bag in a clean environment; calculating the average local texture complexity of the reference image, and using it as the preset texture complexity reference value.

[0024] Preferably, the intensity of the local periodic texture is determined by calculating the sharpness of the peak value of the main frequency in the frequency domain of the enhanced image.

[0025] In a second aspect, the present invention provides a machine vision-based fertilizer packaging bag damage detection system. The machine vision-based fertilizer packaging bag damage detection system includes a memory and a processor. The memory stores computer program instructions, and when the computer program instructions are executed by the processor, the machine vision-based fertilizer packaging bag damage detection method of the first aspect of the present invention is implemented.

[0026] By adopting the above technical solution, a computer program for detecting damage to fertilizer packaging bags based on machine vision, as described in the first aspect of this invention, is generated and stored in a memory for loading and execution by a processor. This allows for the creation of a terminal device based on the memory and processor, facilitating its use.

[0027] The beneficial effects of this invention are as follows: First, this invention combines real-time dust concentration with the local texture complexity of the image to establish a dynamic transmittance calculation model, enabling the dust removal enhancement process to achieve adaptive adjustment. In areas with smooth backgrounds, a stronger dust removal effect is applied to restore the occluded image information; in areas with rich textures, more details are preserved to prevent over-smoothing. Second, a frequency domain phase gradient model for structural damage and a gray-level co-occurrence matrix model for unstructured defects are adopted to achieve complementary coverage of multiple defect types. Then, based on the periodic intensity of the local texture of the image, the results of the two models are adaptively weighted and fused. This invention improves the accuracy and robustness of detection through a multi-model complementarity and dynamic data-driven strategy. Attached Figure Description

[0028] Figure 1 A flowchart illustrating a machine vision-based method for detecting damage to fertilizer packaging bags, provided as an embodiment of the present invention;

[0029] Figure 2 This is a structural block diagram of a machine vision-based fertilizer packaging bag damage detection system provided in an embodiment of the present invention. Detailed Implementation

[0030] The first aspect of this invention provides a machine vision-based method for detecting damage to fertilizer packaging bags, such as... Figure 1 As shown, the method includes steps S100-S500:

[0031] Step S100: Obtain an image of the packaging bag and the dust concentration of the environment in which the packaging bag is located.

[0032] It should be noted that on high-speed fertilizer packaging production lines, image acquisition quality is often affected by environmental factors: airborne dust particles scatter light, forming a dust suspension layer that not only reduces image clarity but also obscures the fine textures of the packaging bag surface. Both types of interference can lead to missed detections and misjudgments in subsequent damage detection. Therefore, this step requires simultaneous acquisition of packaging bag images and corresponding key environmental parameters to provide data support for subsequent image quality compensation.

[0033] Specifically, image acquisition equipment, such as industrial cameras, is installed above the production line to capture images of the packaging bag surface in real time. Simultaneously, dust concentration sensors are deployed near the cameras to measure the dust concentration in the production line environment. In one feasible implementation, considering the high dust concentration in fertilizer workshops, a light absorption method, which offers greater stability for detecting high-concentration dust, can be used to obtain the dust concentration. Light absorption is an existing technology and will not be elaborated upon here. Furthermore, it is necessary to ensure that the acquisition time of the industrial camera and both types of sensors is consistent to achieve a one-to-one correlation between individual packaging bag images and dust concentration data.

[0034] At this point, the packaging bag image and dust concentration data were obtained.

[0035] Step S200: Based on the dust concentration and the texture complexity of the packaging bag image, calculate the transmittance of each pixel in the packaging bag image. Based on the transmittance, use an atmospheric scattering model to perform dust removal and enhancement processing on the packaging bag image to obtain an enhanced image.

[0036] It should be noted that, given the known impact of dust on the clarity of the acquired packaging bag images, this step requires addressing it. However, traditional global dust removal models are ineffective in this scenario because dust adhesion on the packaging bag surface exhibits significant non-uniformity: in smooth areas such as printed characters, dust coverage is thicker, resulting in low light transmittance; while in textured woven seams, dust particles are easily repelled or embedded, leading to relatively higher transmittance. Therefore, a transmittance model that combines dust concentration with the local texture of the packaging bag needs to be constructed. Local texture complexity is the core input parameter of this model; therefore, the definition of local texture complexity must be completed first, followed by integrating dust concentration data to build the complete model.

[0037] Specifically, this step includes steps S210-S230:

[0038] Step S210: Construct a local texture complexity description of the packaging bag's texture.

[0039] It should be noted that the packaging bag has a clear periodic texture, while the dust-covered or printed areas are relatively smooth. Based on the principle that the greater the grayscale difference, the stronger the local gradient change, the local gradient change of the packaging bag image can effectively reflect the complexity of the texture: the more complex the texture, the more obvious the gradient change; the smoother the area, the weaker the gradient change.

[0040] Based on the above logic, local texture complexity can be defined by calculating the gradient variance of a pixel along the horizontal and vertical gradient directions in its neighborhood. This local texture complexity satisfies the following relationship:

[0041] ;

[0042] in, It is the first Local texture complexity per pixel; , They are the first The gradient of a pixel along the horizontal and vertical gradient directions in its neighborhood; It is the first The grayscale variance of all pixels in the neighborhood of a pixel is used to quantify the dispersion of grayscale values ​​within the neighborhood and reflect the smoothness of the region. It is the maximum grayscale value of the image, such as 255.

[0043] In this relation, when the first... When the neighborhood of a pixel contains a periodic woven texture, the grayscale difference between adjacent pixels is large, the gradient changes are rich, and the gradient variance will stabilize at a high value, resulting in the final calculated... The larger the value, the higher the texture complexity and the less dust adheres; conversely, if the value decreases... When a pixel's neighborhood is blurred due to dust coverage or is located in a smooth printing area, the grayscale difference between adjacent pixels is small, and the gradient change is weak. In this case, its grayscale variance approaches 0, and the final calculated... The value also decreases, indicating low texture complexity and high dust adhesion.

[0044] As a preferred implementation, the neighborhood size can be set to Pixel: Considering that the smallest periodic structural unit of most fertilizer packaging bags is approximately Pixels The neighborhood of a pixel is sufficient to completely cover a single periodic structure, ensuring the accuracy of gradient and variance calculations; implementers can also adjust the density based on the actual texture of the packaging bag, such as using fine textures... Pixels, coarse texture Adjust the neighborhood size of pixels.

[0045] Step S220: Obtain the transmittance of each pixel.

[0046] It should be noted that the atmospheric scattering model is a classic model describing the propagation of light in a medium containing suspended particles. Its core logic is that when light passes through an environment containing particulate matter, it will be attenuated due to the scattering and absorption of the particles. The degree of attenuation is related to factors such as particle concentration and propagation path. This characteristic is consistent with the influence of dust particles on light in the fertilizer production environment. As suspended particulate matter, dust interferes with imaging light in essence with scattering phenomena. Therefore, constructing a transmittance model based on the atmospheric scattering model has a clear physical basis.

[0047] Based on this model, light transmittance should primarily be determined by dust concentration. Higher dust concentration leads to more significant light attenuation and lower transmittance. However, in packaging bag inspection scenarios, local texture features have a significant impact: areas with clear woven seams have less dust adhesion and a stronger structure that guides light penetration, resulting in better actual light transmission even at the same dust concentration. Conversely, smooth areas are more prone to dust accumulation, leading to easier light scattering and poorer transmittance. Therefore, it is necessary to further integrate local texture complexity into the atmospheric scattering model to construct a correlation model that simultaneously reflects dust concentration and local texture differences, making transmittance calculations more closely reflect the non-uniform dust coverage characteristics of the packaging bag surface.

[0048] Based on the above logic, the first The transmittance of each pixel satisfies the following relationship:

[0049] ;

[0050] in, It is the first Transmittance per pixel; This is a preset minimum transmittance, reflecting the effect of dust concentration on transmittance. The higher the dust concentration, the lower the transmittance. The lower; It is the first Local texture complexity per pixel; It is a preset texture complexity reference value; It is a preset attenuation rate control factor used to control the degree of nonlinearity in transmittance as texture complexity changes.

[0051] In this relation, through To normalize local texture complexity, in regions with high local texture complexity, the exponent term approaches... transmittance Approaching In smooth regions with low local texture complexity, transmittance Approaching transmittance Thus, texture-aware inverse reconstruction of packaging bag images was achieved.

[0052] It should be noted that the minimum transmittance This represents the minimum proportion of light that the sensor can still receive under the most severe dust-covered environment. Its setting can be determined in conjunction with environmental factors. If the dust control in the production environment is good, You can set it to a higher level, such as Conversely, if the production environment is extremely harsh, in order to ensure the restoration of the true signal in the darkest area, it is necessary to... Set it lower, such as In this embodiment, a value of 0.1 is preferred to ensure more stable reverse image restoration even in the darkest local areas. Attenuation rate control factor It is used to adjust the degree of nonlinearity in transmittance as it changes with texture complexity. The settings need to be determined by considering the texture characteristics and contrast of defects on the packaging bag itself. If the packaging bag has areas that are smooth and have indistinct texture features, then... Set it to a low level, such as This will cause the transmittance to change slowly with the texture, avoiding the introduction of too much noise; if the packaging bag has a clear woven texture and a high contrast is required between defects and normal areas, then... Set it to a higher level, such as This causes the transmittance of normal areas with complex textures to approach 1 more quickly, while the transmittance of defective areas with simple textures remains at 1. The difference between the defect signal and the background is amplified by the proximity of the defect signal, thereby enhancing dust removal. In this embodiment, option 3 is preferred to achieve the best balance between smooth dust removal and amplifying the defect signal.

[0053] It should also be noted that the preset texture complexity reference value When the system is first deployed or when changing to packaging bags of different materials, a reference image of the packaging bag in a clean environment can be captured, and the average texture complexity of the woven area on it can be calculated and recorded as the texture complexity reference value. .

[0054] Step S230: Obtain the enhanced image of the packaging bag based on transmittance.

[0055] It should be noted that the transmittance of each pixel is similar to that of a dust-free light-transmitting medium, which removes ambient light scattered by dust and compensates for the original defect signal attenuated due to dust obstruction. Therefore, this step can be based on which an enhanced packaging bag image without dust interference can be calculated.

[0056] Specifically, the atmospheric scattering physics model describes the relationship between dust-interferenced images, dust-free clear images, global atmospheric light, and transmittance, enabling image inversion. This step uses this model to calculate the enhanced packaging bag image. The global atmospheric light can be obtained by selecting the brightest element from the original packaging bag image. The average pixel value is used for calculation, and these areas are usually the most representative of the characteristics of ambient light. Atmospheric scattering physics models are existing technology and will not be elaborated on here.

[0057] At this point, the enhanced image of the packaging bag has been obtained.

[0058] Step S300: Process the enhanced image using a preset first detection model to obtain a first detection result characterizing structural damage.

[0059] It should be noted that after obtaining the enhanced image of the packaging bag, damage detection can be performed. The detection target is common structural damage to packaging bags, such as cracks and broken threads. Considering that the inherent periodic structure of woven materials like packaging bags exhibits a clear energy concentration in the frequency domain, and that Fourier transform can convert the image from the spatial domain to the frequency domain, clearly presenting this characteristic, and more importantly, the frequency domain phase information obtained after the transformation is not only less sensitive to changes in illumination, but also more sensitive to structural abrupt changes caused by damage, this step utilizes the frequency domain phase information obtained from the Fourier transform to detect structural damage.

[0060] Before utilizing the frequency domain phase information, a sliding window needs to be set up to perform a traversal analysis of the enhanced packaging bag image. The area covered by the sliding window is the image patch, and all subsequent calculations are performed on a single image patch. As a preferred implementation, the window size is set to... The pixel size is large enough to fully encompass multiple weave texture periods, meeting the frequency domain analysis requirements for periodic sample size, without smoothing out small-scale damage features due to excessive size. The movement step size is set to 1 pixel, which balances detection accuracy and computational efficiency, avoiding a surge in computation due to an excessively small step size, or missing small-sized damage due to an excessively large step size.

[0061] When the sliding window moves to any position, the following operations are performed on the image block within the current window: First, a two-dimensional fast Fourier transform is performed on the image block to obtain its spectrogram; second, by detecting the position of the energy peak in the spectrogram, the two orthogonal principal directions of the weave within the image block are identified. The angle at which the energy peak in the spectrogram is located is the principal direction of the weave texture, and the two perpendicular peak angles correspond to the orthogonal principal directions; next, the image block is filtered to extract the phase map along the corresponding orthogonal principal directions. A Log-Gabor filter can be used, which is an existing technology and will not be elaborated here; then, based on the phase map in the principal directions, the phase gradient components of each pixel in the two orthogonal principal directions are obtained by calculating the phase difference between adjacent pixels; finally, for each pixel in the image block, its phase gradient components in the two principal directions are combined into a two-dimensional phase gradient vector.

[0062] It should be noted that in the intact packaging area, the phase changes smoothly and periodically along the main direction, making the phase gradient of any pixel within the image block highly consistent with the average phase gradient vector of its neighborhood. However, when damage occurs, the original periodic structure is disrupted, causing a local interruption of phase continuity, and the phase gradient at the corresponding location will undergo a drastic jump. Based on these differences, this step characterizes the dispersion of the phase gradient field within the current image block by calculating the phase gradient deviation index. This index, by applying nonlinear amplification weights to local deviations, can achieve differentiated processing: effectively suppressing small, randomly generated gradient fluctuations; and amplifying the drastic gradient jumps caused by damage, thereby more clearly highlighting the characteristics of the damaged area.

[0063] Based on the above logic, the specific calculation of the phase gradient deviation index is as follows: First, calculate the average value of the phase gradient vectors of all pixels within the image block. Then, calculate the normalized squared deviation magnitude of each pixel within the image block. Finally, by applying an exponential function weight (with itself as the variable) to the normalized squared deviation magnitude of each pixel and then averaging the results, the phase gradient deviation index is obtained. The phase gradient deviation index satisfies the following relationship:

[0064] ;

[0065] in, It is the first Phase gradient deviation index of an image patch; It is the first The total number of pixels in an image block; It is the first The coordinates of any pixel in an image block; It is the first A set of pixels within an image block; It is the first Pixels within an image block Normalized squared deviation magnitude; It is a preset nonlinear penalty factor used to adjust the nonlinear amplification penalty term. The growth rate.

[0066] In this relation, through Multiplication achieves an exponential amplification of the drastic jumps caused by damage, and in a structurally intact image patch, all pixels... The values ​​are all relatively small. The value will approach 0; however, in image patches containing damage, even a single pixel... A value close to 1 will also lead to... It grows rapidly, thus enabling the differentiation of damaged areas.

[0067] The normalized squared deviation magnitude satisfies the following relationship:

[0068] ;

[0069] in, It is the first Pixels within an image block Normalized squared deviation magnitude; These are the coordinates of any pixel in the image block; It is the first A set of pixels within an image block; It is a pixel. The phase gradient vector; It is the first The average phase gradient of all pixels within an image block; It is the modulo operator; It is a maximum value function used to obtain the th digit. The maximum value of the squared magnitude of the deviation within each image block; It is a preset microvalue used to prevent the denominator from being 0, and can be set to 0.001.

[0070] In this relationship, the molecule This represents the deviation of the pixel gradient from the region's average gradient. The squaring operation enhances the weight of large deviations. The numerator is the magnitude of the squared deviation, and the denominator is the maximum value of the squared deviation magnitudes within the image patch corresponding to the current sliding window. This operation ensures... Scaled stably to Within the range.

[0071] It should be further noted that the value of the nonlinear penalty factor needs to be determined comprehensively by considering both the noise level of the image being inspected and the intensity of the defect signal to be detected. If the inherent noise of the image being inspected is large, or if the normal woven texture itself has many irregularities, it will cause a relatively obvious deviation in the square magnitude of the normal texture's intact areas. At this time, it can be Set to a smaller value, for example, preferably smaller It will make The growth is relatively gradual, effectively suppressing excessive amplification of normal texture fluctuations or noise. Conversely, if the goal is to detect very small, weak structural damage with low background noise levels, then... Set to a higher value, for example, preferably higher The value will make It grows exponentially, even due to tiny defects. Even if the difference is small, the amplifying effect of this weighting term can still affect the final nonlinear deviation index. A noticeable response is generated. In this embodiment, the nonlinear penalty factor... Preferred The implementers can set it up according to their needs.

[0072] Finally, by Value assigned to the first By sliding a window through the entire enhanced packaging bag image, the phase gradient deviation index of each pixel in the area covered by the image patch can be obtained. .

[0073] At this point, the phase gradient deviation index of each pixel has been obtained.

[0074] Step S400: Process the enhanced image using a preset second detection model to obtain a second detection result characterizing unstructured defects.

[0075] It should be noted that the phase gradient method is highly dependent on structural periodicity. The irregular periodic textures in areas such as printing and labeling on packaging bags can create detection blind spots. Unstructured defects such as stains and pinholes are also difficult to identify due to local random gray-level changes. However, the gray-level co-occurrence matrix (GLCM) can effectively characterize the gray-level distribution and spatial dependence of local textures by statistically analyzing the spatial co-occurrence relationships of gray levels in an image. It has good detection capabilities for these types of defects without periodicity. Therefore, this step introduces GLCM to supplement the detection of unstructured defects in the blind spots.

[0076] Specifically, to capture minute local defects, this step traverses the enhanced image using a small sliding window. For each image block covered by the sliding window, the gray-level co-occurrence matrix (GLCM) covering the local area of ​​its center pixel is calculated. Based on this GLCM, two key texture features are extracted: contrast and entropy. Contrast reflects the magnitude of local gray-level changes; abrupt gray-level changes at pinhole edges or stains will result in high contrast. Entropy reflects local disorder or complexity; random blemishes will have higher entropy than a uniform background. The size of this sliding window can be consistent with the size of the sliding window in step S300.

[0077] Considering that minute defects often simultaneously cause high local grayscale changes and high local disorder, this embodiment constructs a microscopic contrast entropy to synergistically amplify the responses of these two characteristics. The microscopic contrast entropy satisfies the following relationship:

[0078] ;

[0079] in, It is the first Image patches in Microscopic contrast entropy at the location; It is the first Image patches in GLCM contrast at the location; It is the first Image patches in The entropy at that point.

[0080] In this relationship, the logarithmic transformation is used to smooth the fluctuation range of the entropy value and ensure that in a completely uniform region... It can stably take values ​​of When both high contrast and high entropy exist near the center pixel, the multiplication operation will amplify the effect. The response value makes it a highly sensitive indicator for small, random defects. In the normal region, even if there is a certain contrast or entropy, as long as both are not simultaneously high, their product will remain at a low level, thus achieving effective localization of unstructured defects.

[0081] Finally, by assigned to No. By sliding a window through the entire enhanced packaging bag image, the phase gradient deviation index of each pixel in the area covered by the image patch can be obtained. .

[0082] At this point, the microscopic contrast entropy of each pixel in each image block has been obtained.

[0083] Step S500: Based on the local periodic texture intensity of the enhanced image, the first detection result and the second detection result are adaptively weighted and fused to obtain the defect score of each pixel; determine whether the packaging bag is damaged based on the defect score.

[0084] It should be noted that the structural damage corresponding to phase gradient deviation and the unstructured defects corresponding to microscopic contrast entropy are complementary. This step fuses the two detection results through weighted fusion to obtain the final defect probability map, thereby achieving comprehensive coverage and highly robust detection of all types of defects. The fusion weights are dynamically adjusted according to the characteristics of the local region. In woven regions with strong periodic structures, the results of phase gradient deviation should be trusted more; in printed or smooth regions with weak periodicity, the results of microscopic contrast entropy should be trusted more.

[0085] Based on the above logic, the defect scores of the weighted fused pixels satisfy the following relationship:

[0086] ;

[0087] in, It is the first Pixels in an image patch Defect score; It is the first Image patches in Microscopic contrast entropy at the location; It is the first Pixels in an image patch Phase gradient deviation; It is a pixel. The weighting coefficients are determined by the frequency domain peak sharpness of the image patch corresponding to the sliding window. High, sharp frequency domain peaks indicate that the region has strong periodicity. This sharpness value is mapped using the Sigmoid function to smoothly control its range. In a preferred implementation, the sharpening coefficient in the Sigmoid function... Possible values This is to enhance the steepness of the transition of the weighting coefficients between regions of strong and weak periodicity.

[0088] In this relationship, the frequency domain peak sharpness is high in the highly periodic weaving region, leading to a higher weight. Approaching 1, fusion result Mainly composed of Contribution; in the printing region with weak periodicity, the frequency domain peak sharpness is low. Approaching 0, fusion result Then mainly by contribute.

[0089] The final defect determination needs to be... Compared with a preset threshold, if If the value is greater than a preset threshold, the pixel is determined to be a defective pixel. In this embodiment, the preset threshold is preferably 0.8. 0.8 is a balance value between the false negative rate and the false positive rate determined based on a large number of sample tests. The implementer can also set it according to the requirements.

[0090] The second aspect of this embodiment provides a machine vision-based fertilizer packaging bag damage detection system, such as... Figure 2 As shown, the machine vision-based fertilizer packaging bag damage detection system includes a memory and a processor. The memory stores computer program instructions, and when the computer program instructions are executed by the processor, the first aspect of the present invention, a machine vision-based fertilizer packaging bag damage detection method, is implemented.

[0091] The machine vision-based fertilizer packaging bag damage detection system also includes other components well known to those skilled in the art, such as communication buses and communication interfaces. Their settings and functions are known in the art and will not be described in detail here.

[0092] In this invention, the aforementioned memory can be any tangible medium containing or storing a program that can be used or combined with an instruction execution system, apparatus, or device. For example, a computer-readable storage medium can be any suitable magnetic or magneto-optical storage medium, such as resistive random access memory (DRAM), dynamic random access memory (DRAM), static random access memory (SRAM), enhanced dynamic random access memory (DRAM), high-bandwidth memory, hybrid memory cube, etc., or any other medium that can be used to store desired information and can be accessed by an application, module, or both. Any such computer storage medium can be part of a device or accessible to or connected to a device.

[0093] The above are all preferred embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Therefore, all equivalent changes made in accordance with the structure, shape and principle of the present invention should be covered within the scope of protection of the present invention.

Claims

1. A method for detecting damage to fertilizer packaging bags based on machine vision, characterized in that, Including the following steps: Obtain images of the packaging bag and the dust concentration in the environment where the packaging bag is located; Based on the dust concentration and the texture complexity of the packaging bag image, the transmittance of each pixel in the packaging bag image is calculated. Based on the transmittance, an atmospheric scattering model is used to perform dust removal and enhancement processing on the packaging bag image to obtain an enhanced image. The enhanced image is processed using a preset first detection model to obtain a first detection result characterizing structural damage. This includes: processing the enhanced image using a sliding window, and performing the following operations on the image blocks within each sliding window: performing frequency domain analysis on the image blocks to obtain the phase gradient of each pixel within the image block; and nonlinearly amplifying and aggregating the difference between the phase gradient of each pixel and the average phase gradient of the image block in which the pixel is located to obtain the first detection result. The nonlinear amplification and aggregation are achieved by calculating the first detection result, i.e., the phase gradient deviation index, which satisfies the following relationship: ; It is the first Phase gradient deviation index of an image patch; It is the first The total number of pixels in an image block; It is the first The coordinates of any pixel in an image block; It is the first A set of pixels within an image block; It is a preset non-linear penalty factor; It is the first Pixels within an image block Normalized squared deviation magnitude; The enhanced image is processed using a preset second detection model to obtain a second detection result characterizing unstructured defects. This includes: processing the enhanced image using a sliding window, and performing the following operations on the image blocks within each sliding window: performing gray-level co-occurrence matrix analysis on the image blocks to obtain the contrast and entropy characterizing the texture properties of the image blocks, and multiplying the contrast with the entropy after logarithmic transformation to obtain the second detection result. Based on the local periodic texture intensity of the enhanced image, the first detection result and the second detection result are adaptively weighted and fused to obtain the defect score of each pixel; the defect score is used to determine whether the packaging bag is damaged.

2. The method for detecting damage to fertilizer packaging bags based on machine vision according to claim 1, characterized in that, The step of obtaining the phase gradient of each pixel within an image block includes: A two-dimensional Fourier transform is performed on the image block to obtain a spectrogram; By detecting the energy peak positions in the spectrum, the two orthogonal principal directions of the image block are determined; The spectrum is filtered by applying a filter along the two orthogonal principal directions to obtain a filtering result. The phase is then extracted from the filtering result to obtain the phase gradient.

3. The method for detecting damage to fertilizer packaging bags based on machine vision according to claim 1, characterized in that, The transmittance of each pixel in the packaging bag image satisfies the following relationship: ; in, It is the first Transmittance per pixel; It is the preset minimum transmittance; It is the first Local texture complexity per pixel; It is a preset texture complexity reference value; It is a preset attenuation rate control factor.

4. The method for detecting damage to fertilizer packaging bags based on machine vision according to claim 3, characterized in that, The acquisition of the local texture complexity includes: Calculate the local variance in the neighborhood of the pixel, as well as the horizontal and vertical gradient components of the pixel; The local variance is used to weight the horizontal and vertical gradient components; The magnitude of the weighted gradient vector is denoted as the local texture complexity.

5. The method for detecting damage to fertilizer packaging bags based on machine vision according to claim 3, characterized in that, The acquisition of the preset texture complexity reference value includes: Collect reference images of standard packaging bags in a clean environment; Calculate the average local texture complexity of the reference image and use it as a preset texture complexity reference value.

6. The method for detecting damage to fertilizer packaging bags based on machine vision according to claim 1, characterized in that, The intensity of the local periodic texture is determined by calculating the sharpness of the peak value of the dominant frequency in the frequency domain of the enhanced image.

7. A machine vision-based fertilizer packaging bag damage detection system, characterized in that, The machine vision-based fertilizer packaging bag damage detection system includes a processor and a memory. The memory stores computer program instructions, which, when executed by the processor, implement a machine vision-based fertilizer packaging bag damage detection method according to any one of claims 1-6.

Citation Information

Patent Citations

  • Cable identification method and system based on image processing

    CN118628983A

  • Inspection image enhancement method for safety production

    CN120765500A