A method for detecting and analyzing ceramic capacitor die
By combining pre-segmentation and manual annotation with a segmentation model that incorporates the Mamba attention mechanism, hybrid convolution, and gradient flow modules, the complexity of ceramic capacitor grain image segmentation was solved. This enabled efficient segmentation of both ultra-large and ultra-small grains, improving the accuracy and efficiency of ceramic material research.
Patent Information
- Application Number
- CN202410635710.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-22
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2044-05-22
AI Technical Summary
Existing image segmentation methods struggle to effectively handle the complex structure and strong contrast of ceramic capacitor grain images. In particular, traditional thresholding or edge detection methods are ineffective, and existing deep learning models also perform poorly in segmenting ceramic capacitor grain images.
A method for detecting and analyzing ceramic capacitor grains is proposed, including pre-segmentation and manual annotation. A segmentation model is constructed, and features are extracted through downsampling and upsampling channels using the Mamba attention mechanism, hybrid convolution module and auxiliary gradient flow module. Gradient flow is generated to reconstruct the grain shape, and full-dimensional dynamic convolution and dilated convolution are combined to improve feature extraction.
It improves the accuracy and efficiency of grain segmentation, especially for images containing ultra-large and ultra-small grains, reduces annotation time, and enhances support for ceramic material research and application.
Smart Images

Figure CN118522009B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the field of image segmentation, and particularly relates to a ceramic capacitor grain detection and analysis method. BACKGROUND
[0002] In the research of ceramic materials, electron microscope images are often used to observe the microstructure, especially the distribution and morphology of ceramic capacitor grains. However, processing these images and accurately segmenting the grains is usually a challenging task. Traditional image segmentation methods may not effectively handle the complex structure and strong contrast of ceramic capacitor grain images. The boundaries between grains are not clearly defined, and the shapes and sizes of the grains vary greatly, which makes traditional threshold segmentation or edge detection methods ineffective. In this context, deep learning technology has become a powerful tool for solving image segmentation problems. Deep learning models can automatically extract key features in images by learning feature representations in large amounts of data, without the need for hand-designed feature extractors.
[0003] However, ceramic capacitor grain images are different from traditional medical images or landscape images. They have a large amount of foreground information and very little background information. The grains in the entire image are not all of regular size, but are interspersed with very large irregular grains or very small irregular grains. Therefore, the existing deep learning models do not work well for ceramic capacitor grain image segmentation. SUMMARY
[0004] The purpose of the present application is to provide a ceramic capacitor grain detection and analysis method that can more effectively improve the accuracy and efficiency of grain segmentation, providing important support for the research and application of ceramic materials.
[0005] The present application is achieved by the following technical solutions:
[0006] A ceramic capacitor grain detection and analysis method, comprising the following steps:
[0007] Step S1, obtaining an electron microscope image of a ceramic capacitor as an image sample;
[0008] Step S2, pre-segmenting the image sample to obtain an initial visualization mask, manually labeling the grain regions in the initial visualization mask that are not labeled, obtaining a final visualization mask, and generating a gradient flow within the final visualization mask, using the image sample and the final visualization mask with the generated gradient flow as a training set;
[0009] Step S3, constructing a segmentation model and training the segmentation model by using the training set to obtain a segmentation image, the segmentation model comprising a down-sampling channel, a style transfer module, an up-sampling channel and an auxiliary gradient flow module connected in sequence, the down-sampling channel being composed of a Mamba attention mechanism module, a mixed convolution module and a global average pooling module, the style transfer module extracting a feature map from the down-sampling channel output by global average pooling and generating a style vector, the up-sampling channel being composed of a plurality of mixed convolution modules, the output of which entering the auxiliary gradient flow module, the Mamba attention mechanism module comprising a spatial attention module and a channel attention module connected in parallel, a Mamba module connected with the output of the spatial attention module and the channel attention module, and a grain attention module connected with the output of the Mamba module, the mixed convolution module comprising a full-dimensional dynamic convolution module and a dilated convolution module connected in parallel;
[0010] Step S4, importing the segmentation image obtained by the segmentation model into the image j software to obtain the grain feature information.
[0011] Further, in the step S2, the specific process of generating the gradient flow in the final visual mask is: for each grain region, a heat source is introduced at the center pixel, in each iteration, each pixel in the grain region is assigned the average value of the pixels in the 3*3 square around it, while the pixels outside the grain region are assigned as 0, and the iteration is performed for N times to generate the gradient flow in the horizontal and vertical directions, and N is set as twice the maximum value of the horizontal range and the vertical range of each grain region.
[0012] Further, in the step S3, the down-sampling channel comprises a plurality of sub-down-sampling modules connected in sequence, the sub-down-sampling module comprising a Mamba attention mechanism module, a mixed convolution module and a global average pooling module connected in sequence, and the output of the mixed convolution module and the input of the Mamba attention mechanism module are jointly input into the global average pooling module.
[0013] Further, the up-sampling channel comprises a plurality of sub-up-sampling modules connected in sequence, and the sub-up-sampling module comprises an up-sampling layer and a mixed convolution module connected in sequence.
[0014] Further, the full-dimensional dynamic convolution module is calculated according to the formula y =( αw ⊗ αf ⊗ αc ⊗ αs ⊗ W 1+...+ α wn ⊗ αfn ⊗ αcn ⊗ αsn ⊗ Wn )∗ x , wherein, x represents the input feature,y represents the output feature, Wn represents the nth convolution kernel, αwn represents the attention scalar of the nth convolution kernel, αcn represents the attention vector on the input channel dimension, αfn represents the attention vector on the output channel dimension, αsn represents the attention matrix on the spatial dimension, represents the element-wise multiplication along the corresponding dimension, and represents the convolution operation.
[0015] Further, the auxiliary gradient flow module converts the grain mask output by the up-sampling module into two images with the same size as the original image, and the two images respectively represent the horizontal and vertical vector flows, which guide each pixel in the image to move to the center of the grain to which the pixel belongs, so as to reconstruct the shape of the grain.
[0016] Further, the feature output by the Mamba module is input into the grain attention module, the input feature is respectively dot multiplied with the transpose of the Q matrix and the K matrix of the grain attention module, the result of the dot multiplication is subjected to softmax calculation to obtain the attention weight, the V matrix and the input feature are weighted and summed using the attention weight and subjected to softmax calculation to obtain the segmentation image.
[0017] Further, the grain feature information in the step S4 includes the perimeter and area of each grain, the position coordinates of each grain in the picture, the length density of all grains and / or the particle size distribution of all grains.
[0018] Further, in the step S2, the Cytoplasm model is used to pre-segment the image sample to obtain an initial visualization mask.
[0019] The present application has the following beneficial effects:
[0020] 1、The present application obtains initial visualization mask by pre-segmenting image samples, and manually annotates the grain region not annotated in the initial visualization mask, so as to greatly reduce the annotation time of the grain, save the originally complex and tedious workload, and obtain very good training results only by annotating a small amount of picture samples, the segmentation model constructed includes a down-sampling channel, a style transfer module, an up-sampling channel and an auxiliary gradient flow module, the down-sampling channel is composed of a Mamba attention mechanism module, a mixed convolution module and a global average pooling module, the mixed convolution module includes a full-dimensional dynamic convolution module and a hollow convolution module in parallel, the full-dimensional dynamic convolution module can improve the feature extraction of the minimum grain, especially when the features of the minimum grain are different from the surrounding environment or the boundary of the minimum grain is fuzzy, the hollow convolution module can improve the feature extraction of the super-large grain, so that the picture containing the super-large grain and the minimum grain has better segmentation effect, the Mamba attention mechanism module includes a spatial attention module and a channel attention module in parallel, a Mamba module connected with the output of the spatial attention module and the channel attention module, and a grain attention module connected with the output of the Mamba module, so that the segmentation model is more suitable for images with complex grains, thereby effectively improving the accuracy and efficiency of grain segmentation, and further improving the accuracy of ceramic capacitor grain detection and analysis, providing important support for the research and application of ceramic materials. BRIEF DESCRIPTION OF DRAWINGS
[0021] The application will be further described in detail below in combination with the drawings.
[0022] Figure 1 The image sample of the ceramic capacitor grain of the present application is shown.
[0023] Figure 2 The structure diagram of the segmentation model of the present application is shown.
[0024] Figure 3 The structure diagram of the Mamba attention mechanism module of the present application is shown.
[0025] Figure 4 The structure diagram of the grain attention module of the present application is shown.
[0026] Figure 5 The structure diagram of the mixed convolution module of the present application is shown.
[0027] Figure 6 The segmentation diagram of the ceramic capacitor grain of the present application is shown. DETAILED DESCRIPTION
[0028] The ceramic capacitor grain detection and analysis method comprises the following steps:
[0029] Step S1, obtaining the electron microscope image of the ceramic capacitor as an image sample, as shown in Figure 1
[0030] Step S2, pre-segmentation of the image sample using the Cytoplasm model to obtain an initial visualization mask, manual labeling of the grain regions in the initial visualization mask that are not labeled to obtain a final visualization mask, and generating a gradient flow in the final visualization mask, taking the image sample and the final visualization mask of the generated gradient flow as a training set;
[0031] For the electron microscope images of ceramic capacitors, the number of grains in each image is very large, and there may still be unlabeled grains after pre-segmentation of the image sample. For this case, manual labeling of a small number of grains can greatly reduce the labeling time of the grains and save the originally complex and tedious workload, thereby improving the efficiency of ceramic capacitor grain research.
[0032] The specific process of generating a gradient flow in the final visualization mask is as follows: for each grain region, a heat source is introduced at the center pixel, and in each iteration, each pixel in the grain region is assigned the average value of the pixels in the surrounding 3x3 square, while the pixels outside the grain region are assigned a value of 0. Iteration is performed N times to generate gradient flows in the horizontal and vertical directions. N is set to twice the maximum value of the horizontal range and the vertical range of each grain region.
[0033] Step S3, constructing a segmentation model and training the segmentation model using the training set to obtain a segmentation image, as shown in Figure 6 , the segmentation model, as shown in Figure 2 , includes a down-sampling channel, a style transfer module, an up-sampling channel, and an auxiliary gradient flow module connected in sequence. The down-sampling channel is composed of a Mamba attention mechanism module, a hybrid convolution module, and a global average pooling module. The style transfer module extracts a feature map from the down-sampling channel output through global average pooling and generates a style vector. The up-sampling channel is composed of multiple hybrid convolution modules, and its output enters the auxiliary gradient flow module. The Mamba attention mechanism module includes a spatial attention module and a channel attention module connected in parallel, a Mamba module connected with the output of the spatial attention module and the channel attention module, and a grain attention module connected with the output of the Mamba module. The hybrid convolution module includes a full-dimensional dynamic convolution module and a dilated convolution module connected in parallel.
[0034] Specifically, the down-sampling channel includes three sub-down-sampling modules connected in sequence. Each sub-down-sampling module includes a Mamba attention mechanism module, a hybrid convolution module, and a global average pooling module connected in sequence. The output of the hybrid convolution module is input into the global average pooling module together with the input of the Mamba attention mechanism module.
[0035] The up-sampling channel includes three sub-up-sampling modules connected in sequence. Each sub-up-sampling module includes an up-sampling layer and a hybrid convolution module connected in sequence.
[0036] The style transfer module introduces style vectors, which encode the global visual features of an image. By taking the image style into account, the segmentation model can capture the outline and shape of the grains more accurately, especially when the grain shape is complex or the image contrast is uneven.
[0037] The auxiliary gradient flow module converts the grain mask output by the upsampling module into two images of the same size as the original image. These two images represent vector flows in the horizontal and vertical directions, respectively. These vector flows guide each pixel in the image to move towards the center of its respective grain to reconstruct the grain's shape. The specific process includes: First, determining the grain center C, which is achieved by finding the median of the pixels within the grain. Initially, a heat source with an initial value of 1 is set at the grain center. For each grain, N1 iterations are performed, where N1 is twice the sum of the horizontal and vertical ranges of the grain. In each iteration, the value of each pixel p is... Vp Through formula To calculate, where, Vp ( t +1) is the value of pixel p after the (t+1)th iteration. Vp ( t ) is the value of pixel p after t iterations. Np It is a 3×3 neighborhood of pixel p. VC This is the value of the heat source, which is 1 in the initial iteration. After the iteration is complete, for each pixel, the gradients in the horizontal and vertical directions are calculated. These gradients will be used to represent the vector flow. The gradients can be approximated by calculating the difference between the values of adjacent pixels. Gx = Vp - Vp -1、 Gy = Vp - Vp −Δ y ,in, G x and Gy These are the gradients in the horizontal and vertical directions, respectively. Vp It is the value of the current pixel. Vp -1 is the value of the horizontally adjacent pixel. Vp −Δ y These are the values of vertically adjacent pixels. To ensure the consistency of the vector field, the gradients are normalized to have unit length: , .
[0038] like Figure 3As shown, for the Mamba attention mechanism module, the input first enters the part in parallel with the spatial attention mechanism and the channel attention mechanism to capture the spatial and channel information of the crystal grains. The channel attention mechanism can enhance the expression ability of the segmentation model for different features by dynamically adjusting the importance of each channel, so that the segmentation model can better capture important features in the image. It can adaptively reduce attention to unimportant features, thereby reducing redundant information, improving the efficiency and generalization ability of the segmentation model, and making the model more suitable for complex scenes and tasks. The parallel spatial attention module can enhance the attention degree of the segmentation model to the spatial information of different positions by dynamically adjusting the importance of each position, so that the segmentation model can better capture important position information in the image, and it is also beneficial to adaptively reduce attention to unimportant positions, thereby reducing the influence of noise and improving the robustness and generalization ability of the segmentation model, making the segmentation model more suitable for complex crystal grain images. Then it enters the Mamba module. Since the Mamba model uses a bidirectional state model, it has good segmentation effect on complex crystal grain images with a large amount of data. For example Figure 4 As shown in the schematic diagram of the crystal grain attention module, the features output by the Mamba module are input into the crystal grain attention module. The input features are respectively dot multiplied with the Q matrix and the transpose of the K matrix of the crystal grain attention module. The results of the dot multiplication are subjected to softmax calculation to obtain attention weights. The attention weights are used to weight sum the V matrix and the input features, and then subjected to softmax calculation to obtain a segmentation image.
[0039] Specifically, the standard Mamba model is designed for one-dimensional sequences. In order to process time tasks, in the Mamba module, the two-dimensional image is first transformed t∈R H×W×C into a planar two-dimensional image X p ∈R J×(P2·C) , where (H, W) is the size of the input image, C is the number of channels, and P is the size of the image block. Then Xp is linearly projected into a vector with a size of D, and a position embedding E pos ∈R J×(P2·C) is added. T 0=[ tcls ; t 1 pW ; t 2 pW ;…; tJpW ]+ Epos , where T 0 is the processed input token sequence, including the class token tcls and the linear projection of the image block tjp , W is a learnable projection matrix, Epos is a position embedding that provides spatial position information.
[0040] The Mamba module uses a Discrete-Time State-Space Model (SSM). A =exp(Δ A ), B =(Δ A )−1(exp(Δ A )− I )⋅Δ B , where Δ A and Δ B These are parameters related to continuous-time models. exp represents the exponential function, used to convert the parameters of a continuous-time model into those of a discrete-time model. I It is an identity matrix.
[0041] like Figure 5 As shown, the hybrid convolution module includes a parallel full-dimensional dynamic convolution module and a dilated convolution module, which is more adaptable to images of capacitor ceramic grains. Full-dimensional dynamic convolution dynamically convolves all dimensions of the convolution kernel (spatial size of the input image, input channels, output channels, and number of kernels), improving feature extraction of extremely small grains, especially when the features of extremely small grains differ from their surroundings or when the boundaries of the grains are blurred. This is mainly because full-dimensional dynamic convolution can consider information from four dimensions simultaneously, thus better capturing the contextual information and subtle features of the target. However, since both extremely small and extremely large grains can appear in the same image, dilated convolution is combined with full-dimensional dynamic convolution to achieve better segmentation of both extremely small and extremely large grains while maintaining good segmentation performance. Dilated convolution changes the sampling points by setting the dilation rate to obtain a larger receptive field. A larger receptive field allows for better segmentation of extremely large grains and capture of multi-scale contextual information.
[0042] The full-dimensional dynamic convolution module calculates according to the formula. y =( αw ⊗ αf ⊗ αc ⊗ αs ⊗ W 1+...+ αwn ⊗ αfn ⊗ αcn ⊗ αsn ⊗ Wn )∗ x ,in, x Indicates input features, y Indicates output features, Wn This represents the nth convolutional kernel. αwn This represents the attention scalar of the nth convolutional kernel. αcn This represents the attention vector along the input channel dimension. αfn This represents the attention vector along the output channel dimension.αsn denotes the attention matrix in the spatial dimension, denotes the element-wise multiplication along the corresponding dimension, and denotes the convolution operation.
[0043] The hollow convolution module is calculated according to the formula wherein, denotes the convolution operation with a dilation factor, l is the dilation factor, when l = 1, it denotes the standard convolution, and when l > 1, it denotes the hollow convolution; denotes the position of the convolution output, in the convolution operation, each position p of the output tensor is calculated by the elements of the input tensor and the convolution kernel; denotes the summation operation, and the summation is performed on all s and t satisfying the condition s + lt = p. This condition s + lt = p means that the indexes of the input F and the convolution kernel k are matched through the dilation factor l; denotes the value of the input signal F at position s; denotes the value of the convolution kernel k at position t; specifically, the key of the hollow convolution lies in that there is a certain 'hollow' or 'interval' between the elements of the convolution kernel k, which is determined by the dilation factor l.
[0044] In step S4, the segmentation image obtained by the segmentation model is imported into the image j software to obtain the grain feature information, specifically, the grain feature information includes the perimeter and area of each grain, the position coordinates of each grain in the picture, the length density of all grains and the particle size distribution of all grains
[0045] The above is only a preferred embodiment of the present application, and therefore cannot limit the scope of the present application. Any equivalent changes and modifications made in accordance with the scope of the present application and the content of the specification shall still fall within the scope of the present application.
Claims
1. A method for ceramic capacitor die detection and analysis, the method comprising: The method comprises the following steps: Step S1, obtaining an electron microscope image of a ceramic capacitor as an image sample; Step S2, performing pre-segmentation on the image sample to obtain an initial visualization mask, manually labeling the grain region not labeled in the initial visualization mask to obtain a final visualization mask, and generating a gradient flow in the final visualization mask, taking the image sample and the final visualization mask with the generated gradient flow as a training set; Step S3, constructing a segmentation model and training the segmentation model using the training set to obtain a segmentation image, the segmentation model comprising a down-sampling channel, a style transfer module, an up-sampling channel and an auxiliary gradient flow module connected in sequence, the down-sampling channel comprising a Mamba attention mechanism module, a mixed convolution module and a global average pooling module, the style transfer module extracting a feature map from the down-sampling channel output through the global average pooling module and generating a style vector, the up-sampling channel comprising a plurality of mixed convolution modules, the output of which enters the auxiliary gradient flow module, the Mamba attention mechanism module comprising a spatial attention module and a channel attention module connected in parallel, a Mamba module connected with the output of the spatial attention module and the channel attention module, and a grain attention module connected with the output of the Mamba module, and the mixed convolution module comprising a full-dimensional dynamic convolution module and a hole convolution module connected in parallel; Step S4, importing the segmentation image obtained by the segmentation model into image j software to obtain grain feature information; In the step S2, the specific process of generating a gradient flow in the final visualization mask is as follows: for each grain region, a heat source is introduced at the center pixel, in each iteration, each pixel in the grain region is assigned the average value of the pixels in the 3*3 square around it, and the pixels outside the grain region are assigned as 0, and the iteration is performed for N times to generate gradient flows in the horizontal and vertical directions, and N is set as twice the maximum value of the horizontal range and the vertical range of each grain region. The full-dimensional dynamic convolution module is calculated according to a formula, the formula is , wherein, x represents an input feature, y represents an output feature, W n represents the first n convolution kernel, αw n represents the first n convolution kernel attention scalar, αc n represents the first n convolution kernel input channel dimension attention vector, αf n represents the first n convolution kernel output channel dimension attention vector, αs n represents the first n convolution kernel spatial dimension attention matrix, represents element-wise multiplication along the corresponding dimension, and represents convolution operation.
2. The method of claim 1, wherein: In the step S3, the down-sampling channel comprises a plurality of sub-down-sampling modules connected in sequence, the sub-down-sampling module comprises a Mamba attention mechanism module, a mixed convolution module and a global average pooling module connected in sequence, and the output of the mixed convolution module and the input of the Mamba attention mechanism module are jointly input into the global average pooling module.
3. The method of claim 1 or 2, wherein: The up-sampling channel comprises a plurality of sub-up-sampling modules connected in sequence, and the sub-up-sampling module comprises an up-sampling layer and a mixed convolution module connected in sequence.
4. The method of claim 1 or 2, wherein: The auxiliary gradient flow module converts the grain mask output by the up-sampling module into two images with the same size as the original image, and the two images represent the vector flow in the horizontal direction and the vertical direction respectively, the vector flow guides each pixel in the image to move to the center of the grain to which it belongs, so as to reconstruct the shape of the grain.
5. The method of claim 1 or 2, wherein: The features output by the Mamba module are input into the grain attention module, the input features are respectively dot multiplied with the transpose of the Q matrix and the K matrix of the grain attention module, the results of the dot multiplication are subjected to softmax calculation to obtain attention weights, the attention weights are used to weight sum the V matrix and the input features, and then the weighted sum is subjected to softmax calculation to obtain the segmentation image.
6. The method of claim 1 or 2, wherein: The grain feature information in the step S4 includes the perimeter and area of each grain, the position coordinates of each grain in the picture, and the size distribution of all grains.
7. The method of claim 1 or 2, wherein: In the step S2, the initial visualization mask is obtained by pre-segmenting the image sample by using the Cytoplasm model.
Citation Information
Patent Citations
Video semantic segmentation method using multi-frequency dynamic cavity convolution
CN113538457A
Image instance segmentation method based on deep learning
CN115131556A