Image processing method, device, electronic device and storage medium
Through the pre-trained image processing model, the landing point generator and the contour extraction model are used to solve the problem of contour discontinuity and inaccuracy in medical image contour delineation, achieving higher image contour accuracy and compatibility.
Patent Information
- Application Number
- CN202110979806.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-25
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2041-08-25
AI Technical Summary
Existing medical image contour delineation methods are difficult to ensure the continuity and accuracy of contours when processing images with uneven grayscale, blurred target edges, and irregular shapes, resulting in delineation results that do not meet practical application requirements.
Using a pre-trained image processing model, combined with a landing point generator and a contour extraction model, the landing point generator determines the starting point of image processing. The contour extraction model draws the image contour point by point based on the starting point, imitating the expert drawing process and improving the accuracy of the contour. Accuracy.
It effectively avoids the deviation of contour drawing from the real contour, improves the accuracy of image contours, and shows high compatibility and accuracy under limited training sample data.
Smart Images

Figure CN113936074B
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of computer technology, and in particular to an image processing method, device, electronic device and storage medium. Background Art
[0002] According to recent statistics from the American Heart Association (AHA), cardiovascular disease has become the number one cause of death worldwide, and the assessment of left ventricle segmentation is crucial for the diagnosis of cardiac lesions. Typically, left ventricle segmentation requires human experts to manually draw the left ventricle contour.
[0003] At present, when traditional contouring methods are used to extract contours from images, a large amount of original image data is often directly input into the network, and the image data is processed according to the designed network algorithm to obtain the image contour.
[0004] However, the above methods have at least the following technical problems: currently, there are few medical images, and the method of randomly extracting features from a large number of images is not advisable. In addition, since most medical images have the characteristics of uneven grayscale distribution, blurred target edges, and irregularly shaped cavities inside the target area, the problem of edge discontinuity occurs, and the accuracy of contour depiction is difficult to meet the requirements of practical applications. Summary of the invention
[0005] The embodiments of the present invention provide an image processing method, an apparatus, an electronic device and a storage medium to improve the accuracy of contour depiction.
[0006] In a first aspect, an embodiment of the present invention provides an image processing method, including:
[0007] Obtain at least one image to be processed;
[0008] Inputting the image to be processed into a pre-trained image processing model to obtain an image contour corresponding to the image to be processed;
[0009] Among them, the image processing model includes a landing point generator and a contour extraction model, the landing point generator is used to determine the processing starting point of the image to be processed, and the contour extraction model is used to determine the image contour of the image to be processed based on the processing starting point.
[0010] In a second aspect, an embodiment of the present invention further provides an image processing device, including:
[0011] An image acquisition module, used to acquire at least one image to be processed;
[0012] A contour generation module, used for inputting the image to be processed into a pre-trained image processing model to obtain an image contour corresponding to the image to be processed;
[0013] Among them, the image processing model includes a landing point generator and a contour extraction model, the landing point generator is used to determine the processing starting point of the image to be processed, and the contour extraction model is used to determine the image contour of the image to be processed based on the processing starting point.
[0014] In a third aspect, an embodiment of the present invention further provides an electronic device, the electronic device comprising:
[0015] one or more processors;
[0016] A storage device for storing one or more programs;
[0017] When the one or more programs are executed by the one or more processors, the one or more processors implement any image processing method described in the embodiments of the present invention.
[0018] In a fourth aspect, an embodiment of the present invention further provides a storage medium comprising computer executable instructions, wherein the computer executable instructions, when executed by a computer processor, are used to implement any image processing method described in any of the embodiments of the present invention.
[0019] The present invention obtains at least one image to be processed; inputs the image to be processed into a pre-trained image processing model to obtain an image contour corresponding to the image to be processed; wherein the image processing model includes a landing point generator and a contour extraction model, the landing point generator is used to determine the processing starting point of the image to be processed, and the contour extraction model is used to determine the image contour of the image to be processed based on the processing starting point. When performing image processing, the above technical solution determines the processing starting point of the image to be processed through the landing point generator, thereby avoiding the situation where the contour drawing deviates from the real contour; the contour extraction model draws the contour based on the processing starting point, effectively imitating the process of contour drawing by experts, so that the obtained image contour has higher accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the following briefly introduces the drawings required to describe the embodiments. Obviously, the drawings introduced are only drawings of a part of the embodiments to be described in the present invention, rather than all the drawings. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0021] Figure 1 is a flowchart of an image processing method provided by Embodiment 1 of the present invention;
[0022] Figure 2 is a flowchart of an image processing method provided by Embodiment 2 of the present invention;
[0023] Figure 3 is a flowchart of an image processing method provided by Embodiment 3 of the present invention;
[0024] Figure 4 is a structural schematic diagram of an image processing device provided by a fourth embodiment of the present invention;
[0025] Figure 5 It is a structural schematic diagram of an electronic device provided in Embodiment 5 of the present invention. DETAILED DESCRIPTION
[0026] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention.
[0027] It should also be noted that, for ease of description, only the part relevant to the present invention but not all content is shown in the accompanying drawings. It should be mentioned before discussing exemplary embodiments in more detail that some exemplary embodiments are described as processing or methods depicted as flow charts. Although the flow chart describes each operation (or step) as sequential processing, many operations therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of each operation can be rearranged. When its operation is completed, the processing can be terminated, but it can also have additional steps not included in the accompanying drawings. The processing can correspond to methods, functions, procedures, subroutines, subprograms, etc.
[0028] Embodiment 1
[0029] Figure 1 This is a flowchart diagram of an image processing method provided in Embodiment 1 of the present invention. This embodiment is applicable to the case where an image is automatically contoured through an image processing model. The method can be executed by an image processing device provided in an embodiment of the present invention. The device can be implemented by software and / or hardware. The device can be configured on an electronic computing device, such as a desktop computer or a server. Specifically, the following steps are included:
[0030] S110: Obtain at least one image to be processed.
[0031] The image to be processed may be an image containing a target processing object, and the type and content of the target processing object are not specifically limited herein. For example, the target processing object may be a heart or a lung. Optionally, the image to be processed includes a medical image, etc. Typically, the medical image may be a computed tomography (CT) image, a magnetic resonance (MR) image, a positron emission tomography (PET) image, or other clinical medical images. Exemplarily, the image to be processed may be a cardiac MRI image or a pulmonary bronchial CT image, etc.
[0032] In an embodiment of the present invention, one, two or more images to be processed are obtained. Optionally, obtaining the images to be processed includes: acquiring the images to be processed containing the target processing object in real time based on an image acquisition device, or acquiring the images to be processed containing the target processing object from a preset storage location, or receiving the images to be processed containing the target processing object sent by the target device. The storage location of the images to be processed is not limited and can be set according to actual needs, and can be directly obtained from the corresponding storage location when needed.
[0033] S120: Input the image to be processed into a pre-trained image processing model to obtain an image contour corresponding to the image to be processed.
[0034] The image processing model includes a landing point generator and a contour extraction model, and the output end of the landing point generator is connected to the input end of the contour extraction model. The landing point generator is used to determine the processing starting point of the image to be processed, and the contour extraction model is used to determine the image contour of the image to be processed based on the processing starting point. The processing starting point is the starting point of the image contour, and the image contour can be drawn point by point from the processing starting point. The accuracy of the processing starting point is conducive to improving the accuracy of the drawn contour. In addition, compared with the traditional supervised learning image drawing method, the drawing method of the embodiment of the present invention does not require a large number of training samples, and the image processing model has strong compatibility and can input images of different sizes to be processed.
[0035] Specifically, the image to be processed is input as input data into a pre-trained image processing model; that is, the image to be processed is input into a landing point generator to obtain a processing starting point, and the processing starting point and the image to be processed are input into a contour extraction model to realize contour extraction of the image to be processed, and an image contour corresponding to the image to be processed is obtained, and output from the image processing model as output data, thereby realizing efficient and accurate automatic contouring of the image.
[0036] Based on the above embodiment, the contour extraction model includes a strategy network model, which is used to cyclically process the determined contour points to obtain the next contour point, and obtain the image contour of the image to be processed based on each determined contour point, wherein the processing starting point is the first determined contour point.
[0037] Among them, the policy network model is a neural network model that can predict the contour points of the image to be processed. Optionally, when the contour points predicted by the policy network model fall within the preset end point range, the contour drawing is terminated and the predicted contour points are used to form the image contour. In some embodiments, the contour points are connected point by point through a contour drawing function or a cropping function to form the image contour of the image to be processed. Exemplarily, the preset end point range can be a square block (or rectangular block) centered on the first five contour points on the image contour.
[0038] It should be noted that, before the contour drawing ends normally, the contour points predicted by the policy network model may have been mistakenly moved outside the image contour. In this case, the present invention provides for terminating the contour drawing process in advance and providing a very small negative action reward as a penalty for the wrong movement.
[0039] On the basis of the above-mentioned embodiment, the loop processing based on the determined contour points to obtain the next contour point includes: generating a current field of view image of the image to be processed based on the current contour points obtained in the image to be processed; determining a movement probability distribution based on the current contour points in the current field of view image; and determining the next contour point of the current contour point based on the movement probability distribution.
[0040] In this embodiment, the strategy network model receives the processing start point sent by the landing point generator, and the processing start point is used as the first determined contour point. The strategy network model uses the processing start point as the current contour point to determine the next contour point, and uses the determined next contour point as the second determined contour point, and determines the next contour point based on the second determined contour point as the current contour point, and so on, until the end condition is met, that is, the predicted contour point falls within the preset end point range.
[0041] Among them, the current field of view image can be an image within the preset visual range of the current contour point, which can be used as the input of the policy network model. In some embodiments, the current field of view image is defined as an M×N square image block centered on the current contour point. One advantage of this setting is that since the input size is always M×N, the policy network model can be designed to have a unified structure; and since the input current field of view image is smaller than the image to be processed, the policy network model can process images to be processed of different sizes, wherein M and N are positive integers greater than or equal to 1, respectively, and in some embodiments, M and N can be the same.
[0042] Specifically, the current field of view image of the current contour point is determined according to the preset visual range, and the current field of view image is input into the policy network model to generate the movement probability distribution of the current contour point, and the movement direction is determined according to the movement probability distribution in each direction. Specifically, the movement probability distribution belongs to the state transition probability in the Markov decision process, that is, after taking the corresponding action under the current field of view image corresponding to the determined current contour point, the next contour point cannot be completely determined, but the next contour point is determined with a certain probability. It is necessary to determine the real movement direction according to the action reward to obtain the next contour point of the current contour point, wherein the action reward is the reward value for the current contour point movement action, so that the current contour point moves on the real contour as much as possible. It should be noted that the movement distance of the next contour point relative to the current contour point in the output direction can be preset, for example, the next contour point can be the next pixel point in the output direction, or the pixel point separated by a preset number of pixels in the output direction, and this is not limited.
[0043] In this embodiment, after obtaining the next contour point of the current contour point, the policy network model performs a cyclic prediction until the next contour point predicted by the policy network model falls within the preset end point range, and then the contour drawing is terminated.
[0044] An image processing method provided by an embodiment of the present invention obtains at least one image to be processed; inputs the image to be processed into a pre-trained image processing model to obtain an image contour corresponding to the image to be processed; wherein the image processing model includes a landing point generator and a contour extraction model, the landing point generator is used to determine the processing starting point of the image to be processed, and the contour extraction model is used to determine the image contour of the image to be processed based on the processing starting point. When performing image processing, the above technical solution determines the processing starting point of the image to be processed through the landing point generator, thereby avoiding the situation where the contour drawing deviates from the real contour; the contour extraction model draws the contour based on the processing starting point, thereby avoiding the interference of the inaccurate starting point on the image contour and invalid calculation, thereby improving the accuracy of the obtained image contour.
[0045] Embodiment 2
[0046] Figure 2A flowchart diagram of an image processing method provided for the second embodiment of the present invention, the embodiment of the present invention can be combined with each optional scheme in the above embodiment. In the embodiment of the present invention, optionally, the training method of the contour extraction model includes: obtaining multiple groups of training sample data, wherein the training sample data includes a sample image and a sample image contour corresponding to the sample image; inputting the field of view image corresponding to the random starting point of the sample image into the initial policy network model, determining the training image contour, and obtaining the action reward according to the movement probability distribution output by the initial policy network model and the corresponding sample image contour; inputting the field of view image corresponding to the random starting point of the sample image into the initial valuation network model to obtain a movement score; based on the training image contour, the action reward and the movement score, updating the parameters of the initial policy network model and the initial valuation network model to obtain an updated policy network model and an updated valuation network model, wherein the updated policy network model and the updated valuation network model are used to iteratively process the next sample image.
[0047] like Figure 2 As shown, the method of the embodiment of the present invention specifically includes the following steps:
[0048] S210: Acquire multiple groups of training sample data, wherein the training sample data includes sample images and sample image contours corresponding to the sample images.
[0049] The sample image is an image without contour drawing, and the contour of the sample image is a contour image drawn by an expert. For example, the sample image is a two-dimensional heart image obtained by magnetic resonance imaging (MRI), and the contour of the sample image is a left ventricle contour drawn by an experienced cardiologist.
[0050] Optionally, in some embodiments, the sample image contour drawn by the expert is usually a discontinuous trajectory, that is, two consecutive contour points on the image contour may fall outside each other's neighborhood (3×3 image block centered on one pixel). In order to meet the training requirements of the contour extraction model, the original image contour is first refined by inserting enough additional points between two consecutive contour points that are not adjacent to each other to meet the continuity requirements, that is, any contour point on the image contour always has a neighboring point located within its 3×3 image block, and then scans every two contour points on the contour and places additional points on each pixel on the row spacing between the two contour points. The reason for this setting is that after thoroughly checking all contour images, it is found based on statistics that the points on the original contour are densely located in the vertical direction (that is, two consecutive contour points are always located on two adjacent rows), while the probability of being located in the horizontal direction is low (that is, two consecutive contour points are rarely located on two adjacent columns).
[0051] S220. Input the field of view image corresponding to the random starting point of the sample image into the initial strategy network model of the image processing model, determine the training image contour, and obtain the action reward based on the movement probability distribution output by the initial strategy network model and the corresponding sample image contour.
[0052] The training image contour is a complete contour generated based on the initial policy network model, which can be used to estimate the relative advantage. During the training process, the starting point of the sample image is randomly determined. The advantage of this setting is that even when the training sample data is limited, the diversity of the collected training image contours can still be guaranteed by randomly selecting the starting point position during each iteration.
[0053] Specifically, the current field of view image is determined by a random starting point, the current field of view image is input into the policy network model, the movement probability distribution is output, the next contour point is determined based on the movement probability distribution, and all contour points are connected to form the training image contour.
[0054] For example, for each sample image, a position point on its contour is randomly selected as the starting point, and the strategy Complete a complete image outline. Then collect a set of image outlines D for all sample images k ={τ i}.in, Represents the strategy under parameter θ at the kth iteration. i represents the i-th completed image contour, D k Represents the set of multiple image contours at the kth iteration.
[0055] Exemplarily, assume that the current field of view image is a 21×21 image block, and the field of view image is used as the input of the policy network model. The network design of the policy network model is shown in Table 1, which contains two convolution-pooling layers and three fully connected layers. Except for the last layer, all layers use the "Relu" activation function. Since the output of the policy network model corresponds to the probability distribution of movement of the current contour point in 8 directions, the policy network model must finally pass through a "softmax" layer to output the movement probability distribution, and determine the movement direction according to the movement probability distribution in each direction, and obtain the field of view image of the next contour point, so as to realize the cyclic call of the policy network model until the current sample image completes the drawing of the training image contour.
[0056] Table 1 Initial strategy network model
[0057]
[0058] S230: Inputting the visual field image corresponding to the random starting point of the sample image into the initial estimation network model to obtain a movement score.
[0059] The motion score can be used to evaluate the current field of view image and update the image contour model parameters. Specifically, the current field of view image is determined by a random starting point in the sample image, the current field of view image is input into the initial estimation network model, and the motion score corresponding to the current field of view image of the sample image is output.
[0060] For example, the current field of view image (21×21 image block) of the current contour point is taken as input, and then a motion score for the current field of view image is output. The design of the initial estimation network model follows that shown in Table 2, which includes two convolution-pooling layers and three fully connected layers. Except for the last layer, all other layers use the "Relu" activation function.
[0061] Table 2 Initial valuation network model
[0062]
[0063] S240: Based on the training image contour, the action reward and the movement score, the parameters of the initial policy network model and the initial valuation network model are updated to obtain an updated policy network model and an updated valuation network model.
[0064] The initial policy network model and the initial valuation network model are located in the contour extraction model, and both can perform parameter updates based on one or more update methods. Exemplary update methods include but are not limited to proximal policy optimization (PPO) algorithm, Q-Learning algorithm or deterministic policy gradient (DPG) algorithm.
[0065] On the basis of the above embodiment, the parameters of the initial policy network model and the initial valuation network model are updated based on the training image contour, action reward and movement score to obtain an updated policy network model and an updated valuation network model, including: determining the relative advantages of each contour extraction direction in the training image contour based on the action reward and movement score.
[0066] In this embodiment, the relative advantage is a calculation parameter of the initial estimation network model, which can be calculated by the following formula:
[0067]
[0068] Among them, s t represents the state of the t-th step, that is, the field of view image of the t-th contour point, a tIndicates the action of the tth step, that is, the moving direction or extraction direction of the tth contour point; represents the mobile score predicted by the initial estimation network model under the initial estimation network model parameters φ and state s. γ∈(0,1], represents the discount factor, r t represents the action reward at step t, Represents the cumulative reward value for the number of steps T required in a complete trajectory.
[0069] Based on the relative advantage, the movement probability distribution of each contour extraction direction and the clipping function, a first objective function is generated, and the parameters of the initial policy network model are updated based on the first objective function.
[0070] Among them, the clipping function is used to clip the drawn outline. Specifically, the formula of the first objective function is as follows:
[0071]
[0072] where, for the kth iteration, π θ represents the strategy under the parameters θ of the initial strategy network model, A π (s,a) represents the advantage of extracting direction a for state s under strategy π; ε is a hyperparameter ranging from 0 to 1, which controls the direction of the current strategy. Update to π θ The deviation between π and π, and CLIP represents the clipping function. θ (a|s) represents the movement probability distribution of the extracted direction a output by the initial policy network model with state s as input. It means taking the average of the parameters under the extraction direction a of multiple states s under the current strategy.
[0073] Specifically, the parameters θ of the initial strategy network model are updated by maximizing the objective function. The formula is:
[0074]
[0075] Among them, |D k | represents the number of image contours at the kth iteration, T i Represents the total number or number of steps of image contour points that fall into the i-th sample image.
[0076] Based on the movement score and the number of image contours, a second objective function of the initial estimation network model is formed, and the parameters of the initial estimation network model are updated based on the second objective function. Specifically, the second objective function is minimized to update the parameter φ of the initial estimation network model, and the formula is as follows:
[0077]
[0078] Among them, γ∈(0,1], represents the discount factor, r t represents the action reward at step t, It represents the cumulative reward value under the number of steps T required in a complete trajectory. represents the mobile score predicted by the initial estimation network model under the initial estimation network model parameters φ and state s; |D k | represents the number of image contours at the kth iteration.
[0079] S250: Obtain at least one image to be processed.
[0080] S260: Input the image to be processed into a pre-trained image processing model to obtain an image contour corresponding to the image to be processed. The image processing model includes a landing point generator and a contour extraction model.
[0081] Exemplarily, two metrics are used to evaluate the performance of contour drawing: Dice coefficient and Hausdorff distance. Dice coefficient is a typical performance indicator for image contour drawing and is defined as follows:
[0082]
[0083] Among them, S p and S g Represent the set of predicted and true contour points (pixels), respectively, and |·| represents the cardinality of the set, that is, the total number of pixels in the image to be processed. The Hausdorff distance is an important metric for quantitatively evaluating the distance between two sets of points, so it can be defined as a performance indicator for evaluating the similarity between two contours. It is defined as follows:
[0084]
[0085] Among them, G and P represent the sets of real contour points and predicted contour points respectively, d(g,p) represents the Euclidean distance between two points g and p, and H represents the Hausdorff distance.
[0086] The proposed method is compared with the existing U-net model, which is used for supervised learning-based medical image processing. The results of the contouring performance comparison with the same training sample data of 32 images are summarized in Table 4. The sample images are resized to 208×162 by horizontal and vertical flipping, scaling and cropping, and the data is increased to 96 images for training the U-Net model.
[0087] According to the numerical results in Table 3, the average dice score of the contour drawing method of the present invention reaches 92.6%, and the average Hausdorff distance reaches 5.784, which is a satisfactory result, especially considering the limited training sample data of only 32 images. Table 3 also shows that, in general, the method proposed by the present invention outperforms the U-net model with limited training set.
[0088] Table 3 Comparison of contour drawing performance
[0089]
[0090] An image processing method provided by an embodiment of the present invention can improve the strategy iteratively with relatively small updates by training the parameters of the initial strategy network model and the initial estimation network model in the contour extraction model. The image processing simulates the process of an expert drawing the target contour boundary point by point. Compared with the most popular existing image processing method (image processing method based on the U-Net model), the method of the present invention achieves higher accuracy in terms of Dice coefficient and Hausdorff distance metrics.
[0091] Embodiment 3
[0092] Figure 3 A flowchart diagram of an image processing method provided for Embodiment 3 of the present invention, the embodiment of the present invention can be combined with the various optional schemes in the above embodiments. In the embodiment of the present invention, optionally, the training method of the landing point generator includes: obtaining multiple sets of training sample data, wherein the training sample data includes sample images and sample image contours corresponding to the sample images; inputting the sample images into the landing point generator to be trained to obtain predicted coordinates; forming a loss function based on the predicted coordinates and any coordinates of the sample image contour, iteratively adjusting the parameters of the landing point generator, and generating a target landing point generator.
[0093] like Figure 3 As shown, the method of the embodiment of the present invention specifically includes the following steps:
[0094] S310: Acquire multiple groups of training sample data, wherein the training sample data includes sample images and sample image contours corresponding to the sample images.
[0095] The sample image is an image without contour drawing, and the contour of the sample image is a contour image drawn by an expert. For example, the sample image is a two-dimensional heart image obtained by magnetic resonance imaging (MRI), and the contour of the sample image is a left ventricle contour drawn by an experienced cardiologist.
[0096] Optionally, multiple sets of training sample data are cropped into images of uniform size. Exemplarily, in some embodiments, it is found that part of the real image contour always falls into the upper right quadrant without exception. Therefore, for each cardiac image, the cardiac image is cropped into an upper right quadrant image of uniform size. In other embodiments, the cropping position is not limited to the upper right quadrant, and can be other positions of the sample image and the sample image contour.
[0097] S320: Input the sample image into the landing point generator to be trained to obtain predicted coordinates.
[0098] Among them, the predicted coordinates are the processing starting points predicted by the landing point generator. For example, the structure of the landing point generator is shown in Table 4. The landing point generator takes a sub-image of uniform size 100×80 as input, and outputs the predicted coordinates through three convolution-pooling layers and three fully connected layers. Except for the last layer, all other layers use the "Relu" activation function.
[0099] Table 4 Structure of the landing point generator
[0100]
[0101] S330. Form a loss function based on the predicted coordinates and any coordinate of the sample image contour, iteratively adjust the parameters of the landing point generator, and generate a target landing point generator.
[0102] Among them, any coordinate in the sample image contour refers to any contour point on the real contour. In this embodiment, the target landing point generator can be obtained by pre-training the landing point generator through a large number of sample images and sample image contours corresponding to the sample images. In the trained landing point generator, the sample image will be pre-processed, and the model parameters in the landing point generator will be trained. By continuously adjusting the model parameters, the deviation between the predicted coordinates output by the landing point generator and the coordinates on the sample image contour is gradually reduced and stabilized, and the target landing point generator is generated.
[0103] On the basis of the above embodiment, the loss function is formed based on the predicted coordinates and any coordinate in the contour image of the sample image, including:
[0104]
[0105] in, represents the predicted coordinates and the t-th point p in the sample image contour t The distance between Indicates is the parameter, the sample image x is used as the landing point generator input, T irepresents the total number of image contour points falling into the i-th sample image, and B represents the batch size of the sample image.
[0106] During the training of the landing point generator, since the training sample data is very small, the entire training sample data needs to be fed into the landing point generator for training in each iteration. Therefore, the standard gradient descent method is used to replace the stochastic gradient descent method, and the learning rate is optimized by the line search method, such as the secant method. Specifically, in the kth iteration of the model training, by solving
[0107]
[0108] To determine the optimal learning rate.
[0109] Since only a sub-image of smaller size is required as input and a small portion of the true contour is involved in the loss function, the landing point generator adapts to heart images of different sizes and the training efficiency can be significantly improved even when the training sample data is limited.
[0110] S340: Obtain at least one image to be processed.
[0111] S350, inputting the image to be processed into a pre-trained image processing model to obtain an image contour corresponding to the image to be processed. The image processing model includes a landing point generator and a contour extraction model.
[0112] An image processing method provided by an embodiment of the present invention obtains multiple groups of training sample data, crops the training sample data into sub-images of smaller sizes, inputs the cropped sample images into a landing point generator to be trained, obtains predicted coordinates, and forms a loss function based on the predicted coordinates and any coordinates of the sample image contour. Since only a sub-image of smaller size is required as input and a small part of the real contour is involved in the loss function, the landing point generator adapts to sample images of different sizes, and even when the training sample data is limited, the training efficiency can be significantly improved.
[0113] Embodiment 4
[0114] Figure 4 This is a schematic diagram of the structure of an image processing device provided in Embodiment 4 of the present invention. The image processing device provided in this embodiment can be implemented by software and / or hardware, and can be configured in a terminal and / or a server to implement the image processing method in the embodiment of the present invention. The device can specifically include: an image acquisition module 410 and a contour generation module 420.
[0115] Among them, the image acquisition module 410 is used to acquire at least one image to be processed; the contour generation module 420 is used to input the image to be processed into a pre-trained image processing model to obtain an image contour corresponding to the image to be processed; wherein the image processing model includes a landing point generator and a contour extraction model, the landing point generator is used to determine the processing starting point of the image to be processed, and the contour extraction model is used to determine the image contour of the image to be processed based on the processing starting point.
[0116] An image processing device provided by an embodiment of the present invention obtains at least one image to be processed; inputs the image to be processed into a pre-trained image processing model to obtain an image contour corresponding to the image to be processed; wherein the image processing model includes a landing point generator and a contour extraction model, the landing point generator is used to determine the processing starting point of the image to be processed, and the contour extraction model is used to determine the image contour of the image to be processed based on the processing starting point. When performing image processing, the above technical solution determines the processing starting point of the image to be processed through the landing point generator, thereby avoiding the situation where the contour drawing deviates from the real contour; the contour extraction model draws the contour based on the processing starting point, effectively imitating the process of contour drawing by experts, so that the obtained image contour has higher accuracy.
[0117] On the basis of any optional technical solution in the embodiments of the present invention, optionally, the contour extraction model includes a strategy network model, which is used to obtain the next contour point based on a cyclic processing based on the determined contour points, and to determine the image contour of the image to be processed based on each determined contour point based on the movement probability distribution, wherein the processing starting point is the first determined contour point.
[0118] Based on any optional technical solution in the embodiments of the present invention, optionally, the looping process based on the determined contour points to obtain the next contour point can be specifically used for:
[0119] Based on the current contour points obtained in the image to be processed, generating a current field of view image of the image to be processed;
[0120] Determining a movement probability distribution based on the current contour point in the current field of view image;
[0121] A next contour point of the current contour point is determined based on the movement probability distribution.
[0122] Based on any optional technical solution in the embodiments of the present invention, optionally, the training device of the contour extraction model includes:
[0123] A sample acquisition module, used to acquire multiple sets of training sample data, wherein the training sample data includes sample images and sample image contours corresponding to the sample images;
[0124] A contour acquisition module, used to input the field of view image corresponding to the random starting point of the sample image into the initial policy network model, determine the training image contour generated by the initial policy network model, and obtain the action reward according to the movement probability distribution output by the initial policy network model and the corresponding sample image contour;
[0125] A score generating module, used for inputting the visual field image corresponding to the random starting point of the sample image into the initial estimation network model to obtain a movement score;
[0126] A parameter updating module is used to update the parameters of the initial policy network model and the initial valuation network model based on the training image contour, action reward and movement score to obtain an updated policy network model and an updated valuation network model, wherein the updated policy network model and the updated valuation network model are used to iteratively process the next sample image.
[0127] Based on any optional technical solution in the embodiments of the present invention, optionally, the parameter updating module may also be used for:
[0128] Determining the relative advantages of each contour extraction direction in the training image contour based on the action reward and the movement score;
[0129] Based on the relative advantage, the movement probability distribution of each contour extraction direction and the clipping function, a first objective function is generated, and the parameters of the initial strategy network model are updated based on the first objective function;
[0130] Based on the movement score and the number of image contours, a second objective function of the initial estimation network model is formed, and based on the second objective function, the parameters of the initial estimation network model are updated.
[0131] Based on any optional technical solution in the embodiments of the present invention, optionally, the training device of the landing point generator includes:
[0132] A training data acquisition module, used to acquire multiple sets of training sample data, wherein the training sample data includes sample images and sample image contours corresponding to the sample images;
[0133] A predicted coordinate generation and acquisition module is used to input the sample image into the landing point generator to be trained to obtain the predicted coordinates;
[0134] A landing point generator generation module is used to form a loss function based on the predicted coordinates and any coordinates of the sample image contour, iteratively adjust the parameters of the landing point generator, and generate a target landing point generator.
[0135] Based on any optional technical solution in the embodiments of the present invention, optionally, the landing point generator generation module can be used to:
[0136]
[0137] in, represents the predicted coordinates and the t-th point p in the sample image contour t The distance between Indicates is the parameter, the sample image x is used as the landing point generator input, T i represents the total number of image contour points falling into the i-th sample image, and B represents the batch size of the sample image.
[0138] The image processing device provided by the embodiment of the present invention can execute the image processing method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0139] Embodiment 5
[0140] Figure 5 This is a schematic diagram of the structure of an electronic device provided in Embodiment 5 of the present invention. Figure 5 A block diagram of an exemplary electronic device 12 suitable for use in implementing embodiments of the present invention is shown. Figure 5 The electronic device 12 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0141] like Figure 5 As shown, the electronic device 12 is in the form of a general purpose computing device. The components of the electronic device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that connects various system components (including the system memory 28 and the processing unit 16).
[0142] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. By way of example, these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.
[0143] The electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 12, including volatile and non-volatile media, removable and non-removable media.
[0144] The system memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Figure 5 not shown, usually called a "hard drive"). Although Figure 5 Not shown in the figure, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The system memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present invention.
[0145] A program / utility 36 having a set (at least one) of program modules 26 may be stored, for example, in system memory 28, such program modules 26 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. Program modules 26 generally perform the functions and / or methods of the embodiments described herein.
[0146] The electronic device 12 may also communicate with one or more external devices 14 (e.g., keyboards, pointing devices, displays 24, etc.), one or more devices that enable a user to interact with the electronic device 12, and / or any device that enables the electronic device 12 to communicate with one or more other computing devices (e.g., network cards, modems, etc.). Such communication may be performed through an input / output (I / O) interface 22. Furthermore, the electronic device 12 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) through a network adapter 20. Figure 5 As shown, the network adapter 20 communicates with other modules of the electronic device 12 via the bus 18. It should be understood that although Figure 5Not shown, other hardware and / or software modules may be used in conjunction with the electronic device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0147] The processing unit 16 executes various functional applications and data processing by running the programs stored in the system memory 28, such as implementing an image processing method provided by the embodiment of the present invention.
[0148] Embodiment 6
[0149] Embodiment 6 of the present invention further provides a storage medium containing computer executable instructions, wherein the computer executable instructions are used to execute an image processing method when executed by a computer processor, the method comprising:
[0150] Obtain at least one image to be processed;
[0151] Inputting the image to be processed into a pre-trained image processing model to obtain an image contour corresponding to the image to be processed;
[0152] Among them, the image processing model includes a landing point generator and a contour extraction model, the landing point generator is used to determine the processing starting point of the image to be processed, and the contour extraction model is used to determine the image contour of the image to be processed based on the processing starting point.
[0153] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.
[0154] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0155] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0156] Computer program code for performing the operation of embodiments of the present invention may be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0157] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. An image processing method, characterized in that: include: Obtain at least one image to be processed; Inputting the image to be processed into a pre-trained image processing model to obtain an image contour corresponding to the image to be processed; The image processing model includes a landing point generator and a contour extraction model, wherein the landing point generator is used to determine a processing starting point of the image to be processed, and the contour extraction model is used to determine an image contour of the image to be processed based on the processing starting point; Wherein, the training method of the contour extraction model includes: Acquire multiple sets of training sample data, wherein the training sample data include sample images and sample image contours corresponding to the sample images; Inputting the field of view image corresponding to the random starting point of the sample image into the initial policy network model, determining the training image contour, and obtaining the action reward according to the movement probability distribution output by the initial policy network model and the corresponding sample image contour; Inputting the visual field image corresponding to the random starting point of the sample image into the initial estimation network model to obtain a movement score; Based on the training image contour, action reward and movement score, the parameters of the initial policy network model and the initial valuation network model are updated to obtain an updated policy network model and an updated valuation network model, wherein the updated policy network model and the updated valuation network model are used to iteratively process the next sample image; The updating of the parameters of the initial policy network model and the initial valuation network model based on the training image contour, the action reward and the movement score to obtain an updated policy network model and an updated valuation network model includes: Determining the relative advantages of each contour extraction direction in the training image contour based on the action reward and the movement score; Based on the relative advantage, the movement probability distribution of each contour extraction direction and the clipping function, a first objective function is generated, and the parameters of the initial strategy network model are updated based on the first objective function; Based on the movement score and the number of image contours, a second objective function of the initial estimation network model is formed, and based on the second objective function, the parameters of the initial estimation network model are updated.
2. The method according to claim 1, characterized in that The contour extraction model includes a strategy network model, which is used to obtain the next contour point based on the determined contour points through cyclic processing, and to obtain the image contour of the image to be processed based on each determined contour point, wherein the processing starting point is the first determined contour point.
3. The method according to claim 2, characterized in that The step of obtaining the next contour point based on the determined contour point through cyclic processing includes: Based on the current contour points obtained in the image to be processed, generating a current field of view image of the image to be processed; Determining a movement probability distribution based on the current contour point in the current field of view image; A next contour point of the current contour point is determined based on the movement probability distribution.
4. The method according to claim 1, characterized in that: The training method of the landing point generator comprises: Acquire multiple sets of training sample data, wherein the training sample data include sample images and sample image contours corresponding to the sample images; Input the sample image into the landing point generator to be trained to obtain the predicted coordinates; A loss function is formed based on the predicted coordinates and any coordinate of the sample image contour, and the parameters of the landing point generator are iteratively adjusted to generate a target landing point generator.
5. The method according to claim 4, characterized in that A loss function is formed based on the predicted coordinates and any coordinate in the sample image contour image, including: in, represents the predicted coordinates and the t-th point p in the sample image contour t The distance between Indicates is the parameter, the sample image x is used as the landing point generator input, T i represents the total number of image contour points falling into the i-th sample image, and B represents the batch size of the sample image.
6. An image processing device, characterized in that: include: An image acquisition module, used to acquire at least one image to be processed; A contour generation module, used for inputting the image to be processed into a pre-trained image processing model to obtain an image contour corresponding to the image to be processed; The image processing model includes a landing point generator and a contour extraction model, wherein the landing point generator is used to determine a processing starting point of the image to be processed, and the contour extraction model is used to determine an image contour of the image to be processed based on the processing starting point; Wherein, the training device of the contour extraction model comprises: A sample acquisition module, used to acquire multiple sets of training sample data, wherein the training sample data includes sample images and sample image contours corresponding to the sample images; A contour acquisition module, used to input the field of view image corresponding to the random starting point of the sample image into the initial strategy network model, determine the training image contour, and obtain the action reward according to the movement probability distribution output by the initial strategy network model and the corresponding sample image contour; A score generating module, used for inputting the visual field image corresponding to the random starting point of the sample image into the initial estimation network model to obtain a movement score; A parameter updating module, used to update the parameters of the initial policy network model and the initial valuation network model based on the training image contour, action reward and movement score, to obtain an updated policy network model and an updated valuation network model, wherein the updated policy network model and the updated valuation network model are used to iteratively process the next sample image; Among them, the parameter updating module is specifically used to determine the relative advantages of each contour extraction direction in the training image contour based on the action reward and the movement score; generate a first objective function based on the relative advantages, the movement probability distribution of each contour extraction direction and the clipping function, and update the parameters of the initial policy network model based on the first objective function; based on the movement score and the number of image contours, form a second objective function of the initial valuation network model, and update the parameters of the initial valuation network model based on the second objective function.
7. An electronic device, characterized in that: The electronic device comprises: one or more processors; A storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement an image processing method as described in any one of claims 1 to 5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, an image processing method as described in any one of claims 1 to 5 is implemented.
