Rare earth crystal observation method based on deep learning model combined with watershed algorithm
By combining deep learning models and watershed algorithms, the problems of low efficiency and accuracy in rare earth crystal observation were solved, and efficient and accurate crystal structure analysis was achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG UNIV OF TECH
- Filing Date
- 2023-07-17
- Publication Date
- 2026-06-12
AI Technical Summary
Traditional methods are inefficient and prone to errors when observing complex rare earth crystals, while deep learning methods lack labeled data in rare earth crystal research and have limited effectiveness when faced with adhesion and shape changes.
By combining a deep learning model and a watershed algorithm, the deep learning model is trained with data augmentation and the watershed algorithm is used for post-processing to optimize the crystal structure segmentation results.
This method enables efficient and accurate observation and analysis of rare earth crystals, overcomes the shortcomings of traditional methods, and improves the accuracy and reliability of the segmentation results.
Smart Images

Figure CN117173093B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a rare earth crystal observation method based on a deep learning model combined with a watershed algorithm, belonging to the fields of artificial intelligence, deep learning, image processing, and crystal structure analysis. Background Technology
[0002] Rare earth crystals have broad application prospects in energy, materials, electronics and other fields. Due to the special electronic structure and magnetic properties of rare earth elements, rare earth crystals are widely used in luminescent materials, energy storage materials, catalysts, magnetic materials and other fields, playing an important role in improving energy efficiency, enhancing material performance and promoting scientific and technological development.
[0003] However, the complex structure and adhesion of rare earth crystals pose challenges to their observation and analysis. Traditional manual observation methods are time-consuming, labor-intensive, and prone to errors, especially when the number of crystals is large, their shapes are diverse, and they are adhered to each other. Image processing and deep learning methods have great potential in rare earth crystal analysis, and can improve observation efficiency and accuracy.
[0004] Traditional image segmentation methods have limited effectiveness when dealing with complex crystal structures, and are easily affected by boundary blurring and shape changes, leading to inaccurate segmentation results. Currently, deep learning-based image segmentation techniques are widely used in various fields. However, deep learning methods typically require large amounts of labeled data for training. In rare earth crystal research, obtaining large-scale labeled datasets is very difficult because rare earth crystals are limited in number and diverse. Furthermore, deep learning methods also have limitations when dealing with issues such as crystal adhesion, shape changes, and noise. Summary of the Invention
[0005] To overcome the limitations of deep learning methods and traditional methods in processing complex rare-earth crystal structures, this invention provides a rare-earth crystal observation method based on a deep learning model combined with a watershed algorithm. This method enables efficient and accurate observation and analysis of rare-earth crystals, providing an effective technical means for rare-earth crystal research.
[0006] The present invention solves its technical problem by adopting the following technical solution:
[0007] A rare-earth crystal observation method based on a deep learning model combined with a watershed algorithm, wherein the deep learning segmentation model can be any existing segmentation model, includes the following steps:
[0008] Step 1: Prepare a rare earth crystal structure image dataset and divide the entire dataset into a training set and a test set;
[0009] Step 2: Perform random data augmentation on the training set images obtained in Step 1;
[0010] Step 3: Train the improved Unet3+ deep learning model using the training set obtained in Step 2, and evaluate the segmentation model on the test set according to the image segmentation evaluation metric to obtain the final image segmentation model. Use the model to predict the crystal structure map to obtain the original segmentation result map.
[0011] Step 4: For the original segmentation result image obtained in Step 3, the watershed algorithm is used to post-process the original segmentation result image to deal with the problem of crystal structure adhesion that makes it difficult to observe.
[0012] Step 5: Observe the final segmentation result image obtained by post-processing the watershed algorithm in Step 4, and use the OpenCV library to count the feature information of all connected regions. A single connected region represents a crystal. The feature information includes the total number of crystals, crystal density, average crystal diameter, average crystal area, and crystal area percentage.
[0013] Furthermore, the process of step 4 is as follows:
[0014] 4.1: Preprocess the original segmentation results image, including denoising, smoothing and enhancement, to improve image quality and highlight crystal structure;
[0015] 4.2: Perform an opening operation on the image obtained in step 4.1 to obtain the background region, and simultaneously perform a distance transformation on the image obtained in step 4.1 to determine the foreground region;
[0016] 4.3: Combining the foreground and background areas obtained in step 4.2, determine the unknown areas;
[0017] 4.4: Create labels and mark each area;
[0018] 4.5: Implement the watershed algorithm to obtain the optimized final segmentation result image.
[0019] Furthermore, in step 5, the connectedComponents function in the OpenCV library is used to count all connected components in the segmentation result to realize the crystal counting function, and the ratio of the number of pixels in these connected regions to the original image size is calculated to obtain the crystal density, the average crystal area, and the area ratio. Finally, each crystal is represented as an equivalent circle to calculate its diameter, that is, its estimated diameter is obtained by substituting the crystal area into the formula for the area of a circle; finally, the observation is completed.
[0020] Preferably, in step 1, the ratio of the training set to the test set is 8:2. Of course, other ratios are also possible.
[0021] The beneficial effects of this invention are as follows: it fully utilizes the advantages of deep learning methods in image segmentation, while introducing a watershed algorithm as a post-processing step, overcoming the shortcomings of traditional methods in handling crystal adhesion and boundary blurring problems. By comprehensively applying the two methods, efficient and accurate observation and analysis of rare earth crystals are achieved, providing an effective analytical tool for rare earth crystal research and promoting the development and application of related fields. Attached Figure Description
[0022] Figure 1 This is an overall block diagram of the method described in this invention;
[0023] Figure 2 This is the original segmentation result image output by the deep learning model in the method described in this invention;
[0024] Figure 3 This is a diagram illustrating the optimization process of the watershed algorithm in the method described in this invention. Detailed Implementation
[0025] In this embodiment, the Unet3+ model is used as the deep learning segmentation model. In actual implementation, it can be replaced with any other segmentation model. The invention will be further described below with reference to the accompanying drawings.
[0026] Reference Figures 1-3 A rare-earth crystal observation method based on a deep learning model combined with a watershed algorithm, wherein the deep learning segmentation model can be any existing segmentation model, includes the following steps:
[0027] Step 1: Prepare a rare earth crystal structure image dataset, and divide the entire dataset into a training set and a test set with a ratio of 8:2;
[0028] Step 2: Perform random data augmentation on the training set images obtained in Step 1 with a 50% probability. The classic image data augmentation methods used include random scaling, random smoothing filtering, random salt and pepper noise, random padding and cropping with a size of 256×256, random vertical and horizontal flipping, and random brightness transformation. For the phenomenon of crystal shapes that are very irregular, elastic deformation data augmentation methods are applied, including affine transformation, random displacement field, and controlled deformation.
[0029] Step 3: Train the segmentation model using the training set obtained in Step 2, and evaluate the segmentation model on the test set according to the image segmentation evaluation metric (IoU) to obtain the final image segmentation model. A cosine decay strategy is used with an initial learning rate of 0.01, a momentum SGD optimizer with a momentum factor of 0.9, a batch size of 4, and a maximum of 800 training iterations. After the training phase, the final segmentation model is used to predict the crystal structure map to obtain the original segmentation result image. (See attached image.) Figure 2.
[0030] Step 4: For the original segmentation result image obtained in Step 3, post-process the image using the watershed algorithm to address the problem of difficulty in observation caused by crystal structure adhesion. Refer to the attached diagram for the watershed algorithm process. Figure 3 The process is as follows:
[0031] 4.1: Preprocess the original segmentation result image. First, convert the original segmentation image into a grayscale image and perform binarization. Then, use the opening operation to remove small noise in the image, so as to improve the image quality and highlight the crystal structure.
[0032] 4.2: The opening operation is performed on the image obtained in step 4.1 so that part of the background becomes the boundary of the object. The black area (pixel value of zero) in the obtained image is regarded as the background area, that is, the area away from the crystal. At the same time, the foreground area is determined by distance transformation of the image obtained in step 4.1. Specifically, the shortest distance from each non-zero pixel in the image to the nearest zero pixel is calculated, and this distance is used as the pixel value of that point.
[0033] 4.3: Determine the unknown area by removing the background and foreground areas obtained in step 4.2. The remaining area is the uncertain unknown area.
[0034] 4.4: Create labels and mark each region. Pixels in uncertain regions are marked as 0, pixels in background regions are marked as 1, and pixels in foreground regions are marked as integer values greater than 1.
[0035] 4.5: Implement the watershed algorithm to obtain the optimized final segmentation result image. The watershed algorithm simulates water irrigating from the lowest point (the local maximum value in the foreground region), converging at the boundary, and finally forming the segmentation line.
[0036] Step 5: Observe the final segmentation result image obtained from the watershed algorithm post-processing in Step 4. Use the OpenCV library to count the feature information of all connected regions. A single connected region represents a crystal. The feature information includes the total number of crystals, crystal density, average crystal diameter, average crystal area, and crystal area percentage. Specifically, use the connectedComponents function in the OpenCV library to count all connected components in the segmentation result to realize the crystal counting function, and calculate the ratio of the number of pixels in these connected regions to the original image size to obtain the crystal density, average crystal area, and area percentage. Finally, treat each crystal as an equivalent circle to calculate its diameter, that is, obtain its estimated diameter by substituting the crystal area into the formula for the area of a circle. Finally, the observation is completed.
[0037] The embodiments described in this specification are merely examples of implementations of the inventive concept and are for illustrative purposes only. The scope of protection of this invention should not be considered limited to the specific forms described in these embodiments; rather, it extends to equivalent technical means conceived by those skilled in the art based on the inventive concept.
Claims
1. A method for observing rare earth crystals based on a deep learning model combined with a watershed algorithm, characterized in that, The method includes the following steps: Step 1: Prepare a rare earth crystal structure image dataset and divide the entire dataset into a training set and a test set; Step 2: Perform random data augmentation on the training set images obtained in Step 1; Step 3: Train the Unet3+ deep learning model using the training set obtained in Step 2, and evaluate the segmentation model on the test set according to the image segmentation evaluation metric to obtain the final image segmentation model. Use the model to predict the crystal structure map to obtain the original segmentation result map. Step 4: For the original segmentation result image obtained in Step 3, the watershed algorithm is used to post-process the original segmentation result image to deal with the problem of crystal structure adhesion that makes it difficult to observe. Step 5: Observe the final segmentation result image obtained by post-processing the watershed algorithm in Step 4, and use the OpenCV library to count the feature information of all connected regions. A single connected region represents a crystal. The feature information includes the total number of crystals, crystal density, average crystal diameter, average crystal area, and crystal area percentage.
2. The rare earth crystal observation method based on a deep learning model combined with a watershed algorithm as described in claim 1, characterized in that, The process of step 4 is as follows: 4.1: Preprocess the original segmentation results image, including denoising, smoothing and enhancement operations, to improve image quality and highlight crystal structure; 4.2: Perform an opening operation on the image obtained in step 4.1 to obtain the background region, and simultaneously perform a distance transformation on the image obtained in step 4.1 to determine the foreground region; 4.3: Combining the foreground and background areas obtained in step 4.2, determine the unknown areas; 4.4: Create labels and mark each area; 4.5: Implement the watershed algorithm to obtain the optimized final segmentation result image.
3. The rare earth crystal observation method based on a deep learning model combined with a watershed algorithm as described in claim 1 or 2, characterized in that, In step 5, the connectedComponents function in the OpenCV library is used to count all connected components in the segmentation result to realize the crystal counting function. The ratio of the number of pixels in these connected regions to the original image size is calculated to obtain the crystal density, average crystal area, and area ratio. Finally, each crystal is represented as an equivalent circle to calculate its diameter, that is, its estimated diameter is obtained by substituting the crystal area into the formula for the area of a circle. Finally, the observation is completed.
4. The rare earth crystal observation method based on a deep learning model combined with a watershed algorithm as described in claim 1 or 2, characterized in that, In step 1, the ratio of the training set to the test set is 8:2.