Image segmentation method, device and storage medium
By combining the U-Net neural network model with a secondary segmentation method based on image features, the problem of insufficient image segmentation accuracy and speed due to lighting conditions in existing technologies is solved, achieving efficient and low-cost image segmentation results.
Patent Information
- Application Number
- CN202111477141.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-06
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2041-12-06
AI Technical Summary
Existing image segmentation methods are greatly affected by image features, especially in poor lighting conditions where accuracy and speed are insufficient, and they require high-cost lighting environments.
A pre-trained U-Net neural network model is used for initial image segmentation to identify target contours and perform secondary image segmentation based on sharpness labels. Local image secondary processing is then performed in conjunction with image features to reduce dependence on the lighting environment.
It achieves fast and high-precision image segmentation under different lighting conditions, reduces the cost requirements of the light source environment, and improves the speed and accuracy of image segmentation.
Smart Images

Figure CN116245896B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to an image segmentation method, apparatus and storage medium. Background Technology
[0002] Currently, machine vision technology has been widely applied in industrial automated production. For example, in the laser processing of PCB products, image segmentation technology is needed to identify the contours of the workpiece's location from the product image.
[0003] Existing image segmentation methods generally classify pixels in an image into regions based on features such as grayscale, gradient, and texture. These methods are highly susceptible to the influence of image features; for example, they achieve relatively low segmentation accuracy in images with indistinct feature boundaries. Furthermore, image features are greatly affected by environmental factors such as lighting conditions. Therefore, existing image segmentation methods require the construction of costly external lighting environments, resulting in high costs, and the speed and accuracy of image segmentation also need improvement. Summary of the Invention
[0004] The embodiments of the present invention provide an image segmentation method, apparatus and storage medium, which can reduce the cost of the external light source environment required, and can perform image segmentation quickly and achieve high-precision image segmentation.
[0005] In a first aspect, this application provides an image segmentation method, the method comprising:
[0006] Obtain the original image;
[0007] The original image is input into a pre-trained neural network model for initial image segmentation, identifying at least one target contour and the sharpness label corresponding to the target contour;
[0008] Extract a preset local image of the target contour whose sharpness label meets the preset index; perform secondary image segmentation on the preset local image of the target contour whose sharpness label meets the preset index based on image features; and extract a preset local image of the target contour whose sharpness label does not meet the preset index, and re-input the preset local image of the target contour whose sharpness label does not meet the preset index into the neural network model for secondary image segmentation.
[0009] The results of the two image segmentations are then merged into the original image.
[0010] In conjunction with the first aspect, in one feasible implementation, the pre-trained neural network model specifically includes the following steps:
[0011] Create a predetermined number of samples, each sample including at least one sample outline and a pre-marked sharpness label corresponding to the sample outline;
[0012] The preset number of samples is divided into a training set and a test set with a preset ratio;
[0013] Create a U-Net neural network model and train the created U-Net neural network model using the training set;
[0014] The U-Net neural network model is tested using the test set to ensure that the accuracy of the U-Net neural network model meets the preset requirements.
[0015] In conjunction with the first aspect, in one feasible implementation, before inputting the original image into a pre-trained neural network model for image segmentation, the method further includes:
[0016] The original image is preprocessed.
[0017] In conjunction with the first aspect, in one feasible implementation, the step of preprocessing the original image includes:
[0018] The original image is then filtered.
[0019] Image enhancement is performed on the filtered image;
[0020] And the enhanced image is scaled according to the parameters of the U-Net neural network model.
[0021] In conjunction with the first aspect, in one feasible implementation, the step of scaling the enhanced image according to the parameters of the U-Net neural network model includes:
[0022] The enhanced image is divided into 2... n-1 The scaling factor is a multiple of n, where n is the number of convolutional kernel layers in the U-Net neural network model.
[0023] In conjunction with the first aspect, in one feasible implementation, the preset local image is a local image of a preset shape:
[0024] The preset shape is specifically a preset rectangle or a preset circle.
[0025] In conjunction with the first aspect, in one feasible implementation, the step of performing image segmentation on the preset local image based on image features includes:
[0026] Image segmentation is performed on the preset local image based on the image's grayscale features, gradient features, or texture features.
[0027] In conjunction with the first aspect, in one feasible implementation, the method includes: using a Blob analysis algorithm to perform image segmentation on the preset local image;
[0028] or,
[0029] The Canny algorithm is used to segment the preset local image.
[0030] Secondly, this application provides an image segmentation apparatus, the apparatus comprising:
[0031] The image acquisition unit is used to acquire the original image;
[0032] The first segmentation unit is used to input the original image into a pre-trained neural network model for initial image segmentation, identify at least one target contour, and the sharpness label corresponding to the target contour;
[0033] The second segmentation unit is used to extract a preset local image of the target contour whose sharpness label meets the preset index, and to perform secondary image segmentation on the preset local image of the target contour whose sharpness label meets the preset index based on image features; and to extract a preset local image of the target contour whose sharpness label does not meet the preset index, and to re-input the preset local image of the target contour whose sharpness label does not meet the preset index into the neural network model for secondary image segmentation.
[0034] The image fusion unit is used to fuse the results of two image segmentations into the original image.
[0035] Thirdly, this application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program, when running, controls the device where the computer-readable storage medium is located to perform the image segmentation method described in the first aspect.
[0036] The image segmentation method, apparatus, and storage medium provided in this application, after acquiring the original image, perform initial image segmentation on the original image using a pre-trained neural network model, which can quickly obtain the first image segmentation result. The first image segmentation result is used to identify at least one target contour and the sharpness label corresponding to the target contour. If the sharpness label meets the preset index, a preset local image containing the target contour is further extracted, and a second image segmentation is performed based on image features. If the sharpness label does not meet the preset index, a second image segmentation is performed based on the neural network model. Thus, segmentation based on neural networks and segmentation based on image features can reduce the cost of the light source environment involved in the existing technology of segmentation methods based entirely on image features. Moreover, the method of this application can also perform image segmentation quickly and achieve high-precision image segmentation. Attached Figure Description
[0037] To more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0038] Figure 1 This is a schematic flowchart of an image segmentation method provided in an embodiment of this application;
[0039] Figure 2 This is a functional block diagram of an image segmentation device according to an embodiment of this application;
[0040] Figure 3 This is a schematic diagram of the structure of a computer device according to an embodiment of this application;
[0041] Figure 4a , Figure 4b and Figure 4c These are schematic diagrams of the original images in three scenarios of the embodiments of this application;
[0042] Figure 5a It corresponds to Figure 4a A schematic diagram of the image after the first image segmentation in an embodiment of this application;
[0043] Figure 5b It corresponds to Figure 4b A schematic diagram of the image after the first image segmentation in an embodiment of this application;
[0044] Figure 5c It corresponds to Figure 4c A schematic diagram of the image after the first image segmentation in an embodiment of this application.
[0045] Figure 6aIt corresponds to Figure 4a A schematic diagram of the image after secondary image segmentation in an embodiment of this application;
[0046] Figure 6b It corresponds to Figure 4b A schematic diagram of the image after secondary image segmentation in an embodiment of this application;
[0047] Figure 6c It corresponds to Figure 4c A schematic diagram of the image after secondary image segmentation in an embodiment of this application. Detailed Implementation
[0048] To better understand the technical solution of the present invention, the embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0049] It should be understood that the described embodiments are merely some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.
[0050] The terminology used in the embodiments of this invention is for the purpose of describing particular embodiments only and is not intended to limit the invention. The singular forms “a,” “the,” and “the” as used in the embodiments of this invention and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise.
[0051] It should be understood that the term "and / or" used in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.
[0052] It should be understood that although the terms first, second, third, etc., may be used to describe terminals in the embodiments of the present invention, these terminals should not be limited to these terms. These terms are only used to distinguish terminals from each other. For example, without departing from the scope of the embodiments of the present invention, a first terminal may also be referred to as a second terminal, and similarly, a second terminal may also be referred to as a first terminal.
[0053] Depending on the context, the word "if" as used here can be interpreted as "when," "when," "in response to determination," or "in response to detection." Similarly, depending on the context, the phrase "if determination" or "if detection (of the stated condition or event)" can be interpreted as "when determination," "in response to determination," "when detection (of the stated condition or event)," or "in response to detection (of the stated condition or event)."
[0054] See Figure 1 This is a flowchart illustrating an image segmentation method provided in an embodiment of this application.
[0055] Specifically, the laser image segmentation method in this application embodiment includes:
[0056] S11, Obtain the original image.
[0057] S12, the original image is input into a pre-trained neural network model for initial image segmentation, identifying at least one target contour and the sharpness label corresponding to the target contour.
[0058] S13, extract a preset local image of the target contour whose sharpness label conforms to the preset index, and perform secondary image segmentation on the preset local image of the target contour whose sharpness label conforms to the preset index based on image features; and extract a preset local image of the target contour whose sharpness label does not conform to the preset index, and re-input the preset local image of the target contour whose sharpness label does not conform to the preset index into the neural network model for secondary image segmentation.
[0059] S14, the results of the two image segmentations are merged into the original image.
[0060] The image segmentation method provided in this application, after acquiring the original image, performs initial image segmentation on the original image using a pre-trained neural network model, which can quickly obtain the first image segmentation result. The first image segmentation result is used to identify at least one target contour and the sharpness label corresponding to the target contour. If the sharpness label meets the preset index, a preset local image containing the target contour is further extracted, and a second image segmentation is performed based on image features. If the sharpness label does not meet the preset index, a second image segmentation is performed based on the neural network model. Thus, segmentation based on neural network and segmentation based on image features can reduce the environmental cost of setting up a light source involved in the existing image feature-based segmentation method, and can also achieve rapid image segmentation and high-precision image segmentation.
[0061] Steps S11-S14 are further described below in a more detailed embodiment of this application.
[0062] S11 is used to obtain the original image.
[0063] Specifically, the original image in this application embodiment may be, but is not limited to, an image of the product to be processed. The product to be processed may be, but is not limited to, a PCB board. The PCB board to be processed needs to accommodate the installation of the workpiece by a robotic arm at the set positioning mark points. The purpose of this application is to identify the outline of the positioning mark point positions of the workpiece from the original image of the PCB board to be processed, wherein the outline may be a preset circle, rectangle, cross shape, etc.
[0064] In one embodiment of this application, the original image may be, but is not limited to, a 5-megapixel (2448*2048) black and white image captured by an industrial camera. The ultimate goal of this application is to achieve image segmentation with sub-pixel accuracy.
[0065] S12, the original image is input into a pre-trained neural network model for initial image segmentation, identifying at least one target contour and the sharpness label corresponding to the target contour.
[0066] In one embodiment of this application, after obtaining the original image, it is necessary to preprocess the original image.
[0067] Specifically, the original image undergoes preprocessing, including Gaussian filtering to remove salt and pepper noise. Preprocessing also includes enhancement processing of the filtered image, such as rotation, mapping, brightness adjustment, and perspective transformation.
[0068] In one embodiment of this application, preprocessing the original image further includes scaling the enhanced image according to the parameters of a neural network model. In this application, the neural network model used is the U-Net neural network model, which includes a symmetrical U-shaped structure formed by compression and expansion paths. In this embodiment, the step of scaling the enhanced image according to the parameters of the U-Net neural network model specifically involves scaling the enhanced image according to a 2... n-1 The scaling factor is a multiple of n, where n is the number of convolutional kernel layers in the U-Net neural network model.
[0069] In this embodiment of the application, the process of training the U-Net neural network includes:
[0070] S1, create a preset number of samples, wherein the samples include at least one sample outline and a pre-marked sharpness label corresponding to the sample outline.
[0071] Specifically, samples can be obtained through human identification or based on existing image segmentation methods, such as image segmentation methods based on image grayscale, image segmentation methods based on thresholds, image segmentation methods based on CNN networks, etc. The sample images are labeled with segmented target contours, which can be preset shapes, such as rectangles, circles, crosses, etc. In this application, a circle (x, y, r) is used as an example, where (x, y) is the center of the circle and r is the radius. Generally, the diameter of the contour detected in the samples using existing image segmentation methods can reach an accuracy level of 20 pixels, but it is difficult to achieve sub-pixel accuracy. Furthermore, each contour (x, y, r) is pre-labeled with a first label or a second label based on the clarity of the contour interface as perceived by the human eye, where the first label indicates a clear segmentation result, and the second label indicates an indistinct boundary.
[0072] S2 divides a preset number of samples into a training set and a test set with a preset ratio.
[0073] In this application, a preset number of samples (e.g., 50,000) are obtained, and the training set and test set can be further divided according to the ratio.
[0074] S3, Create a U-Net neural network model, and train the created U-Net neural network model using the training set.
[0075] S4. The U-Net neural network model is tested using a test set to ensure that the accuracy of the U-Net neural network model meets the preset requirements.
[0076] Specifically, the U-Net neural network model trained in the embodiments of this application can quickly segment images with an accuracy of 99%. However, it is difficult to achieve the required high accuracy by using a neural network alone for segmentation.
[0077] Furthermore, in this embodiment of the application, the U-Net neural network model is used to perform initial image segmentation on the original image, which enables the identification of rough target contours and sharpness labels for each target contour from the image.
[0078] S13, extract a preset local image of the target contour whose sharpness label meets the preset index, and perform secondary image segmentation on the preset local image whose sharpness label meets the preset index based on image features; and extract a preset local image of the target contour whose sharpness label does not meet the preset index, and re-input the preset local image of the target contour whose sharpness label does not meet the preset index into the neural network model for secondary image segmentation.
[0079] Specifically, when the sharpness label meets the preset index (e.g., the sharpness label is the first label, or the sharpness score output by the U-Net neural network is higher than the preset value), it means that the features of the image pixels near the contour edge obtained by image segmentation are significantly distinguishable. This region can then be further segmented using image feature-based methods to obtain high-precision image segmentation results. For example, the preset local image can be segmented using the Blob analysis algorithm or the Canny algorithm. In one embodiment of this application, the preset local image can be a rectangular local image, and this rectangle is the smallest bounding rectangle of the circular contour (x, y, r) identified in the first segmentation.
[0080] When the sharpness label does not meet the preset criteria, it means that the distinguishability of image pixels near the image contour edges is not obvious. Even if an image segmentation method based on image features is used, the accuracy will be reduced. To address this, the image of this local region is extracted, and the U-Net neural network model is used again for image segmentation. This time, since the image input to the U-Net neural network model is a smaller local image compared to the original image, the accuracy of image segmentation is improved, and the segmentation speed is also faster.
[0081] S14, the results of the two image segmentations are merged into the original image.
[0082] Specifically, since the two image segmentation operations are performed on images of different pixel sizes, the segmentation results need to be merged into the original image after the two segmentations, and the merged image is output as the final result of image segmentation. The image segmentation in the embodiments of this application can achieve sub-pixel level accuracy.
[0083] Figure 2 This is a functional block diagram of an image segmentation device provided in an embodiment of this application.
[0084] The image segmentation apparatus 200 described above includes:
[0085] Image acquisition unit 21 is used to acquire the original image;
[0086] The first segmentation unit 22 is used to input the original image into a pre-trained neural network model for initial image segmentation, identify at least one target contour, and the sharpness label corresponding to the target contour;
[0087] The second segmentation unit 23 is used to extract a preset local image of the target contour whose sharpness label conforms to the preset index, and perform secondary image segmentation on the preset local image of the target contour whose sharpness label conforms to the preset index based on image features; and to extract a preset local image of the target contour whose sharpness label does not conform to the preset index, and re-input the preset local image of the target contour whose sharpness label does not conform to the preset index into the neural network model for secondary image segmentation.
[0088] The image fusion unit 24 is used to fuse the results of two image segmentations into the original image.
[0089] The image acquisition unit 21 is used to acquire the original image.
[0090] Specifically, the original image in this application embodiment may be, but is not limited to, an image of the product to be processed. The product to be processed may be, but is not limited to, a PCB board. The PCB board to be processed needs to accommodate the installation of the workpiece by a robotic arm at the set positioning mark points. The purpose of this application is to identify the outline of the positioning mark point positions of the workpiece from the original image of the PCB board to be processed, wherein the outline may be a preset circle, rectangle, cross shape, etc.
[0091] In one embodiment of this application, the original image may include, but is not limited to, a 5-megapixel (2448*2048) black and white image captured by an industrial camera. This application ultimately aims to achieve image segmentation with sub-pixel accuracy.
[0092] In one embodiment of this application, the original image can be as follows: Figure 4a , Figure 4b and Figure 4c The meaning is shown. In Figure 4a , Figure 4b and Figure 4c In the application scenario, the product to be processed is a PCB board, which has one or more positioning mark points located at... Figure 4a , Figure 4b , Figure 4c The center of the circular outline in the diagram. Figure 4a , Figure 4b , Figure 4c For illustrative purposes only, the actual circular outline is very small. In the actual original image, the diameter of the circular outline is approximately 30 pixels, and the thickness of the outer ring of the circular outline is approximately 2-3 pixels.
[0093] exist Figure 4aThe image illustrates that during the acquisition of the original image, the lighting environment at the location of the circular contour was poor, and the gradient boundaries around the contour were complex. Current technologies typically employ image feature-based algorithms (such as gradient features) for image segmentation, which require highly discriminative image features. Existing algorithms are therefore unsuitable for... Figure 4a The image is directly segmented. Therefore, existing techniques require increasing the brightness of the light source. Figure 4b The middle part indicates that it is superior to Figure 4a The lighting environment, but Figure 4b The gradient contours in the image are still not obvious, and existing techniques are not suitable for [further processing]. Figure 4b To handle it directly. Figure 4c In the original image, the gradient features of the adjacent regions of the circular contour are clearly distinguishable, allowing for image segmentation based on image feature-based algorithms. This application uses... Figures 4a to 4c The original image illustrations illustrate that the image segmentation method and apparatus provided in this application can segment these images, and can reduce the cost of environment construction and improve the segmentation speed and accuracy.
[0094] The first segmentation unit 22 is used to input the original image into a pre-trained neural network model for initial image segmentation, and to identify at least one target contour and the sharpness label corresponding to the target contour.
[0095] Specifically, in one embodiment of this application, after obtaining the original image, it is necessary to preprocess the original image.
[0096] Specifically, the original image undergoes preprocessing, including Gaussian filtering to remove salt and pepper noise. Preprocessing also includes enhancement processing of the filtered image, such as rotation, mapping, brightness adjustment, and perspective transformation.
[0097] In one embodiment of this application, preprocessing the original image further includes scaling the enhanced image according to the parameters of a neural network model. In this application, the neural network model used is the U-Net neural network model, which includes a symmetrical U-shaped structure formed by compression and expansion paths. In this embodiment, the step of scaling the enhanced image according to the parameters of the U-Net neural network model specifically involves scaling the enhanced image according to a 2... n-1 The scaling factor is a multiple of n, where n is the number of convolutional kernel layers in the U-Net neural network model.
[0098] In this embodiment of the application, the process of training the U-Net neural network includes:
[0099] S1, create a preset number of samples, wherein the samples include at least one sample outline and a pre-marked sharpness label corresponding to the sample outline.
[0100] Specifically, samples can be obtained through human identification or based on existing image segmentation methods, such as image segmentation methods based on image grayscale, image segmentation methods based on thresholds, image segmentation methods based on CNN networks, etc. The sample images are labeled with segmented target contours, which can be preset shapes, such as rectangles, circles, crosses, etc. In this application, a circle (x, y, r) is used as an example, where (x, y) is the center of the circle and r is the radius. Generally, the diameter of the contour detected in the samples using existing image segmentation methods can reach an accuracy level of 20 pixels, but it is difficult to achieve sub-pixel accuracy. Furthermore, each contour (x, y, r) is pre-labeled with a first label or a second label based on the clarity of the contour interface as perceived by the human eye, where the first label indicates a clear segmentation result, and the second label indicates an indistinct boundary.
[0101] S2 divides the samples into a training set and a test set with a preset ratio.
[0102] In this application, a preset number of samples (e.g., 50,000) are obtained, and the training set and test set can be further divided according to the ratio.
[0103] S3, Create a U-Net neural network model, and train the created U-Net neural network model using the training set.
[0104] S4. The U-Net neural network model is tested using a test set to ensure that the accuracy of the U-Net neural network model meets the preset requirements.
[0105] Specifically, the U-Net neural network model trained in the embodiments of this application can quickly segment images with an accuracy of 99%, but it is difficult to achieve the required high precision when used alone.
[0106] Furthermore, in this embodiment of the application, the U-Net neural network model is used to perform initial image segmentation on the original image, which enables the identification of rough target contours and sharpness labels for each target contour from the image.
[0107] Specifically, in one particular embodiment of this application, Figure 5a , Figure 5b , Figure 5c The initial segmentation and recognition results are shown. Figure 5a and Figure 4a Correspondingly, Figure 5b and Figure 4b Correspondingly, Figure 5c and Figure 4c Correspondingly. Figure 4a This illustrates how poor lighting conditions during the original image acquisition resulted in indistinct image feature differences. Figure 4b The lighting environment in it is slightly better than Figure 4a However, the differences in image gradient features are still not obvious. Figure 4c This illustrates a situation where the gradient features of the image are clearly distinguishable.
[0108] In this embodiment, for Figures 4a to 4c Neural network models can be used for initial image segmentation to improve segmentation speed, but the accuracy is not necessarily high. Figure 4a and Figure 4b The outer ring of the outline in the middle has a thickness of about 3 pixels, while... Figure 5a and Figure 5b In the initial segmentation, the identified contour lines 42 and 41 may fall within a certain pixel error range within the ring. Similarly, Figure 5c The result is the initial image segmentation result corresponding to 4c. The black image outline in the initial image segmentation has some errors.
[0109] The second segmentation unit 23 is used to extract a preset local image of the target contour whose sharpness label conforms to the preset index, and to perform secondary image segmentation on the preset local image of the target contour whose sharpness label conforms to the preset index based on image features; and to extract a preset local image of the target contour whose sharpness label does not conform to the preset index, and to re-input the preset local image of the target contour whose sharpness label does not conform to the preset index into the neural network model for secondary image segmentation.
[0110] Specifically, when the sharpness label meets the preset index (e.g., the sharpness label is the first label, or the sharpness score output by the U-Net neural network is higher than the preset value), it means that the features of the image pixels near the contour edge obtained by image segmentation are significantly distinguishable. This region can then be further segmented using image feature-based methods to obtain high-precision image segmentation results. For example, the preset local image can be segmented using the Blob analysis algorithm or the Canny algorithm. In one embodiment of this application, the preset local image can be a rectangular local image, and this rectangle is the smallest bounding rectangle of the circular contour (x, y, r) identified in the first segmentation.
[0111] When the sharpness label does not meet the preset criteria, it means that the distinguishability of image pixels near the image contour edges is not obvious. Even if an image segmentation method based on image features is used, the accuracy will be reduced. To address this, the image of this local region is extracted, and the U-Net neural network model is used again for image segmentation. This time, since the image input to the U-Net neural network model is a smaller local image compared to the original image, the accuracy of image segmentation is improved, and the segmentation speed is also faster.
[0112] The image fusion unit 24 is used to fuse the results of two image segmentations into the original image.
[0113] Specifically, since the two image segmentation operations are performed on images of different pixel sizes, the segmentation results need to be merged into the original image after the two segmentations, and the merged image is output as the final result of image segmentation. The image segmentation in the embodiments of this application can achieve sub-pixel level accuracy.
[0114] In one embodiment of this application, such as Figure 6a , Figure 6b , Figure 6c The diagram illustrates the recognition results of the contour lines after the second image segmentation. Figure 6a and Figure 4a Correspondingly, Figure 6b and Figure 4b Correspondingly, although Figure 4b The lighting environment is better than Figure 4a ,but Figure 4a and Figure 4b The gradient features around the contours of the images are still not clearly distinguishable. Therefore, the U-Net neural network model is used for the second image segmentation. For comparison purposes, Figure 6a Compared to Figure 5a Some of the rings have been enlarged. Figure 6b Compared to Figure 5b Some of the rings have also been enlarged. Specifically, it can be seen that contour line 52 has higher precision than contour line 42, and contour line 51 also has higher precision than contour line 41.
[0115] In the embodiments of this application, Figure 4c The image provided illustrates a circular outline with clearly distinguishable gradient features. Therefore, the Blob analysis algorithm is used for the second image segmentation of this image. Figure 6c This is a magnified schematic diagram of a portion of the image after the second image segmentation. As can be seen from the diagram, the recognition result of the black outline is closer to the inner boundary of the outer ring of the circular outline, thus improving the segmentation accuracy.
[0116] This application also provides a computer-readable storage medium, which includes a stored program, wherein the program controls the device where the storage medium is located to execute the above-described image segmentation method when it is running.
[0117] This application embodiment also provides a computer device 300, such as... Figure 3 As shown. The computer device 300 of this embodiment includes: a processor 301, a memory 302, and a computer program 303 stored in the memory and executable on the processor 301. When the processor 301 executes the computer program 303, it implements the method of the laser beam-adding device in the embodiment. To avoid repetition, it will not be described in detail here. Alternatively, when the computer program is executed by the processor 301, it implements the functions of each model / unit in the debugging device in the embodiment. To avoid repetition, it will not be described in detail here.
[0118] Computer device 300 can be a desktop computer, laptop, handheld computer, cloud server, laser processing equipment, or other computing device. The computer device may include, but is not limited to, processor 301 and memory 302. Those skilled in the art will understand that... Figure 3 This is merely an example of computer device 300 and does not constitute a limitation on computer device 300. It may include more or fewer components than shown, or combine certain components, or different components. For example, computer device may also include input / output devices, network access devices, buses, etc.
[0119] The processor 301 may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0120] The memory 302 can be an internal storage unit of the computer device 800, such as a hard disk or RAM of the computer device 300. The memory 302 can also be an external storage device of the computer device 300, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card equipped on the computer device 300. Furthermore, the memory 302 can include both internal and external storage units of the computer device 300. The memory 302 is used to store computer programs and other programs and data required by the computer device. The memory 302 can also be used to temporarily store data that has been output or will be output.
[0121] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0122] In the embodiments provided by this invention, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of the units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between devices or units through some interfaces, and may be electrical, mechanical, or other forms.
[0123] The integrated units implemented as software functional units described above can be stored in a computer-readable storage medium. These software functional units, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute some steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0124] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. An image segmentation method, characterized in that, The method includes: Obtain the original image; The original image is input into a pre-trained neural network model for initial image segmentation, identifying at least one target contour and the sharpness label corresponding to the target contour; Extract a preset local image of the target contour whose sharpness label meets the preset index; perform secondary image segmentation on the preset local image of the target contour whose sharpness label meets the preset index based on image features; and extract a preset local image of the target contour whose sharpness label does not meet the preset index, and re-input the preset local image of the target contour whose sharpness label does not meet the preset index into the neural network model for secondary image segmentation. The results of the two image segmentations are then merged into the original image; Specifically, the secondary image segmentation of the preset local image of the target contour whose sharpness label meets the preset index includes: The Blob analysis algorithm is used to segment the preset local image; or, The Canny algorithm is used to segment the preset local image.
2. The method according to claim 1, characterized in that, The pre-trained neural network model specifically includes the following steps: Create a predetermined number of samples, each sample including at least one sample outline and a pre-marked sharpness label corresponding to the sample outline; The preset number of samples is divided into a training set and a test set with a preset ratio; Create a U-Net neural network model and train the created U-Net neural network model using the training set; The U-Net neural network model is tested using the test set to ensure that the accuracy of the U-Net neural network model meets the preset requirements.
3. The method according to claim 2, characterized in that, Before inputting the original image into a pre-trained neural network model for image segmentation, the method further includes: The original image is preprocessed.
4. The method according to claim 3, characterized in that, The step of preprocessing the original image includes: The original image is then filtered. Image enhancement is performed on the filtered image; And the enhanced image is scaled according to the parameters of the U-Net neural network model.
5. The method according to claim 4, characterized in that, The step of scaling the enhanced image according to the parameters of the U-Net neural network model includes: The enhanced image is divided into... The scaling factor is a multiple of n, where n is the number of convolutional kernel layers in the U-Net neural network model.
6. The method according to claim 1, characterized in that, The preset local image is a local image of a preset shape: The preset shape is a preset rectangle or a preset circle.
7. The method according to claim 1, characterized in that, The step of performing image segmentation on the preset local image based on image features includes: Image segmentation is performed on the preset local image based on the image's grayscale features, gradient features, or texture features.
8. An image segmentation apparatus, characterized in that, The device includes: The image acquisition unit is used to acquire the original image; The first segmentation unit is used to input the original image into a pre-trained neural network model for initial image segmentation, identify at least one target contour, and the sharpness label corresponding to the target contour; The second segmentation unit is used to extract a preset local image of the target contour whose sharpness label meets the preset index, and to perform secondary image segmentation on the preset local image of the target contour whose sharpness label meets the preset index based on image features; and to extract a preset local image of the target contour whose sharpness label does not meet the preset index, and to re-input the preset local image of the target contour whose sharpness label does not meet the preset index into the neural network model for secondary image segmentation. An image fusion unit is used to fuse the results of two image segmentations into the original image; Specifically, the secondary image segmentation of the preset local image of the target contour whose sharpness label meets the preset index includes: The Blob analysis algorithm is used to segment the preset local image; or, The Canny algorithm is used to segment the preset local image.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which, when executed, controls the device containing the computer-readable storage medium to perform the image segmentation method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Medical image segmentation method, device and equipment and storage medium
CN110570394A
Definition detection method, system and device and medium
CN111402177A