A film structure weld defect detection method based on image recognition
By employing techniques such as fixed-position imaging, grayscale conversion, and segmented mapping, the problem of low defect segmentation accuracy caused by continuous grayscale changes in images of lap welds of flexible materials with unequal thicknesses was solved. This enabled efficient identification and accurate localization of internal defects, improving the reliability and applicability of the detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-07
- Publication Date
- 2026-03-24
AI Technical Summary
Existing technologies, when inspecting lap welds of flexible materials with unequal thicknesses, suffer from blurred defect boundaries due to continuous changes in image grayscale, resulting in low segmentation accuracy and an inability to effectively identify internal defects, thus increasing the safety risks of membrane structure engineering.
Using fixed-position imaging, grayscale conversion, segmented mapping, and boundary tracking logic, images are acquired through high-resolution equipment, environmental parameters are recorded, grayscale values are adjusted, region segmentation and defect edge feature extraction are performed, and the defect type and location are confirmed by combining grayscale threshold logic.
It significantly improves the defect segmentation accuracy of lap welds of flexible materials with unequal thickness, can identify internal defects, enhance the reliability and engineering applicability of detection, and ensure the geometric consistency and grayscale response stability of image data.
Smart Images

Figure CN121068631B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of nondestructive testing technology for materials, specifically to a method for detecting defects in membrane structure welds based on image recognition. Background Technology
[0002] Membrane structures, as a lightweight and high-strength building form, are widely used in large stadiums, exhibition halls, and transportation hubs. Their core component is a flexible membrane material (such as PVC or PTFE membrane), connected by lap welds. The quality of these welds directly affects the overall stability and durability of the structure; internal defects (such as pores or cracks) can lead to structural failure or safety hazards. Therefore, image recognition-based weld defect detection methods have become a key technology for ensuring the quality of membrane structure engineering. This method acquires weld images, performs grayscale analysis and defect segmentation, and identifies potential problems in a non-destructive manner. However, existing detection technologies face significant challenges when dealing with lap welds of flexible materials with unequal thicknesses.
[0003] In the prior art, CN102279190A discloses a method for detecting surface defects in laser-welded plates of unequal thickness. This method utilizes structured light vision and data fitting processing to acquire and analyze surface images of the weld, primarily targeting the identification of defects such as surface cracks during the laser welding process. By fitting the weld contour curve, this patent achieves preliminary detection of surface morphology, but its focus is on extracting the geometric features of surface defects, without fully considering the internal grayscale changes caused by the uneven thickness of flexible materials. Another prior art, CN103914838A, discloses a method for identifying defects in industrial X-ray weld images. This method processes weld images by normalizing, filtering, and segmenting sample images to extract defect features. This patent is applicable to the general identification of industrial welds and emphasizes the standardization of image preprocessing steps, but it also ignores the unique characteristics of lap welds of unequal-thickness flexible materials, namely the continuous grayscale changes caused by the material thickness gradient, thus affecting the accurate segmentation of defect edges.
[0004] The limitations of the aforementioned existing technologies lie in the fact that, when applied to lap welds of flexible materials with unequal thicknesses, continuous changes in image grayscale can blur defect boundaries, leading to low segmentation accuracy and an inability to effectively identify internal defects. Specifically, in the lap region of flexible membrane materials, due to uneven thickness, the image grayscale gradient exhibits a continuous transition, making it difficult for traditional filtering and segmentation algorithms to distinguish between defective and normal weld areas, resulting in a high rate of false detections or false negatives. This not only reduces detection efficiency but also increases the safety risks of membrane structure engineering. Therefore, there is an urgent need for an image recognition method that can overcome the interference of continuous grayscale changes and improve the accuracy of defect segmentation to meet the actual needs of membrane structure weld inspection. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention provides an image recognition-based method for detecting defects in membrane structure welds. This method solves the problem in traditional methods where the continuous variation in image grayscale of lap welds made of flexible materials with unequal thickness leads to low defect segmentation accuracy and an inability to effectively identify internal defects.
[0006] To achieve the goals mentioned in the background section regarding overcoming interference from continuous grayscale variations and improving defect segmentation accuracy, this invention provides the following technical solution:
[0007] A method for detecting weld defects in membrane structures based on image recognition, comprising:
[0008] S1: Acquire the original image of the lap weld of flexible materials with unequal thickness, use an imaging device in a fixed position to obtain a complete view of the weld area, cover the whole picture of the lap joint, and record the image acquisition parameters.
[0009] S2: Perform grayscale conversion on the acquired raw image, converting the color or multi-channel image into a single-channel grayscale image, unifying the image data format, and maintaining the original distribution of pixel values;
[0010] S3: Analyze the thickness gradient distribution in the grayscale image, identify the continuous grayscale changes caused by regions of unequal thickness, use piecewise mapping to adjust the grayscale values, equalize the contrast of the gradient transition region, and generate the adjusted grayscale image.
[0011] S4: Based on the adjusted grayscale image, perform region segmentation to separate the weld area from the non-weld area, use boundary tracing logic to lock the specific range of the lap weld, and mark the boundary coordinates of the separated area;
[0012] S5: Within the separated weld area, extract the edge features of potential defects, use continuous pixel comparison to locate gray-level anomalies, form defect candidate areas, and record the pixel range of each candidate area.
[0013] S6: Classify and verify the defect candidate region, combine edge features and grayscale threshold logic to confirm the existence and type of internal defects, and output the verified defect information.
[0014] In a preferred embodiment, original images of the lap weld of flexible materials with unequal thickness are acquired. A complete view of the weld area is obtained using an imaging device at a fixed position, covering the entire lap joint. The image acquisition parameters are recorded, including:
[0015] A preliminary assessment of the lap weld area is conducted, and thickness differences are measured using contact or non-contact thickness gauges to identify the thickness of the superimposed layers and guide camera exposure and light source adjustment.
[0016] Employ a high-resolution industrial camera with a wide-angle lens, fixed to a bracket or robotic arm, mounted above or to the side of the weld, adjust the distance and align with the center line;
[0017] Get a complete view, covering the weld and the buffer areas on both sides;
[0018] Use diffuse light sources to reduce surface reflection and control light intensity and ambient temperature and humidity;
[0019] During calibration, grayscale cards are used to adjust exposure, uncompressed images are stored, parameters and environmental factors are recorded, and the data is stored in relation to structured files.
[0020] In automated inspection, the equipment moves along the weld seam path and records the position synchronously.
[0021] In a preferred embodiment, the acquired raw image is converted to grayscale, transforming a color or multi-channel image into a single-channel grayscale image, unifying the image data format, and preserving the original distribution of pixel values, including:
[0022] Based on the acquired original image, the color or multi-channel image is converted to grayscale. After checking the channel structure, the red, green and blue channels are merged into a single grayscale value. The coefficients are calibrated according to the acquisition parameters.
[0023] Unify the pixel value range to a standardized grayscale band while maintaining the original relative pixel distribution;
[0024] Perform histogram verification and readjust the merging coefficients for areas of deviation in the distribution curve;
[0025] Save grayscale images in a lossless format and embed acquisition parameters through metadata;
[0026] Adaptation logic is implemented for different membrane materials, pre-filtering operation in the channel separation stage is applied to high reflective surfaces, and the weld foreground area is preferentially isolated for semi-transparent materials.
[0027] Integrated into the automation system, it reads parameters and dynamically adjusts the compensation coefficient;
[0028] In large-scale image processing, the merging and verification process is performed in blocks, and adjacent blocks are overlapped and stitched together.
[0029] In a preferred embodiment, the process includes analyzing the thickness gradient distribution in a grayscale image, identifying continuous grayscale changes caused by regions of unequal thickness, adjusting grayscale values using piecewise mapping, equalizing the contrast of gradient transition regions, and generating an adjusted grayscale image, including:
[0030] The converted grayscale image is loaded into the processing system, and the acquisition parameters are read to assist in scanning and verify the grayscale value coverage range.
[0031] Scan pixels line by line along the weld seam path, divide the strips to statistically analyze grayscale characteristics, and construct a thickness gradient curve;
[0032] Pixel sequence trend analysis identifies areas of continuous grayscale variation, and profile verification confirms the influence of thickness gradient.
[0033] The image is processed in segments according to the rate of change, and the grayscale value of each segment is adjusted.
[0034] The grayscale distribution in the transition region is optimized through multiple mappings.
[0035] The adjusted image is generated by stitching the images together, and the mapping parameters are saved to metadata.
[0036] The mapping strategy is dynamically adjusted according to environmental conditions, and specific pretreatment or compensation operations are performed for different membrane materials.
[0037] In a preferred embodiment, based on the adjusted grayscale image, region segmentation is performed to separate the weld area from the non-weld area. Boundary tracing logic is used to pinpoint the specific extent of the lap weld and to mark the boundary coordinates of the separated area, including:
[0038] Load the adjusted grayscale image and read the mapping log to assist in the scan;
[0039] Separate weld and non-weld areas by calculating the grayscale mean value through global traversal as a benchmark, comparing and classifying pixels one by one, and dynamically adjusting the threshold.
[0040] Boundary tracing is performed based on the separation mask. Navigation is performed along pixels from the starting point. The path is extended according to the adjacent grayscale difference, the main weld path is locked and the sub-region is marked, and a closed contour is generated to cover the overlapping range.
[0041] Perform neighborhood consistency checks to confirm classification, introduce direction prediction and tracking points for curved welds, and bridge the connection boundary of the interrupted grayscale area.
[0042] In a preferred embodiment, it includes:
[0043] Mark the boundary coordinates and extract the key node coordinates and bounding box parameters;
[0044] Based on the collected parameters calibrated to physical dimensions, the main weld seam is labeled as Level 1 and the sub-region as Level 2, and metadata is embedded in a structured format;
[0045] Apply a high-reflectivity film to filter out reflections, and cut the main body area with a semi-transparent film;
[0046] Large welds are separated into coarse and fine layers;
[0047] Stabilize the baseline for grayscale compensation in outdoor applications;
[0048] The integrated automation system outputs coordinates in real time to support positioning and reporting, and performs threshold judgment, tracking and annotation in a multi-threaded manner.
[0049] In a preferred embodiment, within the separated weld area, edge features of potential defects are extracted, grayscale anomalies are located using continuous pixel comparison to form defect candidate regions, and the pixel range of each candidate region is recorded, including:
[0050] Load the separated weld area image and boundary coordinates, and crop the image using bounding box parameters;
[0051] Traverse the pixel grid line by line, obtain the gray values of the pixels and their neighbors, and calculate the absolute difference to mark the edge points;
[0052] Continuous pixel chain analysis was performed, sequences were extracted along the weld direction, sequences with consistent trends were identified as outlier groups, and the cross-section was expanded laterally to verify and merge the two-dimensional regions.
[0053] Aggregate adjacent anomaly groups and form a closed candidate region through bridging logic;
[0054] For different materials, noise filtering is applied to highly reflective surfaces, and defective foregrounds are preferentially isolated in semi-transparent areas.
[0055] In a preferred embodiment, it includes:
[0056] Record the pixel range of the candidate region, extract the boundary nodes to calculate the bounding rectangle, record the coordinate pairs and center coordinates, and calibrate to the physical size based on the acquisition parameters;
[0057] The density of outliers is labeled and embedded in metadata using a structured format;
[0058] By statistically analyzing the grayscale distribution and defect location of samples, a threshold is set, the boundary point is automatically selected, and the range is dynamically calibrated in combination with the collected parameters.
[0059] Extraction and recording are performed in layers during batch processing.
[0060] In a preferred embodiment, the defect candidate region is classified and verified. By combining edge features and grayscale threshold logic, the existence and type of internal defects are confirmed, and the verified defect information is output, including:
[0061] Load the candidate region list, crop the grayscale image according to the coordinate range, limit the pixel subset and remove the background region;
[0062] Sort by outlier density, prioritize processing high-density areas, extract edge point sets for each area and construct connected chains, and classify them according to geometric shape;
[0063] Collect grayscale statistical features and integrate edge geometry with grayscale values for classification;
[0064] Set grayscale threshold logic and determine the initial threshold using the zone mean coefficient;
[0065] The existence of an edge is confirmed by combining threshold judgment with edge morphology, and the type is marked based on the proportion of edge points.
[0066] Merge adjacent and similar candidate regions into a larger region;
[0067] Output a structured report, including defect number, type, existence status, pixel range, center coordinates and statistical parameters, saved in JSON or XML format, and embedding the collected parameters.
[0068] Compared with existing technologies, this invention provides a method for detecting weld defects in membrane structures based on image recognition, which has the following advantages:
[0069] 1. This invention, starting from the original image of the weld area, employs fixed-position imaging, clear recording of acquisition parameters, multi-exposure fusion, grayscale conversion and gradient mapping, segmented scanning, and sub-image stitching to significantly improve the recognizability of grayscale gradients caused by thickness variations in the image. Furthermore, by combining segmented mapping to adjust grayscale values, unifying pixel value distribution, and enhancing contrast in transition areas, the grayscale blurring phenomenon originally caused by thickness variations is suppressed, thus providing a clearer input for region segmentation. Then, through boundary tracking, region separation, and candidate region extraction logic, abnormal grayscale values within the weld area are effectively identified. By focusing on the degree or edge features and using structured parameter recording, a precise mapping from the pixel level to the physical size is achieved. Finally, in the classification and verification stage, a method combining edge geometry analysis and dynamic adjustment of grayscale threshold is adopted. This method can identify internal defects such as cracks, pores, and interlayer voids in the lap joint area with obvious thickness gradient changes. The detection results are output in a structured manner, including defect type, location, severity, and physical range. This solves the problem in traditional methods where the continuous grayscale change of the image of the lap weld of unequal thickness flexible materials leads to low defect segmentation accuracy and inability to effectively identify internal defects.
[0070] 2. This invention ensures the geometric consistency and grayscale response stability of image data by employing a fixed-position, high-resolution device and recording environmental and optical parameters during the imaging stage. During the grayscale conversion and mapping stage, it unifies pixel distribution and enhances grayscale changes caused by thickness gradients, transforming the grayscale features of the thickness superposition region from continuous blurring to discernible gradient changes. In the candidate region extraction stage, it utilizes segmented scanning, sub-image stitching, and joint edge and grayscale determination logic to accurately locate abnormal grayscale regions. In the final verification stage, it integrates edge geometry, set grayscale thresholds, thickness gradient data, and acquisition parameter correction to classify and confirm different types of defects, and outputs their structured results for subsequent maintenance or management. This overcomes the difficulty of identifying grayscale changes caused by thickness gradients in traditional technologies and significantly improves the detection accuracy, reliability, and engineering applicability of internal defects in lap welds. Attached Figure Description
[0071] Figure 1 This is a flowchart of a membrane structure weld defect detection method based on image recognition according to the present invention. Detailed Implementation
[0072] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0073] Example: Figure 1 A method for detecting weld defects in membrane structures based on image recognition is presented, including:
[0074] S1: Acquire the original image of the lap weld of flexible materials with unequal thickness, use an imaging device in a fixed position to obtain a complete view of the weld area, cover the whole picture of the lap joint, and record the image acquisition parameters.
[0075] S2: Perform grayscale conversion on the acquired raw image, converting the color or multi-channel image into a single-channel grayscale image, unifying the image data format, and maintaining the original distribution of pixel values;
[0076] S3: Analyze the thickness gradient distribution in the grayscale image, identify the continuous grayscale changes caused by regions of unequal thickness, use piecewise mapping to adjust the grayscale values, equalize the contrast of the gradient transition region, and generate the adjusted grayscale image.
[0077] S4: Based on the adjusted grayscale image, perform region segmentation to separate the weld area from the non-weld area, use boundary tracing logic to lock the specific range of the lap weld, and mark the boundary coordinates of the separated area;
[0078] S5: Within the separated weld area, extract the edge features of potential defects, use continuous pixel comparison to locate gray-level anomalies, form defect candidate areas, and record the pixel range of each candidate area.
[0079] S6: Classify and verify the defect candidate region, combine edge features and grayscale threshold logic to confirm the existence and type of internal defects, and output the verified defect information.
[0080] S1: Acquire the original image of the lap weld of flexible materials with unequal thickness, use an imaging device at a fixed position to obtain a complete view of the weld area, covering the entire lap joint, and record the image acquisition parameters. Specifically, the implementation is as follows:
[0081] First, a preliminary assessment is conducted on the lap weld area, measuring the thickness difference at the lap joint. The thickness range (e.g., 0.5 mm to 2 mm) is confirmed using a contact thickness gauge or a non-contact laser thickness gauge, and the thickness of any potential superimposed layer at the lap joint (e.g., 1 mm to 3 mm) is identified. This thickness assessment result guides subsequent camera exposure, lens selection, and light source adjustment to avoid overexposure or underexposure caused by thickness gradients, ensuring that the dynamic range of the acquired image is sufficient to cover subtle changes in grayscale gradient.
[0082] Select a fixed-position imaging device as the primary acquisition tool, employing a high-resolution industrial camera or digital imaging system with a resolution of no less than 2000×1500 pixels to ensure clear image details. The device should be equipped with a wide-angle lens with a focal length ranging from 28 mm to 50 mm to accommodate a wide field of view at the overlap of flexible film materials and reduce distortion caused by material bending. The imaging device should be fixed using a dedicated bracket, tripod, or robotic arm, installed above or to the side of the weld, maintaining a distance of 20 cm to 50 cm from the weld surface, and adjusted according to the weld length and available space. The device must be aligned with the weld centerline using an adjustment mechanism (such as a screw adjuster or pneumatic positioning system) and the optical axis must be perpendicular to the weld plane to ensure the acquisition of a two-dimensional view without tilt or perspective distortion. Avoid handheld device-induced shaking or angular deviations to ensure consistent geometric projection in each acquired image, which is particularly suitable for overlapping welds of flexible materials with significant thickness gradients.
[0083] When acquiring a complete view of the weld area, the entire overlapping area must be covered. This means not only photographing the weld itself, but also including a buffer area extending 5 to 10 centimeters on each side of the weld to provide a background for comparison. If the weld is long (e.g., more than 1 meter), a segmented scanning mode should be used: starting from one end of the weld, move the device position along the length at predetermined intervals (e.g., 5 centimeters) to acquire sub-images segment by segment. The recommended size for each segment image is 1920×1080 pixels. Adjacent sub-images should overlap by at least 30% so that subsequent software can stitch them together into a complete view and perform geometric correction to eliminate stitching errors. This logic of covering the entire view stems from the possible thickness gradient and internal stress concentration areas that may exist at the overlapping weld in flexible membrane structures. The grayscale changes often diffuse from the overlapping edge to the center. If the view is incomplete, minor edge defects (such as pores or initial cracks) may be missed, thus affecting the comprehensiveness of the inspection.
[0084] Lighting and environmental condition control are equally critical. A uniformly diffuse light source (such as a ring-shaped LED array) should be placed around the imaging equipment to provide diffuse light with a color temperature of approximately 4000K to the weld area, thereby reducing the reflection effect of the film material surface on the lens. The light source intensity should be controlled between 500 lux and 800 lux to prevent excessive enhancement of grayscale differences in areas of uneven thickness. The ambient temperature should be maintained between 20°C and 25°C, and the humidity below 60% to prevent deformation caused by thermal expansion and contraction of flexible materials, thereby ensuring the stability and consistency of the overlapping structure. If inspecting transparent or translucent film materials, a backlighting mode should be used: place the light source below the film to enhance the grayscale contrast of internal defects, and record the lighting mode in the parameters.
[0085] Before and during data acquisition, equipment calibration and real-time monitoring should be performed. A standard grayscale card can be placed next to the weld seam, and exposure parameters can be adjusted using the automatic white balance function or manual correction to ensure that the image grayscale range covers 0 to 255 (the entire grayscale spectrum). The exposure time should be set between 1 / 60 and 1 / 125 of a second, and the ISO value should be set between 100 and 400 in shutter priority mode to balance noise control and detail preservation. If the thickness assessment shows a significant change at the thick end of the overlap, a slightly longer exposure time can be used, while a shorter exposure time should be used at the thin end. The difference can be distinguished by recording the parameters. During the acquisition process, the equipment display screen should be monitored in real time to ensure that there is no overexposure or underexposure in the weld seam area. If any abnormality occurs, the light source angle or equipment height should be adjusted in time before acquiring the data again.
[0086] Image formats should be uncompressed (such as RAW or TIFF) to preserve original pixel data and avoid artifacts introduced by JPEG compression. After acquisition, image data should be backed up to storage media immediately, and file integrity should be verified through checksum calculations to prevent data loss. Detailed information should be recorded, including equipment model, lens focal length, aperture size, exposure time, ISO value, gain value, light source intensity, light source color temperature, ambient temperature, humidity, geometric coordinates of the equipment and weld (e.g., XY coordinate system with weld origin), equipment tilt angle (e.g., applicable to curved welds), sensor temperature, noise level, operator ID, timestamp, and serial number. The above parameters should be associated with the image file one by one using JSON or XML structure, or embedded in the image file through EXIF metadata to ensure that the data chain from acquisition to processing is traceable and verifiable.
[0087] In addition, priority should be given to equipment with a wide dynamic range (supporting HDR mode) to address grayscale peaks caused by overlapping reflective points and thickness variations on the flexible membrane material surface. When fixing the equipment, ensure the relative positional error between the support and the weld is less than 1 mm; a laser alignment instrument can be used for assisted positioning. For curved welds, calculate the equipment tilt angle based on the radius of curvature and record the angle value. The view width should be at least twice the weld width to fully capture grayscale variations in the thickness transition zone. If integrated into an automated production line, the imaging equipment can be mounted at the end of a robotic arm and moved along the weld path at a speed controlled at 10 cm / s. Sampling intervals and positions are recorded synchronously, and parameters are uploaded to the database in real time via a PLC system. For outdoor membrane structure inspection, a light shield should be used to block natural light interference, the light source should be switched to a portable battery-powered LED, and the image resolution should be increased to 4K to capture subtle thickness variations.
[0088] In batch inspection scenarios, multiple weld images are acquired in parallel and the image files are named with a unique weld ID prefix. The name management logic facilitates subsequent processing. The images and parameter files can be packaged and transmitted to the processing module as subsequent input, directly supporting continuous grayscale change analysis and defect segmentation.
[0089] S2: Perform grayscale conversion on the acquired raw image, transforming a color or multi-channel image into a single-channel grayscale image, unifying the image data format, and preserving the original distribution of pixel values. Specifically, this is implemented as follows:
[0090] Based on the acquisition and parameter recording of the original images of the unequal thickness flexible material lap weld completed in S1, the acquired color or multi-channel images are converted to grayscale. The purpose is to unify the multi-dimensional image data into a single-channel grayscale format, thereby laying a standardized input foundation for subsequent thickness gradient analysis. First, the images acquired from S1 are usually in color (e.g., RGB three-channel) or multi-channel format with additional metadata. The image covers the entire weld area and is accompanied by detailed acquisition parameters (such as exposure time, aperture value, ISO, light source intensity, etc.). Before conversion, the image is loaded and the recorded acquisition parameters are queried to determine whether compensation is needed for the channel merging ratio or grayscale mapping to avoid grayscale distortion caused by differences in acquisition conditions.
[0091] Next, the image channel structure is checked: If it is a color RGB image, the values of the red, green, and blue channels are combined into a single grayscale value according to the standard weighted average logic. Traditionally, the coefficients are typically 0.299 for the red channel, 0.587 for the green channel, and 0.114 for the blue channel. However, in this method, to accommodate the influence of thickness gradients on brightness in lap welds of unequal-thickness flexible materials, the above coefficients are appropriately calibrated based on the acquisition parameters (such as light source intensity and gain value) to compensate for highlights or shadows. For example, when the light source intensity is higher than... When the setting is 500 lux, the red channel coefficient can be adjusted to 0.28, the green channel to 0.60, and the blue channel to 0.12 to enhance the visibility of grayscale changes at the thin end; ensure that the continuity of grayscale gradient from thick to thin at the weld is preserved, and avoid breakage or jumps during the merging process; if the image contains a fourth channel (such as an alpha transparency channel) or a depth channel, this channel should be stripped first, and only the main color channels should be merged to ensure that the final grayscale image only reflects the physical thickness and surface grayscale differences, rather than transparency or background depth information interference;
[0092] While generating grayscale images, it is necessary to unify the format and pixel value range; standardize all pixel values and map them to the range of 0 to 255, while maintaining the relative relationship between the original pixel values; that is, the pixel grayscale values before and after merging should satisfy: if the grayscale response of pixel A in the original color image is higher than that of pixel B (where A and B are two arbitrarily selected different pixels), then the relationship A>B should still be maintained in the grayscale image; for this purpose, the conversion program adopts a linear mapping method, without applying gamma correction or nonlinear transformation, to preserve the original brightness gradient characteristics to the maximum extent; if the original image is 16-bit channel depth, it should first be linearly scaled to 8-bit format: that is, all 16-bit pixel values are divided by 256 and mapped to the range of 0-255, during which nonlinear transformation or resampling blur is prohibited to ensure that the grayscale slope caused by the thickness change of the overlapping area remains unchanged;
[0093] Simultaneously, histogram verification should be performed before and after image conversion. After conversion, the grayscale histogram of the grayscale image is extracted and compared with the weighted histograms extracted from each channel of the original color image. If the peak offset exceeds the preset threshold (e.g., offset of more than 5%), or if the grayscale distribution curve shows breaks or abnormal jumps, it is necessary to revert to the channel merging coefficient or exposure compensation step for readjustment and perform the conversion again. This ensures that the grayscale image faithfully reflects the brightness changes in the original multi-channel image in terms of numerical distribution, thereby supporting the reliability of subsequent thickness gradient analysis.
[0094] After generating the grayscale image, the image should be saved in a lossless format (such as TIFF or BMP). At the same time, the acquisition parameters recorded in S1 (including but not limited to device model, lens focal length, aperture, exposure time, ISO, gain, light source intensity, color temperature, ambient temperature, humidity, device position coordinates, device tilt angle, sensor temperature, etc.) should be embedded in the image file header as metadata or saved as an accompanying JSON / XML log file. It should be ensured that the image file name corresponds one-to-one with the parameter record file. The file association logic constructs a traceable data chain from acquisition to conversion and provides convenience for subsequent processing module calls.
[0095] To accommodate the characteristics of different membrane structure materials, this grayscale conversion step also includes adaptation logic. For high-reflectivity surface films, a pre-filtering operation should be applied before merging channels: for example, using low-pass filtering or median filtering per channel pixel value to remove high-frequency noise, followed by standard channel merging, thereby avoiding isolated peaks caused by high-reflectivity points in the grayscale image. This pre-filtering operation is limited to the channel separation stage and does not change the grayscale distribution curve after merging. For translucent films, the weld foreground area should be isolated first: using the weld boundary coordinates recorded in S1, the main weld area is automatically trimmed or calibrated, and only the pixels in this area are converted to avoid background transmitted light interfering with the grayscale distribution. The parameter record should be marked with "backlight mode" to distinguish it from general transmission / diffuse reflection acquisition.
[0096] In production line or field application environments, this grayscale conversion module can also be integrated into automated inspection systems. The system can read the acquired parameters in real time and dynamically adjust the channel merging coefficient or exposure compensation coefficient. For example, if the humidity is higher than the set 60% and the temperature is higher than 30℃, the humidity or thermal expansion compensation coefficient (such as multiplying by 0.98) is applied to the channel values before merging to correct the offset caused by material state changes to the grayscale response. The conversion program should be optimized to millisecond-level response to adapt to the production rhythm of membrane structure weld inspection. In batch processing scenarios, the average grayscale distribution can be calculated after grayscale conversion of images of the same weld from different perspectives to improve the robustness of gradient recognition.
[0097] Furthermore, when processing large weld seam images (such as those exceeding 1000 pixels in width or 1 meter in length), this method supports an image block merging process: the original image is divided into several sub-blocks (e.g., 512×512 pixel blocks), each of which independently undergoes channel merging, normalization, and verification processes, and then these are sequentially stitched together to form a complete grayscale image. The stitching process requires adjacent blocks to overlap by at least 30%, and seam errors are corrected through feature matching or histogram matching of overlapping areas within sub-blocks to ensure the continuity of overall grayscale changes is not interrupted by block boundaries. After the sub-blocks are processed, a complete grayscale image and associated conversion logs are generated.
[0098] S3: Analyze the thickness gradient distribution in the grayscale image, identify continuous grayscale changes caused by regions of unequal thickness, adjust grayscale values using piecewise mapping, equalize the contrast in gradient transition regions, and generate the adjusted grayscale image. The specific implementation is as follows:
[0099] First, the single-channel grayscale image output by S2 is loaded into the image processing system. The image has been standardized in data format and includes its acquisition parameters (such as exposure time, gain value, light source intensity, device position coordinates, etc.). The system reads these parameters to assist in the initial image scanning, such as confirming whether the grayscale values cover the complete range from 0 to 255, and detecting whether there is saturation or an overall response that is too low. The initial loading logic ensures a seamless connection between the analysis starting point and the conversion stage, ensuring that image information is not lost or distorted due to the previous processing.
[0100] During the analysis phase, a global scan is performed on the thickness gradient distribution in the grayscale image. The processing logic starts from the weld area of the image and traverses the pixel values row by row or column by column along the weld length (or according to preset coordinates) to identify the spatial variation pattern of grayscale values. For example, in the image of the overlapping part, a gradual transition from the thicker part (lower grayscale) to the thinner part (higher grayscale) can generally be observed. This change reflects the physical characteristics of the material's superposition thickness. During the scanning process, the image can be divided into multiple horizontal strips (e.g., each strip is set to a width of 10 pixels), and the grayscale mean and variance of each strip are calculated to generate a gradient curve related to the thickness. In addition, the previous thickness measurement results (e.g., thickness gradually changing from 1 mm to 1.5 mm) can be used as a physical reference, prioritizing the corresponding grayscale slope change segments to enhance the physical relevance of the analysis.
[0101] The system identifies continuous grayscale changes caused by areas of unequal thickness. This identification can be achieved by extracting pixel value sequences along the weld centerline and observing continuously increasing or decreasing segments within the sequence. If a segment exceeds a preset threshold (e.g., 20 pixels) and its grayscale change trend is stable (rather than abrupt changes), it is marked as a "continuous change area." During the identification process, multiple vertical profiles can be extracted from the weld edge towards the center, and the grayscale profiles of each profile can be compared. If multiple profiles show similar change trends, the area is confirmed to be a gradient region caused by thickness variations. Cross-validation logic avoids isolated noise or reflection points from entering the area, and the grayscale distribution maintained by S2 ensures that subtle changes are captured (e.g., grayscale fluctuation amplitude can be controlled within a relative unit of 0.05).
[0102] After identifying the gradient region, the segmented mapping and adjustment stage begins. The processing logic first divides the weld grayscale image into several sub-segments (e.g., low gradient, medium gradient, and high gradient segments) based on the gradient profile, with each segment reflecting a different thickness gradient level. The segmentation criteria can be based on the grayscale change rate (e.g., grayscale increase rates below a certain threshold T1 within pixels / unit distance are classified as low gradient segments, those between T1 and T2 as medium gradient segments, and those above T2 as high gradient segments, where T1 and T2 are the grayscale change rates in the image). Within each sub-segment, grayscale values are mapped using linear stretching or compression. For example, for a low-contrast segment, whose pixel grayscale range is originally 50-100, it can be mapped and expanded to 30-120, thereby improving the contrast within the area. For thin segments, low grayscale valleys can be expanded and thick peaks can be moderately compressed to make the overall grayscale distribution more balanced. During the mapping process, the relative order of pixels within the segment is strictly maintained to ensure that the adjusted grayscale image still accurately reflects the original thickness information. This mapping is entirely based on statistics within the sub-segment (e.g., mean, extreme values) and does not introduce external data.
[0103] To further enhance the visualization and recognition performance of the transition area, a contrast equalization logic for the gradient transition region is also included. This logic is based on an iterative mapping mechanism: first, a preliminary mapping is performed on all identified continuous change areas; then, a global histogram analysis is performed on the adjusted image (e.g., calculating entropy and grayscale distribution smoothness); if the entropy is lower than the preset expected value (e.g., 4.5 bits), or the grayscale distribution is still blurry, the sub-segment with the steepest gradient change is selected as the target for secondary mapping; in the secondary mapping, a local stretching logic is applied to this sub-segment: based on the mean grayscale value of its neighborhood, the pixel value is shifted to increase the grayscale difference by at least 20%, but distortion of non-gradient segments is avoided; this iteration is performed at most three times to balance efficiency and effect; the grayscale blurry boundary at the thick-thin junction of the lap weld can be sharpened economically and effectively, enhancing the boundary locking capability of subsequent region segmentation;
[0104] After adjustment, the final grayscale image output is generated. It is generated by stitching the adjusted pixel segments of each sub-segment back to the original image coordinate system, and its size and position are consistent with the original grayscale image. The output image is accompanied by a mapping log, such as the adjustment coefficient, response segment position, and application count of each sub-segment. These are all embedded in the image file as metadata or accompanied by a JSON / XML format log file. If large welds are to be processed (such as those with a width of more than 1000 pixels or a length of more than 1 meter), image segmentation technology can be used: the original image is divided into several 512×512 pixel sub-blocks, each of which is independently recognized, segmented, mapped, and verified, and then stitched together to reconstruct the overall output. When stitching, adjacent sub-blocks are required to overlap by at least 30%, and the seam error is corrected by feature matching or histogram matching of the overlapping area to ensure that the gradient continuity is not interrupted due to segmentation.
[0105] To adapt to industrial or real-time on-site detection systems, this analysis and processing can also be integrated into production line environments: the system can read grayscale images and their acquisition parameters in real time, and adjust the recognition threshold and mapping coefficient according to dynamic conditions such as humidity, temperature, and light intensity; for example, if the system detects that the humidity is higher than 60% and the temperature is higher than 30℃, then before mapping, all sub-segment pixel values are multiplied by a compensation coefficient (such as 0.98) to correct the grayscale shift caused by material thermal expansion; the overall processing logic can be executed in a multi-threaded manner: one thread performs gradient region recognition, and another thread performs mapping adjustment, reducing the latency to the millisecond level, thereby meeting production cycle requirements; in a laboratory environment, the grayscale profiles before and after adjustment can be compared to verify the gradient recognition and mapping effects, thereby enhancing the reliability of the method;
[0106] Regarding material type differences, the system incorporates adaptive logic. For high-reflectivity PVC films, low-pass filtering or median filtering is prioritized to remove high-frequency reflection noise before the identification and mapping process is executed. For semi-transparent PTFE films, the weld foreground area should be isolated first, background transmission interference should be skipped, and a backlight mode identifier should be added to the annotation parameters. When identifying continuously changing areas, if isolated noise points are detected, the system can apply neighborhood smoothing (e.g., 3×3 window averaging) before extracting the sequence to reduce mislabeling. For extreme gradient areas with thickness differences exceeding 1 mm, the mapping logic can select curve segmentation (non-linear mapping) to better match the natural gradient changes of the membrane structure.
[0107] S4: Based on the adjusted grayscale image, perform region segmentation to separate the weld area from the non-weld area. Use boundary tracing logic to lock the specific range of the lap weld and mark the boundary coordinates of the separated area. The specific implementation is as follows:
[0108] First, the grayscale image output by S3 is loaded into the processing system, and its mapping log (including mapping coefficients of each sub-segment, segment position, device acquisition coordinates, scaling ratio, etc.) is read. The system uses these parameters to perform an initial scan to confirm whether the overall distribution after grayscale equalization of the image has improved the edge contrast of the overlapping parts as expected, and to ensure that the segmentation starting point and the previous adjustment stage are seamlessly connected.
[0109] After loading, the system enters the first stage: initial separation of the weld area and non-weld area. The system globally traverses the grayscale image and calculates the grayscale mean of the entire image as the initial segmentation benchmark. Subsequently, pixel-by-pixel comparison is performed: pixels with grayscale values higher than the mean are initially classified as the film material background area (non-weld area), while pixels with grayscale values lower than the mean are initially marked as weld candidate areas. The threshold-based comparison logic adapts to the characteristics of enhanced light absorption and lower grayscale caused by the overlapping thickness of the weld. To avoid edge blurring caused by thickness gradients, a dynamic adjustment logic is adopted: the threshold can be appropriately reduced in areas with significant gradient changes (based on the gradient profile in S3). For example, the grayscale threshold is lowered by about 10% at the thickness boundary to ensure that the continuous transition area is also included in the weld candidate mask. This ensures that the gradient area is not misclassified as background while maintaining the purity of the background film area, forming a binary-like mask.
[0110] Subsequently, the second stage begins: boundary tracking and locking of the main region of the lap weld. Edge navigation is performed on the preliminary weld candidate mask, scanning from a preset starting point (such as the upper left corner of the image) to the first boundary pixel encountered, and clockwise or counterclockwise tracking logic is initiated. During the tracking process, the grayscale difference between adjacent pixels is judged: if the grayscale difference between adjacent pixels is less than a preset value (e.g., 5 grayscale units) and the pixel connectivity satisfies 8-neighborhood or 4-neighborhood, the boundary path is expanded. The continuity judgment is adapted to the lap weld of flexible membrane structure, because its boundary is mostly linear or slightly curved, and the grayscale changes smoothly along the boundary. If a branch is encountered (such as the extension of a side crack), the system prioritizes the identification of the main weld path, marks it as the first-level boundary, and marks the branch path as the second-level sub-region to ensure the complete locking of the main lap range. After the tracking is completed, a closed polygonal outline is generated, covering the weld area from the lap start point to the end point.
[0111] The third stage is boundary coordinate annotation and calibration. For the locked contour, the coordinates of its key nodes are extracted, including each inflection point and equally spaced sampling points, forming a list of (x, y) coordinate pairs. At the same time, the coordinates of the region center and the bounding box parameters (minimum x, maximum x, minimum y, maximum y) are recorded. If the grayscale image has scaling or acquisition ratio offset (based on the device position coordinates or scaling ratio recorded in S1), the system multiplies the coordinates by the corresponding scaling factor to calibrate to the actual physical size (e.g., millimeters or centimeters). The coordinate annotation also includes hierarchical information: the first level represents the main weld boundary, and the second level represents the sub-crack or auxiliary lap area. All annotation records are saved in JSON or XML format and embedded in the image metadata. This structured annotation provides high-precision input for subsequent edge feature extraction.
[0112] Furthermore, the system incorporates various extension and adaptation mechanisms during implementation. To mitigate the impact of image noise, the system performs a neighborhood consistency check before initial threshold judgment: classification results are only confirmed when more than a certain percentage (e.g., 75%) of pixels in a pixel's neighborhood are of the same category, thus improving robustness. The boundary tracking logic introduces a direction prediction mechanism for curved weld seams: predicting the next candidate point based on the distance and direction vector of the most recent boundary pixels to avoid deviating from the main path in grayscale fluctuation areas. If grayscale interruptions exist in the weld seam (e.g., due to material folding or reflection causing grayscale anomalies), bridging logic is employed: when the gap is less than, for example, 10 pixels, linear interpolation is performed to connect adjacent boundary segments, thereby avoiding misjudgments due to splitting.
[0113] The system has been adapted to different material types and application scenarios. For images of high-reflectivity PVC film, high-frequency reflection filtering logic can be used during the initial separation: low-pass filtering is used to reduce false edges in flat background areas before segmentation. For semi-transparent PTFE film, due to significant background transmission interference, the system prioritizes cropping the main weld area, excluding the background before segmentation and annotation. For welds of large membrane structures (length exceeding 1 meter or width exceeding 1000 pixels), the system adopts layered execution: global coarse separation is performed first, followed by fine tracking within sub-regions to improve processing efficiency. For outdoor inspection scenarios, if the acquisition parameters indicate unstable lighting or large environmental changes, a global grayscale compensation coefficient is applied before segmentation to stabilize the background baseline.
[0114] In practical integrated applications, the segmentation module can be embedded in an automated inspection system and connected in series with imaging equipment, grayscale conversion modules, and defect recognition modules. It receives the output image and mapping log from step S3, performs segmentation and coordinate output in real time, and transmits the coordinate results to the control system or database, supporting robot arm positioning, automatic defect marking, or report generation. The software process is designed as multi-threaded: one thread performs threshold judgment, one thread performs boundary tracking, and one thread performs coordinate annotation to reduce latency to tens of milliseconds. For laboratory scenarios, the automatically annotated coordinates are compared with the results of manual annotation to evaluate the locking accuracy, facilitating subsequent module calls and audit tracking.
[0115] S5: Within the separated weld area, extract the edge features of potential defects, use continuous pixel comparison to locate grayscale anomalies, form defect candidate areas, and record the pixel range of each candidate area. Specifically, the implementation is as follows:
[0116] First, load the adjusted grayscale image output by S4 and its corresponding boundary coordinates, bounding box parameters, etc.; read the minimum x, maximum x, minimum y, and maximum y coordinates recorded in the bounding box, and use them to crop the image, keeping only the pixels inside the weld seam overlap area to eliminate interference from the non-weld seam background, ensuring that the starting point of the extraction logic is seamlessly connected with the previous segmentation results, thereby avoiding false detections caused by pixels in the external area.
[0117] After cropping, the edge feature extraction stage begins. The pixel grid of the weld area is traversed row by row. For each pixel, its gray value and the gray values of its neighboring pixels are obtained, and the absolute difference between the center pixel and its neighboring pixels is calculated. When the difference exceeds a preset threshold (e.g., 10 gray units, which can be adjusted according to the specific material and acquisition parameters), the center pixel is marked as an "edge point". This neighborhood comparison logic is based on the edge detection principle commonly used in industrial image processing, distinguishing gray-level abrupt change areas to lock in defects such as cracks and pores. In addition, since the gray-level changes at the thick-thin junction of the overlap have been enhanced by gradient mapping in the previous steps, the identification of edge points is more reliable, thereby improving sensitivity and reducing false background detection.
[0118] Next, the system performs continuous pixel chain analysis to locate grayscale anomaly point sequences; it extracts pixel value sequences along the weld length or along the image centerline to determine sequences with continuous increasing or decreasing trends; if a sequence length reaches a preset number of pixels (e.g., three or more consecutive pixels) and the grayscale change direction remains consistent, then the sequence is located as an "anomaly point group"; subsequently, it verifies the lateral expansion profile: for the anomaly point group, the system extracts lateral pixel chains in its left and right neighborhoods; if the lateral pixel differences also satisfy the anomaly trend, then the point group is combined into a defect candidate center; the continuous pixel chain logic is adapted to flexible membrane structures with unequal thicknesses, because thickness changes at the overlap or internal pores are usually represented by continuous grayscale changes rather than isolated scattered points, thereby improving the positioning accuracy;
[0119] Based on all located anomalies, the system proceeds to the candidate region formation stage. Anomalies are aggregated according to distance and spacing: when the horizontal or vertical distance between two anomaly groups is less than a preset number of pixels (e.g., 3 pixels), the system bridges them into a common candidate region; when multiple subgroups are close together and have small spacing, they are merged into a closed candidate region. This bridging logic considers the potential network or series distribution of weld defects in flexible materials. Finally, the system outputs several candidate regions, each encompassing a group of anomalies and their extended neighborhood. Each candidate region corresponds to a grayscale anomaly region that may be caused by thickness variations or lap stress concentration, matching high-risk inspection areas.
[0120] After the candidate regions are output, the system records the pixel range and coordinate information of each region; it extracts the boundary nodes of each candidate region and calculates the minimum bounding rectangle, recording the coordinates of the top left corner (x1, y1) and the bottom right corner (x2, y2), as well as the total number of pixels in the region and the center coordinates (xc, yc); if a scaling or sampling ratio factor is detected in the image (based on the device position coordinates or pixel-to-physical unit conversion ratio recorded in S1), the system automatically converts the pixel coordinates to standard physical size units (e.g., millimeters or centimeters); in addition, to support subsequent priority processing, the density of outliers is recorded for each candidate region, and priority is marked based on this density (e.g., high / medium / low); all candidate region information is saved in a structured format (e.g., JSON or XML) and embedded in image metadata or a separate log file; this recording logic not only ensures the traceability of defect candidate regions, but also facilitates defect classification, physical location, and report generation;
[0121] The preset thresholds used (e.g., grayscale difference of 10 units, number of consecutive pixels of 3 points, bridging spacing of 3 pixels) are not arbitrarily set. First, in the initial stage, several typical lap weld samples are selected, covering the thickness range (e.g., membrane material thickness of 0.5mm to 2mm, lap overlay layer of 1mm to 3mm), and the entire process from S1 to S4 in the acquisition system is completed. Then, the grayscale images generated from these samples are statistically analyzed, including grayscale histogram distribution, neighborhood grayscale jump amplitude, and continuous pixel chain length. Based on histogram analysis, an automatic threshold selection technique can be used to identify the boundary points between low-gray-level and high-gray-level groups in the image's gray-level distribution. Then, using manually annotated defect locations as a reference, the automatically generated thresholds are compared with the gray-level jump amplitude, continuous length of defect points, and neighborhood expansion range in real defects. Through this verification, empirical thresholds such as: gray-level difference exceeding approximately 10 units, continuous pixel chain length ≥ 3 pixels, and anomaly group spacing less than approximately 3 pixels can be derived. Subsequently, to adapt to different membrane structure materials, thickness variations, and acquisition parameters (such as light source intensity, exposure time, and gain value), these empirical thresholds can be set to an adjustable range. For example, the grayscale difference threshold can be adjusted between 8 and 15 units; the number of consecutive pixels can be between 2 and 5 pixels. Finally, in the actual detection system, this threshold setting process is embedded in the software module. After the system loads the acquisition parameters of this image (such as light source intensity, ambient temperature, and exposure time), it can automatically recommend a preliminary threshold for the current image. If necessary, the operator or the system can fine-tune it through rapid verification (such as repeated testing on known defect samples) to form the final threshold used for this weld inspection. Thus, the preset threshold used has both statistical basis and dynamic correction, thereby ensuring reliability and applicability in the inspection of lap welds of flexible materials with unequal thickness.
[0122] S6: Classify and verify the defect candidate region. Combining edge features and grayscale threshold logic, confirm the existence and type of internal defects, and output the verified defect information. The specific implementation is as follows:
[0123] First, the system loads the candidate region list generated in step S5, where each region has recorded parameters such as the top-left corner coordinates (x1, y1), bottom-right corner coordinates (x2, y2), center coordinates, total number of pixels, outlier density, and priority. Based on the recorded coordinate range, the system limits the original grayscale cropped image to a subset of pixels within each candidate region, stripping away non-candidate background areas to ensure that the verification analysis accurately focuses on the extracted target area and minimizes external pixel interference. The cropping and loading logic closely follows the output of step S5, ensuring that candidate region verification starts from the correct starting point.
[0124] Next, the system sorts the candidate areas by anomaly density from high to low, prioritizing the areas with the highest density. This sorting logic is based on the experience that internal defects such as cracks or pores in membrane structure lap welds are often distributed in point groups, chains, or clusters. For each candidate area, the system extracts the edge point set generated by S5 edge detection and constructs these edge points into connected chains. The system classifies the connected chains into three categories based on their geometric morphology: if the chain extends into a thin straight line or is slightly curved, it is initially judged as a crack defect; if the chain closes into a ring structure, it is initially judged as a pore defect; if the chain is scattered or network-like, without obvious extension or closure characteristics, it is judged as a scattered / network defect. On this basis, the system also collects gray-level statistical features of the candidate areas (including gray-level mean, gray-level variance, and edge point gray-level distribution) as auxiliary judgment criteria, forming an integrated classification logic of edge geometric features and gray-level numerical features. This improves the verification accuracy for the complex gray-level behavior of thickness superposition, light absorption changes, and light transmission changes in lap welds of flexible materials with unequal thickness.
[0125] Meanwhile, this method sets grayscale threshold logic to support the judgment of defect existence and type. Specifically, the system determines the initial grayscale threshold by multiplying the overall grayscale mean of the image corresponding to the candidate area by a certain coefficient (e.g., 0.8). If the grayscale values of most edge points in the candidate area are lower than the threshold, the system strengthens the possibility that the area is indeed defective. In addition, this threshold is adjusted according to the thickness gradient profile identified in step S3: in sections with high thickness gradients, since thickness changes may cause continuous grayscale changes, the system appropriately lowers the threshold (e.g., from 0.8 to 0.7 or lower) to encompass grayscale gradient areas; while in thin areas with low gradients, the ratio can be maintained or slightly increased to enhance the distinguishing ability. This dynamic adjustment mechanism ensures that the threshold is neither too sensitive to cause false alarms nor too conservative to cause false negatives.
[0126] After combining grayscale threshold judgment and edge morphology classification, a final confirmation logic is implemented for each candidate region: when the proportion of edge points (i.e., the number of edge points / the total number of pixels in the candidate region) in a candidate region exceeds a certain preset ratio (e.g., 30%) and its grayscale value is generally lower than the threshold, the system confirms that there is a defect in the region; subsequently, according to its classification as crack, porosity, or scattered defects, its type is specifically labeled; for example: if a linear chain with a length ≥ 20 pixels and a width ≤ 3 pixels is detected, and its grayscale value is lower than the threshold, it is labeled as a crack; if the number of nodes in a closed chain is ≥ 6... If the maximum diameter is ≤10 pixels, it is marked as a pore; if the scatter density is high, the chain is discontinuous but the overall structure is abnormal, it is marked as a mesh / scatter defect; the category determination also refers to the thickness difference parameter recorded in step S1: when the sample thickness difference is large (e.g., the superposition exceeds 2mm), the verification logic is more inclined to internal defects (e.g., pores, interlayer voids) rather than surface cracks; to prevent false positives, if the gray level is abnormal but the edge point chain is discontinuous or the number of points is insufficient, the candidate area is marked as an "unconfirmed defect" state, thus forming a rigorous and traceable verification judgment mechanism;
[0127] Furthermore, the system supports multi-candidate region merging logic: if two or more adjacent candidate regions show similar defect types, have close boundaries (e.g., the distance between the lower right / upper left coordinates of their enclosing rectangles is less than 3 pixels), and have similar outlier density, they are merged into a larger defect region to avoid splitting an actual defect into multiple outputs. All confirmed defects are output in a structured report format. Each report data item includes: defect number, type, presence status (True / False), pixel range (x1, y1, x2, y2), center coordinates, total number of pixels, number of outliers, outlier percentage, severity score (e.g., High / Medium / Low), related assets such as original image links, and acquisition parameters for traceability. The report uses JSON or XML format for easy system storage, display, and subsequent analysis. This output data includes both verified defect information and retains the complete data chain of the acquisition, conversion, analysis, extraction, and verification processes, ensuring traceability from the original image to the final defect list and facilitating manual review and engineering applications.
[0128] In this embodiment, the solution first involves acquiring original images of the weld seam using a fixed-position imaging device during the initial detection phase. This ensures a complete view of the overlapping area and records the acquisition parameters, providing reliable foundational data for subsequent steps. Next, the original image undergoes grayscale conversion, unifying multi-channel data into a single-channel format while maintaining the original pixel value distribution to simplify analysis and preserve thickness gradient information. This conversion directly prepares an image for thickness gradient distribution analysis. In this analysis, areas with continuous grayscale variations are identified, and values are adjusted through segmented mapping to balance contrast, generating an optimized grayscale image that improves the accuracy of subsequent processing. Based on the adjusted image, further region segmentation is performed, separating the weld seam from non-weld seam areas. Boundary tracking is used to pinpoint the specific range, and coordinates are marked to accurately locate the target area. This segmentation locks in the extraction range, extracting potential defect edge features within the weld seam area. Grayscale anomalies are located through continuous pixel comparison, forming defect candidate areas, and the pixel range is recorded to support verification. Finally, the candidate areas are classified and verified. The type of defect is confirmed by combining edge features and grayscale threshold logic, and verification information is output. The entire process data is then integrated to complete the detection.
[0129] It should be noted that this invention can be deployed on the device itself to realize embedded applications, or it can run on a PC or other terminal with a user interface, thereby meeting various hardware environments and usage requirements.
[0130] The above embodiments can be implemented, in whole or in part, by software, hardware, firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wireless or wired transmission; wired transmission methods include optical fiber, twisted pair, coaxial cable, etc.; wireless transmission includes infrared, microwave, etc. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center containing one or more sets of available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium. A semiconductor medium can be a solid-state drive.
[0131] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and modules described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0132] In the embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or modules may be electrical, mechanical, or other forms.
[0133] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0134] In addition, the functional modules in the embodiments of this application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module.
[0135] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0136] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0137] In conclusion, the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for detecting weld defects in membrane structures based on image recognition, characterized in that, include: S1: Acquire the original image of the lap weld of flexible materials with unequal thickness, use an imaging device in a fixed position to obtain a complete view of the weld area, cover the whole picture of the lap joint, and record the image acquisition parameters. S2: Perform grayscale conversion on the acquired raw image, converting the color or multi-channel image into a single-channel grayscale image, unifying the image data format, and maintaining the original distribution of pixel values; S3: Analyze the thickness gradient distribution in the grayscale image, identify the continuous grayscale changes caused by regions of unequal thickness, use piecewise mapping to adjust the grayscale values, equalize the contrast of the gradient transition region, and generate the adjusted grayscale image. S4: Based on the adjusted grayscale image, perform region segmentation to separate the weld area from the non-weld area, use boundary tracing logic to lock the specific range of the lap weld, and mark the boundary coordinates of the separated area; S5: Within the separated weld area, extract the edge features of potential defects, perform continuous pixel chain analysis to locate the gray-scale anomaly point sequence, form defect candidate areas, and record the pixel range of each candidate area. S6: Classify and verify the defect candidate region, combine edge features and grayscale threshold logic to confirm the existence and type of internal defects, and output the verified defect information. Based on the acquired original image, the color or multi-channel image is converted to grayscale. After checking the channel structure, the red, green and blue channels are merged into a single grayscale value. The channel merging coefficient is calibrated according to the acquisition parameters. Unify the pixel value range to a standardized grayscale band while maintaining the original relative pixel distribution; Perform histogram verification and readjust the merging coefficients for areas of deviation in the distribution curve; Save grayscale images in a lossless format and embed acquisition parameters through metadata; Adaptation logic is implemented for different membrane materials, pre-filtering operation in the channel separation stage is applied to high reflective surfaces, and the weld foreground area is preferentially isolated for semi-transparent materials. Integrated into an automated system, it reads parameters and dynamically adjusts exposure and thermal expansion compensation coefficients; In large-scale image processing, the merging and verification process is performed in blocks, and adjacent blocks are overlapped and stitched together. The converted grayscale image is loaded into the processing system, and the acquisition parameters are read to assist in scanning and verify the grayscale value coverage range. Scan pixels line by line along the weld seam path, divide the strips to statistically analyze grayscale characteristics, and construct a thickness gradient curve; Pixel sequence trend analysis identifies areas of continuous grayscale variation, and profile verification confirms the influence of thickness gradient. The image is processed in segments according to the rate of change, and the grayscale value of each segment is adjusted. The grayscale distribution in the transition region is optimized through multiple mappings. The adjusted image is generated by stitching the images together, and the mapping parameters are saved to metadata. Based on the collected light intensity, exposure time, gain, temperature and humidity, the thickness gradient change rate threshold and the stretching or compression coefficient of each segment grayscale mapping are adaptively calibrated, and the iterative equalization parameters are determined accordingly. Before mapping, for high-reflectivity films, median filtering or low-pass filtering is performed on high-brightness reflection points, and for semi-transparent films, foreground clipping is performed according to the weld range and baseline subtraction compensation is performed on the background transmission grayscale.
2. The method for detecting weld defects in membrane structures based on image recognition according to claim 1, characterized in that, Original images of lap welds in flexible materials of unequal thickness were acquired. A complete view of the weld area was obtained using an imaging device at a fixed position, covering the entire lap joint. The image acquisition parameters were recorded, including: A preliminary assessment of the lap weld area is conducted, and thickness differences are measured using contact or non-contact thickness gauges to identify the thickness of the superimposed layers and guide camera exposure and light source adjustment. Employ a high-resolution industrial camera with a wide-angle lens, fixed to a bracket or robotic arm, mounted above or to the side of the weld, adjust the distance and align with the center line; Get a complete view, covering the weld and the buffer areas on both sides; Use diffuse light sources to reduce surface reflection and control light intensity and ambient temperature and humidity; During calibration, grayscale cards are used to adjust exposure, uncompressed images are stored, parameters and environmental factors are recorded, and the data is stored in relation to structured files. In automated inspection, the equipment moves along the weld seam path and records the position synchronously.
3. The method for detecting weld defects in membrane structures based on image recognition according to claim 1, characterized in that, Based on the adjusted grayscale image, region segmentation is performed to separate the weld seam area from the non-weld seam area. Boundary tracing logic is used to pinpoint the specific range of the lap weld seam, and the boundary coordinates of the separated region are marked, including: Load the adjusted grayscale image and read the mapping log to assist in the scan; Separate weld and non-weld areas by calculating the grayscale mean value through global traversal as a benchmark, comparing and classifying pixels one by one, and dynamically adjusting the threshold. Boundary tracing is performed based on the separation mask. Navigation is performed along pixels from the starting point. The path is extended according to the adjacent grayscale difference, the main weld path is locked and the sub-region is marked, and a closed contour is generated to cover the overlapping range. Perform neighborhood consistency checks to confirm classification, introduce direction prediction and tracking points for curved welds, and bridge the connection boundary of the interrupted grayscale area.
4. The method for detecting weld defects in membrane structures based on image recognition according to claim 3, characterized in that, include: Mark the boundary coordinates and extract the key node coordinates and bounding box parameters; Based on the collected parameters calibrated to physical dimensions, the main weld seam is labeled as Level 1 and the sub-region as Level 2, and metadata is embedded in a structured format; Apply a high-reflectivity film to filter out reflections, and cut the main body area with a semi-transparent film; Large welds are separated into coarse and fine layers; Stabilize the baseline for grayscale compensation in outdoor applications; The integrated automation system outputs coordinates in real time to support positioning and reporting, and performs threshold judgment, tracking and annotation in a multi-threaded manner.
5. The method for detecting weld defects in membrane structures based on image recognition according to claim 1, characterized in that, Within the separated weld area, edge features of potential defects are extracted, and grayscale anomalies are located using continuous pixel comparison to form defect candidate regions. The pixel range of each candidate region is recorded, including: Load the separated weld area image and boundary coordinates, and crop the image using bounding box parameters; Traverse the pixel grid line by line, obtain the gray values of the pixels and their neighbors, and calculate the absolute difference to mark the edge points; Continuous pixel chain analysis was performed, sequences were extracted along the weld direction, sequences with consistent trends were identified as outlier groups, and the cross-section was expanded laterally to verify and merge the two-dimensional regions. Aggregate adjacent anomaly groups and form a closed candidate region through bridging logic; For different materials, noise filtering is applied to highly reflective surfaces, and defective foregrounds are preferentially isolated in semi-transparent areas.
6. The method for detecting weld defects in membrane structures based on image recognition according to claim 5, characterized in that, include: Record the pixel range of the candidate region, extract the boundary nodes to calculate the bounding rectangle, record the coordinate pairs and center coordinates, and calibrate to the physical size based on the acquisition parameters; The density of outliers is labeled and embedded in metadata using a structured format; By statistically analyzing the grayscale distribution and defect location of samples, a threshold is set, the boundary point is automatically selected, and the range is dynamically calibrated in combination with the collected parameters. Extraction and recording are performed in layers during batch processing.
7. The method for detecting weld defects in membrane structures based on image recognition according to claim 1, characterized in that, The candidate defect regions are classified and verified. By combining edge features and grayscale threshold logic, the existence and type of internal defects are confirmed, and the verified defect information is output, including: Load the candidate region list, crop the grayscale image according to the coordinate range, limit the pixel subset and remove the background region; Sort by outlier density, prioritize processing high-density areas, extract edge point sets for each area and construct connected chains, and classify them according to geometric shape; Collect grayscale statistical features and integrate edge geometry with grayscale values for classification; Set grayscale threshold logic and determine the initial threshold using the zone mean coefficient; The existence of an edge is confirmed by combining threshold judgment with edge morphology, and the type is marked based on the proportion of edge points. Merge adjacent and similar candidate regions into a larger region; Output a structured report, including defect number, type, existence status, pixel range, center coordinates and statistical parameters, saved in JSON or XML format, and embedding the collected parameters.
Citation Information
Patent Citations
A method for detecting surface defects in laser-welded plates of unequal thickness
CN102279190A
Method for identifying defects of industrial x-ray weld joint image
CN103914838A
Film material surface treatment defect detection method and system based on image recognition
CN119887755A
Defect identifying and marking system for concrete member
CN120522094A