Neodymium-iron-boron magnetic rare earth material crystal dividing method based on chain code method
By combining the deeplabv3+ image segmentation model and chain code optimization, the problem of crystal adhesion in the crystal segmentation of NdFeB magnetic rare earth materials was solved, and more accurate crystal segmentation and feature statistics were achieved.
Patent Information
- Application Number
- CN202310856822.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-13
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2043-07-13
AI Technical Summary
Existing image processing or deep learning methods cannot effectively deal with the problems of crystal adhesion and shape change in the segmentation of NdFeB magnetic rare earth material crystals, resulting in inaccurate segmentation results.
The chain code method is combined with the deeplabv3+ image segmentation model and morphological processing. The segmentation results are optimized by the chain code method, and the segmentation points of the adhesion crystals are determined by using the chain code difference and chord-arc ratio to achieve accurate segmentation.
The segmentation accuracy of NdFeB magnetic rare earth material crystals and the accuracy of crystal structure feature statistics are improved, and the problem of crystal adhesion is solved.
Smart Images

Figure CN117011317B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a NdFeB magnetic rare earth material crystal segmentation method based on a chain code method, and belongs to the fields of artificial intelligence, deep learning, and image processing. Background Art
[0002] NdFeB magnetic crystals, composed of rare earth elements, have broad application prospects in energy, materials, electronics, and other fields. Due to their unique electronic structure and magnetic properties, NdFeB magnetic rare earth elements are widely used in luminescent materials, energy storage materials, catalysts, magnetic materials, and other fields. Analysis of NdFeB magnetic rare earth material crystals is crucial for studying their structural characteristics, optimizing material properties, and exploring new applications.
[0003] However, the complexity of the crystal structure of NdFeB magnetic rare earth materials presents significant challenges in counting and characterizing them. The sheer number and diversity of NdFeB magnetic rare earth material crystals makes traditional manual counting methods time-consuming, labor-intensive, and error-prone. Image processing technology is a highly effective method for rapidly analyzing crystal structure, but traditional image segmentation methods, including those based on deep learning, are limited in their effectiveness when dealing with issues such as adhesion, shape variation, and noise in NdFeB magnetic rare earth material crystals. NdFeB magnetic rare earth material crystals often have multiple crystals adhered together, resulting in blurred boundaries and inaccurate segmentation results, complicating subsequent analysis and research.
[0004] In summary, NdFeB magnetic crystal segmentation is of great significance in the research and application of NdFeB magnetic rare earth materials, but it is also a difficult problem in this direction. Existing methods based on image processing or deep learning have limitations and cannot effectively deal with problems such as crystal adhesion and shape change. Therefore, the present invention proposes a NdFeB magnetic rare earth material crystal segmentation method based on the chain code method, which not only combines traditional digital image processing technology and deep learning methods, but more importantly, uses the chain code method for optimization, effectively improving the problem of crystal adhesion in the image segmentation results. Summary of the Invention
[0005] In order to overcome the shortcomings of the existing technology, the present invention provides a transfer learning method for the task of few-sample NdFeB magnetic rare earth material crystal segmentation, which mainly uses the chain code method to solve the phenomenon of crystal adhesion in the classic image segmentation results; the chain code is a method of representing edge contours, which can be used to find crystal concave points and use the chord-to-arc ratio to screen suitable segmentation points to separate the adhered crystal structure.
[0006] The present invention solves its technical problems by adopting the following technical solutions:
[0007] A method for segmenting NdFeB magnetic rare earth material crystals based on a chain code method comprises the following steps:
[0008] Step 1: Input the crystal structure image of NdFeB magnetic rare earth material and perform histogram equalization on it to enhance the contrast;
[0009] Step 2: Train the deeplabv3+ image segmentation model;
[0010] Step 3: After the training is completed, the segmentation model is used to predict the segmentation of the NdFeB magnetic rare earth material crystal structure image to obtain the original segmentation result image;
[0011] Step 4: Perform opening operation morphological image processing on the original segmentation result image;
[0012] Step 5: Use the chain code method to optimize and process the adhesion crystal structure;
[0013] Step 6: Output the optimized final segmentation result image and count the number of crystals in the image and their characteristic information.
[0014] Furthermore, the process of step 5 is as follows:
[0015] 5.1: Extract the boundaries of the foreground connected area in the segmentation result image;
[0016] 5.2: Convert the extracted boundary curve into digital form, that is, use chain code representation, and generate a chain code sequence to represent the position and connection relationship of each point on the boundary curve;
[0017] 5.3: Optimize the generated chain code sequence, including smoothing, pumping and closing;
[0018] 5.4: Calculate the chain code difference, that is, the difference in two directions. Corner points represented by positive difference are considered convex points, and corner points represented by negative difference are considered concave points.
[0019] 5.5: Use the chord-to-arc ratio to determine whether the two concave points are the dividing points of the adhered crystals, whether the boundary segments belong to the same crystal, and finally segment them;
[0020] Furthermore, in 5.2, the boundary curve is represented as a sequence of connected line segments. The direction and length of each line segment are encoded with a number. The range of the direction encoding is [-3, 4]. Positive values represent counterclockwise rotation, and negative values represent clockwise rotation. There are a total of 8 two-dimensional plane directions. The angle of rotation for each direction rotation is (360° / 8). c(i) represents the chain code value of the current boundary point i, and r(i) represents the relative chain code value of the current boundary point i. The formula is as follows:
[0021] r(i)=[c(i)-c(i-1)+8]%8
[0022] if(r(i)>4),then r(i)=r(i)-8
[0023] A(i)=A(i-1)+r(i)
[0024] A(i) is used to represent the absolute chain code value. The absolute chain code at the initial starting point is initially 0, that is, A(i) = 0, then the final absolute value A(N) is always 8, that is, the relative size of the chain code rotates one circle.
[0025] In 5.4 above, the total chain code difference calculation formula is as follows:
[0026] S(i)=A(i)+A(i-1)+A(i-2)
[0027] D(i)=S(i+3)-S(i)
[0028] Where S(i) represents the three-point chain code sum, i.e., the absolute chain code sum of the current point and the two preceding points. The chain code sum indicates the direction of the boundary, i.e., the slope, or the direction of the tangent. The chain code difference D(i) represents the difference between the two three-point chain code sums. The concave point threshold is set to -2. Any chain code difference less than -2 is considered a concave point and stored in the concave point set.
[0029] In 5.5 above, the chord-arc ratio is the ratio of the chord length between two points to the arc length, that is, the ratio of the length of the two points around the contour to the distance between the two points. The chord-arc ratio is calculated as follows:
[0030]
[0031] Among them, L(i,j) represents the chord length between two points. Since it is an 8-direction chain code representation, the step size is 1 in the horizontal and vertical directions, and the step size is 1.5 in other directions such as diagonal lines. Dist(i,j) represents the Euclidean distance between points i and j. Based on the final set of concave points generated in step 4, compare the chord_ratio between adjacent concave points. Fix the reference point and find the concave point with the largest chord_ratio. Set this concave point and the reference point as the optimal split points, and then segment. Set the chord_ratio threshold to 3. Only when the chord_ratio is greater than 3 will the point be segmented.
[0032] The present invention has the beneficial effect of accurately segmenting crystal structure images using a chain code method for segmenting NdFeB magnetic rare earth material crystals. The chain code method effectively solves the problem of crystal structure adhesion, improving the accuracy of crystal counting and crystal structure feature statistics. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 This is an overall block diagram of the method described in the present invention;
[0034] Figure 2 This is a diagram showing the chain code optimization effect of the method described in the present invention;
[0035] Figure 3 This is the final segmentation effect diagram of the method of the present invention, wherein (a) represents the original crystal structure diagram, and (b) represents the crystal structure diagram with marked features. DETAILED DESCRIPTION
[0036] The present invention will be further described below with reference to the accompanying drawings.
[0037] Reference Figure 1 and Figure 2 A method for segmenting NdFeB magnetic rare earth material crystals based on a chain code method comprises the following steps:
[0038] Step 1: Input the crystal structure image of NdFeB magnetic rare earth material and perform histogram equalization on it to enhance the contrast.
[0039] Step 2: Train the deeplabv3+ image segmentation model.
[0040] Step 3: After training, the segmentation model is used to predict the segmentation of the NdFeB magnetic rare earth material crystal structure image to obtain the original segmentation result image.
[0041] Step 4: Perform opening operation morphological image processing on the original segmentation result image.
[0042] Step 5: Use the chain code method to optimize and process the adhesion crystal structure. The process is as follows:
[0043] 5.1: Extract the boundaries of the foreground connected area in the segmentation result image;
[0044] 5.2: Convert the extracted boundary curve into a digital form, that is, use chain code representation, and generate a chain code sequence to represent the position and connection relationship of each point on the boundary curve. The boundary curve is represented as a sequence consisting of a series of connected line segments. The direction and length of each line segment are encoded with a number. The range of the direction encoding is [-3, 4]. Positive values represent counterclockwise rotation and negative values represent clockwise rotation. There are a total of 8 two-dimensional plane directions. Each rotation angle is (360° / 8). Use c(i) to represent the chain code value of the current boundary point i, and r(i) to represent the relative chain code value of the current boundary point i. The formula is as follows:
[0045] r(i)=[c(i)-c(i-1)+8]%8
[0046] if(r(i)>4),then r(i)=r(i)-8
[0047] A(i)=A(i-1)+r(i)
[0048] A(i) represents the absolute chain code value. The absolute chain code at the initial starting point is initially 0, that is, A(i) = 0. Then the final absolute value A(N) is always 8, that is, the relative size of the chain code rotates one circle;
[0049] 5.3: Optimize the generated chain code sequence, including smoothing, pumping and closing;
[0050] 5.4: Calculate the chain code difference, that is, the difference in two directions. Corner points represented by positive differences are considered convex points, and corner points represented by negative differences are considered concave points. The total calculation formula for the chain code difference is as follows:
[0051] S(i)=A(i)+A(i-1)+A(i-2)
[0052] D(i)=S(i+3)-S(i)
[0053] Where S(i) represents the three-point chain code sum, i.e., the absolute chain code sum of the current point and the two preceding points. The chain code sum indicates the direction of the boundary, i.e., the slope, or the direction of the tangent. The chain code difference D(i) represents the difference between the two three-point chain code sums. The concave point threshold is set to -2. Any chain code difference less than -2 is considered a concave point and stored in the concave point set.
[0054] 5.5: Since the segmentation points of the adhered crystals are usually concave points, the chord-arc ratio can be used to determine whether the segmentation points between two concave points are the segmentation points of the adhered crystals, whether the boundary segments belong to the same crystal, and finally to segment them. Figure 2 The left, middle, and right images show the original segmentation result, the adhesion crystal structure, and the segmentation result after optimization using the chain code method. The chord-to-arc ratio is the ratio of the chord length to the arc length between two points, that is, the ratio of the length of the contour around the two points to the distance between the two points. The chord-to-arc ratio is calculated as follows:
[0055]
[0056] Among them, L(I,j) represents the chord length between two points. Since it is an 8-direction chain code representation, the step size is 1 in the horizontal and vertical directions, and the step size is 1.5 in other directions such as diagonal lines. Dist(i,j) represents the Euclidean distance between two points i and j. Based on the final set of concave points generated in step 5.4, compare the chord_ratio between adjacent concave points. Fix the reference point and find the concave point with the largest chord_ratio. Set this concave point and the reference point as the optimal segmentation points, and then segment them. Set the chord_ratio threshold to 3. Only when the chord_ratio is greater than 3 will it be segmented.
[0057] Step 6: Output the optimized final segmentation result image and count the number of crystals in the image and their characteristic information.
[0058] The embodiments of this specification are merely examples of implementations of the invention and are provided for illustrative purposes only. The scope of protection of the present invention should not be considered limited to the specific embodiments described in these embodiments. The scope of protection of the present invention also extends to equivalent technical means that can be conceived by a person of ordinary skill in the art based on the invention.
Claims
1. A method for segmenting NdFeB magnetic rare earth material crystals based on a chain code method, characterized in that: The method comprises the following steps: Step 1: Input the crystal structure image of NdFeB magnetic rare earth material and perform histogram equalization on it to enhance the contrast; Step 2: Train the deeplabv3+ image segmentation model; Step 3: After the training is completed, the segmentation model is used to predict the segmentation of the NdFeB magnetic rare earth material crystal structure image to obtain the original segmentation result image; Step 4: Perform opening operation morphological image processing on the original segmentation result image; Step 5: Use the chain code method to optimize and process the adhesion crystal structure; Step 6: Output the optimized final segmentation result image and count the number of crystals in the image and their characteristic information; The process of step 5 is as follows: 5.1: Extract the boundaries of the foreground connected area in the segmentation result image; 5.2: Convert the extracted boundary curve into digital form, that is, use chain code representation, and generate a chain code sequence to represent the position and connection relationship of each point on the boundary curve; 5.3: Optimize the generated chain code sequence, including smoothing, pumping and closing; 5.4: Calculate the chain code difference, that is, the difference in two directions. Corner points represented by positive difference are considered convex points, and corner points represented by negative difference are considered concave points. 5.5: Use the chord-to-arc ratio to determine whether the two concave points are the dividing points of the adhered crystals, whether the boundary segments belong to the same crystal, and finally segment them; In 5.2, the boundary curve is represented as a sequence of connected line segments. The direction and length of each line segment are encoded with a number. The range of the direction encoding is [-3, 4]. Positive values represent counterclockwise rotation and negative values represent clockwise rotation. There are a total of 8 two-dimensional plane directions. The rotation angle of each direction is (360° / 8). Indicates the chain code value of the current boundary point i, The formula for the relative chain code value of the current boundary point i is as follows: use Indicates the absolute chain code value. The absolute chain code of the initial starting point is initially 0, that is, , then the final absolute value It is always 8, that is, the chain code rotates one circle relative to the size; In 5.4 above, the total calculation formula for chain code difference is as follows: in It represents the sum of the three-point chain code, that is, the absolute sum of the chain code of the current point and the two points before it. The sum of the chain code represents the direction of the boundary, that is, the slope, that is, the tangent direction. The chain code difference It represents the difference between the sum of two three-point chain codes. The concave point threshold is set to -2. That is, if the chain code difference is less than -2, it is considered a concave point and stored in the concave point set.
2. The method for dividing NdFeB magnetic rare earth material crystals based on the chain code method according to claim 1, wherein: In 5.5 above, the chord-arc ratio is the ratio of the chord length between two points to the arc length, that is, the ratio of the length of the two points around the contour to the distance between the two points. The chord-arc ratio is calculated as follows: in, Indicates the length of the chord between two points. Since it is an 8-direction chain code representation, the step size is 1 in the horizontal and vertical directions, and 1.5 in other diagonal directions. express Euclidean distance between two points , according to the concave point set finally generated in 5.4, compare the adjacent concave points Chord-arc ratio: fix the reference point, find the concave point with the largest chord-arc ratio, set this concave point and the reference point as the optimal segmentation point, and then segment it. Set the chord-arc ratio threshold to 3. When the chord-arc ratio is greater than 3, it will be segmented.
Citation Information
Patent Citations
Automatic cutting and counting method for fluorescent microscopic images of retinal cells
CN104778442A
Automatic unlabeled pancreas image segmentation system based on adversarial learning
WO2023098289A1