Coal rock image preparation method based on wire cutting and image repairing
By combining diamond wire cutting and a two-stage scratch repair network with attention mechanisms and self-supervised training, the problem of scratches in coal and petrology images caused by wire cutting is solved, achieving efficient and high-quality preparation of coal and petrology microscopic images, which is suitable for coal quality analysis and coal petrology research.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- INNER MONGOLIA RESEARCH INSTITUTE CHINA UNIVERSITY OF MINING AND TECHNOLOGY (BEIJING)
- Filing Date
- 2026-03-04
- Publication Date
- 2026-06-09
AI Technical Summary
In existing technologies, wire cutting processes cause scratches and texture disturbances in coal and rock microscopic images, affecting image quality and subsequent analysis. Traditional restoration methods are unable to accurately restore the complex mineral grain boundaries and texture information of coal and rock, resulting in inaccurate restoration results.
Coal and rock cross-section images were obtained using diamond wire cutting, and scratch regions were identified by a semantic segmentation network with an attention mechanism. A two-stage scratch repair network was then used for repair, including structural reconstruction and texture generation. Self-supervised training and multiple attention mechanisms were used to ensure the geometric structure and texture authenticity of the repair results.
This technology enables the restoration of high-quality and complete coal and petrology microscopic images while maintaining efficient wire cutting, ensuring the reliability and accuracy of coal petrology research and reducing reliance on human manipulation.
Smart Images

Figure CN122175907A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of coal and rock analysis and image processing technology, and particularly relates to a method for preparing coal and rock images based on wire cutting and image restoration. Background Technology
[0002] Light section microscopy images are important tools and fundamental materials for coal quality analysis and coal petrology research. By observing the microstructure, mineral distribution, and organic matter morphology of coal samples under a microscope, they provide important information for coal quality evaluation, coal processing and utilization, coal genesis research, and environmental geology studies. Traditional light section preparation processes typically involve multiple steps, including bonding coal samples to form sections, cutting, grinding, and polishing.
[0003] Currently, wire cutting technology is commonly used to directly slice coal bricks, thereby quickly obtaining images of coal and rock cross-sections. This includes methods such as electrical discharge wire cutting, abrasive wire cutting, and diamond wire cutting. Compared to the other two methods, diamond wire cutting can effectively cut hard materials and avoid structural changes caused by high temperatures or mechanical damage, making it suitable for acquiring high-quality coal and rock cross-section images. However, it still leaves fine scratches, texture disturbances, and noise on the cut surface, affecting not only the visual quality of the image but also potentially interfering with subsequent quantitative analysis and discrimination studies in coal petrology. Therefore, effective repair of scratches or defective areas in the images is necessary. Commonly used methods include traditional image processing methods based on interpolation, diffusion, or patch matching, and deep learning methods based on generative adversarial networks (GANs). The former fills the scratched area with information from surrounding pixels but struggles to reconstruct the complex and fine mineral grain boundaries and texture information in coal and rock microscopic images, easily resulting in smoothed or blurred images. The latter learns image repair capabilities through data-driven learning and can generate texture information to some extent, but it struggles to accurately preserve the true microscopic texture and grain details of coal and rock. The repair results may produce texture drift or pseudo-structures, reducing the credibility of research results. Summary of the Invention
[0004] To address the aforementioned shortcomings in existing technologies, this invention provides a method for preparing coal and rock images based on wire cutting and image restoration. This method solves the problems of existing technologies, which suffer from inefficiencies in physical cutting processes and low fidelity in restoration methods, resulting in complex preparation processes, low image quality, and difficulty in meeting the needs of coal quality analysis and coal petrology research.
[0005] To achieve the above objectives, the technical solution adopted by this invention is: a method for preparing coal and rock images based on wire cutting and image restoration, comprising the following steps: The coal and rock samples were wire-cut to obtain the original microscopic images of the cut surfaces. Based on the original microscopic image, the scratch region of the original microscopic image is identified and processed by a semantic segmentation network with an attention mechanism to obtain a binary mask image of the scratch region. Based on the original microscopic image and the binary mask image, a two-stage scratch repair network is used to reconstruct the structure and generate texture of the scratched area by utilizing information from the undamaged area around the scratched area, thus obtaining a repaired coal and rock microscopic image.
[0006] To address the problems of image scratch defects inevitably introduced by the use of efficient wire cutting in existing coal and rock image preparation technologies, and the difficulty in ensuring restoration efficiency and accuracy of complex microstructure and texture restoration using traditional single-stage digital inpainting methods, this invention proposes a rapid preparation method based on wire cutting and image inpainting. First, the original microscopic image of the cut surface of the coal and rock sample is rapidly acquired using wire cutting technology. Then, a semantic segmentation network integrating an attention mechanism automatically and accurately identifies and segments the scratch regions in the image, generating a binary mask image. Finally, a two-stage inpainting network is used for high-fidelity restoration: the first-stage structural reconstruction network prioritizes the restoration of scratch regions. The first stage involves analyzing the geometric structure of coal and rock particles within the trace area, including their outlines and edges, to ensure accurate boundaries in the restoration results. The second stage, a texture generation network guided by a structural reconstruction map, synthesizes microscopic textures within a masked area that are highly consistent with the surrounding undamaged areas in terms of visual features and material semantics, ensuring the texture of the restoration results is realistic and reliable. Simultaneously, this invention incorporates a loss function designed based on coal and rock images polished using a polishing process. This enables the output of high-quality coal and rock microscopic images that rival traditional polishing processes in both microstructural integrity and texture realism, while maintaining the efficiency of wire cutting. This solves the problem of balancing efficiency and high quality in coal and rock image preparation.
[0007] Further: obtaining the binary mask image of the scratch region specifically includes: The original coal and rock microscopic images were normalized and enhanced to obtain preprocessed images. The preprocessed image is input into a semantic segmentation network, and an attention mechanism is used to extract multi-scale features from scratch edges and detailed feature regions to obtain scratch region features. Based on the characteristics of the scratched area, edge information, linear texture, and local contrast changes are extracted through encoding. Based on the scratch area features, edge information, linear texture, and local contrast changes, a preliminary scratch prediction map is obtained by fusing the data. Based on the preliminary scratch prediction map, thresholding is performed through binarization and mask generation to obtain a binary mask image of the scratch area. In the binary mask image of the scratch area, white represents the scratch area and black represents the non-scratched area.
[0008] Furthermore: the two-stage scratch repair network includes a structure reconstruction network and a texture generation network connected in sequence; The structure reconstruction network is used to reconstruct the edge and contour structure of coal and rock particles within the scratched area based on the original microscopic image, and output a structure reconstruction map. The texture generation network is used to generate a texture that blends with the surrounding undamaged area within the scratched area of a binary mask image based on the structure reconstruction map, and outputs a repaired coal and rock microscopic image.
[0009] To address the problem that existing single-stage image restoration methods struggle to simultaneously ensure the correctness of the geometric structure and the authenticity of the microtexture in complex structural images such as coal and rock, this invention's dual-stage scratch restoration network divides the restoration process into two stages: structural reconstruction followed by texture generation. Structural reconstruction ensures the accurate restoration of particle contours and boundaries. Then, based on the correctly reconstructed structural map, texture generation synthesizes an accurate texture that is semantically consistent with the intact area surrounding the scratched region, achieving a high-fidelity image restoration effect for wire-cut scratches.
[0010] Furthermore: the output structure reconstruction map specifically includes: The original microscopic images are input into the structural reconstruction network; The encoder of the structure reconstruction network extracts multi-scale features of the original microscopic image; Based on multi-scale features, the decoder of the structure reconstruction network performs upsampling to reconstruct the edge and contour structure of coal and rock particles within the scratched area, resulting in a structure reconstruction map. The structure reconstruction map includes the coarse structure of the scratched area and the original image of the non-scratched area.
[0011] To address the problem that existing restoration methods often suffer from distorted geometric shapes and blurred boundaries of coal and rock particles when directly generating pixels within scratched areas due to the lack of explicit structural priors, the structural reconstruction network of this invention employs an encoder-decoder architecture. The encoder utilizes multi-scale features extracted to capture contextual information from local textures to global structures in coal and rock images. The decoder then progressively upsamples the data to reconstruct edges and contours within the scratched areas that conform to the surrounding semantic logic. This generates an intermediate image that integrates the undamaged original image with the coarse structure of the scratched area, providing accurate geometric constraints for subsequent texture generation and ensuring the structural correctness of the restoration result.
[0012] Furthermore: the structure reconstruction network includes an encoder and a decoder, and is trained in a self-supervised manner. By randomly generating scratches on the microscopic image of intact coal sheet, a scratch binary image of the pseudo-defect region is formed, which is then paired with the microscopic image of intact coal sheet for training to obtain the structure reconstruction model. The expression for the loss function of the generator is as follows:
[0013]
[0014]
[0015] in, Let the loss function of the generator be... For pixel loss in the scratched area, The weights for the full-image perception loss, For full-image perception loss, For image repair, This is the original image. This is a binary mask for the scratched area. It is an L1 norm. To pre-train the VGG network, It is an L2 norm.
[0016] This invention employs a self-supervised data construction method, generating high-quality training samples using scratch-free coal and rock images. In the design of the loss function, the pixel loss of the scratched area ensures that the reconstructed area is aligned with the real coal and rock texture structure in terms of pixel values. The full-image perception loss is constrained by deep features extracted by the pre-trained VGG network, ensuring that the structure reconstruction result is consistent with the real image in terms of visual semantics and overall naturalness. The two are balanced by weights, jointly driving the structure reconstruction network to learn the structure reconstruction capability suitable for coal and rock image restoration.
[0017] Furthermore: the restored coal and rock microscopic image specifically includes: The reconstructed structure map and the binary mask image are input into the texture generation network; By using the generator in the texture generation network, within the scratched area of the binary mask image, the edge and contour structures provided by the rough structure of the scratched area in the structural reconstruction image are used as a guide to generate a coal and rock micro-texture consistent with the undamaged area around the scratched area, thus obtaining a restored coal and rock micro-image.
[0018] To address the problem that existing restoration methods often produce semantic errors and visual inconsistencies between the generated texture and the scratched mineral particles due to a lack of accurate structural constraints when generating textures in scratched areas, this invention first performs structural reconstruction to determine the boundaries. Then, guided by the structural reconstruction map, the texture generation network synthesizes textures only within the masked area based on the correct edge contours. This ensures that the generated micro-texture is consistent with the visual characteristics and material properties of the surrounding real coal and rock components, achieving a high-fidelity image restoration effect that can be used for quantitative analysis.
[0019] Furthermore: the generator integrates a multi-attention mechanism, and the generator's loss function introduces style constraints; The multiple attention mechanism includes channel attention and spatial attention; The channel attention is used to adaptively adjust the feature weights of different channels based on the feature importance of the scratch region in the structural reconstruction image. The spatial attention is used to adaptively adjust the feature weights of different spatial locations based on the local spatial distribution characteristics of the scratched area in the structural reconstruction image. The style constraints include pixel loss and perceptual loss; The pixel loss is used to constrain the consistency between the reconstructed image and the real image within the scratch area at the pixel level. The perceptual loss is used to constrain the semantic consistency between the repaired image and the real image in the deep feature space.
[0020] Furthermore, the expression for the loss function of the generator is as follows:
[0021]
[0022]
[0023] in, Let the loss function of the generator be... For pixel loss in the scratched area, The weights for the full-image perception loss, For full-image perception loss, For image repair, This is the original image. This is a binary mask for the scratched area. It is an L1 norm. To pre-train the VGG network, It is an L2 norm.
[0024] To address the issues of inaccurate texture generation and unnatural blending with surrounding textures caused by the lack of feature focusing and multi-level constraints in existing generative networks for scratch repair, this paper introduces a dual attention mechanism of channel and spatial attention. This mechanism enables the network to focus on key features and local spatial information in the scratch area. Simultaneously, by combining pixel loss and perceptual loss, texture generation is constrained from two dimensions: pixel-level accuracy and semantic-level consistency. This achieves high-fidelity, artifact-free micro-texture repair of coal and rock.
[0025] The beneficial effects of this invention are as follows: By integrating efficient wire cutting technology with two-stage coal and rock image restoration, this invention solves the problem of balancing efficiency and quality in traditional coal and rock image preparation methods. It utilizes diamond wire cutting to replace manual polishing, enabling rapid slicing and image acquisition of coal and rock samples. Furthermore, it achieves automated, high-precision localization of scratched areas through a semantic segmentation network integrating an attention mechanism. The two-stage restoration network, employing a strategy of first structural reconstruction and then texture generation, ensures that the repaired scratched areas in the coal and rock images not only have correct geometric contours but also exhibit high visual and semantic consistency with the surrounding real coal and rock components in terms of microtexture, avoiding structural distortion and texture artifacts caused by wire cutting and existing digital image restoration methods. Simultaneously, the structural reconstruction network employs a self-supervised training mode, overcoming the problem of data scarcity and enabling the processing from scratched coal and rock images to high-quality prepared coal and rock images. This reduces reliance on professional operators, ensures the repeatability and objectivity of the results, and provides an efficient, accurate, and reliable technical tool for quantitative analysis of coal petrology and rapid evaluation of coal quality. Attached Figure Description
[0026] Figure 1 This is a schematic diagram of a coal and rock image preparation method based on wire cutting and image restoration; Figure 2 This is a diagram showing the effect of the present invention on image restoration of small scratches; Figure 3 This is a diagram showing the effect of the present invention on image restoration of large scratches; Figure 4 This is an image showing the effect of the present invention in enhancing the texture of blurred images. Detailed Implementation
[0027] The specific embodiments of the present invention are described below to enable those skilled in the art to understand the present invention. However, it should be understood that the present invention is not limited to the scope of the specific embodiments. For those skilled in the art, various changes are obvious as long as they are within the spirit and scope of the present invention as defined and determined by the appended claims. All inventions utilizing the concept of the present invention are protected.
[0028] Example 1 like Figure 1 The diagram shows a flowchart of a coal and rock image preparation method based on wire cutting and image inpainting. This invention provides a coal and rock image preparation method based on wire cutting and image inpainting, comprising the following steps: The coal and rock samples were wire-cut to obtain the original microscopic images of the cut surfaces. Based on the original microscopic image, the scratch region of the original microscopic image is identified and processed by a semantic segmentation network with an attention mechanism to obtain a binary mask image of the scratch region. Based on the original microscopic image and the binary mask image, a two-stage scratch repair network is used to reconstruct the structure and generate texture of the scratched area by utilizing information from the undamaged area around the scratched area, thus obtaining a repaired coal and rock microscopic image.
[0029] In existing coal and rock slide preparation, the acquisition of high-quality coal and rock images mainly relies on traditional physical polishing processes. However, this process is cumbersome, time-consuming, and labor-intensive. Furthermore, it is prone to introducing artificial scratches on the slide surface due to improper operation or uneven coal and rock materials. These scratches can severely damage the integrity of the microscopic image, resulting in coal and rock sample images that cannot meet the needs of analysis and scientific research. Therefore, it is necessary to repair the cut images. However, most existing image repair methods use deep learning-based repair models or digital repair methods. But coal and rock have complex mineral grains and textures, which can easily lead to blurring of the repaired area or texture drift during repair, generating pseudo-textures that appear reasonable but do not conform to the real mineral grain texture, thus reducing the scientific validity and reliability of the coal and rock image preparation results. Therefore, this invention provides a method for preparing coal and rock images based on wire cutting and image restoration. It employs wire cutting methods, such as diamond wire cutting, to acquire the original microscopic image of the coal and rock cut surface, improving sample preparation efficiency. For the scratched areas after cutting, a two-stage scratch restoration network is designed for scratch repair. The first stage is a reconstruction network, based on self-supervised training and a loss function, capable of restoring the core contour and edge structure of coal and rock particles within the scratched area. The second stage is a texture generation network, guided by the structural reconstruction map, which generates textures within the scratch mask-defined area that are visually and semantically highly consistent with the surrounding undamaged areas through an internally integrated attention mechanism and loss function. This invention achieves high-quality restoration of scratches caused by wire cutting through collaborative restoration of structural reconstruction followed by texture generation. While ensuring the accuracy of the morphology, boundaries, and texture information of key mineral components in the coal and rock microscopic image, this invention shortens the coal and rock image preparation cycle, enabling rapid acquisition and high-quality display of coal and rock images, providing reliable technical support for the automated and refined analysis of coal petrology.
[0030] In one embodiment of the present invention, in order to quickly acquire coal and rock images, existing technologies often use wire cutting technology to directly slice coal bricks, including: electrical discharge wire cutting, which relies on electric spark discharge to corrode materials and is only suitable for conductive materials, while coal bricks are non-conductive materials and therefore cannot be directly applied; abrasive wire cutting, which uses wire coated with abrasive to achieve cutting and is mainly used for brittle materials such as glass and ceramics, but its cutting accuracy and surface quality are limited, making it difficult to guarantee the flatness of the coal and rock cut surface and the optical quality required for microscopic analysis; and diamond wire cutting, which coats or embeds diamond particles on the surface of a steel wire and achieves grinding cutting through high-speed motion. Its advantages are low cutting force, high precision, and wide applicability. It can effectively cut hard materials and avoid structural changes to the sample due to high temperature or mechanical damage, and is especially suitable for non-conductive materials with complex internal structures such as coal bricks. Therefore, this invention employs a diamond wire cutting method to cut coal and rock samples. Specifically, it includes: cutting coal bricks using a diamond wire cutting machine, with the tension of the entire diamond wire being approximately 40N; setting the saw wire speed to 5mm / s and the cutting height greater than the height of the coal brick according to the sample's hardness; using clean water or a special coolant to reduce wear between the diamond wire and the cutting surface and to ensure effective temperature control in the cutting area; after cutting, removing the sample and photographing it under a microscope to obtain a microscopic image of the coal sample with scratches to be repaired, thus obtaining the original microscopic image of the cut surface of the coal and rock sample.
[0031] In one embodiment of the present invention, for the original microscopic image of the cut surface of a coal and rock sample, a binary mask is often manually annotated to mark the area to be repaired and the intact image area to obtain the original microscopic image of the cut surface of the coal and rock sample. However, the manual method is extremely inefficient, highly subjective, and inconsistent, making it difficult to meet the needs of large-scale image processing. Moreover, because coal and rock themselves contain rich mineral grain boundaries, fissures, and differences in optical properties, the resulting edge and texture interference is often similar to real mechanical scratches in grayscale and contrast, leading to a high likelihood of false detection or false detection, such as misjudging mineral boundaries as scratches or failing to identify faint, fine real scratches. If inaccurate detection results are used for subsequent repair, it will lead to incorrect modification of intact effective areas or omission of some scratches, significantly reducing the reliability and practicality of coal and rock image preparation. The present invention identifies and processes the scratch area of the original microscopic image using a semantic segmentation network with an attention mechanism, based on the original microscopic image, to obtain a binary mask image of the scratch area; specifically including: The original coal and rock microscopic images are normalized and enhanced to obtain preprocessed images, so that the subsequent network can extract scratch features more accurately. The preprocessed image is input into the semantic segmentation network, and the multi-scale feature extraction of scratch edges and detailed feature regions is performed by combining the attention mechanism to obtain scratch region features. Among them, the attention mechanism module is embedded in the semantic segmentation network, which enables the semantic segmentation network to automatically focus on scratch edges and detailed feature regions, thereby improving the accuracy of scratch region recognition. Based on the characteristics of the scratched area, edge information, linear texture, and local contrast changes are extracted through encoding. Based on the scratch area features, edge information, linear texture, and local contrast changes, a preliminary scratch prediction map is obtained by fusing the data. Based on the preliminary scratch prediction image, thresholding is performed through binarization and mask generation to obtain a binary mask image of the scratch region. In the binary mask image of the scratch region, white represents the scratch region and black represents the non-scratched region. By employing an attention mechanism, the semantic segmentation network can selectively focus on regions in an image that exhibit typical scratch characteristics such as thin, elongated lines, specific directionality, and sharp edges, thus suppressing interference from complex coal and rock background textures. In practical engineering applications, it can accurately classify the input raw microscopic image and generate an accurate binary mask image after thresholding. This invention solves the problems of low automation, poor recognition accuracy, and weak resistance to background interference in existing scratch classification methods. Through precise localization of scratch regions, it improves the efficiency of the coal and rock image preparation process and eliminates human error, ensuring that repair operations only affect the truly damaged areas, rather than modifying undamaged areas and causing quality degradation.
[0032] In one embodiment of the present invention, the restoration of scratched coal and rock microscopic images commonly employs models based on generative adversarial networks or encoders / decoders to fill in the scratched areas. However, this single-stage restoration method, when processing images like coal and rock with highly complex and structured microstructures, may suffer from structural errors such as distorted particle contours, breaks, or blurred boundaries in the restored area due to the distinct morphological, edge, and texture characteristics of different mineral components within the coal and rock image. Furthermore, the generated texture may not match the surrounding real coal and rock components, resulting in texture drift and generating seemingly reasonable but actually incorrect material textures. Ultimately, this reduces the accuracy of the coal and rock image restoration results, rendering them unusable for scientific research. Therefore, the present invention designs a two-stage scratch restoration network for image restoration, comprising a structure reconstruction network and a texture generation network connected sequentially. The structure reconstruction network is used to reconstruct the edge and contour structure of coal and rock particles within the scratched area based on the original microscopic image, and outputs a structure reconstruction map, specifically including: The original microscopic images are input into the structural reconstruction network; The encoder of the structure reconstruction network extracts multi-scale features of the original microscopic image; Based on multi-scale features, the decoder of the structure reconstruction network is used for upsampling to reconstruct the edge and contour structure of coal and rock particles within the scratched area, resulting in a structure reconstruction map. The structure reconstruction map includes the coarse structure of the scratched area and the original image of the non-scratched area.
[0033] The structure reconstruction network comprises an encoder and a decoder, trained using a self-supervised approach. It generates random scratches on intact coal micrographs to create binary scratch images of pseudo-defect regions, which are then paired with intact coal micrographs for training, resulting in the structure reconstruction model. The expression for the structure reconstruction model is as follows:
[0034] in, , This refers to the image generated by the restoration model and the original image. A binary mask representing the scratched area.
[0035] The generator's loss function is expressed as follows:
[0036]
[0037]
[0038] in, Let the loss function of the generator be... For pixel loss in the scratched area, The weights for the full-image perception loss, For full-image perception loss, The L1 norm is used to calculate pixel differences. To extract high-level features (including semantic information, structure, and texture of the image) from an image using a pre-trained VGG network. The L2 norm is used to measure the difference in high-level features between two images. The structural reconstruction network of this invention focuses on and recovers the edge and contour structure of damaged coal and rock particles within the scratched region. It learns the mapping relationship between damaged and intact structures by simulating scratches on intact coal and rock images, and uses a composite loss function that combines pixel loss and perceptual loss to ensure that the reconstructed contour is geometrically consistent with the global context of the coal and rock image.
[0039] A texture generation network is used to generate textures that blend with the surrounding undamaged areas within the scratched region of a binary mask image, based on the structure reconstruction map, and outputs a restored coal and rock microscopic image. Specifically, it includes: The reconstructed structure map and the binary mask image are input into the texture generation network; The texture generation network uses a generator within a texture generation network to generate a coal and rock micro-texture consistent with the surrounding undamaged areas within the scratched region of a binary masked image. Guided by the rough structure of the scratched region in the structural reconstruction image, the network generates a micro-texture consistent with the surrounding undamaged areas, resulting in a restored coal and rock microscopic image. The texture generation network of this invention operates based on the structural reconstruction image output in the first stage. This reconstruction image provides reliable scratch boundary conditions for texture generation, enabling the generator in the network to clearly identify the location of the texture to be repaired. The texture generation network of this invention is typically built upon a generative adversarial network and integrates an attention mechanism to better understand long-range contextual dependencies. Its loss function specifically incorporates a style loss to ensure that the newly generated texture maintains a high degree of visual consistency with the surrounding areas, ultimately achieving a high-fidelity restoration result that seamlessly integrates with the original image.
[0040] In a specific embodiment of the present invention, the generator in the texture generation network integrates a multi-attention mechanism, and at the same time, the loss function of the generator introduces style constraints. Multiple attention mechanisms, including channel attention and spatial attention; Channel attention is used to adaptively adjust the feature weights of different channels based on the feature importance of the scratched area in the structural reconstruction image, so that the generator prioritizes enhancing the response to the small texture features of the scratched area, thereby generating a texture that is more consistent with the surrounding undamaged area during the repair process. Spatial attention is used to adaptively adjust the feature weights of different spatial locations based on the local spatial distribution characteristics of the scratched area in the structural reconstruction image. This allows the generator to focus on processing the local spatial information of the scratched area and its edges, thereby avoiding interference with the undamaged area and maintaining the continuity of the texture between the repaired area and the overall texture of the original image.
[0041] Style constraints include pixel loss and perceptual loss; Pixel loss is used to constrain the consistency between the reconstructed image and the real image at the pixel level within the scratched area. Pixel loss can address the loss of most pixel information in the scratched area, but it is difficult to recover micro-texture. Perceptual loss is used to constrain the semantic consistency between the restored image and the real image in the deep feature space. Perceptual loss can measure the difference between the predicted image and the original image in terms of texture statistics and particle distribution, thereby guiding the network to reconstruct the texture structure of the scratch region.
[0042] In a specific embodiment of the present invention, the expression for the loss function of the generator in the texture generation network is as follows:
[0043]
[0044]
[0045] in, Let the loss function of the generator be... For pixel loss in the scratched area, The weights for the full-image perception loss, For full-image perception loss, For image repair, This is the original image. This is a binary mask for the scratched area. It is an L1 norm. To pre-train the VGG network, It is an L2 norm.
[0046] In one embodiment of the present invention, MSE and PSNR can be used to measure differences at the pixel level, intuitively reflecting the restoration accuracy. Their expressions are as follows:
[0047] in, This represents the height, width, and number of channels of an image. This represents the pixel value of the Kth channel at position (i,j) in the image being repaired. This represents the actual pixel value at the corresponding location in the original image. The smaller the MSE, the smaller the pixel difference between the restored image and the original image, and the higher the restoration accuracy.
[0048]
[0049] in, This represents the maximum possible value of a pixel. The higher the PSNR, the more similar the restored image is to the original image.
[0050] SSIM measures the consistency between structure and texture, reflecting perceived quality. The formula is as follows:
[0051] in, A block represents a local image segment in the original image and the restored image. This represents the mean of an image patch. Represents the variance of an image patch. Represents the covariance of an image patch. The stability coefficient prevents the denominator from being 0. The closer SSIM is to 1, the more consistent the restored image is with the original image in terms of brightness, contrast, and structure.
[0052] FID reflects the consistency of the overall distribution between the restored image and the real image, and measures the realism of the generated image. The formula is as follows:
[0053] in This represents the mean vector of features extracted from the original image and the restored image through the network. FID represents the covariance matrix of the extracted features from the original image and the restored image, and Tr represents the trace of the matrix. The smaller the FID, the closer the restored image is to the original image in terms of overall distribution, and the more realistic the generated image is.
[0054] In this invention, to obtain corresponding real, scratch-free microscopic images, the coal bricks after wire cutting are polished to a certain extent, and the similarity between the polished microscopic images and the scratched images is evaluated using the Learned Perceptual Image Patch Similarity (LPIPS) index. To achieve the effect of eliminating scratches without destroying the general structure, LPIPS extracts rich features through deep neural networks, which is significantly better than traditional pixel-level indicators (such as PSNR and SSIM), and is closer to the subjective judgment of human image similarity.
[0055] The beneficial effects of this invention are as follows: By integrating efficient wire cutting technology with two-stage coal and rock image restoration, this invention solves the problem of balancing efficiency and quality in traditional coal and rock image preparation methods. It utilizes diamond wire cutting to replace manual polishing, enabling rapid slicing and image acquisition of coal and rock samples. Furthermore, it achieves automated, high-precision localization of scratched areas through a semantic segmentation network integrating an attention mechanism. The two-stage restoration network, employing a strategy of first structural reconstruction and then texture generation, ensures that the repaired scratched areas in the coal and rock images not only have correct geometric contours but also exhibit high visual and semantic consistency between their micro-texture and the surrounding real coal and rock components, avoiding structural distortions and texture artifacts caused by wire cutting and existing digital image restoration methods. Simultaneously, the structural reconstruction network employs a self-supervised training mode, overcoming the problem of data scarcity and enabling the processing from coal and rock scratched images to high-quality coal and rock prepared images. This reduces reliance on professional operators, ensures the repeatability and objectivity of the results, and provides an efficient, accurate, and reliable technical tool for quantitative analysis of coal petrology and rapid coal quality evaluation.
[0056] Example 2 This invention provides a method for preparing coal and rock images based on wire cutting and image restoration. Based on Example 1, this invention is used for image restoration of small scratches. In this Example 2, a coal radiograph micrograph with a resolution of 2048×2048 is selected. There are fine linear scratches on the surface of the image, with a scratch width of about 3 to 5 pixels.
[0057] Manual annotation generates a corresponding scratch mask image, where the white part represents the scratch area.
[0058] The original image and scratch mask are input into the structure reconstruction network, and multi-scale features are extracted through encoding and decoding to reconstruct the structural information of the defective area.
[0059] Under the combined constraints of perceptual loss and local pixel loss, the structural reconstruction map reconstructed the edge contour of the scratch region quite well.
[0060] The structural information map and scratch mask are then input into the texture generation network, and texture generation is performed only on the mask area, while the texture features of the surrounding undamaged areas are fused together.
[0061] After the repair was completed, the quantitative evaluation results showed that for images with small scratches, this method can achieve almost seamless repair, and the scratched area blends naturally with the surrounding texture; for example... Figure 2 The image shown is an illustration of the effect of this invention on the repair of small scratches. From left to right, the images are the original image, the scratched image, the structural repair image, and the texture repair image.
[0062] Example 3 This invention provides a method for preparing coal and rock images based on wire cutting and image restoration. Building upon Example 1, this invention is used for restoring images with large scratches. This example selects a coal micrograph with significant scratches; the image size is also 2048×2048. The scratches are approximately 20-50 pixels wide and can extend across the central area of the image, severely obscuring the coal and rock structure.
[0063] First, a scratch mask is generated using manual annotation, with the white areas representing the areas that need to be repaired.
[0064] The original image and the mask input structure are used to train and infer the network to restore the edge contours of large-area defect areas.
[0065] Subsequently, the structural reconstruction map and the scratch mask were used. Figure 1 Then input the texture generation network to generate textures.
[0066] During the texture restoration process, texture restoration is performed only on the mask area, effectively avoiding texture drift.
[0067] Calculation of post-repair evaluation indicators: The repair results show that even with large scratches, this method can still restore the boundaries and texture details of coal and rock particles well, with a natural overall visual effect; such as Figure 3 The image shown is an illustration of the effect of this invention on the restoration of images with large scratches. From left to right, the images are the original image, the scratched image, the structural restoration image, and the texture restoration image.
[0068] Example 4 This invention provides a method for preparing coal and rock images based on wire cutting and image restoration. Based on Example 1, this invention is used to enhance the texture of blurred images. In this example, a coal radiograph micrograph is selected. During the shooting, the inaccurate focus caused local blurring of the image. The overall image has no obvious scratches, but the particle outlines are not clear.
[0069] Create a mask image of the blurred areas, mark the blurred areas that need to be sharpened and repaired, and the white parts in the mask are the areas to be enhanced.
[0070] The original blurred image is used as input to the mask structure to reconstruct the network, generating a clear edge and structure information map.
[0071] The structural information map and mask are input into the texture generation network, and a delicate texture is generated through adversarial learning. Only the blurred areas are replaced, while the original texture of the unblurred areas is preserved.
[0072] After restoration, image details were significantly enhanced, and grain boundaries were clear.
[0073] Calculation of quantitative evaluation indicators: The results show that this method is not only suitable for scratch repair, but also for repairing details lost due to blurring in coal micrographs, achieving image enhancement and improved realism; such as Figure 4 The image shown is an illustration of the effect of the present invention on texture enhancement of blurred images. From left to right, the images are the original image, the blurred image, the structure-repaired image, and the texture-repaired image.
Claims
1. A method for preparing coal and rock images based on wire cutting and image inpainting, characterized in that, Includes the following steps: The coal and rock samples were wire-cut to obtain the original microscopic images of the cut surfaces. Based on the original microscopic image, the scratch region of the original microscopic image is identified and processed by a semantic segmentation network with an attention mechanism to obtain a binary mask image of the scratch region. Based on the original microscopic image and the binary mask image, a two-stage scratch repair network is used to reconstruct the structure and generate texture of the scratched area by utilizing information from the undamaged area around the scratched area, thus obtaining a repaired coal and rock microscopic image.
2. The method for preparing coal and rock images based on wire cutting and image restoration according to claim 1, characterized in that, The process of obtaining the binary mask image of the scratched region specifically includes: The original coal and rock microscopic images were normalized and enhanced to obtain preprocessed images. The preprocessed image is input into a semantic segmentation network, and an attention mechanism is used to extract multi-scale features from scratch edges and detailed feature regions to obtain scratch region features. Based on the characteristics of the scratched area, edge information, linear texture, and local contrast changes are extracted through encoding. Based on the scratch area features, edge information, linear texture, and local contrast changes, a preliminary scratch prediction map is obtained by fusing the data. Based on the preliminary scratch prediction map, thresholding is performed through binarization and mask generation to obtain a binary mask image of the scratch area. In the binary mask image of the scratch area, white represents the scratch area and black represents the non-scratched area.
3. The method for preparing coal and rock images based on wire cutting and image restoration according to claim 1, characterized in that, The two-stage scratch repair network includes a structure reconstruction network and a texture generation network connected in sequence; The structure reconstruction network is used to reconstruct the edge and contour structure of coal and rock particles within the scratched area based on the original microscopic image, and output a structure reconstruction map. The texture generation network is used to generate a texture that blends with the surrounding undamaged area within the scratched area of a binary mask image based on the structure reconstruction map, and outputs a repaired coal and rock microscopic image.
4. The method for preparing coal and rock images based on wire cutting and image restoration according to claim 3, characterized in that, The output structure reconstruction map specifically includes: The original microscopic images are input into the structural reconstruction network; The encoder of the structure reconstruction network extracts multi-scale features of the original microscopic image; Based on multi-scale features, the decoder of the structure reconstruction network performs upsampling to reconstruct the edge and contour structure of coal and rock particles within the scratched area, resulting in a structure reconstruction map. The structure reconstruction map includes the coarse structure of the scratched area and the original image of the non-scratched area.
5. The method for preparing coal and rock images based on wire cutting and image restoration according to claim 4, characterized in that, The structure reconstruction network includes an encoder and a decoder, and is trained in a self-supervised manner. By randomly generating scratches on the microscopic image of intact coal sheet, a binary image of the scratches in the pseudo-defect region is formed. This image is then paired with the microscopic image of intact coal sheet for training to obtain the structure reconstruction model.
6. The method for preparing coal and rock images based on wire cutting and image restoration according to claim 3, characterized in that, The restored coal and rock microscopic images specifically include: The reconstructed structure map and the binary mask image are input into the texture generation network; By using the generator in the texture generation network, within the scratched area of the binary mask image, the edge and contour structures provided by the rough structure of the scratched area in the structural reconstruction image are used as a guide to generate a coal and rock micro-texture consistent with the undamaged area around the scratched area, thus obtaining a restored coal and rock micro-image.
7. The method for preparing coal and rock images based on wire cutting and image restoration according to claim 6, characterized in that, The generator integrates a multi-attention mechanism, and the generator's loss function introduces style constraints. The multiple attention mechanism includes channel attention and spatial attention; The channel attention is used to adaptively adjust the feature weights of different channels based on the feature importance of the scratch region in the structural reconstruction image. The spatial attention is used to adaptively adjust the feature weights of different spatial locations based on the local spatial distribution characteristics of the scratched area in the structural reconstruction image. The style constraints include pixel loss and perceptual loss; The pixel loss is used to constrain the consistency between the reconstructed image and the real image within the scratch area at the pixel level. The perceptual loss is used to constrain the semantic consistency between the repaired image and the real image in the deep feature space.
8. The method for preparing coal and rock images based on wire cutting and image restoration according to claim 7, characterized in that, The expression for the loss function of the generator is as follows: in, Let the loss function of the generator be... For pixel loss in the scratched area, The weights for the full-image perception loss, For full-image perception loss, For image repair, This is the original image. For summation, This is a binary mask for the scratched area. It is an L1 norm. To pre-train the VGG network, It is an L2 norm.