A method of borehole wall residue analysis and localization
By using semantic segmentation and spatial proximity clustering of downhole borehole wall images, the problem of misjudgment and omission of downhole borehole wall residues was solved, enabling automatic identification and precise positioning of residue types, dynamic adjustment of cleaning parameters, and improved efficiency and intelligence of borehole cleaning operations.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- INST OF ROCK & SOIL MECHANICS CHINESE ACAD OF SCI
- Filing Date
- 2026-06-18
- Publication Date
- 2026-07-31
AI Technical Summary
In existing technologies, the detection methods for residues on the borehole wall are highly subjective and inefficient. Traditional image processing is easily affected by fluid reflections, leading to false positives and false negatives. Furthermore, there is a lack of systematic conversion methods from pixel coordinates to actual borehole wall spatial coordinates, making it impossible to accurately locate and quantify the anchoring effect between the residues and the borehole wall.
A semantic segmentation network with reflective mask is used to process the downhole borehole wall image. Combined with the angle and depth resolution obtained by field calibration, the pixel coordinates are converted to the actual spatial coordinates of the borehole wall. Through spatial proximity clustering and anchoring effect quantification, the automatic identification of residue type, accurate spatial location and quantitative assessment of coverage area are realized.
It enables automatic identification and precise positioning of residues on the wellbore wall, quantifies the coverage area and thickness, and dynamically adjusts cleaning parameters to accurately remove stubborn residues, thereby improving the efficiency and intelligence of well cleaning operations.
Smart Images

Figure CN122492790A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to a method for analyzing and locating residues on the downhole borehole wall. Background Technology
[0002] In coal mining, oil and gas drilling, and other fields, borehole washing is a crucial step in removing mud, rock cuttings, and other residues from the borehole wall surface and restoring its cleanliness. After washing, some mud or rock cuttings may still remain on the borehole wall. The distribution, area, thickness, and anchorage of these residues directly affect the quality and safety of subsequent operations (such as logging and cementing). Accurate analysis and location of these residues on the borehole wall after washing are key to achieving differentiated reinforcement cleaning and improving the overall washing effect.
[0003] Existing methods for detecting residues on borehole walls mainly fall into two categories. One category relies on visual inspection or playback of downhole television images. Operators observe unfolded images of the borehole wall, relying on experience to determine the type of residue and roughly estimate its location. This method is highly subjective, inefficient, and struggles to quantify the area, thickness, and anchorage degree of the residue to the borehole wall, failing to provide structured positioning data for automated cleaning systems. The other category uses automated segmentation methods based on traditional image processing, such as threshold segmentation, edge detection, or watershed algorithms to extract residue areas. However, downhole environments commonly exhibit non-uniform lighting, strong fluid reflection, and small grayscale differences between mud and clean borehole walls. Traditional methods easily misclassify highly reflective areas as residues or miss weakly adhering mud, resulting in classification accuracy and stability far from meeting engineering requirements. Existing publicly available solutions have the following technical defects: most methods only output a single residue category map, ignoring the masking effect of fluid reflection on the actual residue. The reflective area often submerges the pixel features of mud or rock debris, causing misclassification or underestimation of area; there is a lack of a systematic conversion method from image pixel coordinates to actual borehole wall spatial coordinates, making it impossible to accurately locate the boundary range of each residue area on the three-dimensional cylindrical surface of the borehole wall, thus making it impossible to drive the cleaning actuator to perform targeted spraying; only focusing on the static geometric properties of the residue, ignoring the anchoring effect between the residue and the borehole wall, which precisely determines the actual cleaning difficulty. Low-anchoring residues are easy to flush away, while high-anchoring residues require higher pressure or pulsed spraying. Summary of the Invention
[0004] This application provides a method for analyzing and locating residues on the borehole wall, which solves the problems of subjective and inefficient manual visual interpretation, difficulty in quantifying the area and thickness of residues, susceptibility of traditional image processing methods to interference from fluid reflection leading to misjudgment or omission of mud and cuttings, lack of systematic conversion from pixel coordinates to actual borehole wall spatial coordinates, and inability to reasonably set cleaning parameters due to the lack of consideration for the anchoring effect between residues and the borehole wall. It achieves the technical effects of automatic identification of borehole wall residue types, precise spatial positioning, quantitative assessment of coverage area and thickness, quantitative classification of anchoring effect, and differentiated cleaning parameter-driven operation.
[0005] This application provides a method for analyzing and locating residues on the downhole borehole wall, including: S1: Acquire borehole wall images and record the well depth and circumferential azimuth angle corresponding to each frame; preprocess the images to obtain preprocessed grayscale images; S2: Use a pre-defined semantic segmentation network to infer the grayscale image and output a residue type label map and a reflection mask map; S3: Based on the residue type label map and reflective mask map, combined with the recorded well depth and circumferential azimuth, the pixel coordinates are converted to the actual borehole wall spatial coordinates. The reflective areas marked in the reflective mask map are excluded. Then, the spatial proximity clustering of the converted residue pixels is performed to obtain the position coordinates of each residue area on the actual borehole wall and the residue type. S4: Calculate the coverage area and thickness level of each residue region on the actual borehole wall, generate a borehole wall residue distribution map, and output the location results of each residue region.
[0006] Furthermore, the preprocessing includes: using median filtering to remove isolated noise points, with the filtering window size being a preset window size; using a contrast-limited adaptive histogram equalization algorithm to enhance image contrast; uniformly scaling all images to the same pixel size, maintaining the original aspect ratio, and filling insufficient areas with black pixels.
[0007] Furthermore, the reasoning of the grayscale image includes: inputting the grayscale image into a semantic segmentation network, the network adopting an encoder and decoder structure, and outputting a residue type label map and a reflection mask map with the same size as the input image; The residue type label diagram shows that pixel value 0 indicates a cleaned borehole wall, 1 indicates mud coverage, and 2 indicates rock debris adhesion. In the reflective mask image, a pixel value of 1 indicates the presence of fluid reflection, and 0 indicates no reflection. When the target pixel has a value of 1 or 2 in the residue type label image and is 1 in the reflective mask image, the area corresponding to the target pixel is determined to be a residue area affected by reflective interference.
[0008] Furthermore, the conversion from pixel coordinates to actual borehole wall spatial coordinates includes: obtaining the circumferential azimuth resolution and well depth distance resolution in advance through on-site calibration; for circumferential unfolding imaging, linearly mapping the horizontal coordinate to 0° to 360° and the vertical coordinate to the well depth distance; for local imaging, combining the starting and ending circumferential azimuth angles recorded during acquisition, linearly mapping the column number to the corresponding angle range.
[0009] Furthermore, the spatial proximity clustering includes: grouping pixels with a circumferential azimuth difference less than a preset angle threshold and a well depth difference less than a preset distance threshold into the same residue region; for residue regions detected in different frame images, if there is overlap in the well depth direction and the overlap rate of the circumferential azimuth range exceeds a preset overlap rate threshold, they are merged into the same region, and the starting well depth of the merged region is taken as the minimum value in each frame, the ending well depth is taken as the maximum value, the circumferential azimuth range is taken as the union, and the residue type is determined according to the category with the most pixels.
[0010] Furthermore, the coverage area is calculated as follows: , in, For the coverage area of the region, This represents the total number of pixels contained in the region within the label map. The actual area represented by each pixel; The thickness level is determined as follows: for mud-covered areas, the mud thickness is estimated using the gray-scale difference method, and the estimated thickness is compared with a preset mud thickness threshold to determine whether it is a thin layer, a medium layer, or a thick layer; for rock debris-attached areas, the rock debris height is obtained using the shadow height measurement method, and the height is compared with a preset rock debris height threshold to determine whether it is a thin layer, a medium layer, or a thick layer.
[0011] Furthermore, the method also includes: performing edge detection on the preprocessed grayscale image to obtain a binarized edge feature map; for each residue region, extracting its boundary pixels, taking a square window of a preset size centered on each boundary pixel, calculating the density of edge pixels within the window, and calculating the boundary irregularity based on the average density of all boundary pixels; sampling a preset number of pixels outward along the normal direction, calculating the grayscale change steepness and performing normalization processing to obtain the grayscale tailing index; for the rock debris attachment region, calculating the convex hull of the region's pixel set, and calculating the shape penetration index based on the ratio of the number of region pixels to the number of pixels covered by the convex hull.
[0012] Furthermore, the method also includes: calculating the anchoring effect index based on the boundary irregularity, grayscale tailing index, and thickness coefficient corresponding to the residue type; for mud-covered areas, the formula for calculating the anchoring effect index is: , in, This represents the anchoring effect index in the mud zone. For boundary irregularity, This refers to the grayscale trailing index. For thickness coefficient, , and For the corresponding weight coefficients, and ; For the area where rock cuttings adhere, the formula for calculating the anchoring effect index is: , in, The anchoring effect index for the rock cuttings region. For boundary irregularity, This refers to the grayscale trailing index. The shape penetration index, For thickness coefficient, , , and For the corresponding weight coefficients, and .
[0013] Furthermore, the anchoring effect index also includes: adjusting cleaning parameters according to the anchoring effect index in stages; when the anchoring effect index is lower than a first preset threshold, using conventional cleaning parameters; when the anchoring effect index is between the first preset threshold and a second preset threshold, increasing the cleaning pressure by a first preset ratio, increasing the number of spray sweeps, and extending the cleaning time; when the anchoring effect index is higher than the second preset threshold, increasing the cleaning pressure by a second preset ratio and using a pulse spray mode; after cleaning, re-acquiring images and calculating the anchoring effect index; if it is still higher than the second preset threshold, repeating the process until the maximum number of cleaning cycles is reached, and marking areas still higher than the second preset threshold as stubborn anchoring areas.
[0014] Furthermore, the persistent anchoring zone also includes: recording the location coordinates, residue type, coverage area, thickness level and anchoring effect index of the persistent anchoring zone, generating a list of persistent anchoring zones; and highlighting the persistent anchoring zone with a preset symbol on the hole wall residue distribution map.
[0015] One or more technical solutions provided in this application have at least the following technical effects or advantages: By employing semantic segmentation with reflective masks, pixel-to-hole wall spatial coordinate transformation, and quantitative grading of anchoring effect, this approach effectively overcomes the interference of uneven downhole illumination and fluid reflection, solving the problems of misjudgment and omission in traditional methods. It not only achieves automatic differentiation of residue types and centimeter-level precise spatial positioning, but also quantitatively calculates the coverage area and thickness level. By assessing the anchoring strength between residues and the hole wall, and dynamically adjusting the cleaning pressure and spraying mode, it achieves closed-loop control of the entire process from detection and assessment to cleaning, resulting in precise removal of stubborn residues, energy savings, and improved efficiency and intelligence in hole cleaning operations. Attached Figure Description
[0016] Figure 1 This is a flowchart of a method for analyzing and locating residues on the borehole wall in an embodiment of the present invention. Detailed Implementation
[0017] To facilitate understanding of the present invention, a more complete description of this application will be given below with reference to the accompanying drawings, which illustrate preferred embodiments of the invention. However, the invention can be implemented in many different forms and is not limited to the embodiments described herein. Rather, these embodiments are provided to enable a more thorough and complete understanding of the disclosure of the present invention.
[0018] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains; the terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to limit the invention; the term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.
[0019] Example 1: As Figure 1 As shown, a method for analyzing and locating residues on the downhole borehole wall is presented.
[0020] S1: Acquire borehole wall images and record the well depth and circumferential azimuth angle corresponding to each frame; preprocess the images to obtain preprocessed grayscale images; Specifically, during the operation of the borehole cleaning tool, images of the borehole wall surface are captured. For each frame of the acquired borehole wall image, the current borehole depth and the circumferential azimuth angle of the camera relative to a fixed reference point on the borehole wall (such as the borehole opening marker line) are recorded. If circumferential unfolding imaging is used, the borehole depth corresponding to the panoramic image is recorded; if partial imaging is used, the starting and ending angles of the image coverage also need to be recorded. All images, along with their corresponding depth and angle labels, are saved together to form the original dataset.
[0021] After converting the raw data to grayscale images, preprocessing is performed. Median filtering is used to remove isolated noise points caused by mud splashes or signal interference. The filtering window size is 3×3 pixels, ensuring that the edges of the residue are not blurred while denoising. Adaptive contrast enhancement is then applied to the denoised images: due to uneven downhole lighting, the grayscale difference between the mud-covered area and the clean borehole wall may be small. The Limiting Contrast Adaptive Histogram Equalization (CLAHE) algorithm is used to divide the image into several small blocks, perform histogram equalization on each block, and then stitch adjacent blocks together to enhance local texture and boundary contrast. All images are then uniformly scaled to the same pixel size, such as 512×512 pixels, while maintaining the original aspect ratio. Insufficient areas are filled with black pixels.
[0022] S2: Use a pre-defined semantic segmentation network to infer the grayscale image and output a residue type label map and a reflection mask map; Specifically, to achieve pixel-level automatic residue classification of preprocessed borehole wall images, a semantic segmentation training set was constructed. Original borehole wall images were acquired from different well sections, under different lighting conditions, and with varying residue distributions. These original images underwent the same median filtering, CLAHE enhancement, and resizing preprocessing to ensure consistency between the training data and actual operational data. Each preprocessed image was labeled using a two-layer structure: the first layer indicated the residue type, with each pixel labeled as 0 (cleaned borehole wall), 1 (mud cover), or 2 (cuttings attachment); the second layer was a reflective mask, generating a separate binary reflective mask where a pixel value of 1 indicated the presence of fluid reflection, and 0 indicated no reflection. If a pixel was classified as category 1 or 2 in the first layer and 1 in the second layer, the area was identified as a residue area affected by reflective interference. The "cleaned borehole wall" value indicated no residue, no fluid reflection, and clearly visible rock texture. The "mud cover" value indicated a semi-solid or liquid mud attachment area, with a darker color and irregularly diffused boundaries. Rock cuttings adhesion value indicates solid rock cuttings or fragments, often irregularly polygonal or circular in shape, with noticeable protrusions or shadows. Fluid reflectivity value indicates specular reflection areas caused by water films or pore-washing fluids, exhibiting extremely high brightness, appearing as bright white or highlight spots with sharp edges. After annotation, each original image corresponds to a label image of the same size. All images and label images are saved as pairs to form a complete semantic segmentation training set.
[0023] After constructing the semantic segmentation training set, a lightweight semantic segmentation network was trained to automatically classify each pixel in the hole wall image. The network structure adopted an encoder-decoder configuration, with the encoder part using MobileNetV2 and the decoder part using a U-Net structure. The network input size was fixed at 512×512 pixels, and the output was a single-channel class label map of the same size. All preprocessed images and their corresponding label maps in the training set were randomly divided into training, validation, and test sets in an 8:1:1 ratio. The training set was used to update network parameters, the validation set was used to monitor overfitting during training, and the test set was used to finally evaluate the model performance. The Adam optimizer was used, with an initial learning rate of 0.001, which decayed by multiplying by 0.9 every 20 complete training epochs. The batch size was set to 8, processing 8 images simultaneously in each iteration. The loss function uses weighted cross-entropy loss, with weights set for different residue types: the proportion of pixels in clean borehole wall (0) is usually much larger than the other two types, so its weight is set to 0.5 to avoid bias in predicting clean categories; the weight of mud cover (1) is set to 1.0 as the baseline weight; the weight of rock cuttings attachment (2) is set to 1.5 because it is the most important solid blockage to be removed and has the highest cost of missed detection. For reflective masks, binary cross-entropy loss is used for supervision with a weight of 1.2 to enhance the recognition accuracy of reflective areas and prevent them from masking real residues. During training, data augmentation operations such as random rotation, random scaling, random brightness adjustment, and horizontal flipping are performed on the training set images in real time to simulate different lighting and shooting angle changes in the well and improve the model's generalization ability. The network parameters are iteratively updated using the backpropagation algorithm using the training set data. After each complete traversal, the average intersection-union ratio is calculated on the validation set. When the index no longer improves after multiple consecutive traversals, the training is stopped using the early stopping method, and the model parameters with the best performance on the validation set are saved. After training is complete, the network model and its weight parameters are stored and saved.
[0024] The preprocessed image is input into a semantic segmentation network. After forward inference, the network outputs two single-channel images of the same size as the input image: one is a residue type label image, where a pixel value of 0 corresponds to a clean borehole wall, 1 corresponds to mud coverage, and 2 corresponds to rock debris adhesion; the other is a reflectivity mask image, where a pixel value of 1 indicates the presence of fluid reflection and 0 indicates no reflection. If a location has a value of 1 or 2 in the residue type label image and a value of 1 in the reflectivity mask image, then that area is determined to be a residue area affected by reflectivity. The category label image represents the classification result for each pixel location in the original borehole wall image. By reading the value at any location in the label image, it is possible to determine what type of residue or whether the corresponding location in the original image belongs to a clean area. For example, if a pixel value of 2 in the label image indicates that rock debris is adhered at the same location in the original borehole wall image.
[0025] S3: Based on the residue type label map and reflective mask map, combined with the recorded well depth and circumferential azimuth, the pixel coordinates are converted to the actual borehole wall spatial coordinates. The reflective areas marked in the reflective mask map are excluded. Then, the spatial proximity clustering of the converted residue pixels is performed to obtain the position coordinates of each residue area on the actual borehole wall and the residue type. Specifically, after obtaining the category label image, the pixel positions in the image plane are converted into real spatial coordinates on the borehole wall, namely the circumferential azimuth and well depth. The actual circumferential azimuth value corresponding to each pixel column is pre-determined through on-site calibration, for example, 0.5° per pixel, and the actual well depth length corresponding to each pixel row, for example, 0.2 mm per pixel. The specific calibration method is as follows: a calibration cylinder with known circumferential markings is placed inside the borehole. After taking the unfolded image, the number of pixels between adjacent angle lines is counted, and the average value is taken to obtain the angular resolution (degrees / pixel). For the depth direction, a ring-shaped calibration band with known spacing is used. After taking the image, the number of pixel rows between the calibration bands is counted to obtain the depth resolution (mm / pixel). The horizontal axis (column number) of the circumferential unfolded image directly corresponds linearly to the circumferential azimuth from 0° to 360°, and the vertical axis (row number) corresponds to the distance along the borehole depth.
[0026] Coordinate transformation is handled according to the imaging mode: For circumferential unfolding imaging, a single image covers a circumferential angle from 0° to 360°, and the horizontal coordinate (column number) is linearly mapped to [0°, 360°], with the initial circumferential azimuth angle always being 0°; for partial imaging, a single image only covers a portion of the circumferential angle, and the initial circumferential azimuth angle recorded during acquisition needs to be considered. With the ending circumferential azimuth angle Linearly map column numbers to In both modes, the vertical coordinate (row number) is linearly mapped to the distance in the well depth direction.
[0027] During coordinate transformation, for each category label image, the starting well depth and starting circumferential azimuth recorded during image acquisition are used to traverse all pixels in the label image. For each pixel location, the circumferential azimuth of the point is calculated based on its column number, and the well depth distance of the point is calculated based on its row number. Simultaneously, the category code corresponding to the pixel is recorded. After completing the coordinate transformation of all pixels, pixels with category 1 or 2 in the residue type label image are clustered according to spatial proximity, excluding areas with a value of 1 in the reflective mask image: pixels with a circumferential azimuth difference less than an angle threshold (e.g., 2°) and a well depth distance difference less than a distance threshold (e.g., 5 mm) are grouped into the same residue region. The angle threshold and distance threshold are experimentally calibrated, with the angle threshold ranging from [1, 5]° and the distance threshold ranging from [2, 10] mm. For residue regions detected in different image frames, if they overlap in the well depth direction and the circumferential azimuth range overlap rate exceeds 50%, they are merged into the same region. After merging, the starting well depth of the merged region is taken as the minimum value among all frames, and the ending well depth is taken as the maximum value. The circumferential azimuth range is taken as the union, and the category code is determined by the category with the most pixels. The area and thickness are recalculated based on the merged pixels. Each region records its minimum and maximum circumferential azimuth, minimum and maximum well depth distance, and category code. After coordinate transformation and clustering, the precise location of each residual region on the actual borehole wall can be obtained. For example, there is a rock cuttings attachment area within the range of depth 125.3 m to 125.4 m and circumferential azimuth 45° to 52°.
[0028] S4: Calculate the coverage area and thickness level of each residue region on the actual borehole wall, generate a borehole wall residue distribution map, and output the location results of each residue region.
[0029] Specifically, for each residue area, the coverage area is calculated based on the total number of pixels contained in the label map and the actual area represented by each pixel obtained through on-site calibration. , in, For the coverage area of the region, This represents the total number of pixels contained in the region within the label map. The actual area represented by each pixel. , For circumferential azimuth resolution, For well depth distance resolution, The borehole wall diameter is calculated using the circumferential azimuth resolution (degrees / pixel) and well depth resolution (millimeters / pixel). In practical applications, the area of a single pixel can also be directly measured using a calibration plate.
[0030] Extract the region with category 1 from the residue type label map, remove pixels with a value of 1 from the reflective mask map, and calculate the average gray value of the remaining mud region in the original grayscale image. If there are pixels of category 0 in the frame image, then the average gray value of those pixels is taken as the clean gray value. If no category 0 pixel exists in the image frame, then the clean reference frame from the most recently successfully acquired image in the same well section is used. If no reference frame is available for the current well section, a pre-calibrated clean grayscale value is used. This value is obtained by collecting data through a calibration tube under mud-free conditions, and the grayscale difference is defined as follows: Before on-site construction, standard mud test blocks of known thicknesses (0 mm, 0.5 mm, 1.0 mm, 2.0 mm, and 3.0 mm) were used to conduct calibration experiments in the downhole environment to establish... With mud thickness The mapping relationship is used to form a lookup table. In actual operation, based on the current... By referring to the table, the estimated mud thickness can be obtained. ,when When, it is determined to be a thin layer; when When, it is determined to be a middle layer; when At that time, it was determined to be a thick layer.
[0031] A standard calibration boss of known height was lowered to the target borehole section at heights of 1 mm, 2 mm, 5 mm, and 10 mm. Images were captured under the same light source configuration. Regions of category 2 were extracted from the residue type label image, and pixels with a value of 1 in the reflective mask image were removed. The shadow length of the remaining rock debris region in the original grayscale image was measured. (pixels), combined with well depth resolution, to calculate the actual shadow length. And with The independent variable is the actual height of the calibrated boss. Using the dependent variable as the model, the following relationship is obtained through fitting: , in, To calibrate the true height of the boss, This is the actual shadow length. These are calibration coefficients, reflecting the effects of light source incident angle, lens perspective distortion, and aperture wall curvature. Thickness grades are determined based on the actual height: when... When it is a thin layer, when 0.5 ≤ ≤1.5 At that time, as a middle-level manager, >1.5 The thickness is determined by experimental calibration based on the physical properties of downhole cuttings and cleaning requirements. If an area contains multiple cuttings particles, the height of each particle is calculated and averaged before the thickness grade of the area is determined according to the rules. After calculation, each residue area outputs the following indicators: residue type, coverage area, thickness grade (thin, medium, thick), and location coordinates.
[0032] Generate a borehole wall residue distribution map, constructing a two-dimensional coordinate system with the circumferential azimuth (0° to 360°) as the horizontal axis and the well depth (distance downwards from the wellhead) as the vertical axis. Based on the minimum and maximum circumferential azimuth and minimum and maximum well depth distances for each residue region, draw corresponding rectangular areas on the distribution map, using different colors or fill patterns to represent residue types: red represents cuttings adhesion, yellow represents mud coverage; gray represents fluid reflection areas, marked with dashed borders, and the legend indicates that these are reflection interference areas, not residue. Label the coverage area and thickness level within each region. Simultaneously, output the detailed location results for each residue region in the form of a text table, with each row corresponding to one region. Each region includes: region number, residue type, whether it is affected by reflection, starting circumferential azimuth, ending circumferential azimuth, starting well depth, ending well depth, coverage area, and thickness level. For areas with fluid reflection, their location coordinates are also output and separately marked as reflection interference, indicating that this area may be obscuring other residues, requiring a change in lighting conditions and re-image acquisition. The well depth range and circumferential azimuth range corresponding to the fluid reflection area are recorded, and the incident angle or intensity of the downhole light source is automatically adjusted, such as by increasing side supplementary lighting or reducing the brightness of the main light, driving the camera to re-capture the borehole wall image of this area. The new image undergoes preprocessing, semantic segmentation, and coordinate transformation again. If the reflection disappears, the actual residue classification, area, and thickness of the area are updated; if the reflection still exists, the lighting parameters are adjusted again until the maximum number of attempts (e.g., 3 times) is reached, and the final identification result after cleaning is used as the standard.
[0033] The location results of all areas are compiled into a single data file (e.g., JSON format) for the control system of the borehole cleaning device to read. The coordinates of each area in this data file can be used to drive the cleaning actuator for enhanced cleaning. For example, for areas with residues affected by reflective interference, the lighting parameters are adjusted first and the image is retaken; for areas without reflective interference, differentiated cleaning is performed according to thickness level: higher jetting pressure and longer action time are set for thick rock debris areas; lower cleaning intensity is used for thin mud areas.
[0034] The technical solutions described in the embodiments of this application have at least the following technical effects or advantages: This application employs median filtering and CLAHE enhancement to preprocess borehole wall images, improving image quality under non-uniform illumination. A two-layer pixel-level labeled training set for residue types and reflective masks is constructed, and a lightweight network is designed. Combining weighted cross-entropy loss and data augmentation, rapid and accurate classification of residues is achieved, solving the identification problem of key blockages such as rock cuttings. The segmentation results are transformed with the angle, depth resolution, and location labels calibrated on-site, and spatial proximity clustering is used to accurately locate the residue area on the actual borehole wall. Simultaneously, the gray-scale difference method is used to calculate the mud coverage area and thickness, and the shadow height measurement method is used to calculate the rock cutting thickness, outputting quantitative evaluation indicators. Finally, a borehole wall residue distribution map and JSON data file are generated to drive the borehole cleaning device for differentiated reinforcement cleaning, achieving the technical effects of precise cleaning, energy saving, improved borehole cleaning efficiency, and increased automation.
[0035] Example 2: Example 1 achieved the classification, location, area and thickness assessment, and differentiated cleaning of residues, but it still had the shortcoming of not considering the impact of the anchoring effect between residues and the hole wall on the cleaning difficulty. This example further supplements and explains the content of Example 1.
[0036] The method further includes: performing edge detection on the preprocessed grayscale image to obtain a binarized edge feature map; for each residue area, extracting its boundary pixels, taking a square window of a preset size centered on each boundary pixel, calculating the density of edge pixels within the window, and calculating the boundary irregularity based on the average density of all boundary pixels; sampling a preset number of pixels outward along the normal direction, calculating the grayscale change steepness and performing normalization processing to obtain the grayscale tailing index; for the rock debris attachment area, calculating the convex hull of the set of pixels in the area, and calculating the shape penetration index based on the ratio of the number of pixels in the area to the number of pixels covered by the convex hull.
[0037] Specifically, during the borehole cleaning process, images of the borehole wall surface are captured, and the borehole depth and circumferential azimuth angle corresponding to each frame are recorded. For the acquired raw images, median filtering is used to remove isolated noise points, contrast-limited adaptive histogram equalization is used to enhance image contrast, and all images are uniformly scaled to the same pixel size to obtain preprocessed grayscale images. Edge detection is then performed on the preprocessed grayscale images. The Canny edge detection operator is used, with a low threshold of 30 and a high threshold of 90, to extract pixels in the image where grayscale changes drastically, thus obtaining a binarized edge feature map. In this edge feature map, a pixel value of 1 indicates that the point belongs to an edge, and a pixel value of 0 indicates that the point does not belong to an edge. This edge feature map reflects the rock texture boundary of the borehole wall itself, the outline of micro-cracks, and the boundary between residues and the borehole wall.
[0038] The preprocessed grayscale image is input into a pre-trained semantic segmentation network, and forward inference yields a residue type label map and a reflective mask map. In the residue type label map, a pixel value of 0 indicates a clean borehole wall, 1 indicates mud coverage, and 2 indicates rock debris adhesion. In the reflective mask map, a pixel value of 1 indicates fluid reflection interference, and 0 indicates no reflection. Each residue region is obtained through coordinate transformation and spatial proximity clustering, and the set of all pixel coordinates of that region in the original image coordinate system is recorded. For each residue region, the number of pixels in each category is counted, and the category with the most occurrences is taken as the residue type for that region: if the majority of pixels are category 1, the region is a mud-covered region; if the majority of pixels are category 2, the region is a rock debris-attached region. If all valid residue pixels in a residue region are zero (i.e., pixels of category 1 or 2 with a reflective mask value of 0), the region is skipped. For regions containing valid residue pixels, anchoring effect feature extraction continues.
[0039] For each residue region, its corresponding pixel position in the preprocessed grayscale image is obtained. Using edge information from the edge feature map adjacent to this region, anchoring feature parameters are extracted from three aspects: boundary morphology, grayscale transition, and particle shape. Boundary pixels are extracted from the residue region; these are pixels that belong to the region and whose eight-neighborhood contains at least one pixel that does not belong to the region. Let B be the set of boundary pixels for this region, and the total number of boundary pixels be... For each boundary pixel Take a size as the center of it. A square window, for example Count the number of edge pixels (with a value of 1) in the edge feature map within the window, and denote it as . The total number of pixels within the window is Then the local edge density within the window is: , in, For boundary pixels Local edge density, Indicates the boundary pixel point Centered on, with side length as The number of edge pixels in the edge feature map within the square window; This represents the total number of pixels within the square window.
[0040] Local edge density reflects the richness of hole wall texture and microcracks near the boundary pixels. The boundary irregularity is obtained by averaging the local edge density of all boundary pixels in the region. , in, The value of represents the boundary irregularity, which ranges from [0, 1]. The larger the value, the more tortuous and broken the boundary between the residue and the pore wall, that is, the higher the degree of penetration of the residue into the microcracks of the pore wall, and the stronger the anchoring effect. For the set of boundary pixels Total number of pixels in the middle The set of boundary pixels of the residue region. This is used to sum the local edge densities of all pixels on the boundary.
[0041] For each boundary pixel ,by Centered on the boundary pixel, find the internal pixels of the residual material and the external hole wall pixels adjacent to it in its neighborhood. Calculate the direction of the line connecting the gray-level centroids of the internal and external pixels as an approximation of the normal direction. Along this normal direction, from the boundary pixel... Starting from there, continuously sample the outside of the borehole wall. pixel position, for example The gray value at the sampling point is denoted as ,in Closest to the boundary, The pixel furthest from the boundary. Calculate the steepness of the grayscale change at that boundary pixel, which is the average of the sum of the absolute values of the grayscale differences between adjacent sampling points: , in, For boundary pixels The steepness of the grayscale change at that location. This represents the total number of pixels sampled outwards from the boundary pixel along the normal direction. Let i be the gray value of the i-th sampling point in the grayscale image. It represents the absolute value of the grayscale difference between two adjacent sampling points. To sum the absolute values of the grayscale differences over all adjacent sampling points, To divide by step size This yields the absolute value of the average grayscale change at each step size.
[0042] The larger the value, the more drastic the grayscale change and the clearer the boundary. The smaller the value, the smoother the grayscale change, indicating a noticeable grayscale tail. The average steepness is obtained by averaging the steepness of all boundary pixels in this region: , in, To determine the average steepness, the maximum and minimum steepness values for different residue regions were obtained through calibration experiments. The average steepness was then normalized to eliminate the influence of differences in image illumination contrast. , in, The average steepness after normalization. The original average steepness, This represents the maximum steepness. This represents the minimum steepness. A larger value indicates a steeper boundary and a lower likelihood of grayscale trailing. Therefore, the grayscale trailing index is: , in, The grayscale tailing index ranges from [0, 1]. A value closer to 1 indicates a more pronounced tailing, deeper penetration of residues along microcracks, and a stronger anchoring effect.
[0043] For areas with debris attachment, the shape penetration index needs to be calculated additionally. Obtain the set of all pixel coordinates for that area. Calculate its convex hull That is, including The smallest convex polygon with all points in the region. Count the total number of pixels in the region and the total number of pixels covered by the convex hull, and define the shape fullness as: , in, For the fullness of the shape, The total number of pixels in the region. This represents the total number of pixels covered by the convex hull.
[0044] When the rock fragments are completely convex and not embedded, near , Approximately 1; when rock fragments are caught by the borehole wall, forming multiple depressions, much smaller , It is relatively small. Therefore, the shape penetration index is: , in, The shape penetration index ranges from [0, 1]. A larger value indicates a higher degree of rock cuttings embedding into the borehole wall and a stronger anchoring effect.
[0045] For each residue area, its thickness level is uniformly quantified into a thickness coefficient: 0.2 for thin layer, 0.5 for medium layer, and 0.8 for thick layer.
[0046] The boundary irregularity and gray-scale tailing index of the mud-covered area have been obtained, both of which are within the range of [0, 1]. The anchoring effect index of the mud area is: , in, is the anchoring effect index of the mud area, with a value range of [0, 1]. The larger the value, the stronger the anchoring effect, and the more difficult it is to clean the mud in this area. For boundary irregularity, This refers to the grayscale trailing index. For thickness coefficient, , and For the corresponding weight coefficients, and The determination is made through calibration experiments based on actual downhole working conditions, for example... , , .
[0047] The boundary irregularity, gray scale tailing index, and shape penetration index of the rock debris attachment area were all obtained, and all three were within the range of [0, 1]. The anchoring effect index of the rock debris area is: , in, This is the anchoring effect index of the rock debris area, with a value range of [0, 1]. The larger the value, the stronger the anchoring effect and the greater the difficulty of cleaning. For boundary irregularity, This refers to the grayscale trailing index. The shape penetration index, For thickness coefficient, , , and For the corresponding weight coefficients, and ,For example , , , Adjustments can be made based on the typical morphology of rock fragments and cleaning experience.
[0048] For each residual area on the distribution map, different shades of color are filled according to its anchoring effect index: the higher the index, the darker the color. For example, in the red area, low anchoring is light red, medium anchoring is red, and high anchoring is dark red; in the yellow area, low anchoring is light yellow, medium anchoring is yellow, and high anchoring is brownish-yellow. The anchoring effect index value is also marked next to the area. For high anchoring areas, a star is added to the upper right corner; for medium anchoring areas, a triangle is added; and no additional marking is added for low anchoring areas. Specifically, an anchoring effect index < 0.3 indicates low anchoring, 0.3 ≤ anchoring effect index < 0.7 indicates medium anchoring, and an anchoring effect index ≥ 0.7 indicates high anchoring.
[0049] The anchoring effect index also includes: adjusting cleaning parameters according to the anchoring effect index classification; Specifically, for each area with residue, the cleaning intensity is further adjusted based on the anchoring effect index, in addition to setting the cleaning parameters according to the thickness level. For low-anchoring areas, the standard cleaning parameters remain unchanged. For medium-anchoring areas, the cleaning pressure is increased by 20% to 30%, the number of spray passes is increased by one, and the cleaning time is extended by 30%. For high-anchoring areas, the cleaning pressure is increased by 50%, and a pulse spraying mode is used: a 1-second pause after every 2 seconds of spraying, repeated three times. After cleaning, the borehole wall image of the area is re-acquired, and the anchoring effect index is calculated. If the index is still greater than or equal to 0.7, high-anchoring cleaning is performed again until the maximum number of cleaning passes (e.g., 3 times) is reached.
[0050] The persistent anchoring zone also includes: recording the location coordinates, residue type, coverage area, thickness level and anchoring effect index of the persistent anchoring zone, generating a list of persistent anchoring zones; and highlighting the persistent anchoring zone with a preset symbol on the hole wall residue distribution map.
[0051] Specifically, areas where the index remains above 0.7 after reaching the maximum number of cleaning cycles are marked as stubborn anchoring zones. The complete attributes of these zones are recorded, including location coordinates, residue type, coverage area, thickness level, and anchoring effect index, generating a list of stubborn anchoring zones. Each stubborn anchoring zone is highlighted using a preset symbol on the borehole wall residue distribution map. For example, an H-shaped symbol with a circle is overlaid on top of the original color fill of the area; the legend clearly indicates that this symbol represents a stubborn anchoring zone. For multiple overlapping or adjacent stubborn anchoring zones, the symbols are marked according to the center position of each zone, ensuring that the location of each stubborn anchoring zone is clearly identifiable.
[0052] The technical solutions described in the embodiments of this application have at least the following technical effects or advantages: This application employs edge detection to extract borehole wall edge feature maps, and combines semantic segmentation results to extract boundary irregularity, grayscale tailing index, and shape penetration index of the residue area, constructing an anchoring effect index model for mud cover and rock cuttings adhesion. This enables a quantitative assessment of the anchoring strength between the residue and the borehole wall. Based on different anchoring effect indices, the cleaning pressure, number of sprays, action time, and pulse mode are adjusted differentially. Stubborn anchoring areas are marked and given special attention, avoiding energy waste caused by blindly increasing cleaning intensity. This achieves enhanced cleaning of highly anchored residues and energy-saving cleaning of low-anchoring areas, improving cleaning effectiveness and operational efficiency, and enhancing the automation and intelligence level of borehole cleaning operations.
[0053] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. For those skilled in the art, the present invention can have various modifications and variations. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for analyzing and locating residues on the downhole borehole wall, characterized in that, include: S1: Acquire borehole wall images and record the well depth and circumferential azimuth for each frame; The image is preprocessed to obtain a preprocessed grayscale image; S2: Use a pre-defined semantic segmentation network to infer the grayscale image and output a residue type label map and a reflection mask map; S3: Based on the residue type label map and reflective mask map, combined with the recorded well depth and circumferential azimuth, the pixel coordinates are converted to the actual borehole wall spatial coordinates. The reflective areas marked in the reflective mask map are excluded. Then, the spatial proximity clustering of the converted residue pixels is performed to obtain the position coordinates of each residue area on the actual borehole wall and the residue type. S4: Calculate the coverage area and thickness level of each residue region on the actual borehole wall, generate a borehole wall residue distribution map, and output the location results of each residue region.
2. The method for analyzing and locating residues on the downhole borehole wall according to claim 1, characterized in that, The preprocessing includes: using median filtering to remove isolated noise points, with the filtering window size being a preset window size; using a contrast-limited adaptive histogram equalization algorithm to enhance image contrast; and uniformly scaling all images to the same pixel size while maintaining the original aspect ratio, filling insufficient areas with black pixels.
3. The method for analyzing and locating residues on the downhole borehole wall according to claim 1, characterized in that, The reasoning of the grayscale image includes: inputting the grayscale image into a semantic segmentation network, the network adopting an encoder and decoder structure, and outputting a residue type label map and a reflection mask map with the same size as the input image; The residue type label diagram shows that pixel value 0 indicates a cleaned borehole wall, 1 indicates mud coverage, and 2 indicates rock debris adhesion. In the reflective mask image, a pixel value of 1 indicates the presence of fluid reflection, and 0 indicates no reflection. When the target pixel has a value of 1 or 2 in the residue type label image and is 1 in the reflective mask image, the area corresponding to the target pixel is determined to be a residue area affected by reflective interference.
4. The method for analyzing and locating residues on the downhole borehole wall according to claim 1, characterized in that, The conversion from pixel coordinates to actual borehole wall spatial coordinates includes: obtaining the circumferential azimuth resolution and well depth distance resolution in advance through on-site calibration; for circumferential unfolding imaging, linearly mapping the horizontal coordinate to 0° to 360° and the vertical coordinate to the well depth distance; for local imaging, combining the starting and ending circumferential azimuth angles recorded during acquisition, linearly mapping the column number to the corresponding angle range.
5. The method for analyzing and locating residues on the downhole borehole wall according to claim 1, characterized in that, The spatial proximity clustering includes: grouping pixels with a circumferential azimuth difference less than a preset angle threshold and a well depth difference less than a preset distance threshold into the same residue region; for residue regions detected in different frames of images, if there is overlap in the well depth direction and the overlap rate of the circumferential azimuth range exceeds a preset overlap rate threshold, they are merged into the same region. The starting well depth of the merged region is taken as the minimum value in each frame, the ending well depth is taken as the maximum value, the circumferential azimuth range is taken as the union, and the residue type is determined according to the category with the most pixels.
6. The method for analyzing and locating residues on the downhole borehole wall according to claim 1, characterized in that, The coverage area is calculated as follows: , in, For the coverage area of the region, This represents the total number of pixels contained in the region within the label map. The actual area represented by each pixel; The thickness level is determined as follows: for mud-covered areas, the mud thickness is estimated using the gray-scale difference method, and the estimated thickness is compared with a preset mud thickness threshold to determine whether it is a thin layer, a medium layer, or a thick layer; for rock debris-attached areas, the rock debris height is obtained using the shadow height measurement method, and the height is compared with a preset rock debris height threshold to determine whether it is a thin layer, a medium layer, or a thick layer.
7. The method for analyzing and locating residues on the downhole borehole wall according to claim 1, characterized in that, The method further includes: performing edge detection on the preprocessed grayscale image to obtain a binarized edge feature map; for each residue area, extracting its boundary pixels, taking a square window of a preset size centered on each boundary pixel, calculating the density of edge pixels within the window, and calculating the boundary irregularity based on the average density of all boundary pixels; sampling a preset number of pixels outward along the normal direction, calculating the grayscale change steepness and performing normalization processing to obtain the grayscale tailing index; for the rock debris attachment area, calculating the convex hull of the set of pixels in the area, and calculating the shape penetration index based on the ratio of the number of pixels in the area to the number of pixels covered by the convex hull.
8. The method for analyzing and locating residues on the downhole borehole wall according to claim 7, characterized in that, The method further includes: calculating the anchoring effect index based on the boundary irregularity, grayscale tailing index, and thickness coefficient corresponding to the residue type; for mud-covered areas, the formula for calculating the anchoring effect index is: , in, This represents the anchoring effect index in the mud zone. For boundary irregularity, This refers to the grayscale trailing index. For thickness coefficient, , and For the corresponding weight coefficients, and ; For the area where rock cuttings adhere, the formula for calculating the anchoring effect index is: , in, The anchoring effect index for the rock cuttings region. For boundary irregularity, This refers to the grayscale trailing index. The shape penetration index, For thickness coefficient, , , and For the corresponding weight coefficients, and .
9. The method for analyzing and locating residues on the downhole borehole wall according to claim 8, characterized in that, The anchoring effect index further includes: adjusting cleaning parameters according to the anchoring effect index in stages; when the anchoring effect index is lower than the first preset threshold, using conventional cleaning parameters; when the anchoring effect index is between the first preset threshold and the second preset threshold, increasing the cleaning pressure by a first preset ratio, increasing the number of spray sweeps, and extending the cleaning time; when the anchoring effect index is higher than the second preset threshold, increasing the cleaning pressure by a second preset ratio and using a pulse spray mode; after cleaning, re-acquiring images and calculating the anchoring effect index; if it is still higher than the second preset threshold, repeating the process until the maximum number of cleaning cycles is reached, and marking areas still higher than the second preset threshold as stubborn anchoring areas.
10. The method for analyzing and locating residues on the downhole borehole wall according to claim 9, characterized in that, The persistent anchoring zone also includes: recording the location coordinates, residue type, coverage area, thickness level and anchoring effect index of the persistent anchoring zone, generating a list of persistent anchoring zones; and highlighting the persistent anchoring zone with a preset symbol on the hole wall residue distribution map.