Rock sample pore dynamic observation method and system based on image difference analysis and electronic equipment

By constructing visual difference color images in nuclear magnetic resonance imaging technology, the error problem of traditional observation methods in rock sample porosity discrimination is solved, and accurate analysis and efficient monitoring of rock sample porosity changes are realized.

CN122049073APending Publication Date: 2026-05-15GENERAL PROSPECTING INSTITUTE OF CHINA NATIONAL ADMINISTRATION OF COAL GEOLOGY
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GENERAL PROSPECTING INSTITUTE OF CHINA NATIONAL ADMINISTRATION OF COAL GEOLOGY
Filing Date
2026-01-12
Publication Date
2026-05-15

AI Technical Summary

Technical Problem

Traditional human visual observation methods cannot accurately identify sub-millimeter-level morphological changes in the pore network and microfractures of rock samples in nuclear magnetic displacement experiments. Furthermore, due to visual fatigue and subjective judgment, continuous comparative analysis of multiple images may result in errors, affecting the accuracy of the discrimination.

Method used

By acquiring grayscale images of rock samples in their initial and target displacement states, a difference matrix is ​​calculated and a visual difference color image is constructed. The difference values ​​are mapped to different colors using a preset brightness threshold, and the variation characteristics of the pore region are quantitatively analyzed. Pixel-level grayscale value comparison and noise reduction processing are used to improve the image comparison accuracy.

Benefits of technology

This improved the accuracy of rock sample porosity identification, reduced errors in manual observation and analysis, and enhanced the visualization and quantitative analysis capabilities of porosity changes during displacement.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122049073A_ABST
    Figure CN122049073A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a rock sample pore dynamic observation method and system based on image difference analysis and electronic equipment, and relates to the technical field of geotechnical engineering and geomechanics testing. The rock sample pore dynamic observation method comprises the following steps: acquiring a first grayscale image of a rock sample in an initial displacement state and a second grayscale image of the rock sample in a target displacement state; pixel-level gray value comparison is carried out on at least one frame of the first gray image and the second gray image according to a corresponding time sequence, a difference matrix of the first gray image and the second gray image is obtained through calculation, and each element in the difference matrix is a gray difference value of a corresponding pixel; based on a preset brightness threshold value, mapping the difference matrix into a visual difference color image; and based on the visual difference color image, quantitatively analyzing the regional change characteristics of the rock sample pores in the displacement process. The precision of rock sample pore discrimination in the displacement process can be improved. The device and the method are suitable for pore dynamic observation scenes of nuclear magnetic displacement experiments of rock samples.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of geotechnical engineering and geomechanical testing technology, and in particular to a method, system and electronic equipment for dynamic observation of rock sample porosity based on image difference analysis. Background Technology

[0002] Nuclear magnetic resonance imaging (NMR) technology provides an important observational tool for studying the internal pore structure and microfracture development of rocks. Its core value lies in enabling intuitive and qualitative analysis of pore evolution through the distribution of bright spots and differences in brightness in the images.

[0003] However, traditional human observation methods have significant limitations in the dynamic monitoring of nuclear magnetic resonance displacement experiments: first, they cannot accurately identify sub-millimeter-level morphological changes in pore networks and microfractures; second, due to visual fatigue and subjective judgment, continuous comparative analysis of multiple images results in errors. This technical bottleneck severely restricts the identification of rock sample porosity during the displacement process, affecting the accuracy of identification. Summary of the Invention

[0004] In view of this, embodiments of the present invention provide a method, system and electronic equipment for dynamic observation of rock sample porosity based on image difference analysis, which can improve the accuracy of rock sample porosity identification during displacement.

[0005] In a first aspect, embodiments of the present invention provide a method for dynamic observation of rock sample porosity based on image difference analysis, comprising the steps of: acquiring a first grayscale image of a rock sample in an initial displacement state and a second grayscale image in a target displacement state; comparing the pixel-level grayscale values ​​of at least one frame of the first grayscale image and the second grayscale image according to a corresponding time sequence, and calculating a difference matrix between the first grayscale image and the second grayscale image, wherein each element in the difference matrix is ​​the grayscale difference value of the corresponding pixel; mapping the difference matrix into a visual difference color image based on a preset brightness threshold, wherein pixel positions in the difference matrix with difference values ​​greater than the brightness threshold are marked with a first preset color; pixel positions in the difference matrix with difference values ​​less than the negative brightness threshold are marked with a second preset color; and displaying pixel positions in the difference matrix with difference values ​​between positive and negative brightness thresholds as grayscale images; and quantitatively analyzing the regional change characteristics of rock sample porosity during the displacement process based on the visual difference color image.

[0006] Optionally, mapping the difference matrix into a visual difference color image based on a preset brightness threshold includes: selecting pixel positions from the difference matrix where the grayscale difference value is greater than the brightness threshold, and generating a positive difference mask; selecting pixel positions from the difference matrix where the grayscale difference value is less than the negative brightness threshold, and generating a negative difference mask; converting the first grayscale image into a three-channel color image as a base, replacing the corresponding region pixel values ​​with a first preset color using the positive difference mask, and replacing the corresponding region pixel values ​​with a second preset color using the negative difference mask; wherein the region replaced by the first preset color is the region where the grayscale of the pores and cracks increases during the displacement process, and the region replaced by the second preset color is the region where the grayscale of the pores and cracks decreases during the displacement process.

[0007] Optionally, the step of comparing the pixel-level grayscale values ​​of at least one frame of the first grayscale image and the second grayscale image according to the corresponding time sequence to calculate the difference matrix between the first grayscale image and the second grayscale image includes: extracting the acquisition timestamp of the first grayscale image and the acquisition timestamp of the second grayscale image; confirming the displacement state corresponding to the acquisition timestamp of the second grayscale image based on the displacement experiment log, and verifying whether the first grayscale image and the second grayscale image correspond to different displacement stages at the same spatial location of the rock sample; converting the pixel grayscale values ​​of the first grayscale image and the second grayscale image into 16-bit signed integers respectively; performing point-by-point subtraction on all pixels of the first grayscale image and the second grayscale image to obtain an initial difference matrix, wherein the value range of each element in the matrix is ​​[-255, 255]; performing 3×3 neighborhood mean filtering on the initial difference matrix, and calculating the mean difference value between each pixel and its 8 neighboring pixels; if the deviation between the difference value of a pixel and the mean difference value exceeds a predetermined threshold, then the difference value of the pixel is corrected to the mean value to obtain the noise-reduced difference matrix.

[0008] Optionally, before acquiring the first grayscale image of the rock sample in the initial displacement state and the second grayscale image in the target displacement state, the method further includes: acquiring images corresponding to different displacement states of the rock sample during the displacement process, including at least the image of the initial displacement state and the image of the target displacement state; converting the image of the initial displacement state and the image of the target displacement state into grayscale images to obtain the first grayscale image and the second grayscale image; verifying whether the sizes of the first grayscale image and the second grayscale image are consistent; and setting the image sizes to be consistent when the sizes of the first grayscale image and the second grayscale image are inconsistent.

[0009] Optionally, different displacement states include scanning at different pressure points or at different time points during the injection or extraction of displacement fluid into the rock sample to obtain images representing the dynamic changes in the fluid distribution inside the rock sample.

[0010] Secondly, embodiments of the present invention also provide a dynamic observation system for rock sample porosity based on image difference analysis, comprising: an image input module for acquiring a first grayscale image of a rock sample in an initial displacement state and a second grayscale image in a target displacement state; an image processing module for comparing the pixel-level grayscale values ​​of at least one frame of the first grayscale image and the second grayscale image according to a corresponding time sequence, and calculating a difference matrix between the first grayscale image and the second grayscale image, wherein each element in the difference matrix is ​​the grayscale difference value of the corresponding pixel; a visualization rendering module for mapping the difference matrix into a visualized difference color image based on a preset brightness threshold, wherein pixel positions in the difference matrix with difference values ​​greater than the brightness threshold are marked with a first preset color; pixel positions in the difference matrix with difference values ​​less than the negative brightness threshold are marked with a second preset color; and pixel positions in the difference matrix with difference values ​​between positive and negative brightness thresholds are displayed as grayscale images; and a quantitative analysis module for quantitatively analyzing the regional change characteristics of rock sample porosity during the displacement process based on the visualized difference color image.

[0011] Optionally, the visualization rendering module is specifically used to: filter out pixel positions with grayscale difference values ​​greater than the brightness threshold from the difference matrix and generate a positive difference mask; filter out pixel positions with grayscale difference values ​​less than the negative brightness threshold from the difference matrix and generate a negative difference mask; convert the first grayscale image into a three-channel color image as a base, replace the corresponding region pixel values ​​with a first preset color using the positive difference mask, and replace the corresponding region pixel values ​​with a second preset color using the negative difference mask; wherein, the region replaced by the first preset color is the region where the grayscale of the pores and cracks increases during the displacement process, and the region replaced by the second preset color is the region where the grayscale of the pores and cracks decreases during the displacement process.

[0012] Optionally, the image processing module is specifically used to extract the acquisition timestamp of the first grayscale image and the acquisition timestamp of the second grayscale image; confirm the displacement state corresponding to the acquisition timestamp of the second grayscale image based on the displacement experiment log, and verify whether the first grayscale image and the second grayscale image correspond to different displacement stages at the same spatial location of the rock sample; convert the pixel grayscale values ​​of the first grayscale image and the second grayscale image into 16-bit signed integers respectively; perform point-by-point subtraction operation on all pixels of the first grayscale image and the second grayscale image to obtain an initial difference matrix, wherein the value range of each element in the matrix is ​​[-255, 255]; perform 3×3 neighborhood mean filtering on the initial difference matrix, and calculate the mean difference value between each pixel and its 8 neighboring pixels; if the deviation between the difference value of a pixel and the mean difference value exceeds a predetermined threshold, then the difference value of the pixel is corrected to the mean value to obtain the noise-reduced difference matrix.

[0013] Optionally, different displacement states include scanning at different pressure points or at different time points during the injection or extraction of displacement fluid into the rock sample to obtain images representing the dynamic changes in the fluid distribution inside the rock sample.

[0014] Thirdly, embodiments of the present invention also provide an electronic device, the electronic device comprising: a processor and a memory, wherein the memory is used to store executable program code; the processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, for executing the image difference analysis-based dynamic observation method for rock sample porosity described in any of the first aspects above.

[0015] This invention provides a method, system, and electronic device for dynamic observation of rock sample porosity based on image difference analysis. The method compares pixel-level grayscale values ​​of a first grayscale image of a rock sample in its initial displacement state and a second grayscale image in its target displacement state, calculates a difference matrix, and constructs a visual difference color image to quantitatively analyze the regional changes in rock sample porosity during the displacement process. Specifically, when constructing the visual difference color image, the difference matrix is ​​mapped to the visual difference color image based on a preset brightness threshold. Pixels with difference values ​​greater than the brightness threshold are marked with a first preset color; pixels with difference values ​​less than a negative brightness threshold are marked with a second preset color; and pixels with difference values ​​between the positive and negative thresholds are displayed as grayscale images. This intuitively demonstrates the changes in rock sample porosity during the displacement process, improving the accuracy of rock sample porosity identification during displacement. Attached Figure Description

[0016] 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 only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0017] Figure 1 A schematic diagram of a method for dynamic observation of rock sample porosity based on image difference analysis provided in an embodiment of the present invention;

[0018] Figure 2 A visual difference color image provided in an embodiment of the present invention;

[0019] Figure 3 This is a schematic diagram of the architecture of a dynamic observation system for rock sample porosity based on image difference analysis, provided in an embodiment of the present invention.

[0020] Figure 4 This is a schematic block diagram illustrating the architecture of an embodiment of the electronic device of the present invention. Detailed Implementation

[0021] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0022] It should be understood that the described embodiments are merely some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.

[0023] Example 1

[0024] This embodiment provides a method for dynamic observation of rock sample porosity based on image difference analysis. (See attached image) Figure 1 As shown, the method includes the following steps:

[0025] S110. Obtain the first grayscale image of the rock sample in the initial displacement state and the second grayscale image in the target displacement state.

[0026] In this step, image processing technology is applied to the dynamic monitoring of rock sample displacement experiments. A first grayscale image of the rock sample in its initial displacement state and a second grayscale image in its target displacement state are acquired. The grayscale image of the initial displacement state is compared with grayscale images of multiple target displacement states during the displacement process to compare the pixel differences between the images of different displacement states and the image of the initial displacement state. Specifically, a nuclear magnetic resonance imaging (NMR) system can be used to acquire NMR images of the rock sample in different displacement states in real time during the displacement experiment.

[0027] In some embodiments, before step S110, acquiring a first grayscale image of the rock sample in its initial displacement state, and a second grayscale image in its target displacement state, the method further includes:

[0028] Collect images of rock samples at different displacement states during the displacement process, including at least images of the initial displacement state and images of the target displacement state;

[0029] The images of the initial displacement state and the target displacement state are converted into grayscale images to obtain a first grayscale image and a second grayscale image;

[0030] Verify whether the dimensions of the first grayscale image and the second grayscale image are consistent;

[0031] When the sizes of the first grayscale image and the second grayscale image are inconsistent, set the image sizes to be consistent.

[0032] In this embodiment, when using image data of rock samples during the displacement experiment to analyze the dynamic evolution of pores and fractures in the rock samples, image data corresponding to different displacement states during the displacement process are collected. For example, a nuclear magnetic resonance imaging (NMR) system is used to scan the same rock sample at different pressure points and time points during water injection displacement to obtain a series of two-dimensional or three-dimensional NMR images. This embodiment uses two-dimensional NMR images as an example for illustration. NMR images can be color or directly grayscale images. When the collected image data is color, the images of the initial displacement state and the target displacement state are converted into grayscale format to obtain a first grayscale image of the initial displacement state and a second grayscale image of the target displacement state.

[0033] Different displacement states are used to represent the scanning at different pressure points or time points during the injection or extraction of displacement fluid into the rock sample, in order to obtain images representing the dynamic changes in the fluid distribution inside the rock sample. Different pressure points can capture the fluid distribution state of the rock sample under specific mechanical conditions, and different time points can record the dynamic evolution of fluid transport over time. It should be noted that the images in this embodiment are not limited to nuclear magnetic resonance (NMR) images. Specifically, a strategy of graded loading of axial pressure can be adopted, with increments of 5 MPa, to monitor the changes in axial pressure from 0 to the rock sample's ultimate strength range. After each axial pressure level stabilizes, NMR images of the rock sample are simultaneously sampled. For example, at 0 MPa, the initial displacement state image of the rock sample is obtained. With increments of 5 MPa, images are collected after each pressure level stabilizes to obtain the target displacement state image of the rock sample, and the collected images are stored in a preset storage path.

[0034] The specific process for acquiring time-series nuclear magnetic resonance images is as follows:

[0035] Rock sample preparation and saturation: Select the rock sample to be tested, for example, a sample from a coal mine at a distance... Rock samples were taken from the fine sandstone layer at about 1-10m, the siltstone layer at 10-20m, and the medium sandstone layer at 30-40m in the coal roof. The samples were then linearly cut along the vertical direction to obtain three cylindrical rock samples of the same size (e.g., 25mm in diameter and 80mm in height). The cylindrical rock samples were then vacuumed and pressurized with saturated brine.

[0036] Installation and displacement: The saturated rock sample is loaded into a pressure-resistant core holder and placed in a magnet homogenizer. The displacement system is connected, and the nuclear magnetic resonance imaging system (NMR imager) is started to inject displacement fluid into the rock sample in a staged pressurization manner.

[0037] Image sequence acquisition: Pressure point acquisition: The inlet pressure is detected by a pressure sensor. When the pressure stabilizes at a preset value (such as 5MPa, 10MPa, 20MPa, etc.), the displacement is paused or the pressure is maintained, and the magnetic resonance imaging system is started to scan.

[0038] Time-based acquisition: Timing starts from the displacement and scanning is performed at fixed time intervals (such as the 1st minute, the 5th minute, the 10th minute, etc.);

[0039] Finally, the NMR images of the initial displacement state and NMR images of different displacement states are stored in the preset storage path.

[0040] Furthermore, this embodiment utilizes the OpenCV library to implement comparative analysis of nuclear magnetic resonance images of rock samples under different displacement states. During image processing, the first grayscale image of the initial displacement state and the second grayscale image of the target displacement state are first read from the pre-stored image data storage path. After reading the image data, two levels of verification are performed to ensure the validity of the image data: the first level verifies whether the image was successfully loaded, avoiding processing invalid data; the second level verifies whether the image sizes are consistent, avoiding comparison failures due to size differences. When the sizes of the first grayscale image and the second grayscale image are inconsistent, the image sizes are set to be consistent to ensure the accuracy of the comparison results.

[0041] In some embodiments, after acquiring the first grayscale image and the second grayscale image, pixel registration is performed on the first grayscale image and the second grayscale image to solve the noise caused by the small displacement due to displacement pressure and imaging system errors during the displacement experiment, and the spatial position deviation between images, so as to ensure that pixels of different displacement states to the same physical position can be accurately compared.

[0042] Specifically, the ORB (Oriented FAST and Rotated BRIEF, a fast feature point extraction and description algorithm) feature point detection and Homography matrix transformation in the OpenCV library can be used to register the image of the target displacement state with the image of the initial state, so that the pixel positions between the images correspond one-to-one, ensuring that the rock sample positions are completely aligned.

[0043] S120. Compare the pixel-level grayscale values ​​of at least one frame of the first grayscale image and the second grayscale image according to the corresponding time sequence, and calculate the difference matrix between the first grayscale image and the second grayscale image, wherein each element in the difference matrix is ​​the grayscale difference value of the corresponding pixel.

[0044] In this step, the first grayscale image and the second grayscale image are aligned in time sequence. For the aligned grayscale images (the first grayscale image and the second grayscale image), the difference in grayscale values ​​is calculated pixel by pixel to obtain the difference matrix.

[0045] In some embodiments, step S120, comparing the pixel-level grayscale values ​​of at least one frame of the first grayscale image and the second grayscale image according to a corresponding time sequence, and calculating the difference matrix between the first grayscale image and the second grayscale image, includes:

[0046] Extract the acquisition timestamp of the first grayscale image and the acquisition timestamp of the second grayscale image;

[0047] Based on the displacement experiment log, the displacement state corresponding to the acquisition timestamp of the second grayscale image was confirmed, and it was verified whether the first grayscale image and the second grayscale image corresponded to different displacement stages at the same spatial location of the rock sample.

[0048] The pixel grayscale values ​​of the first grayscale image and the second grayscale image are converted into 16-bit signed integers respectively.

[0049] Perform pointwise subtraction on all corresponding pixels of the first grayscale image and the second grayscale image to obtain an initial difference matrix, where the value of each element in the matrix is ​​in the range of [-255, 255].

[0050] Perform 3×3 neighborhood mean filtering on the initial difference matrix and calculate the mean difference value of the 3×3 neighborhood of each pixel;

[0051] If the difference value of a pixel deviates from the mean difference value by more than a predetermined threshold, the difference value of that pixel is corrected to the mean value to obtain the noise-reduced difference matrix.

[0052] In this embodiment, the precise acquisition timestamps of the first and second grayscale images are read from the image metadata. Based on the displacement experiment log database, the displacement parameters corresponding to the acquisition timestamp of the second grayscale image are queried, such as the type and concentration of the injected fluid, the experimental environment temperature and pressure, and the displacement pressure gradient, to verify that the first and second grayscale images correspond to different displacement stages at the same spatial location of the rock sample. The pixel grayscale values ​​of the original grayscale images are converted into 16-bit signed integers to avoid overflow during subtraction operations and to ensure negative values. Point-by-point subtraction operations are performed on all pixels of the first and second grayscale images to obtain the initial difference matrix, and the initial difference matrix is ​​then subjected to noise reduction processing.

[0053] Specifically, noise reduction is achieved using neighborhood statistics, including 3×3 neighborhood mean filtering and outlier correction.

[0054] The 3×3 neighborhood mean filtering involves: for each pixel position in the difference matrix, constructing a 3×3 neighborhood window centered on that pixel. This window contains the center pixel and its eight surrounding neighbors, totaling nine pixels. The arithmetic mean of all pixels within this neighborhood window is then calculated. Pixels at boundary positions can be specially processed, calculating only the average of valid neighborhood positions to avoid the influence of invalid data. For example, for the top-left pixel position (0,0), its valid neighborhood includes only four pixels (including itself), and the average is calculated based on these four valid values.

[0055] Outlier correction includes: for each pixel location, calculating the absolute deviation of its difference value from the neighborhood mean; comparing the calculated deviation with a predetermined threshold: if the deviation is greater than the predetermined threshold, the pixel is determined to be an outlier noise point; if the deviation is less than or equal to the predetermined threshold, the original difference value is retained; correction is performed only on pixels determined to be outlier noise points, correcting the pixel's difference value to the mean. This improves the accuracy and reliability of image difference analysis.

[0056] In this step, the difference matrix is ​​a two-dimensional array with the same size as the original image, and the value of each pixel position represents the gray level difference between the registered image and the initial state image at the corresponding pixel.

[0057] In some embodiments, calculating the difference matrix between the first grayscale image and the second grayscale image further includes: calculating the difference matrix between the first grayscale image and the second grayscale image based on a weighted difference algorithm, wherein the formula for the weighted difference algorithm is:

[0058] ;

[0059] in, This represents the difference in pixel grayscale values ​​at position (x, y) in the difference matrix. Let t be the grayscale image representing the t-th displacement state. Represented as Let represent the pixel grayscale value of the grayscale image in the t-th displacement state. Represented as a grayscale image in its initial state. This represents the pixel grayscale values ​​of the grayscale image in its initial state. Represented as a grayscale image based on the initial state Weighting factors calculated from local features;

[0060] The weighting factor The local features include at least: the grayscale image at position (x,y) in the initial state. Local contrast and position (x,y) of the grayscale image in the initial state The preset range of gray values ​​and their positions (x, y) in the initial state of the grayscale image. The degree of consistency of grayscale value changes in neighboring pixels.

[0061] When calculating the weighting factor based on local contrast, the Sobel operator is used to calculate the gradient magnitudes of the displaced state image and the initial state image respectively as a measure of local contrast. Then, the local contrast is normalized to obtain the weighting factor based on local contrast. Specifically, this can be implemented using Python and the NumPy library.

[0062] When calculating weights based on the grayscale values ​​of the original image (e.g., focusing on the grayscale range corresponding to a specific pore fluid), a weight is created that has a high weight within the target range and a low weight outside the range.

[0063] When calculating the weights based on neighborhood consistency, the difference between each pixel and its preset neighborhood mean is calculated. Points with large differences from the neighborhood mean may be noise and are assigned low weights.

[0064] This embodiment employs a weighted difference algorithm. Compared to traditional simple absolute or relative difference algorithms, it introduces weight factors related to local image features to achieve intelligent modulation of difference calculation. This adaptively enhances change signals occurring on key geological structures such as pore edges, while effectively suppressing interference from imaging noise and small fluctuations in uniform background areas, thus improving the signal-to-noise ratio of the visualized difference image.

[0065] S130. Based on a preset brightness threshold, the difference matrix is ​​mapped into a visual difference color image, wherein the pixel positions in the difference matrix with difference values ​​greater than the brightness threshold are marked with a first preset color; the pixel positions in the difference matrix with difference values ​​less than the negative brightness threshold are marked with a second preset color; and the pixel positions in the difference matrix with difference values ​​between the positive and negative brightness thresholds are displayed as grayscale images.

[0066] In this embodiment, after generating the difference matrix, it is mapped into a visual difference color image to intuitively show the regional variation characteristics of the rock sample microstructure during the displacement process.

[0067] In this embodiment, a two-color difference annotation method can be used. By setting a specific brightness threshold, pixel positions with difference values ​​greater than the brightness threshold are marked with a first preset color; pixel positions with difference values ​​less than a negative brightness threshold are marked with a second preset color. For example, the first preset color is red, which represents a positive difference when the difference value is greater than the brightness threshold, and the second preset color is blue, which represents a negative difference when the difference value is less than a negative brightness threshold, so as to intuitively show the changes in the microstructure of the rock sample during the displacement process.

[0068] Specifically, mapping the difference matrix into a visual difference color image based on a preset brightness threshold includes:

[0069] Pixel positions with grayscale difference values ​​greater than the brightness threshold are selected from the difference matrix to generate a positive difference mask;

[0070] Pixel positions whose grayscale difference values ​​are less than the negative brightness threshold are selected from the difference matrix to generate a negative difference mask;

[0071] The first grayscale image is converted into a three-channel color image as a base. The pixel values ​​of the corresponding regions are replaced with a first preset color by a positive difference mask, and the pixel values ​​of the corresponding regions are replaced with a second preset color by a negative difference mask. The regions replaced by the first preset color are the regions where the grayscale of the pores and cracks increases during the displacement process, and the regions replaced by the second preset color are the regions where the grayscale of the pores and cracks decreases during the displacement process.

[0072] Specifically, the process of generating color images for image processing and visualization is illustrated using a concrete implementation example:

[0073] Read the first grayscale image of the initial displacement state and the second grayscale image of the target displacement state from the storage path of the pre-stored image data;

[0074] Verify that the first grayscale image and the second grayscale image are the same size;

[0075] When the first grayscale image and the second grayscale image are the same size, the grayscale difference between the two images is calculated pixel by pixel to obtain the difference matrix;

[0076] The first grayscale image is converted into a three-channel color image as a base. By setting a configurable brightness threshold and utilizing two symmetrical conditions—grayscale difference values ​​greater than the brightness threshold and grayscale difference values ​​less than the negative brightness threshold—significant positive and negative variation regions can be accurately and efficiently separated from the background and noise. Finally, by assigning red and blue to the positive and negative variation regions respectively, and initializing insignificant variation regions to neutral gray, a visual difference color image is obtained. The generated visual difference color image is not only highly contrasting and intuitive, but also effectively suppresses image noise interference through threshold filtering, significantly improving the signal-to-noise ratio and intuitively displaying the changes in the microstructure of the rock sample during displacement.

[0077] In some embodiments, after obtaining the denoised difference matrix, the absolute values ​​of all non-zero elements in the denoised difference matrix are counted, and their mean μ and standard deviation σ are calculated.

[0078] Define a significant difference threshold S = μ + 1.5σ, and filter out pixels in the difference matrix whose |difference value| > S, and mark them as pixels with high significant differences;

[0079] The method of mapping the difference matrix into a visual difference color image based on a preset brightness threshold further includes: during the generation of a positive difference mask and the generation of a negative difference mask, appending a marker bit to the corresponding pixel value for the mask region containing highly significant difference pixel markers;

[0080] When generating a color image of visual differences, the regions with attached markers are automatically overlaid with a white outline of a predetermined width when displayed to distinguish between regions of ordinary difference and regions of high significance difference.

[0081] Optionally, in some embodiments, replacing the pixel values ​​of the corresponding region with a first preset color using a positive difference mask includes: dividing the positive difference mask region into three gradient intervals based on the magnitude of the difference value.

[0082] Brightness threshold < difference value ≤ S, corresponding to a light shade of the first preset color, such as light red;

[0083] S < difference value ≤ 2S, corresponding to the standard hue of the first preset color, such as bright red;

[0084] If the difference value is greater than 2 seconds, it corresponds to the darker shade of the first preset color, such as dark red.

[0085] For the negative difference mask region, it is divided into 3 gradient intervals based on the magnitude of the absolute difference value:

[0086] Brightness threshold <|difference value|≤S, corresponding to a light shade of the second preset color, such as light blue;

[0087] S<|difference value|≤2S, corresponding to the standard hue of the second preset color, such as dark blue;

[0088] |Difference value|>2S, corresponding to the darker shade of the second preset color, such as indigo;

[0089] By replacing the pixel values ​​of the corresponding mask regions with the aforementioned gradient intervals, a visual color image with differential intensity gradients is generated. This allows for quick identification of which regions have changed and the direction of those changes. Furthermore, by using varying shades of the same color to represent the intensity gradient of the differences, the magnitude of the changes is visually displayed, facilitating the focus on areas of significant change. This provides support for subsequent quantitative analysis.

[0090] S140. Based on the visualized color difference image, quantitatively analyze the regional variation characteristics of rock sample porosity during the displacement process.

[0091] In this step, the generated visual difference color images are analyzed, allowing for clear observation of changes in the rock sample's microstructure during displacement. For example, see... Figure 2 As shown in (a) to (f), Figure 2 (a) represents the pixel difference between the NMR grayscale image at 0 MPa axial pressure and the reference image at an initial state of 0 MPa. Figure 2 (b) represents the pixel difference between the NMR grayscale image under axial pressure of 5 MPa and the reference image under initial state of 0 MPa. Figure 2 (c) represents the pixel difference between the NMR grayscale image under axial pressure of 10 MPa and the reference image under initial state of 0 MPa. Figure 2 (d) represents the pixel difference between the NMR grayscale image under axial pressure of 20 MPa and the reference image under initial state of 0 MPa. Figure 2 (e) represents the pixel difference between the NMR grayscale image under axial pressure of 30 MPa and the reference image under initial state of 0 MPa. Figure 2 (f) represents the pixel difference between the NMR grayscale image under axial pressure of 39 MPa and the reference image under the initial state of 0 MPa. According to the figure, the blue (negative difference value) is concentrated at the injection end and shifts to the left with the axial pressure, indicating that the signal on the left side of the rock sample is weakened, reflecting the compression state; the red (positive difference value) gradually connects from a sporadic distribution, indicating that the water conduction channels are connected under the combined action of seepage and stress, and eventually macroscopic cracks are formed.

[0092] In some embodiments, based on the visualized color difference image, quantitative analysis of the regional variation characteristics of rock sample porosity during the displacement process further includes: analyzing the incremental changes of multiple consecutive displacement stages, using the previous state as a baseline, calculating the difference between the previous state and the next state, and generating a series of incremental difference maps arranged in a time series.

[0093] Specifically, by analyzing images of multiple consecutive displacement stages, such as the incremental changes in the injection pressure gradient, and using the previous state as a baseline, the difference between the previous and subsequent states is calculated to generate a series of difference increment maps arranged in time sequence. This dynamically displays the entire process of pore opening, expansion, and connection, captures instantaneous and minute structural changes, and reveals the dynamic evolution law of displacement dynamics.

[0094] In some embodiments, after calculating the difference matrix between the first grayscale image and the second grayscale image, the method further includes:

[0095] Based on the difference matrix, a grayscale difference image is output, and the grayscale difference image is binarized to obtain a binarized difference image.

[0096] Mathematical morphological operations are performed on the binarized difference image to quantitatively analyze the changes in rock sample porosity during the displacement process; the mathematical morphological operations include opening and closing operations.

[0097] In this embodiment, after obtaining the difference matrix, an initial grayscale difference image is generated. An adaptive thresholding method is then used to convert the initial grayscale difference image into a binary difference image, transforming the continuous grayscale change image into an image of clearly defined changed or unchanged regions, preparing for subsequent morphological analysis. Specifically, a threshold is set for the grayscale difference image. Regions with pixel values ​​greater than the threshold are considered changed and assigned a value of 1 (white), while regions with pixel values ​​less than or equal to the threshold are considered unchanged and assigned a value of 0 (black), resulting in a preliminary binary difference image. Subsequently, opening operations are used to remove noise, and closing operations are used to connect breaks and fill holes to optimize the shape and connectivity of the changed regions.

[0098] It also includes: performing overlay analysis on the optimized change area and the pore structure diagram of the rock sample under the baseline state to obtain the overlay analysis results; and classifying the change area based on the overlay analysis results to distinguish at least two types: newly added pores and expansion of existing pores.

[0099] Specifically, the initial state image (such as the NMR image of the initial water-saturated state) The baseline rock sample pore structure map is obtained by binarization. The optimized change region is extracted from the initial grayscale difference image. Logical operation is performed between the optimized change region and the baseline rock sample pore structure map. If there is an intersection between the two, the region is determined to be an expansion of the original pores. If there is no intersection between the two, the region is determined to be a newly generated pore or fracture during the process. Different label values ​​are assigned to different change types. For example, in the final result image, the original pore expansion is marked with a grayscale value of 128, and the newly added pores are marked with a grayscale value of 255. Finally, a classification change image is generated.

[0100] Based on the classified change images, a series of quantitative parameters can be extracted, including the area and proportion of pore regions.

[0101] Through the above process, the automatic differentiation of change types was achieved during the graphical analysis, which improved the accuracy of rock sample porosity analysis and increased experimental efficiency.

[0102] This embodiment provides a method for dynamic observation of rock sample porosity based on image difference analysis. It compares pixel-level grayscale values ​​of a first grayscale image of a rock sample in its initial displacement state and a second grayscale image in its target displacement state, calculates a difference matrix, and constructs a visual difference color image to quantitatively analyze the regional change characteristics of rock sample porosity during the displacement process. Specifically, when constructing the visual difference color image, the difference matrix is ​​mapped to the visual difference color image based on a preset brightness threshold. Pixels with difference values ​​greater than the brightness threshold are marked with a first preset color; pixels with difference values ​​less than a negative brightness threshold are marked with a second preset color; and pixels with difference values ​​between the positive and negative thresholds are displayed as grayscale images. This method intuitively demonstrates the change characteristics of rock sample porosity during the displacement process, thereby improving the accuracy of rock sample porosity identification during displacement.

[0103] Furthermore, the automated analysis of rock sample nuclear magnetic resonance images reduces errors from manual observation and analysis, while improving experimental efficiency.

[0104] Example 2

[0105] This embodiment also provides a dynamic observation system for rock sample porosity based on image difference analysis, see below. Figure 3 As shown, the system includes:

[0106] Image input module 31 is used to acquire a first grayscale image of the rock sample in the initial displacement state and a second grayscale image in the target displacement state;

[0107] Image processing module 32 is used to compare the pixel-level grayscale values ​​of at least one frame of the first grayscale image and the second grayscale image according to the corresponding time sequence, and calculate the difference matrix between the first grayscale image and the second grayscale image, wherein each element in the difference matrix is ​​the grayscale difference value of the corresponding pixel.

[0108] The visualization rendering module 33 is used to map the difference matrix into a visualization difference color image based on a preset brightness threshold, wherein the pixel positions in the difference matrix with difference values ​​greater than the brightness threshold are marked with a first preset color; the pixel positions in the difference matrix with difference values ​​less than the negative brightness threshold are marked with a second preset color; and the pixel positions in the difference matrix with difference values ​​between the positive and negative brightness thresholds are displayed as grayscale images.

[0109] The quantitative analysis module 34 is used to quantitatively analyze the regional variation characteristics of rock sample porosity during the displacement process based on the visualized difference color image.

[0110] In some embodiments, the visualization rendering module is specifically used to: filter out pixel positions with grayscale difference values ​​greater than the brightness threshold from the difference matrix and generate a positive difference mask; filter out pixel positions with grayscale difference values ​​less than the negative brightness threshold from the difference matrix and generate a negative difference mask; convert the first grayscale image into a three-channel color image as a base, replace the corresponding region pixel values ​​with a first preset color using the positive difference mask, and replace the corresponding region pixel values ​​with a second preset color using the negative difference mask; wherein, the region replaced by the first preset color is the region where the grayscale of the pores and cracks increases during the displacement process, and the region replaced by the second preset color is the region where the grayscale of the pores and cracks decreases during the displacement process.

[0111] In some embodiments, the image processing module is specifically used to extract the acquisition timestamp of the first grayscale image and the acquisition timestamp of the second grayscale image; confirm the displacement state corresponding to the acquisition timestamp of the second grayscale image based on the displacement experiment log, and verify whether the first grayscale image and the second grayscale image correspond to different displacement stages at the same spatial location of the rock sample; convert the pixel grayscale values ​​of the first grayscale image and the second grayscale image into 16-bit signed integers respectively; perform point-by-point subtraction operation on all pixels of the first grayscale image and the second grayscale image to obtain an initial difference matrix, wherein the value range of each element in the matrix is ​​[-255, 255]; perform 3×3 neighborhood mean filtering on the initial difference matrix, and calculate the mean difference value between each pixel and its 8 neighboring pixels; if the deviation between the difference value of a pixel and the mean difference value exceeds a predetermined threshold, then the difference value of the pixel is corrected to the mean value to obtain the noise-reduced difference matrix.

[0112] In some embodiments, different displacement states include scanning at different pressure points or at different time points during the injection or extraction of displacement fluid into the rock sample to obtain images representing the dynamic changes in the fluid distribution inside the rock sample.

[0113] Example 3

[0114] Figure 4 This is a schematic block diagram of the architecture of an embodiment of the electronic device of the present invention; based on the same technical concept as the foregoing Embodiment 1, the electronic device 40 provided in this embodiment of the present invention, such as... Figure 4 As shown, the steps and flow of any of the embodiments described in Embodiment 1 of the present invention can be implemented.

[0115] The aforementioned electronic device 40 may include a processor 41 and a memory 42, wherein the memory 42 is used to store executable program code; the processor 41 runs a program corresponding to the executable program code by reading the executable program code stored in the memory 42, for executing any of the image difference analysis-based dynamic observation methods for rock sample porosity described in the aforementioned embodiment 1.

[0116] For details on the specific execution process of the above steps by the processor 41 and the steps further executed by the processor 41 by running executable program code, please refer to the description of Embodiment 1 of the present invention, which will not be repeated here.

[0117] The electronic device exists in various forms, including but not limited to: (1) Mobile communication devices: These devices are characterized by their mobile communication capabilities and are primarily designed to provide voice and data communication. These terminals include smartphones (such as iPhones), multimedia phones, feature phones, and low-end phones.

[0118] (2) Ultra-mobile personal computer devices: These devices fall under the category of personal computers, possessing computing and processing capabilities, and generally also have mobile internet access features. These terminals include PDAs, MIDs, and UMPCs, such as the iPad.

[0119] (3) Portable entertainment devices: These devices can display and play multimedia content. This category includes audio and video players (such as iPods), handheld game consoles, e-book readers, as well as smart toys and portable car navigation devices.

[0120] (4) Server: A device that provides computing services. The components of a server include a processor, hard disk, memory, system bus, etc. Servers are similar to general computer architectures, but because they need to provide highly reliable services, they have higher requirements in terms of processing power, stability, reliability, security, scalability, and manageability.

[0121] (5) Other electronic devices with data interaction functions.

[0122] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0123] The various embodiments in this specification are described in a related manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on describing the differences from other embodiments.

[0124] For ease of description, if systems, servers, etc. are involved, they may be described separately as various units / modules based on their functions. Of course, in implementing this invention, the functions of each unit / module can be implemented in one or more software and / or hardware.

[0125] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.

[0126] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A method for dynamic observation of rock sample porosity based on image difference analysis, characterized in that, The method includes: Acquire the first grayscale image of the rock sample in the initial displacement state, and the second grayscale image in the target displacement state; At least one frame of the first grayscale image and the second grayscale image are compared at the pixel level according to the corresponding time sequence to calculate the difference matrix between the first grayscale image and the second grayscale image. Each element in the difference matrix is ​​the grayscale difference value of the corresponding pixel. Based on a preset brightness threshold, the difference matrix is ​​mapped to a visual difference color image, wherein the pixel positions in the difference matrix with difference values ​​greater than the brightness threshold are marked with a first preset color; the pixel positions in the difference matrix with difference values ​​less than the negative brightness threshold are marked with a second preset color; and the pixel positions in the difference matrix with difference values ​​between positive and negative brightness thresholds are displayed as grayscale images. Based on the visualized color difference images, the regional variation characteristics of rock sample porosity during the displacement process are quantitatively analyzed.

2. The method for dynamic observation of rock sample porosity based on image difference analysis according to claim 1, characterized in that, The step of mapping the difference matrix into a visual difference color image based on a preset brightness threshold includes: Pixel positions with grayscale difference values ​​greater than the brightness threshold are selected from the difference matrix to generate a positive difference mask; Pixel positions with grayscale difference values ​​less than the negative brightness threshold are selected from the difference matrix to generate a negative difference mask; The first grayscale image is converted into a three-channel color image as a base. The pixel values ​​of the corresponding regions are replaced with a first preset color by a positive difference mask, and the pixel values ​​of the corresponding regions are replaced with a second preset color by a negative difference mask. The regions replaced by the first preset color are the regions where the grayscale of the pores and cracks increases during the displacement process, and the regions replaced by the second preset color are the regions where the grayscale of the pores and cracks decreases during the displacement process.

3. The method for dynamic observation of rock sample porosity based on image difference analysis according to claim 1, characterized in that, The step of comparing the pixel-level grayscale values ​​of at least one frame of the first grayscale image and the second grayscale image according to the corresponding time sequence, and calculating the difference matrix between the first grayscale image and the second grayscale image, includes: Extract the acquisition timestamp of the first grayscale image and the acquisition timestamp of the second grayscale image; Based on the displacement experiment log, the displacement state corresponding to the acquisition timestamp of the second grayscale image was confirmed, and it was verified whether the first grayscale image and the second grayscale image corresponded to different displacement stages at the same spatial location of the rock sample. The pixel grayscale values ​​of the first grayscale image and the second grayscale image are converted into 16-bit signed integers respectively. Perform pointwise subtraction on all corresponding pixels of the first grayscale image and the second grayscale image to obtain an initial difference matrix, where the value of each element in the matrix is ​​in the range of [-255, 255]. Perform 3×3 neighborhood mean filtering on the initial difference matrix and calculate the mean difference between each pixel and its 8 neighboring pixels; If the difference value of a pixel deviates from the mean difference value by more than a predetermined threshold, the difference value of that pixel is corrected to the mean value to obtain the noise-reduced difference matrix.

4. The method for dynamic observation of rock sample porosity based on image difference analysis according to claim 1, characterized in that, Before acquiring the first grayscale image of the rock sample in its initial displacement state and the second grayscale image in its target displacement state, the method further includes: Collect images of rock samples at different displacement states during the displacement process, including at least images of the initial displacement state and images of the target displacement state; The images of the initial displacement state and the target displacement state are converted into grayscale images to obtain a first grayscale image and a second grayscale image; Verify whether the dimensions of the first grayscale image and the second grayscale image are consistent; When the sizes of the first grayscale image and the second grayscale image are inconsistent, set the image sizes to be consistent.

5. The method for dynamic observation of rock sample porosity based on image difference analysis according to claim 1, characterized in that, Different displacement states are used to represent the scanning at different pressure points or different time points during the injection or extraction of displacement fluid into the rock sample, in order to obtain images representing the dynamic changes in the fluid distribution inside the rock sample.

6. A dynamic observation system for rock sample porosity based on image difference analysis, characterized in that, The system includes: The image input module is used to acquire a first grayscale image of the rock sample in the initial displacement state and a second grayscale image in the target displacement state. The image processing module is used to compare the pixel-level grayscale values ​​of at least one frame of the first grayscale image and the second grayscale image according to the corresponding time sequence, and calculate the difference matrix between the first grayscale image and the second grayscale image, wherein each element in the difference matrix is ​​the grayscale difference value of the corresponding pixel. A visualization rendering module is used to map the difference matrix into a visual difference color image based on a preset brightness threshold. Pixels in the difference matrix with difference values ​​greater than the brightness threshold are marked with a first preset color; pixels in the difference matrix with difference values ​​less than or equal to the negative brightness threshold are marked with a second preset color; and pixels in the difference matrix with difference values ​​between the positive and negative brightness thresholds are displayed as grayscale images. The quantitative analysis module is used to quantitatively analyze the regional variation characteristics of rock sample porosity during the displacement process based on the visualized color difference image.

7. The rock sample porosity dynamic observation system based on image difference analysis according to claim 6, characterized in that, The visualization rendering module is specifically used to: select pixel positions whose grayscale difference value is greater than the brightness threshold from the difference matrix, and generate a positive difference mask; Pixel positions with grayscale difference values ​​less than the negative brightness threshold are selected from the difference matrix to generate a negative difference mask; The first grayscale image is converted into a three-channel color image as a base. The pixel values ​​of the corresponding regions are replaced with a first preset color by a positive difference mask, and the pixel values ​​of the corresponding regions are replaced with a second preset color by a negative difference mask. The regions replaced by the first preset color are the regions where the grayscale of the pores and cracks increases during the displacement process, and the regions replaced by the second preset color are the regions where the grayscale of the pores and cracks decreases during the displacement process.

8. The rock sample porosity dynamic observation system based on image difference analysis according to claim 6, characterized in that, The image processing module is specifically used to extract the acquisition timestamp of the first grayscale image and the acquisition timestamp of the second grayscale image. Based on the displacement experiment log, the displacement state corresponding to the acquisition timestamp of the second grayscale image was confirmed, and it was verified whether the first grayscale image and the second grayscale image corresponded to different displacement stages at the same spatial location of the rock sample. The pixel grayscale values ​​of the first grayscale image and the second grayscale image are converted into 16-bit signed integers respectively. Perform pointwise subtraction on all corresponding pixels of the first grayscale image and the second grayscale image to obtain an initial difference matrix, where the value of each element in the matrix is ​​in the range of [-255, 255]. Perform 3×3 neighborhood mean filtering on the initial difference matrix and calculate the mean difference between each pixel and its 8 neighboring pixels; If the difference value of a pixel deviates from the mean difference value by more than a predetermined threshold, the difference value of that pixel is corrected to the mean value to obtain the noise-reduced difference matrix.

9. The rock sample porosity dynamic observation system based on image difference analysis according to claim 6, characterized in that, Different displacement states include scanning at different pressure points or at different time points during the injection or extraction of displacement fluid into the rock sample to obtain images representing the dynamic changes in the fluid distribution inside the rock sample.

10. An electronic device, characterized in that, The electronic device includes a processor and a memory, wherein the memory is used to store executable program code; the processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, for executing the dynamic observation method of rock sample porosity based on image difference analysis as described in any one of claims 1 to 5.