A method for constructing an underwater artificial fracture data set under complex lighting conditions
By constructing an underwater artificial crack dataset under complex lighting conditions, the problem of insufficient training data for underwater crack recognition models was solved, and the robustness and detection accuracy of the models were improved, thus meeting the needs of engineering practice.
Patent Information
- Application Number
- CN202610080143.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-21
- Publication Date
- 2026-03-31
- Estimated Expiration
- 2046-01-21
AI Technical Summary
Existing technologies lack training data for underwater structure crack recognition models, and lack datasets with different lighting conditions, which limits detection accuracy. Furthermore, artificially created cracks have uniform and unrealistic shapes.
We constructed an underwater artificial crack dataset under complex lighting conditions. By collecting actual crack images, we generated 3D crack models, prepared standard concrete specimens with cracks, collected images under various lighting conditions, trained and extended the image style using a LoRA-tuned Stable Diffusion model, and combined it with image enhancement algorithms for annotation, resulting in a rich dataset.
It provides abundant training data for underwater crack identification models, improving the robustness of the models, meeting the needs of engineering practice, and saving experimental time and costs.
Smart Images

Figure CN121582766B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image dataset creation technology, and in particular to a method for constructing an underwater artificial crack dataset under complex lighting conditions. Background Technology
[0002] In the field of intelligent structural safety inspection, underwater structural safety is of paramount importance. Surface cracks in underwater structures are a key hidden danger affecting their safety, and timely and accurate identification of cracks is of great significance for ensuring the normal operation of transportation infrastructure and preventing major accidents. However, there are currently problems such as difficulty in obtaining real underwater data and a lack of publicly available data on underwater structural defects. The lack of other methods for obtaining underwater structural crack datasets poses many challenges to the identification of surface cracks in underwater structures.
[0003] Currently, the common method for artificially creating cracked concrete is destructive, which only produces near-straight cracks. However, in actual engineering projects, cracks of various shapes often appear due to the coupling of multiple factors. Therefore, destructive methods result in cracks with uniform and unrealistic morphology. Furthermore, most current image datasets are based on conventional lighting conditions, lacking datasets with different lighting scenarios. This leads to a shortage of training data for underwater crack recognition models and limits their detection accuracy. Summary of the Invention
[0004] This invention provides a method for constructing an underwater artificial crack dataset under complex lighting conditions to overcome the aforementioned technical problems.
[0005] To achieve the above objectives, the technical solution of the present invention is as follows:
[0006] A method for constructing an underwater artificial crack dataset under complex lighting conditions includes:
[0007] S1: Collect actual crack images, extract crack curves from the crack images, and generate crack coordinate information based on the crack curves;
[0008] S2: Construct a 3D model of the crack based on the crack coordinate information, and prepare standard concrete test blocks with cracks based on the 3D model of the crack;
[0009] S3: Place the standard concrete specimen with cracks in water, collect underwater specimen crack images under various preset lighting conditions, and preprocess the underwater specimen crack images under various preset lighting conditions. Classify them according to the lighting conditions to obtain preprocessed images under different preset lighting conditions. The preset lighting conditions include normal lighting conditions, dim lighting conditions, and uneven lighting conditions.
[0010] S4: Introduce a Stable Diffusion model based on LoRA fine-tuning. Input preprocessed images under different lighting conditions to train the aforementioned model. Optimize the trained model to obtain an optimized model. Use the optimized model to perform image style extension to obtain extended images under different lighting conditions. Combine these extended images with the preprocessed images under different lighting conditions to form unlabeled image data.
[0011] S5: An image enhancement algorithm is introduced to enhance the images in the unlabeled image data. The enhanced images are then labeled to obtain the label files of the enhanced images. The label files are matched one-to-one with the original unenhanced images to obtain the underwater artificial crack dataset under complex lighting conditions.
[0012] Furthermore, a 3D model of the crack is constructed based on the crack coordinate information, including:
[0013] S21. Standardize the crack coordinate information and scale the standardized coordinates according to the preset scaling parameters.
[0014] S22. Generate a 3D model of the crack based on the scaled coordinates.
[0015] Furthermore, the crack coordinate information is standardized, and the standardized coordinates are scaled according to preset scaling parameters, including:
[0016] S211: After verifying the data validity of the crack coordinate information, extract the original coordinate points of the crack from the crack coordinate information, and clean the original coordinate points according to the Euclidean distance, removing any one of the two coordinate points whose Euclidean distance is less than the preset value.
[0017] S212: Calculate the preset Euclidean distance between the original first and last points. If the distance is greater than the tolerance value, add a point with the same coordinates as the original first point after the original last point as the last point to form a closed polygon, thereby achieving the polygon closure process.
[0018] S213: Calculate the scaling ratio based on the target size, and scale the coordinates of the closed polygon based on the scaling ratio to obtain the scaled coordinates.
[0019] Furthermore, preprocessing was performed on underwater specimen crack images under various preset lighting conditions, including:
[0020] Step 1: Convert the underwater test block crack images under various preset lighting conditions from the RGB color space to the HSV color space;
[0021] Step 2: Introduce the Otsu thresholding method to adaptively threshold the image pixels of the S channel to generate a binary image;
[0022] Step 3: Locate all contours in the binary image; the contours are the boundaries of the white areas in the binary image.
[0023] Step 4: Select the contour with the largest area from all contours and set it as the contour of the standard test block for cracked concrete in the image.
[0024] Step 5: Calculate the minimum bounding rectangle of the maximum outline. Using the center point of the minimum bounding rectangle as a reference, set the clipping area based on the width and height of the outer rectangle; the aspect ratio of the clipping area is 1:1.
[0025] Step 6: Crop the original image based on the cropping region to obtain the cropped image. Convert the cropped image from the HSV color space to the RGB color space to obtain the preprocessed image.
[0026] Furthermore, a Stable Diffusion model based on LoRA fine-tuning is introduced. Preprocessed images under different lighting conditions are input to train the aforementioned model. The trained model is then optimized to obtain an optimized model. The optimized model is used for image style extension to obtain extended images under different lighting conditions, including:
[0027] S41. Use the BLIP visual language model to generate corresponding text descriptions for each input image. The text descriptions contain general quality words and style keywords to obtain image-text pairs.
[0028] S42. Introduce a pre-trained Stable Diffusion model. Inject the LoRA module into the weight matrix of all cross-attention layers of the U-Net module in the Stable Diffusion model to obtain a Stable Diffusion model fine-tuned based on LoRA.
[0029] S43. Input the image-text pair into the Stable Diffusion model based on LoRA fine-tuning, train the LoRA module, and optimize the trained model using the noise prediction loss function and the Adam optimizer to obtain the optimized model.
[0030] S44. Set semantic prompts and use the optimized model to generate a new image with the same style as the input image based on the semantic prompts, i.e., an extended image.
[0031] Furthermore, an image enhancement algorithm is introduced to enhance the images in the unlabeled image data. The enhanced images are then labeled to obtain label files. These label files are then mapped one-to-one with the original, unenhanced images to obtain a dataset of underwater artificial cracks under complex lighting conditions, including:
[0032] S51. Visual enhancement of dimly lit images in the image dataset is performed using an algorithm based on adaptive histogram equalization.
[0033] S52. Use the multi-scale Retinex algorithm to process images with uneven lighting in an image dataset;
[0034] S53. Use LabelMe's AI annotation function to annotate the images in the image dataset that are under normal lighting, enhanced dim lighting, and processed uneven lighting. Make secondary adjustments to the annotations in LabelMe to obtain the label file.
[0035] S54. Pair the unenhanced original images with the corresponding label files to construct an underwater artificial crack dataset under complex lighting conditions.
[0036] Furthermore, visual enhancement of dimly lit images in the image dataset is performed using an algorithm based on adaptive histogram equalization, including:
[0037] S511: Converts dimly lit images from the RGB color space to the YCrCb color space, separating the luminance and chrominance channels;
[0038] S512: Applying an adaptive histogram equalization algorithm that limits contrast to the luminance channel:
[0039] Divide the brightness channel into For local blocks, the histogram of each block will exceed the threshold. The pixel values are cropped and redistributed, and the threshold formula is shown in formula (1).
[0040] (1)
[0041] in, This is the preset contrast limit parameter. For local block size, The number of gray levels in the image;
[0042] The cropped histogram is equalized to obtain the enhanced brightness value of each block. Bilinear interpolation is performed on the pixels at the block edges to obtain the enhanced brightness channel.
[0043] S513: Merge the enhanced luminance channel with the original chroma channel, convert back to RGB format, and obtain the enhanced dim lighting image.
[0044] Beneficial effects: This invention provides a method for constructing an underwater artificial crack dataset under complex lighting conditions. It constructs a 3D model based on actual crack images and then prepares test blocks, supplementing the current limited methods for creating artificial cracks. The data is expanded using a LoRA-based fine-tuned Stable Diffusion method, saving experimental time and reducing costs. Training with datasets under different lighting conditions enables detection and segmentation of images under varying illumination, improving the model's robustness. This invention solves the problem of difficult data collection for actual underwater crack defects, meeting the core needs of engineering practice and providing richer data support for model training for underwater structural crack target detection. Attached Figure Description
[0045] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0046] Figure 1 A flowchart illustrating the method for constructing an underwater artificial crack dataset under complex lighting conditions;
[0047] Figure 2 A crack model drawn for SolidWorks;
[0048] Figure 3 This is a screenshot showing the result of cropping the image.
[0049] Figure 4 The image shows the effect of visually enhancing a dim image using an algorithm based on adaptive histogram equalization (CLAHE).
[0050] Figure 5 The effect of processing images with uneven lighting using the multi-scale Retinex algorithm. Detailed Implementation
[0051] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, 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, 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.
[0052] This embodiment provides a method for constructing an underwater artificial crack dataset under complex lighting conditions, such as... Figure 1 As shown, it includes:
[0053] S1: Collect actual crack images, extract crack curves from the crack images, and generate crack coordinate information based on the crack curves;
[0054] S2: Construct a 3D model of the crack based on the crack coordinate information, and prepare standard concrete test blocks with cracks based on the 3D model of the crack;
[0055] S3: Place the standard concrete specimen with cracks in water, collect underwater specimen crack images under various preset lighting conditions, and preprocess the underwater specimen crack images under various preset lighting conditions. Classify them according to the lighting conditions to obtain preprocessed images under different preset lighting conditions. The preset lighting conditions include normal lighting conditions, dim lighting conditions, and uneven lighting conditions.
[0056] S4: Introduce a Stable Diffusion model based on LoRA fine-tuning. Input preprocessed images under different lighting conditions to train the aforementioned model. Optimize the trained model to obtain an optimized model. Use the optimized model to perform image style extension to obtain extended images under different lighting conditions. Combine these extended images with the preprocessed images under different lighting conditions to form unlabeled image data.
[0057] S5: An image enhancement algorithm is introduced to enhance the images in the unlabeled image data. The enhanced images are then labeled to obtain the label files of the enhanced images. The label files are matched one-to-one with the original unenhanced images to obtain the underwater artificial crack dataset under complex lighting conditions.
[0058] Specifically, this solution first collects crack images and extracts crack curves; then uses SolidWorks to draw crack models; and uses additive manufacturing technology to create crack molds based on the drawn models to prepare standard concrete test blocks containing artificial cracks (with preset cracks), i.e., cracked concrete standard test blocks.
[0059] Secondly, concrete standard test blocks containing artificial cracks (with preset cracks) were placed in water, and underwater data were collected under complex lighting conditions. Small sample image style expansion was performed using the LoRA-based fine-tuning Stable Diffusion method.
[0060] Finally, image enhancement algorithms were used to obtain clearer images, and image annotation, data cleaning, dataset partitioning, and data format conversion were performed to obtain an underwater artificial crack dataset under complex lighting conditions.
[0061] In a specific embodiment, the scheme of acquiring actual crack images, extracting crack curves from the crack images, and generating crack coordinate information based on the crack curves is as follows:
[0062] S11. Use a camera to collect images of cracks of different shapes in land-based building structures;
[0063] S12. Use the EfficientSam model to extract the crack shape from the acquired image and save it as a JSON file containing coordinate information.
[0064] In a specific embodiment, the scheme for constructing a 3D model of the crack based on the crack coordinate information and preparing standard concrete test blocks based on the 3D model of the crack is as follows:
[0065] S21. Standardize the crack coordinate information and scale the standardized coordinates according to the preset scaling parameters.
[0066] Specifically, this solution converts the JSON file into a TXT text format arranged in xyz order and standardizes it, unifying the size to 148mm×148mm, 148mm×146mm, or 146mm×146mm as needed. The specific steps are as follows:
[0067] S211: After verifying the data validity of the crack coordinate information, extract the original coordinate points of the crack from the crack coordinate information, and clean the original coordinate points according to the Euclidean distance, removing any one of the two coordinate points whose Euclidean distance is less than the preset value.
[0068] Specifically, firstly, valid numbers are extracted from the target size and their validity is verified; the validity of the numbers includes the validity of the number of coordinates, the validity of the format, and the validity of the logic.
[0069] The number of valid coordinates means that the number of coordinates must appear in pairs, that is, the width and height numbers must appear in pairs; the format must be valid means that the extracted valid numbers can be converted into floating-point numbers; and the logic must be valid means that the converted numbers must be positive.
[0070] In this solution, the original coordinates of the polygon are extracted by reading the input JSON file. The original coordinates are taken by default from the points field of the first shape. All coordinates are traversed, the Euclidean distance between each pair of points is calculated, and a preset threshold is set. When the distance between two points is less than the threshold, any one of the points is removed.
[0071] S212: Calculate the preset Euclidean distance between the original first and last points. If the distance is greater than the tolerance value, add a point with the same coordinates as the original first point after the original last point as the last point to form a closed polygon, thereby achieving the polygon closure process.
[0072] S213: Calculate the scaling ratio based on the target size, scale the coordinates of the closed polygon based on the scaling ratio, obtain the scaled coordinates, and center them within the target size area. The specific steps are as follows:
[0073] 1. Calculate the bounding box and dimensions of the original image:
[0074] The x-coordinate range of the original image: , ;
[0075] The range of the y-coordinates of the original graph: , ;
[0076] Original width: ;
[0077] Original height ;
[0078] 2. Calculate the scaling ratio:
[0079] To maintain the aspect ratio and ensure the graphic fits completely within the target area, the minimum scaling ratio in the x and y directions is used, as follows:
[0080]
[0081] In the formula, The width of the target size, The height of the target dimension;
[0082] 3. Calculate the center offset to center the scaled graphic within the target area:
[0083] The offset formula is as follows:
[0084] ;
[0085] 4. Perform a three-step transformation on each original coordinate (x, y): "translate to origin → scale → translate to target center" to obtain the transformed coordinates;
[0086] 5. Write the coordinates to a txt file. Write the final coordinates (after cleaning / scaling) to the txt file in the format "xy 0". The z coordinate is fixed at 0. Keep 6 decimal places.
[0087] S22. Generate a 3D model of the crack based on the scaled coordinates;
[0088] Specifically, this solution uses SolidWorks to draw the 3D model:
[0089] Import the points from the txt text file into SolidWorks, use the Insert-Curve function in SolidWorks to draw a curve through the xyz points, then use Sketch-Convert Entity Reference to make the image editable, and use the Loft Feature Boss / Base to set the depth to 3mm to obtain a 3D graphic of the crack shape.
[0090] S23. Using the Sketch - Corner Rectangle tool in SolidWorks, draw a rectangle of 148mm×148mm, 148mm×146mm, or 146mm×146mm. Then, use the Extrude Boss / Base tool to set the depth of the rectangle to 1mm, ultimately obtaining a crack model with a protruding shape. The result is shown below. Figure 2 As shown;
[0091] S24. Generate standard test blocks for cracked concrete based on the 3D model. The specific steps are as follows:
[0092] 1. Process the crack model using slicing software and save the gcode file;
[0093] 2. Use a 3D printer to print a crack mold;
[0094] 3. Prepare materials according to the formula, mix the materials using a concrete mixer, and pour the concrete into a 150mm×150mm×150mm standard concrete mold for placing crack molds (in the standard mold, place 148mm×148mm×1mm crack molds on the top and bottom plates, 148mm×146mm×1mm crack molds on the left and right side plates, and 146mm×146mm×1mm crack molds on the front and rear side plates).
[0095] 4. After 24-48 hours, demold the concrete (depending on the actual air temperature and humidity), remove the cracked mold, and perform standard curing on the obtained test blocks to obtain standard concrete test blocks with cracks.
[0096] The cracked concrete test blocks produced in this scheme can achieve data collection under different scenarios, which can effectively supplement the artificial crack production method.
[0097] In a specific embodiment, a standard concrete specimen with cracks is placed in water, and underwater images of the cracks are collected under various preset lighting conditions. These images are then preprocessed and categorized according to lighting conditions to obtain preprocessed images under different preset lighting conditions. The preset lighting conditions include conventional lighting conditions, dim lighting conditions, and uneven lighting conditions.
[0098] S31. Use an underwater camera to collect images of cracks and defects in underwater test blocks under normal lighting, dim lighting, and uneven lighting conditions, with about 50 photos collected under each lighting condition.
[0099] S32. Preprocess the images of underwater test blocks with cracks under multiple lighting conditions. In this scheme, screenshots are taken from images under different lighting conditions and output in JPG file format. The specific steps are as follows:
[0100] Step 1: Convert the underwater specimen crack images under multiple lighting conditions from the RGB color space to the HSV color space;
[0101] This solution uses OpenCV for conversion, which is a common technique used by those skilled in the art; therefore, the conversion process will not be described in detail.
[0102] Step 2: Introduce the Otsu thresholding method to adaptively threshold the image pixels in the S channel, generating a binary image; where white areas represent low-saturation areas (concrete test block) and black areas represent high-saturation areas (background). The specific steps are as follows:
[0103] 1. Image grayscale statistics:
[0104] Let the pixel gray levels of the S-channel image be... (Usually 0-255), counts the number of pixels at each gray level in the image;
[0105] 2. For each possible threshold The image pixels are divided into two categories:
[0106] Category 1: Grayscale values Pixels, second category: grayscale values Pixels;
[0107] 3. Calculate the between-class variance:
[0108] For each threshold Calculate the following statistics:
[0109] The percentage of pixels in the first class, the percentage of pixels in the second class, the average gray level of the first class, the average gray level of the second class, and the inter-class variance;
[0110] 4. Determine the optimal threshold:
[0111] 5. Iterate through all possible thresholds. Find the threshold that maximizes the inter-class variance;
[0112] 6. Generate a binary image:
[0113] Binarize the S-channel image using the optimal threshold:
[0114] If the pixel grayscale value is less than or equal to the optimal threshold, the pixel is set to white (grayscale value 255); if the pixel grayscale value is greater than the optimal threshold, the pixel is set to black (grayscale value 0).
[0115] Step 3: Locate all contours in the binary image; the contours are the boundaries of the white areas in the binary image.
[0116] Step 4: Select the contour with the largest area from all contours and set it as the contour of the standard test block for cracked concrete in the image.
[0117] Step 5: Calculate the minimum bounding rectangle of the maximum outline. Using the center point of the minimum bounding rectangle as a reference, set the clipping area based on the width and height of the outer rectangle; the aspect ratio of the clipping area is 1:1.
[0118] In this scheme, the rectangle completely encloses the outline, and its edges are parallel to the image axis;
[0119] Step Six: Crop the original image based on the cropping region to obtain the cropped image. Convert the cropped image from the HSV color space to the RGB color space to obtain the preprocessed image. The cropped image is shown below. Figure 3 As shown, the cropping area in this scheme is a square.
[0120] In a specific embodiment, a Stable Diffusion model based on LoRA fine-tuning is introduced. Preprocessed images under different lighting conditions are input to train the aforementioned model. The trained model is then optimized to obtain an optimized model. The optimized model is used for image style extension to obtain extended images under different lighting conditions. These extended images, along with the preprocessed images under different lighting conditions, form unlabeled image data.
[0121] S41. Use the BLIP visual language model to generate corresponding text descriptions for each input image. The text descriptions contain general quality words and style keywords to obtain image-text pairs.
[0122] In this scheme, 30 images with different content are selected from three groups under different lighting conditions. The images are in RGB format and the resolution is uniformly set to 512×512 pixels.
[0123] S42. Introduce a pre-trained Stable Diffusion model. Inject the LoRA module into the weight matrix of all cross-attention layers of the U-Net module in the Stable Diffusion model to obtain a Stable Diffusion model fine-tuned based on LoRA.
[0124] S43. Input the image-text pair into the Stable Diffusion model based on LoRA fine-tuning, train the LoRA module, and optimize the trained model using the noise prediction loss function and the Adam optimizer to obtain the optimized model.
[0125] In this scheme, the learning rate for training the model is 1e. -4 ~5e -5 The training rounds are 10-50 epochs (adjusted according to the number of samples), and prior preservation regularization is enabled to prevent language drift.
[0126] S44. Set semantic prompts and use the optimized model to generate a new image with the same style as the input image based on the semantic prompts, i.e., an expanded image;
[0127] Specifically, the prompt words are fed into the text encoder in the optimized model. During inference, the trained LoRA weights A and B are injected into U-Net, and standard diffusion sampling (such as DDIM and DPM++) is performed to generate new images, resulting in high-fidelity, style-consistent synthetic images.
[0128] The Stable Diffusion model is a commonly used model in the field of image generation, so its specific structure and data processing will not be described in detail.
[0129] In this approach, the LoRA-based fine-tuned Stable Diffusion method can expand the data, save experimental time, reduce costs, and expand the dataset, providing richer data support for model training of underwater structure crack target detection.
[0130] In a specific embodiment, an image enhancement algorithm is introduced to enhance the images in the unlabeled image data. The enhanced images are then labeled to obtain label files. These label files are then mapped one-to-one with the original, unenhanced images. The scheme for obtaining the underwater artificial crack dataset under complex lighting conditions is as follows:
[0131] S51. Visual enhancement is performed on dimly lit images in the image dataset using an algorithm based on adaptive histogram equalization. The specific steps are as follows:
[0132] S511: Converts dimly lit images from the RGB color space to the YCrCb color space, separating the luminance and chrominance channels to avoid disrupting color balance during enhancement;
[0133] S512: Applying an adaptive histogram equalization algorithm that limits contrast to the luminance channel:
[0134] Divide the brightness channel into For local blocks, the histogram of each block will exceed the threshold. The pixel values are cropped and redistributed, and the threshold formula is shown in formula (2).
[0135] (2)
[0136] in, The preset contrast limit parameter is set to 2.0 in this solution. For local block size, The number of gray levels in the image;
[0137] The cropped histogram is equalized to obtain the enhanced brightness value of each block. Bilinear interpolation is performed on the pixels at the block edges to eliminate the boundary effect between blocks and obtain the enhanced brightness channel.
[0138] S513: Merge the enhanced luminance channel with the original chroma channel, then convert back to RGB format to obtain the enhanced low-light image; the enhanced image is as follows. Figure 4 As shown;
[0139] S52. Use the multi-scale Retinex algorithm to process images with uneven lighting in the image dataset. The specific steps are as follows:
[0140] Step 1: Use OpenCV to convert the default BGR format to RGB format, and then normalize the pixel values from integers 0 to 255 to 64-bit floating-point numbers 0 to 1 to avoid overflow / precision loss and adapt to logarithmic operations; extract the height, width, and number of channels of the image to provide a basis for subsequent channel-by-channel calculations.
[0141] Step 2: Calculate the reflection components using the multi-scale Retinex algorithm;
[0142] By iterating through different Gaussian scales, the illumination components at each scale are simulated using Gaussian blur, and the single-scale reflection components are extracted and superimposed to obtain the superimposed reflection components.
[0143] Calculate the average value of the superimposed reflection components to obtain the final reflection component that eliminates the influence of illumination;
[0144] Step 3: Calculate the global mean and standard deviation of the reflection component. Based on the global mean and standard deviation, perform contrast stretching on the reflection component to map it to a range close to 0~255. Then, truncate the values that exceed 0~255 to obtain the processed reflection component.
[0145] The processed reflection components are converted into 8-bit unsigned integers, and then the converted data is converted into RGB format.
[0146] Step 4: Format Conversion and Image Saving. The processed RGB pixel array is converted back to OpenCV-compatible BGR format (ensuring correct color saving). An output directory is automatically created to prevent save failures. The BGR format data is written to the specified path to generate the final image file, i.e., the processed uneven lighting image. Simultaneously, an enhanced RGB format image array is returned for subsequent secondary processing. The processed image is shown below. Figure 5 As shown;
[0147] S53. Use LabelMe's AI annotation function to annotate the images in the image dataset that are under normal lighting, enhanced dim lighting, and processed uneven lighting. Make secondary adjustments to the annotations in LabelMe to obtain the label file.
[0148] Specifically, in this solution, the secondary adjustment in LabelMe is done by manually refining the annotations to obtain a label file with the same name as the image;
[0149] S54. Pair the unenhanced original images with the corresponding label files to construct an underwater artificial crack dataset under complex lighting conditions;
[0150] Specifically, this solution takes generating a dataset that conforms to the YOLO algorithm as an example. First, CleanVision is used to automatically detect common quality problems in the image dataset (such as blurring, duplication, and damage). No labels are required, and a visual report is generated with one click, achieving rapid cleaning and improvement of data quality.
[0151] Secondly, Python code was used to jointly rename the paired image files and label files under different lighting conditions according to the same incremental numbering rule to maintain filename consistency.
[0152] Next, Python code was used to hierarchically divide the JSON-formatted images and their corresponding annotation files under different lighting conditions by category, ensuring that the training set and validation set maintain an approximately 8:2 ratio in terms of the number of images and the distribution of labels for each category.
[0153] Convert the polygon annotations (instance segmentation) of LabelMe into YOLO format polygon txt files (for instance segmentation training) and YOLO standard rectangle txt files (for object detection training), respectively.
[0154] Different detection or segmentation algorithms have different requirements for images in the dataset. Those skilled in the art can perform corresponding image processing on the training and validation sets of images according to the requirements of the specific algorithm. Therefore, the proportion and form of the images are not limited.
[0155] The original images and their refined label files under normal lighting conditions, as well as the original images and their refined label files under dim lighting conditions and uneven lighting conditions, were matched one-to-one to form an underwater crack disease dataset.
[0156] This approach involves collecting datasets under different lighting conditions, using algorithms to enhance images, and then labeling, refining, and partitioning the datasets to effectively expand the richness of underwater datasets, thus possessing significant engineering application value.
[0157] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for constructing an underwater artificial fracture dataset under complex lighting conditions, characterized in that, The method comprises the following steps: S1: Collecting actual crack pictures, extracting crack curves in the crack pictures, and generating crack coordinate information according to the crack curves; S2: Constructing a crack 3D model based on the crack coordinate information, and preparing a crack concrete standard test block according to the crack 3D model; S3: Placing the crack concrete standard test block into water, collecting underwater test block crack disease images under multiple preset light conditions, and preprocessing the underwater test block crack disease images under multiple preset light conditions, classifying according to the light conditions to obtain preprocessed images under different preset light conditions; the preset light conditions include normal light conditions, dim light conditions and uneven light conditions; S4: Introducing a Stable Diffusion model based on LoRA fine-tuning, inputting the preprocessed images under different light conditions into the model to train the model, optimizing the trained model to obtain an optimized model; using the optimized model to expand the image style to obtain expanded images under different light conditions, and forming no-label image data together with the preprocessed images under different light conditions; S5: Introducing an image enhancement algorithm to enhance the images in the no-label image data, labeling the enhanced images to obtain a label file of the enhanced images, and corresponding the label file with the original images without enhancement to obtain an underwater artificial crack dataset under complex light conditions.
2. The method according to claim 1, wherein, Constructing a crack 3D model based on crack coordinate information comprises: S21, standardizing the crack coordinate information, and scaling the standardized coordinates according to a preset scaling parameter; S22, generating a crack 3D model based on the scaled coordinates.
3. The method according to claim 2, wherein, Standardizing the crack coordinate information and scaling the standardized coordinates according to a preset scaling parameter comprises: S211: After verifying the data legality of the crack coordinate information, extracting the original coordinate points of the crack in the crack coordinate information, and cleaning the original coordinate points according to the Euclidean distance, removing any one of the two coordinate points with a Euclidean distance less than a preset value; S212: Calculate the Euclidean distance of the preset original first and last points. If the distance is greater than the tolerance value, add a point with the same coordinate as the original first point after the original last point as the last point to form a closed polygon, thereby realizing the closing processing of the polygon; S213: Calculate the scaling ratio according to the target size, scale the closed polygon coordinates based on the scaling ratio to obtain the scaled coordinates.
4. The method of claim 1, wherein, The preprocessing of the underwater test block crack disease images under multiple preset light conditions comprises: Step 1: Convert the underwater test block crack disease images under multiple preset light conditions from RGB color space to HSV color space; Step 2: Introducing Otsu threshold segmentation method to perform adaptive threshold segmentation on the image pixels of S channel to generate a binary image; Step 3: Find all contours in the binary image; the contour is the boundary of the white area in the binary image; Step 4: Select the largest one from all contours and set it as the contour of the crack concrete standard test block in the image; Step five, calculate the minimum circumscribed rectangle of the maximum contour, and set a clipping area based on the center point of the minimum circumscribed rectangle and the width and height of the circumscribed rectangle; the width-to-height ratio of the clipping area is 1:1; Step six, clip the original image based on the clipping area to obtain a clipped image, and convert the clipped image from the HSV color space to the RGB color space to obtain a preprocessed image.
5. The method of claim 1, wherein, Introduce the Stable Diffusion model based on LoRA fine-tuning, input the preprocessed images under different light conditions into the aforementioned model respectively, optimize the trained model, and obtain an optimized model; Use the optimized model to expand the image style, and obtain expanded images under different light conditions, including: S41, use the BLIP visual language model to generate a corresponding text description for each input image, the text description contains general quality words and style keywords, and obtain an image-text pair; S42, introduce a pre-trained Stable Diffusion model, inject a LoRA module into the weight matrix of all cross-attention layers in the U-Net module of the Stable Diffusion model, and obtain a Stable Diffusion model based on LoRA fine-tuning; S43, input the image-text pair into the Stable Diffusion model based on LoRA fine-tuning, train the LoRA module, use the noise prediction loss function and the Adam optimizer to optimize the trained model, and obtain an optimized model; S44, set a semantic prompt word, and use the optimized model to generate a new image consistent with the style of the input image according to the semantic prompt word, i.e. an expanded image.
6. The method of claim 1, wherein, Introduce an image enhancement algorithm to enhance the images in the unlabeled image data, label the enhanced images to obtain a label file of the enhanced images, and correspond the label file with the original images that are not enhanced to obtain an underwater artificial crack dataset under complex light conditions, including: S51, use an algorithm based on adaptive histogram equalization to visually enhance the dark light images in the image dataset; S52, use a multi-scale Retinex algorithm to process the non-uniform light images in the image dataset; S53, use the AI labeling function of LabelMe to label the regular light images, the enhanced dark light images, and the processed non-uniform light images in the image dataset, and adjust the labels in LabelMe again to obtain a label file; S54, pair the original images that are not enhanced with the corresponding label files to construct an underwater artificial crack dataset under complex light conditions.
7. The method according to claim 6, wherein, Use an algorithm based on adaptive histogram equalization to visually enhance the dark light images in the image dataset, including: S511: convert the dark light image from the RGB color space to the YCrCb color space, and separate the luminance channel and the chrominance channel; S512: apply a limited-contrast adaptive histogram equalization algorithm to the luminance channel: The luminance channel is divided into local blocks, for each block's histogram, pixel values exceeding a threshold are clipped and reassigned, the threshold formula is shown as formula (1), (1) wherein, is a preset contrast limit parameter, is a local block size, L is a number of gray levels of the image; The cropped histogram is equalized to obtain an enhanced luminance value of each block, and pixels on a block edge are bilinearly interpolated to obtain an enhanced luminance channel; S513: The enhanced luminance channel is combined with the original chrominance channel, and is converted back to the RGB format to obtain an enhanced dimly-lit image.
Citation Information
Patent Citations
Method for identifying underwater crack behavior of concrete faced rockfill dam
CN119986669A
Underwater concrete structure crack detection method based on edge calculation and deep learning
CN120563443A
