Image processing method and device, equipment and storage medium

By identifying the purple edge area in the image and correcting it using the adjustment parameters in the preset shooting scene characteristics, the accuracy and cost problems of removing the purple edge area in the existing technology are solved, and efficient and low-cost image processing effects are achieved.

CN118646958APending Publication Date: 2024-09-13VIVO MOBILE COMM CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410913378.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-08
Publication Date
2024-09-13

AI Technical Summary

Technical Problem

Existing technology has insufficient accuracy and high cost when removing purple fringe areas in images, and solutions to improve lens hardware performance are expensive and cannot completely solve the problem.

Method used

By obtaining the image containing the purple edge area and the shooting scene characteristics, identify the purple edge area, use the adjustment parameters in the preset shooting scene characteristics to correct the mask image, and select the target adjustment parameters that match the actual scene to correct the purple edge area. , achieving precise, low-cost removal.

Benefits of technology

It improves the accuracy of eliminating purple edge areas, obtains images with accurate and natural transitions that eliminate purple edge areas, reduces hardware costs, and achieves precise, low-cost removal effects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118646958A
    Figure CN118646958A
Patent Text Reader

Abstract

The invention discloses an image processing method and device, equipment and a storage medium, and belongs to the technical field of image processing. The method comprises the steps that a first image and a first shooting scene feature for shooting the first image are acquired, and the first image comprises a purple boundary area; identifying a purple edge region in the first image to obtain a mask image corresponding to the purple edge region; determining a target adjustment parameter corresponding to the mask image according to the first shooting scene feature, a preset shooting scene feature and an adjustment parameter corresponding to the preset shooting scene feature; wherein the preset shooting scene features comprise at least two second shooting scene features, and the adjustment parameters corresponding to the preset shooting scene features are obtained by respectively shooting a red color card, a green color card, a blue color card, a cyan color card, a magenta color card and a yellow color card under the at least two second shooting scene features; and performing purple edge correction on the mask image based on the target adjustment parameter to obtain a second image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of image processing technology, and specifically relates to an image processing method, device, equipment and storage medium. Background Art

[0002] With the development of science and technology, people have higher and higher requirements for image quality. However, sometimes the captured image will have purple fringing at the edge of a highly backlit object or at the junction of high brightness and dark. For example, when standing under a tree and shooting upward, a purple fringing will appear at the edge of the leaves and the sky in the picture, or when shooting a building under bright light, a purple fringing will also appear at the edge of the building.

[0003] There are currently two methods for removing the purple-fringed area of ​​an image. One is to correct the purple-fringed area by reducing the saturation of the purple-fringed area after detecting it. However, this method may cause a large number of gray areas to appear in the image, resulting in stripes in the image that are significantly different in color from the surrounding purple-fringed area, and sacrificing the original color of the image, reducing the authenticity of the image. Another solution is to improve the hardware performance of the lens and use high-quality lenses to reduce dispersion, but this lens is expensive and cannot completely solve the purple-fringed area problem. Summary of the invention

[0004] The purpose of the embodiments of the present application is to provide an image processing method, device, equipment and storage medium, which can accurately and cost-effectively eliminate the purple-fringed area, and obtain an image with more accurate and natural transition and eliminated purple-fringed areas.

[0005] In a first aspect, an embodiment of the present application provides an image processing method, the method comprising:

[0006] Acquire a first image and a first shooting scene feature of shooting the first image, wherein the first image includes a purple-fringe area;

[0007] Identify a purple-fringed region in the first image to obtain a mask image corresponding to the purple-fringed region;

[0008] Determining a target adjustment parameter corresponding to the mask image according to the first shooting scene feature, a preset shooting scene feature, and an adjustment parameter corresponding to the preset shooting scene feature; wherein the preset shooting scene feature includes at least two second shooting scene features, and the adjustment parameter corresponding to the preset shooting scene feature is obtained by photographing a red color card, a green color card, a blue color card, a cyan color card, a magenta color card, and a yellow color card respectively under the at least two second shooting scene features;

[0009] Purple fringing correction is performed on the mask image based on the target adjustment parameter to obtain a second image.

[0010] In a second aspect, an embodiment of the present application provides an image processing device, the device comprising:

[0011] A first acquisition module, used to acquire a first image and a first shooting scene feature for shooting the first image, wherein the first image includes a purple-edge region;

[0012] A recognition module, used for recognizing a purple-fringed region in the first image, and obtaining a mask image corresponding to the purple-fringed region;

[0013] A first determination module is used to determine a target adjustment parameter corresponding to the mask image according to the first shooting scene feature, a preset shooting scene feature, and an adjustment parameter corresponding to the preset shooting scene feature; wherein the preset shooting scene feature includes at least two second shooting scene features, and the adjustment parameter corresponding to the preset shooting scene feature is obtained by photographing a red color card, a green color card, a blue color card, a cyan color card, a magenta color card, and a yellow color card respectively under the at least two second shooting scene features;

[0014] The second determination module is used to perform purple fringing correction on the mask image based on the target adjustment parameter to obtain a second image.

[0015] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the program or instructions are executed by the processor, the steps of the method described in the first aspect are implemented.

[0016] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.

[0017] In a fifth aspect, an embodiment of the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the method described in the first aspect.

[0018] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method described in the first aspect.

[0019] In an embodiment of the present application, by acquiring a first image including a purple-fringed area and features of a first shooting scene for shooting the first image, the purple-fringed area in the first image is identified to obtain a mask image corresponding to the purple-fringed area, and then target adjustment parameters corresponding to the first shooting scene are selected from adjustment parameters obtained by respectively shooting a red color card, a green color card, a blue color card, a cyan color card, a magenta color card and a yellow color card in at least two second shooting scenes, and finally the mask image is corrected for purple fringing using the target adjustment parameters. Compared with the method in the prior art, the solution of the embodiment of the present application can improve the accuracy of eliminating the purple-fringed area in the first image, and thus can obtain a second image with the purple-fringed area eliminated accurately and with a natural transition, and there is no need to replace a high-quality lens to capture the first image, thereby reducing hardware costs and achieving accurate and low-cost elimination of the purple-fringed area. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 is a flowchart of an image processing method provided by some embodiments of the present application;

[0021] Figure 2 is a schematic diagram of a third image provided by some embodiments of the present application;

[0022] Figure 3 is a schematic diagram of a fourth image provided by some embodiments of the present application;

[0023] Figure 4 is a schematic diagram of a partial image provided by some embodiments of the present application;

[0024] Figure 5 is a flow chart of using a first training model to process a first image to obtain a third image, provided in some embodiments of the present application;

[0025] Figure 6 is a schematic diagram of the structure of an image processing device shown in some embodiments of the present application;

[0026] Figure 7 is a schematic diagram of the structure of an electronic device shown in some embodiments of the present application;

[0027] Figure 8 It is a schematic diagram of the hardware structure of an electronic device shown in some embodiments of the present application. DETAILED DESCRIPTION

[0028] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.

[0029] The terms "first", "second", etc. in the specification of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are usually a class, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0030] As described in the background technology, the existing technology has the problem that the elimination of purple-fringed areas in images is not accurate enough and the cost is too high. In order to solve the above problems, the embodiments of the present application provide an image processing method, device, equipment and storage medium. By acquiring a first image including a purple-fringed area and a first shooting scene feature for shooting the first image, the purple-fringed area in the first image is identified to obtain a mask image corresponding to the purple-fringed area, and then the target adjustment parameters corresponding to the first shooting scene are selected from the adjustment parameters obtained by shooting a red color card, a green color card, a blue color card, a cyan color card, a magenta color card and a yellow color card in at least two second shooting scenes. Finally, the mask image is corrected for purple fringing using the target adjustment parameters. Compared with the method in the prior art, the solution of the embodiments of the present application can improve the accuracy of eliminating the purple-fringed area in the first image, and then obtain a second image with the purple-fringed area eliminated accurately and with a natural transition. There is no need to replace a high-quality lens to capture the first image, which reduces the hardware cost and achieves accurate and low-cost elimination of the purple-fringed area.

[0031] The technical solution of the embodiment of the present application can be applied to the scenario of eliminating the purple-fringed area in the image.

[0032] The image processing method provided in the embodiment of the present application is described in detail below through specific embodiments and their application scenarios in conjunction with the accompanying drawings.

[0033] Figure 1 It is a flowchart of an image processing method provided in an embodiment of the present application. The image processing method can be applied to electronic devices, where the electronic devices can be but are not limited to personal computers (PCs), smart phones, tablet computers or personal digital assistants (PDAs). It should be noted that the above-mentioned execution entities are not limitations on the embodiments of the present application.

[0034] like Figure 1As shown, the image processing method provided in the embodiment of the present application may include steps 110 to 140.

[0035] Step 110: Acquire a first image and a first shooting scene feature of the first image, wherein the first image includes a purple-fringe area.

[0036] The first image may be an image with a purple-fringe area, an image acquired in real time by an image acquisition device, or an image acquired in advance from a memory of an electronic device.

[0037] The purple-fringe area mentioned above may be at least one of the following situations where the image edge of the first image appears: purple fringing, blue fringing, and blue-purple fringing.

[0038] The first shooting scene feature may be a scene feature when the first image is shot. Since the performance of the purple-fringe area varies under different color temperatures and brightnesses, the first shooting scene feature here may be the brightness and color temperature of the external environment when the first image is shot.

[0039] Step 120: Identify the purple-fringe region in the first image to obtain a mask image corresponding to the purple-fringe region.

[0040] The mask image may be an image obtained by identifying the purple-fringe region in the first image and including only the purple-fringe region.

[0041] In some embodiments of the present application, in order to accurately obtain the mask image corresponding to the purple-fringed region, step 120 may specifically include:

[0042] Inputting the first image into a pre-trained first training model to obtain a fourth image;

[0043] Processing the first annotation box in the fourth image using a non-maximum suppression algorithm to obtain a fifth image;

[0044] Obtaining a first curve according to the feature points of each second annotation box in the fifth image;

[0045] The first curve is expanded according to a preset expansion parameter to obtain a mask image.

[0046] Among them, the first training model can be a pre-trained model for detecting the purple-fringed area in the first image, and the first training model can be a VGG-16 model. The VGG-16 model has a total of 16 layers, which is also the origin of the name of VGG-16. It is a very deep convolutional neural network. The structures of various levels of VGG use 5 convolutions, and each segment has one or more convolution layers. At the same time, the tail of each segment is followed by a maximum pooling layer to reduce the image size. The number of convolution kernels in each segment is the same, and the number of convolution kernels at the end is more 64->128->256->512->512.

[0047] The first training model may be obtained by training based on at least two groups of training samples, and each group of training samples may include an original image with a purple-fringed region and a marked image in which the purple-fringed region in the original image is marked.

[0048] The original image here may be an image with a purple-fringed region obtained directly. The marked image may be an image in which the purple-fringed region in the original image is marked, and specifically may be an image in which the purple-fringed region in the original image is marked with a marking frame.

[0049] The fourth image may be an image obtained by inputting the first image into a pre-trained first training model. The fourth image may include a first annotation box for marking the purple-fringe area.

[0050] The purple-fringe area marked by the first annotation box here may be a purple-fringe area in the first image detected based on a pre-trained first training model, and the purple-fringe area marked by the first annotation box here may be a purple-fringe area finally obtained in the mask image.

[0051] The first marking box may be a marking box used to mark the purple-edge region in the fourth image, and the number of the first marking boxes may be multiple.

[0052] The fifth image may be an image obtained by processing the first annotation box in the fourth image using a non-maximum suppression algorithm. The fifth image here may include a second annotation box for selecting a purple-edge region, and the number of the second annotation boxes here may also be multiple, but the number of the second annotation boxes is less than the number of the first annotation boxes.

[0053] In one example, reference Figure 2 , Figure 2 is a schematic diagram of a fourth image, in which there are multiple first annotation boxes 21, each of which is used to mark the purple-edge region in the fourth image. Then, the first annotation boxes in the fourth image are processed by a non-maximum suppression algorithm to obtain the optimal annotation box for marking the purple-edge region, that is, the second annotation box, such as Figure 3 As shown, Figure 3 The second annotation box 31 in Figure 2 The first annotation box 21 in the figure is much less.

[0054] The first curve may be a curve obtained by connecting the feature points of each second annotation frame of the fifth image, and the feature point of the second annotation frame here may be the center point of the second annotation frame.

[0055] The preset expansion parameters may be pre-set parameters for expanding the first curve. The preset expansion parameters here may include position information for expanding the first curve and the number of pixels expanded on the position information. For example, the preset expansion parameters may be expanding 20 pixels in the positive and negative directions of the curve gradient of the first curve.

[0056] In one example, after connecting the center points of each second annotation box in the fifth image to obtain the first curve, 20 pixel points can be expanded in the positive and negative directions of the curve gradient of the first curve to obtain the following: Figure 4 The mask image is shown.

[0057] In some embodiments of the present application, the purple-fringe area in the first image can be extracted by a pre-trained first training model to obtain a fourth image, and then the first annotation box in the fourth image is processed to obtain an accurate mask image.

[0058] In an embodiment of the present application, the purple-fringed area in the first image is extracted through a pre-trained first training model to obtain a fourth image, thereby improving the recognition accuracy and efficiency of the purple-fringed image in the first image. After obtaining the fourth image, the first annotation box in the fourth image is further processed to simplify the annotation boxes marking the purple-fringed area to obtain the fifth image, and then the feature points of each second annotation box in the fifth image are connected to obtain a first curve, and the curve is expanded to obtain a mask image that accurately marks the purple-fringed area.

[0059] In some embodiments of the present application, in order to accurately obtain the fourth image, inputting the first image into the first training model to obtain the fourth image may specifically include:

[0060] Inputting the first image into a first feature extraction layer of a pre-trained first training model to obtain a first feature map;

[0061] Inputting the first feature map into a second feature extraction layer of the first training model to obtain a second feature map;

[0062] Inputting the second feature map into the third feature extraction layer of the first training model to obtain a third feature map;

[0063] Inputting the third feature map into the third feature extraction layer to obtain a fourth feature map;

[0064] Inputting the fourth feature map into the third feature extraction layer to obtain a fifth feature map;

[0065] Inputting the fifth feature map into the third feature extraction layer to obtain a sixth feature map;

[0066] The first feature map, the second feature map, the third feature map, the fourth feature map, the fifth feature map, and the sixth feature map are input into the prediction convolution layer of the first training model to obtain a fourth image.

[0067] Among them, the first feature extraction layer, the second feature extraction layer and the third feature extraction layer can all be layers used for feature extraction in a pre-trained first training model.

[0068] The prediction convolution layer may be a layer in a pre-trained first training model for predicting the purple-fringe area.

[0069] The first feature map may be an image obtained by extracting features of the first image using the first feature layer.

[0070] The second feature map may be an image obtained by extracting features in the first feature map using the second feature layer.

[0071] The third feature map may be an image obtained by extracting features in the second feature map using the third feature layer.

[0072] The fourth feature map may be an image obtained by extracting features in the third feature map using the third feature layer.

[0073] The fifth feature map may be an image obtained by extracting features in the fourth feature map using the third feature layer.

[0074] The sixth feature map may be an image obtained by extracting features in the fifth feature map using the third feature layer.

[0075] In some embodiments of the present application, the first image can be input into a first training model, different feature maps can be obtained based on different levels of convolutional layers in the first training model, and then a fourth image can be obtained according to each feature map.

[0076] In one example, reference Figure 5 , Figure 5 A schematic diagram of the process of using the first training model to process the first image to obtain the fourth image is shown. Taking the first training model as the VGG-16 model as an example, the VGG-16 model can include a 38*38*512 convolution layer, a 3*3*1024 convolution layer, a 1*1*256 convolution layer, a 1*1*128 convolution layer, a 3*3*512 convolution layer and a prediction convolution layer.

[0077] When the first image is input to Figure 5 Before the VGG-16 model shown in the figure, the size of the first image can be adjusted to a 300*300*3 RGB channel image 50, and then the 300*300*3 RGB channel image 50 is passed through the first 5 convolutional layers of the VGG-16 model (i.e., a 38*38*512 convolutional layer) to obtain a 19*19*512 first feature map 51, and then the first feature map 51 is input into a 3*3*1024 convolutional layer to obtain a 19*19*1024 feature map, and then input into a 1*1*256 convolutional layer to obtain a second feature map 52, and then the second feature map 53 is input into a 1*1*256 convolutional layer to obtain a second feature map 54. After Figure 52 is input into a 1*1*128 convolution layer and a 3*3*256 convolution layer, a third feature map 53 of 10*10*512 is obtained. After the third feature map 53 is input into a 1*1*128 convolution layer and a 3*3*256 convolution layer, a fourth feature map 54 of 5*5*256 is obtained. After the fourth feature map 54 is input into a 1*1*128 convolution layer and a 3*3*256 convolution layer, a fifth feature map 55 of 3*3*256 is obtained. After the fifth feature map 55 is input into a 1*1*128 convolution layer and a 3*3*256 convolution layer, a sixth feature map 56 of 1*1*256 is obtained.

[0078] Then, the first feature map 51 , the second feature map 52 , the third feature map 53 , the fourth feature map 54 , the fifth feature map 55 and the sixth feature map 56 are input into the prediction convolution layer to obtain a fourth image 57 .

[0079] In an embodiment of the present application, a first image is input into a first feature extraction layer of a first training model to obtain a first feature map, and then the first feature map is input into a second feature extraction layer to obtain a second feature map, the second feature map is input into a third feature extraction layer to obtain a third feature map, the third feature map is input into the third feature extraction layer to obtain a fourth feature map, the fourth feature map is input into the third feature extraction layer to obtain a fifth feature map, and the fifth feature map is input into the third feature extraction layer to obtain a sixth feature map. In this way, feature extraction is performed on feature maps of different scales through feature extraction layers of different scales, that is, purple-fringed regions of corresponding scales are detected on feature maps of different scales, so that the position of the purple-fringed region can be effectively extracted. Since the first training model is a single-stage target detection model, the labeling box of the purple-fringed region can be directly regressed from the feature map, thereby improving the determination efficiency of the fourth image.

[0080] In some embodiments of the present application, in order to accurately obtain the first training model, before inputting the first image into the first training model to obtain the fourth image, the above method may further include:

[0081] Inputting the original image into the first training model to be trained to obtain a prediction result;

[0082] Based on the prediction results and the labeled images, calculate the target loss function;

[0083] The parameters of the first training model to be trained are adjusted based on the target loss function to obtain a pre-trained first training model.

[0084] Among them, the prediction result can be the result predicted after the original image is input into the first training model to be trained, and the prediction result can include a predicted image and a confidence level. The predicted image here may include a third annotation box for selecting the purple-edge area in the predicted original image. The confidence level can be used to characterize the confidence level that the purple-edge area selected by the third annotation box is a real purple-edge area. The marked image may include a fourth annotation box for selecting the purple-edge area.

[0085] The third annotation box here may be an annotation box for selecting the purple-edge region of the original image predicted based on the first training model to be trained, and the number of the third annotation boxes may be multiple. The fourth annotation box here may be an annotation box for selecting the purple-edge region of the original image, and the number of the fourth annotation boxes may be multiple, and the fourth annotation box here may be manually marked by the user.

[0086] The target loss function may be a loss function of a first training model to be trained.

[0087] In some embodiments of the present application, the original image can be input into the first training model to be trained to obtain a prediction result, and then the target loss function of the first training model to be trained is calculated based on the prediction result and the labeled image, and the parameters of the first training model to be trained are adjusted based on the target loss function to obtain a pre-trained first training model.

[0088] In an embodiment of the present application, the first training model to be trained is trained using the original image to obtain a trained first training model. In this way, the purple-fringed area in the first image can be quickly and accurately extracted based on the trained first training model, and the mask image corresponding to the purple-fringed area can be obtained, thereby improving the efficiency and accuracy of obtaining the mask image.

[0089] In some embodiments of the present application, in order to obtain a first training model with good robustness, the calculation of the target loss function based on the predicted image and the labeled image may specifically include:

[0090] Determine a first loss function according to each confidence level of the prediction result;

[0091] Selecting a labeling frame whose confidence level is greater than a first threshold from the third labeling frame of the predicted image to obtain a fifth labeling frame;

[0092] Calculate the intersection and union ratio of the fifth annotation frame and the fourth annotation frame;

[0093] According to the intersection-union ratio, determine the second loss function;

[0094] A target loss function is calculated based on the first loss function and the second loss function.

[0095] Among them, the first loss function can be a loss function determined based on each confidence level in the prediction result, and the loss function can be used to measure the error between the purple-fringed area predicted by the first training model to be trained and the actual purple-fringed area.

[0096] The first threshold may be a preset confidence threshold. If the confidence is greater than the first threshold, it indicates that the purple-fringed region predicted based on the first training model is consistent with the actual situation. If the confidence is less than the first threshold, it indicates that the purple-fringed region predicted based on the first training model to be trained is not consistent with the actual situation.

[0097] The fifth annotation box may be a annotation box selected from the third annotation boxes of the predicted image and having a confidence level greater than the first threshold.

[0098] The intersection-to-union ratio may be a ratio of the intersection and union of the fifth standard frame and the fourth annotation frame.

[0099] The second loss function may be a loss function determined according to the intersection-over-union ratio, and the second loss function may be used to measure the error between the position of the purple-fringed area predicted by the first training model to be trained and the actual position.

[0100] In some embodiments of the present application, a first loss function of a first training model to be trained can be determined based on the confidence levels in the prediction results and the annotated purple-edge areas in the marked image, and then an annotation box having a confidence level greater than a first threshold is selected from the third annotation box of the predicted image to obtain a fifth annotation box, that is, only the third annotation box with a high confidence level is selected, because the third annotation box with a low confidence level may not be consistent with the actual situation, and then the intersection-and-union ratio of the fifth annotation box to the fourth annotation box is calculated. According to the intersection-and-union ratio, the second loss function can be determined, and then the target loss function can be calculated based on the first loss function and the second loss function. Specifically, the sum of the first loss function and the second loss function can be determined as the target loss function of the first training model to be trained.

[0101] In some embodiments of the present application, the loss function of the first training model to be trained may be a cross entropy loss function. The loss function of the first training model to be trained may be obtained by the following formula (1):

[0102]

[0103] Among them, L conf(x,c) is the first loss function, αL loc (x, l, g) is the second loss function, N is the number of training samples, α is a constant used to characterize the weight of the position loss of the third annotation box and the fourth annotation box, N is the total number of training samples, x represents the matching result of the third annotation box and the fourth annotation box, x=0 represents a matching failure, x=1 represents a matching success, c is the confidence, l is the third annotation box, and g is the fourth annotation box.

[0104] In an embodiment of the present application, a first loss function is determined according to the confidence level, and then a fifth annotation frame is obtained by selecting an annotation frame whose confidence level is greater than a first threshold value from the third annotation frame of the predicted image, and the intersection-and-union ratio of the fifth annotation frame and the fourth annotation frame is calculated. According to the intersection-and-union ratio, a second loss function can be determined, so that the third annotation frame is pre-screened, thereby reducing the complexity of subsequent annotation frame processing. At the same time, the target loss function of the first training model to be trained is determined by using a first loss function for measuring the error between the purple-fringed region predicted by the first training model to be trained and the actual purple-fringed region, and a second loss function for measuring the error between the position of the purple-fringed region predicted by the first training model to be trained and the actual position, so that the purple-fringed region can be accurately predicted, and the position of the purple-fringed region can be predicted, thereby improving the robustness of the first training model.

[0105] Step 130 : Determine a target adjustment parameter corresponding to the mask image according to the first shooting scene feature, the preset shooting scene feature, and the adjustment parameter corresponding to the preset shooting scene feature.

[0106] Among them, the preset shooting scene features can be pre-set shooting scene features, and the preset shooting scene features here can include at least two second shooting scene features. The at least two second shooting scene features here can be at least two shooting scene features different from the first shooting scene features, or can be at least two shooting scene features including the first shooting scene features, which is not limited in the embodiments of the present application.

[0107] The adjustment parameters corresponding to the above-mentioned preset shooting scene characteristics may be obtained by photographing a red color card, a green color card, a blue color card, a cyan color card, a magenta color card and a yellow color card respectively under at least two second shooting scene characteristics. Specifically, for each second shooting scene characteristic, the adjustment parameters corresponding to the second shooting scene characteristic may be obtained by photographing a red color card, a green color card, a blue color card, a cyan color card, a magenta color card and a yellow color card respectively under the second shooting scene characteristic. Specifically, the method for determining the adjustment parameters corresponding to each second shooting scene characteristic is further described in detail in the following embodiments.

[0108] The target adjustment parameter may be an adjustment parameter determined to correspond to the shooting scene feature corresponding to the mask image, and specifically, may be an adjustment parameter corresponding to the first shooting scene feature.

[0109] In some embodiments of the present application, since the performance of the purple-fringe area varies under different color temperatures and brightnesses, the target adjustment parameters corresponding to the color temperature and brightness combination when the first image is captured can be used to more accurately restore the purple-fringe area effect.

[0110] In order to accurately determine the target adjustment parameters corresponding to the mask image, step 130 may specifically include:

[0111] Respectively obtain reference pixel values ​​of a red color card, a green color card, a blue color card, a cyan color card, a magenta color card, and a yellow color card in a target color space, and third images corresponding to the red color card, the green color card, the blue color card, the cyan color card, the magenta color card, and the yellow color card respectively taken under preset shooting scene characteristics;

[0112] Obtaining a first pixel value of a purple-fringe region in each third image in a target color space;

[0113] Determine a correction equation for correcting a purple-fringe region in each color card according to a first pixel value and a second pixel value of each color card under characteristics of a target shooting scene;

[0114] According to the correction equation corresponding to each color card, the adjustment parameters corresponding to the characteristics of the target shooting scene are determined;

[0115] The adjustment parameter corresponding to the first shooting scene feature is selected from the adjustment parameters corresponding to each second shooting scene feature as the target adjustment parameter.

[0116] The target color space may be a preset color space, for example, the target color space may be an HSV color space.

[0117] For each color card, its reference pixel value may be the pixel value of the color card in the target color space.

[0118] In some embodiments of the present application, for each color card, the reference pixel value of the color card in the target color space can be obtained by converting the average value of the pixel values ​​of the color card into the target color space.

[0119] For each color card, the third image can be an image obtained by photographing the color card under the preset shooting scene characteristics, specifically, it can be an image obtained by looking up from the bottom to the reference color card under the preset shooting scene characteristics. This is because purple fringing areas generally appear in the bright edge area (a typical real scene is looking up at the sky under a tree on a sunny day outdoors), so in a laboratory environment, to simulate the real scene where purple fringing areas appear, try to shoot from the bottom to the top, so that more purple fringing area materials can be obtained.

[0120] In an example, taking the target color space as the HSV color space, and the number of the above-mentioned color cards as 18 as an example, specifically, 3 cyan color cards with different saturations, 3 blue color cards with different saturations, 3 magenta color cards with different saturations, 3 red color cards with different saturations, 3 yellow color cards with different saturations, and 3 green color cards with different saturations, taking the preset shooting scene features including 3 second shooting scene features as an example, wherein the 3 second shooting scene features are shooting scene feature 1, shooting scene feature 2, and shooting scene feature 3, and then the third images of the 18 color cards are respectively captured under shooting scene feature 1, the third images of the 18 color cards are respectively captured under shooting scene feature 2, and the third images of the 18 color cards are respectively captured under shooting scene feature 3.

[0121] For each third image, its corresponding first pixel value can be the pixel value of the purple-fringed area in the third image in the target color space. Specifically, it can be obtained by converting the average value of the pixel values ​​of the purple-fringed area of ​​the third image obtained by shooting into the target color space to obtain the first pixel value of the purple-fringed area in the third image in the target color space.

[0122] The target shooting scene feature is any one of the at least two second shooting scene features.

[0123] For each color card, the second pixel value of the color card can be determined based on the reference pixel value of the color card. Specifically, the second pixel value of the color card can be the reference pixel value of the first area in the color card, and the first area here can be the area corresponding to the purple-edge area in the third image of the color card.

[0124] In one example, since a purple-fringed area generally appears at the edge of an object in an image, for a red color card, after shooting the red color card under a second shooting scene feature, a third image of the red color card is obtained. In the third image, a purple-fringed area appears at the edge of the color card. The second pixel value corresponding to the red color card may be a reference pixel value of the edge of the red color card in the target color space, that is, in the third image, the edge of the red color card may be purple due to the appearance of purple fringing, that is, the first pixel value is a pixel value that is biased towards purple, but the red color card is actually red, and the second pixel value is a pixel value that is biased towards red.

[0125] The correction equation may be an equation for correcting the purple-fringe area in each color card determined according to the first pixel value and the second pixel value of each color card in the target shooting scene.

[0126] In some embodiments of the present application, reference pixel values ​​of a red color card, a green color card, a blue color card, a cyan color card, a magenta color card, and a yellow color card in a target color space, and third images corresponding to the red color card, the green color card, the blue color card, the cyan color card, the magenta color card, and the yellow color card respectively taken under preset shooting scene characteristics can be obtained, and then a first pixel value of a purple-fringed region in each third image in the target color space is obtained, and a correction equation for correcting the purple-fringed region in each color card is determined according to the first pixel value and the second pixel value of each color card under the target shooting scene characteristics, and then an adjustment parameter corresponding to the target shooting scene characteristics is determined according to the correction equation corresponding to each color card, and the adjustment parameter corresponding to the first shooting scene characteristics is selected from the adjustment parameters corresponding to each second shooting scene characteristics as the target adjustment parameter.

[0127] Continuing with the reference example, after shooting the third images of the 18 color cards under shooting scene feature 1, shooting the third images of the 18 color cards under shooting scene feature 2, and shooting the third images of the 18 color cards under shooting scene feature 3, the first pixel values ​​of the purple-fringe areas in the third images of the 18 color cards shot under shooting scene feature 1, the first pixel values ​​of the purple-fringe areas in the third images of the 18 color cards shot under shooting scene feature 2, and the first pixel values ​​of the purple-fringe areas in the third images of the 18 color cards shot under shooting scene feature 3 are measured respectively.

[0128] Then, for each of the third images corresponding to the color cards taken under the above three shooting scene characteristics, for example, taking the third image corresponding to the yellow color card taken under shooting scene characteristic 1 as an example, according to the first pixel value and the second pixel value of the yellow color card under shooting scene characteristic 1, a correction equation for correcting the purple-edge region in the yellow color card under shooting scene characteristic 1 can be determined, as shown in the following formula (2). According to formula (2), the adjustment parameters for correcting the purple-edge region in the yellow color card under shooting scene characteristic 1 can be obtained, that is, the adjustment parameters corresponding to shooting scene characteristic 1:

[0129]

[0130] Among them, (h out ,s out ,v out ) is the second pixel value of the yellow color card under the shooting scene feature 1, (h in ,s in ,v in ) is the first pixel value of the yellow color card under the shooting scene feature 1, Adjustment parameters for correcting the purple-fringe area in the yellow color card under shooting scene feature 1.

[0131] The above process is repeated for the third images corresponding to the other 17 color cards except the third image of the yellow color card obtained under the shooting scene feature 1, so as to obtain correction equations for respectively correcting the purple-fringed areas in the other 17 color cards under the shooting scene feature 1, and then the adjustment parameters corresponding to the shooting scene feature 1 can be obtained according to the correction equations corresponding to the 18 color cards.

[0132] Similarly, for shooting scene feature 2 and shooting scene feature 3, the method for determining the adjustment parameters corresponding to the shooting scene feature 1 is respectively adopted to obtain the adjustment parameters corresponding to the shooting scene feature 2 and the adjustment parameters corresponding to the shooting scene feature 3.

[0133] In some embodiments of the present application, the adjustment parameter corresponding to each second shooting scene feature can be obtained in the above manner, and then the adjustment parameter corresponding to the first shooting scene feature is selected from the adjustment parameters corresponding to each second shooting scene feature as the target adjustment parameter.

[0134] In an embodiment of the present application, the adjustment parameters corresponding to each second shooting scene feature are pre-calibrated using a standard color card, so that the adjustment parameters corresponding to the first shooting scene features can be obtained as target adjustment parameters, and then the purple-fringed areas in the mask image under the first shooting scene features can be corrected based on the target adjustment parameters, so as to obtain a more accurate second image with the purple-fringed areas eliminated.

[0135] In some embodiments of the present application, the correction equation corresponding to each color card may include correction parameters for correcting the purple-fringed area in each color card, such as the adjustment parameters for correcting the purple-fringed area in the yellow color card under shooting scene feature 1 in the above formula (2).

[0136] In order to accurately determine the adjustment parameter corresponding to each second shooting scene feature, determining the adjustment parameter corresponding to the target shooting scene feature according to the correction equation corresponding to each color card may specifically include:

[0137] The least squares calculation is performed on the correction parameters in the correction equation corresponding to each color card to obtain the adjustment parameters corresponding to the target shooting scene characteristics.

[0138] In some embodiments of the present application, after obtaining the correction equation corresponding to each color card under the target shooting scene characteristics, the correction parameters in the correction equation corresponding to each color card can be calculated by least squares, so that the adjustment parameters corresponding to the target shooting scene characteristics can be obtained.

[0139] Continuing to refer to the above example, taking shooting scene feature 1 as an example, after obtaining the correction equations corresponding to the 18 color cards respectively, the correction parameters in the correction equations corresponding to the 18 color cards are obtained to obtain 18 correction parameters, and then the least squares calculation is performed on the 18 correction parameters to obtain the adjustment parameters corresponding to shooting scene feature 1.

[0140] In the embodiment of the present application, by performing least square calculation on the correction parameters in the correction equation corresponding to each color card, the adjustment parameters corresponding to the target shooting scene characteristics can be accurately obtained.

[0141] In some embodiments of the present application, selecting the adjustment parameter corresponding to the first shooting scene feature from the adjustment parameters corresponding to each second shooting scene feature as the target adjustment parameter may include:

[0142] In a case where the at least two second shooting scene features include the first shooting scene feature, selecting, from the adjustment parameters corresponding to each second shooting scene feature, an adjustment parameter corresponding to a shooting scene feature consistent with the first shooting scene feature as a target adjustment parameter;

[0143] When the at least two second shooting scene features do not include the first shooting scene feature, the adjustment parameter corresponding to the shooting scene feature having the smallest difference with the first shooting scene feature is selected from the adjustment parameters corresponding to each second shooting scene feature as the target adjustment parameter.

[0144] In some embodiments of the present application, when at least two second shooting scene features include the first shooting scene feature, the adjustment parameters corresponding to the shooting scene features consistent with the first shooting scene feature are selected from the adjustment parameters corresponding to each second shooting scene feature as the target adjustment parameters; and when at least two second shooting scene features do not include the first shooting scene feature, the adjustment parameters corresponding to the shooting scene feature with the smallest shooting scene feature difference from the first shooting scene feature are selected from the adjustment parameters corresponding to each second shooting scene feature as the target adjustment parameters.

[0145] In one example, taking the case where the preset shooting scene features include three second shooting scene features, wherein the three second shooting scene features are shooting scene feature 1, shooting scene feature 2, and shooting scene feature 3, when the first shooting scene feature is included in the three second shooting scene features, for example, shooting scene feature 2 is the first shooting scene feature, then the adjustment parameter corresponding to the shooting scene feature 2 is directly used as the target adjustment parameter of the first shooting scene feature. When the first shooting scene feature is not included in the three second shooting scene features, wherein the shooting scene feature 3 is closest to the shooting scene feature of the first shooting scene feature, then the adjustment parameter corresponding to the shooting scene feature 3 can be used as the target adjustment parameter of the first shooting scene feature.

[0146] In an embodiment of the present application, when the first shooting scene feature is included in at least two second shooting scene features, the adjustment parameter corresponding to the shooting scene feature consistent with the first shooting scene feature is selected from the adjustment parameters corresponding to each second shooting scene feature as the target adjustment parameter; when the first shooting scene feature is not included in the at least two second shooting scene features, the adjustment parameter corresponding to the shooting scene feature with the smallest difference from the first shooting scene feature is selected from the adjustment parameters corresponding to each second shooting scene feature as the target adjustment parameter, thereby the target adjustment parameter can be accurately determined.

[0147] Step 140: Perform purple fringing correction on the mask image based on the target adjustment parameters to obtain a second image.

[0148] The second image may be an image obtained after purple-fringe correction is performed on the mask image based on the target adjustment parameters. In the second image, the purple-fringe area is well eliminated, and no stripes with obvious color differences around the purple-fringe area in the first image are generated.

[0149] The image processing method provided in the embodiment of the present application can be executed by an image processing device. In the embodiment of the present application, an image processing device executing the image processing method is taken as an example to illustrate the image processing device provided in the embodiment of the present application.

[0150] Figure 6The figure is a schematic diagram showing the structure of an image processing device according to an exemplary embodiment.

[0151] like Figure 6 As shown, the image processing device 600 may include:

[0152] A first acquisition module 610 is used to acquire a first image and a first shooting scene feature of shooting the first image, wherein the first image includes a purple-fringe area;

[0153] An identification module 620 is used to identify the purple-fringed region in the first image and obtain a mask image corresponding to the purple-fringed region;

[0154] A first determination module 630 is used to determine a target adjustment parameter corresponding to the mask image according to the first shooting scene feature, a preset shooting scene feature, and an adjustment parameter corresponding to the preset shooting scene feature; wherein the preset shooting scene feature includes at least two second shooting scene features, and the adjustment parameter corresponding to the preset shooting scene feature is obtained by photographing a red color card, a green color card, a blue color card, a cyan color card, a magenta color card, and a yellow color card respectively under the at least two second shooting scene features;

[0155] The second determination module 640 is configured to perform purple fringing correction on the mask image based on the target adjustment parameter to obtain a second image.

[0156] In an embodiment of the present application, by acquiring a first image including a purple-fringed area and features of a first shooting scene for shooting the first image, the purple-fringed area in the first image is identified to obtain a mask image corresponding to the purple-fringed area, and then target adjustment parameters corresponding to the first shooting scene are selected from adjustment parameters obtained by respectively shooting a red color card, a green color card, a blue color card, a cyan color card, a magenta color card and a yellow color card in at least two second shooting scenes, and finally the mask image is corrected for purple fringing using the target adjustment parameters. Compared with the method in the prior art, the solution of the embodiment of the present application can improve the accuracy of eliminating the purple-fringed area in the first image, and thus can obtain a second image with the purple-fringed area eliminated accurately and with a natural transition, and there is no need to replace a high-quality lens to capture the first image, thereby reducing hardware costs and achieving accurate and low-cost elimination of the purple-fringed area.

[0157] In some embodiments of the present application, the first determination module 630 may include:

[0158] A first acquisition unit is used to respectively acquire reference pixel values ​​of the red color card, the green color card, the blue color card, the cyan color card, the magenta color card and the yellow color card in a target color space, and third images corresponding to the red color card, the green color card, the blue color card, the cyan color card, the magenta color card and the yellow color card respectively taken under the preset shooting scene characteristics;

[0159] A second acquisition unit, used for acquiring a first pixel value of a purple-fringe region in each of the third images in the target color space;

[0160] A first determining unit is used to determine a correction equation for correcting a purple-fringed area in each color card according to a first pixel value and a second pixel value of each color card under a target shooting scene feature, wherein the target shooting scene feature is any one of the at least two second shooting scene features, and for each color card, the second pixel value is determined based on the reference pixel value of the color card;

[0161] A second determination unit, configured to determine, according to the correction equation corresponding to each color card, an adjustment parameter corresponding to the target shooting scene feature;

[0162] A selection unit is used to select the adjustment parameter corresponding to the first shooting scene feature from the adjustment parameters corresponding to each second shooting scene feature as the target adjustment parameter.

[0163] In some embodiments of the present application, the correction equation corresponding to each color card includes a correction parameter for correcting the purple-fringed area in each color card; and the second determination unit is specifically configured to:

[0164] The least squares calculation is performed on the correction parameters in the correction equation corresponding to each color card to obtain the adjustment parameters corresponding to the target shooting scene characteristics.

[0165] In some embodiments of the present application, the identification module 620 may include:

[0166] a third determining unit, configured to input the first image into a pre-trained first training model to obtain a fourth image, wherein the fourth image includes a first annotation box for marking a purple-fringed area;

[0167] a fourth determining unit, configured to process the first annotation box in the fourth image by using a non-maximum suppression algorithm to obtain a fifth image, wherein the fifth image includes a second annotation box for selecting a purple-edge region, and the number of the second annotation boxes is less than the number of the first annotation boxes;

[0168] a fifth determining unit, configured to obtain a first curve according to the feature points of each of the second annotation boxes in the fifth image;

[0169] The sixth determination unit is used to expand the first curve according to preset expansion parameters to obtain the mask image; wherein the first training model is trained based on at least two groups of training samples, each group of training samples includes an original image with a purple-fringed area and a marked image in which the purple-fringed area in the original image is marked.

[0170] In some embodiments of the present application, the third determining unit is specifically configured to:

[0171] Inputting the first image into a first feature extraction layer of a pre-trained first training model to obtain a first feature map;

[0172] Inputting the first feature map into a second feature extraction layer of the first training model to obtain a second feature map;

[0173] Inputting the second feature map into the third feature extraction layer of the first training model to obtain a third feature map;

[0174] Inputting the third feature map into the third feature extraction layer to obtain a fourth feature map;

[0175] Inputting the fourth feature map into the third feature extraction layer to obtain a fifth feature map;

[0176] Inputting the fifth feature map into the third feature extraction layer to obtain a sixth feature map;

[0177] The first feature map, the second feature map, the third feature map, the fourth feature map, the fifth feature map and the sixth feature map are input into the prediction convolution layer of the first training model to obtain the fourth image.

[0178] In some embodiments of the present application, the above-mentioned device may further include:

[0179] A third determination module is used to input the original image into a first training model to be trained to obtain a prediction result;

[0180] A first calculation module, used for calculating a target loss function based on the prediction result and the marked image;

[0181] The fourth determination module is used to adjust the parameters of the first training model to be trained based on the target loss function to obtain a pre-trained first training model.

[0182] In some embodiments of the present application, the prediction result includes a predicted image and a confidence level, the predicted image includes a third annotation box for selecting a predicted purple-edge region, the confidence level is used to characterize the confidence level that the purple-edge region selected by the third annotation box is a real purple-edge region, and the marked image includes a fourth annotation box for selecting the purple-edge region;

[0183] The first calculation module is specifically used for:

[0184] Determining the first loss function according to each of the confidence levels of the prediction results;

[0185] Selecting a labeling frame whose confidence level is greater than a first threshold from the third labeling frame of the predicted image to obtain a fifth labeling frame;

[0186] Calculating an intersection-and-union ratio of the fifth annotation frame and the fourth annotation frame;

[0187] Determine a second loss function according to the intersection-over-union ratio;

[0188] A target loss function is calculated based on the first loss function and the second loss function.

[0189] The image processing device in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or it can be other devices other than a terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmentedreality, AR) / virtual reality (virtualreality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.

[0190] The image processing device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.

[0191] The image processing device provided in the embodiment of the present application can achieve Figure 1 The various processes implemented in the method embodiment achieve the same technical effect and will not be described again here to avoid repetition.

[0192] Alternatively, if Figure 7 As shown, an embodiment of the present application also provides an electronic device 700, including a processor 701 and a memory 702, wherein the memory 702 stores programs or instructions that can be executed on the processor 701, and when the program or instructions are executed by the processor 701, the various steps of the above-mentioned image processing method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, they are not described here.

[0193] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.

[0194] Figure 8 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application.

[0195] The electronic device 800 includes but is not limited to: a radio frequency unit 801, a network module 802, an audio output unit 803, an input unit 804, a sensor 805, a display unit 806, a user input unit 807, an interface unit 808, a memory 809, and a processor 810 and other components.

[0196] Those skilled in the art will appreciate that the electronic device 800 may also include a power source (such as a battery) for supplying power to each component, and the power source may be logically connected to the processor 810 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Figure 8 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.

[0197] Among them, the processor 810 is used to obtain a first image and a first shooting scene feature for shooting the first image, wherein the first image includes a purple-fringed area; identify the purple-fringed area in the first image to obtain a mask image corresponding to the purple-fringed area; determine the target adjustment parameters corresponding to the mask image according to the first shooting scene feature, a preset shooting scene feature and the adjustment parameters corresponding to the preset shooting scene feature; wherein the preset shooting scene feature includes at least two second shooting scene features, and the adjustment parameters corresponding to the preset shooting scene features are obtained by shooting a red color card, a green color card, a blue color card, a cyan color card, a magenta color card and a yellow color card respectively under the at least two second shooting scene features; perform purple-fringing correction on the mask image based on the target adjustment parameters to obtain a second image.

[0198] In this way, by acquiring a first image including a purple-fringed area and features of a first shooting scene for shooting the first image, the purple-fringed area in the first image is identified, and a mask image corresponding to the purple-fringed area is obtained. Then, target adjustment parameters corresponding to the first shooting scene are selected from adjustment parameters obtained by respectively shooting a red color card, a green color card, a blue color card, a cyan color card, a magenta color card, and a yellow color card in at least two second shooting scenes. Finally, the mask image is corrected for purple fringing using the target adjustment parameters. Compared with the methods in the prior art, the scheme of the embodiments of the present application can improve the accuracy of eliminating the purple-fringed area in the first image, and thus can obtain a second image with the purple-fringed area eliminated accurately and with a natural transition. There is no need to replace a high-quality lens to capture the first image, thereby reducing hardware costs and achieving accurate and low-cost elimination of the purple-fringed area.

[0199] In some embodiments, the processor 810 is further configured to respectively obtain reference pixel values ​​of the red color card, the green color card, the blue color card, the cyan color card, the magenta color card, and the yellow color card in a target color space, and third images corresponding to the red color card, the green color card, the blue color card, the cyan color card, the magenta color card, and the yellow color card respectively captured under the preset shooting scene feature; obtain a first pixel value of a purple-fringed region in each of the third images in the target color space; determine a correction equation for correcting the purple-fringed region in each color card according to the first pixel value and the second pixel value of each color card under the target shooting scene feature, wherein the target shooting scene feature is any one of the at least two second shooting scene features, and for each color card, the second pixel value is determined based on the reference pixel value of the color card; determine an adjustment parameter corresponding to the target shooting scene feature according to the correction equation corresponding to each color card; and select an adjustment parameter corresponding to the first shooting scene feature from the adjustment parameters corresponding to each second shooting scene feature as the target adjustment parameter.

[0200] In this way, the adjustment parameters corresponding to each second shooting scene feature are pre-calibrated using a standard color card, so that the adjustment parameters corresponding to the first shooting scene features can be obtained as target adjustment parameters, and then the purple-fringed area in the mask image under the first shooting scene feature can be corrected based on the target adjustment parameters, so as to obtain a more accurate second image with the purple-fringed area eliminated.

[0201] In some embodiments, the correction equation corresponding to each color card includes correction parameters for correcting the purple-fringed area in each color card; the processor 810 is also used to perform least squares calculation on the correction parameters in the correction equation corresponding to each color card to obtain adjustment parameters corresponding to the target shooting scene characteristics.

[0202] In this way, by performing least square calculation on the correction parameters in the correction equation corresponding to each color card, the adjustment parameters corresponding to the target shooting scene characteristics can be accurately obtained.

[0203] In some embodiments, the processor 810 is further used to input the first image into a pre-trained first training model to obtain a fourth image, wherein the fourth image includes a first annotation box for marking a purple-fringed area; use a non-maximum suppression algorithm to process the first annotation box in the fourth image to obtain a fifth image, wherein the fifth image includes a second annotation box for selecting a purple-fringed area, and the number of the second annotation boxes is less than the number of the first annotation boxes; obtain a first curve based on the feature points of each of the second annotation boxes in the fifth image; expand the first curve according to a preset expansion parameter to obtain the mask image; wherein the first training model is trained based on at least two groups of training samples, and each group of training samples includes an original image with a purple-fringed area and a marked image in which the purple-fringed area in the original image is marked.

[0204] In this way, the purple-fringed area in the first image is extracted through the pre-trained first training model to obtain the fourth image, thereby improving the recognition accuracy and efficiency of the purple-fringed image in the first image. After obtaining the fourth image, the first annotation box in the fourth image is further processed to simplify the annotation box marking the purple-fringed area to obtain the fifth image, and then the feature points of each second annotation box in the fifth image are connected to obtain a first curve. The curve can be expanded to obtain a mask image that accurately marks the purple-fringed area.

[0205] In some embodiments, the processor 810 is further used to input the first image into the first feature extraction layer of a pre-trained first training model to obtain a first feature map; input the first feature map into the second feature extraction layer of the first training model to obtain a second feature map; input the second feature map into the third feature extraction layer of the first training model to obtain a third feature map; input the third feature map into the third feature extraction layer to obtain a fourth feature map; input the fourth feature map into the third feature extraction layer to obtain a fifth feature map; input the fifth feature map into the third feature extraction layer to obtain a sixth feature map; input the first feature map, the second feature map, the third feature map, the fourth feature map, the fifth feature map and the sixth feature map into the prediction convolution layer of the first training model to obtain the fourth image.

[0206] In this way, the first image is input into the first feature extraction layer of the first training model to obtain a first feature map, and then the first feature map is input into the second feature extraction layer to obtain a second feature map, the second feature map is input into the third feature extraction layer to obtain a third feature map, the third feature map is input into the third feature extraction layer to obtain a fourth feature map, the fourth feature map is input into the third feature extraction layer to obtain a fifth feature map, and the fifth feature map is input into the third feature extraction layer to obtain a sixth feature map. In this way, feature extraction is performed on feature maps of different scales through feature extraction layers of different scales, that is, purple-fringed regions of corresponding scales are detected on feature maps of different scales. In this way, the position of the purple-fringed region can be effectively extracted, and since the first training model is a single-stage target detection model, the labeling box of the purple-fringed region can be directly regressed from the feature map, thereby improving the efficiency of determining the fourth image.

[0207] In some embodiments, the processor 810 is also used to input the original image into the first training model to be trained to obtain a prediction result; calculate the target loss function based on the prediction result and the labeled image; and adjust the parameters of the first training model to be trained based on the target loss function to obtain a pre-trained first training model.

[0208] In this way, by using the original image to train the first training model to be trained, a trained first training model is obtained. Based on the trained first training model, the purple-edge area in the first image can be quickly and accurately extracted to obtain a mask image corresponding to the purple-edge area, thereby improving the efficiency and accuracy of obtaining the mask image.

[0209] In some embodiments, the prediction result includes a predicted image and a confidence level, the predicted image includes a third annotation box for selecting the predicted purple-fringe area, the confidence level is used to characterize the confidence level that the purple-fringe area selected by the third annotation box is a real purple-fringe area, and the marked image includes a fourth annotation box for selecting the purple-fringe area;

[0210] Processor 810 is also used to determine a first loss function based on the confidence levels of the prediction results; select a labeling box whose confidence level is greater than a first threshold from the third labeling box of the predicted image to obtain a fifth labeling box; calculate an intersection-and-union ratio of the fifth labeling box and the fourth labeling box; determine a second loss function based on the intersection-and-union ratio; and calculate a target loss function based on the first loss function and the second loss function.

[0211] In this way, by determining the first loss function according to the confidence, and then selecting the annotation box with a confidence greater than the first threshold from the third annotation box of the predicted image, the fifth annotation box is obtained, and the intersection and union ratio of the fifth annotation box and the fourth annotation box is calculated. According to the intersection and union ratio, the second loss function can be determined, so that the third annotation box is pre-screened, thereby reducing the complexity of subsequent annotation box processing. At the same time, the target loss function of the first training model to be trained is determined by the first loss function used to measure the error between the purple-fringed area predicted by the first training model to be trained and the actual purple-fringed area, and the second loss function used to measure the error between the position of the purple-fringed area predicted by the first training model to be trained and the actual position. The purple-fringed area can be accurately predicted, and the position of the purple-fringed area can be predicted, thereby improving the robustness of the first training model.

[0212] It should be understood that in the embodiment of the present application, the input unit 804 may include a graphics processor (Graphics Processing Unit, GPU) 8041 and a microphone 8042, and the graphics processor 8041 processes the image data of the static picture or video obtained by the image capture device (such as a color camera) in the video capture mode or the image capture mode. The display unit 806 may include a display panel 8061, and the display panel 8061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 807 includes a touch panel 8071 and at least one of other input devices 8072. The touch panel 8071 is also called a touch screen. The touch panel 8071 may include two parts: a touch detection device and a touch controller. Other input devices 8072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.

[0213] The memory 809 can be used to store software programs and various data. The memory 809 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 809 may include a volatile memory or a non-volatile memory, or the memory 809 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 809 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.

[0214] The processor 810 may include one or more processing units; optionally, the processor 810 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 810.

[0215] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned image processing method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0216] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.

[0217] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned image processing method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0218] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.

[0219] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned image processing method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0220] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0221] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0222] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. An image processing method, characterized in that: The method comprises: Acquire a first image and a first shooting scene feature of shooting the first image, wherein the first image includes a purple-fringe area; Identify a purple-fringed region in the first image to obtain a mask image corresponding to the purple-fringed region; Determining a target adjustment parameter corresponding to the mask image according to the first shooting scene feature, a preset shooting scene feature, and an adjustment parameter corresponding to the preset shooting scene feature; wherein the preset shooting scene feature includes at least two second shooting scene features, and the adjustment parameter corresponding to the preset shooting scene feature is obtained by photographing a red color card, a green color card, a blue color card, a cyan color card, a magenta color card, and a yellow color card respectively under the at least two second shooting scene features; Purple fringing correction is performed on the mask image based on the target adjustment parameter to obtain a second image.

2. The method according to claim 1, characterized in that The determining, according to the first shooting scene feature, the preset shooting scene feature and the adjustment parameter corresponding to the preset shooting scene feature, the target adjustment parameter corresponding to the mask image includes: Respectively obtaining reference pixel values ​​of the red color card, the green color card, the blue color card, the cyan color card, the magenta color card and the yellow color card in a target color space, and third images corresponding to the red color card, the green color card, the blue color card, the cyan color card, the magenta color card and the yellow color card respectively taken under the preset shooting scene characteristics; Obtaining a first pixel value of a purple-fringe region in each of the third images in the target color space; Determining a correction equation for correcting a purple-fringed region in each color card according to a first pixel value and a second pixel value of each color card under a target shooting scene feature, wherein the target shooting scene feature is any one of the at least two second shooting scene features, and for each color card, the second pixel value is determined based on the reference pixel value of the color card; Determining adjustment parameters corresponding to the target shooting scene characteristics according to the correction equation corresponding to each color card; The adjustment parameter corresponding to the first shooting scene feature is selected from the adjustment parameters corresponding to each second shooting scene feature as the target adjustment parameter.

3. The method according to claim 2, characterized in that The correction equation corresponding to each color card includes correction parameters for correcting the purple-fringed area in each color card; The step of determining the adjustment parameters corresponding to the target shooting scene features according to the correction equation corresponding to each color card includes: The least squares calculation is performed on the correction parameters in the correction equation corresponding to each color card to obtain the adjustment parameters corresponding to the target shooting scene characteristics.

4. The method according to claim 1, characterized in that: The step of identifying the purple-fringed region in the first image to obtain a mask image corresponding to the purple-fringed region includes: Inputting the first image into a pre-trained first training model to obtain a fourth image, wherein the fourth image includes a first annotation box for marking a purple-fringed area; Processing the first annotation box in the fourth image by using a non-maximum suppression algorithm to obtain a fifth image, wherein the fifth image includes second annotation boxes for selecting purple-edge regions, and the number of the second annotation boxes is less than the number of the first annotation boxes; Obtaining a first curve according to the feature points of each of the second annotation boxes in the fifth image; Expanding the first curve according to a preset expansion parameter to obtain the mask image; The first training model is trained based on at least two groups of training samples, each group of training samples includes an original image with a purple-fringe area and a marked image in which the purple-fringe area in the original image is marked.

5. The method according to claim 4, characterized in that The step of inputting the first image into a pre-trained first training model to obtain a fourth image includes: Inputting the first image into a first feature extraction layer of a pre-trained first training model to obtain a first feature map; Inputting the first feature map into a second feature extraction layer of the first training model to obtain a second feature map; Inputting the second feature map into the third feature extraction layer of the first training model to obtain a third feature map; Inputting the third feature map into the third feature extraction layer to obtain a fourth feature map; Inputting the fourth feature map into the third feature extraction layer to obtain a fifth feature map; Inputting the fifth feature map into the third feature extraction layer to obtain a sixth feature map; The first feature map, the second feature map, the third feature map, the fourth feature map, the fifth feature map and the sixth feature map are input into the prediction convolution layer of the first training model to obtain the fourth image.

6. The method according to claim 4, characterized in that Before inputting the first image into a pre-trained first training model to obtain a fourth image, the method further includes: Inputting the original image into a first training model to be trained to obtain a prediction result; Calculating a target loss function based on the prediction result and the labeled image; The parameters of the first training model to be trained are adjusted based on the target loss function to obtain a pre-trained first training model.

7. The method according to claim 6, characterized in that The prediction result includes a prediction image and a confidence level, wherein the prediction image includes a third annotation frame for selecting a predicted purple-edge region, the confidence level is used to characterize the confidence level that the purple-edge region selected by the third annotation frame is a real purple-edge region, and the marked image includes a fourth annotation frame for selecting the purple-edge region; The calculating the target loss function based on the prediction result and the marked image includes: Determining a first loss function according to each of the confidence levels of the prediction results; Selecting a labeling frame whose confidence is greater than a first threshold from the third labeling frame of the predicted image to obtain a fifth labeling frame; Calculating an intersection-and-union ratio of the fifth annotation frame and the fourth annotation frame; Determine a second loss function according to the intersection-over-union ratio; A target loss function is calculated based on the first loss function and the second loss function.

8. An image processing device, characterized in that: The device comprises: A first acquisition module, used to acquire a first image and a first shooting scene feature for shooting the first image, wherein the first image includes a purple-edge region; A recognition module, used for recognizing a purple-fringed region in the first image, and obtaining a mask image corresponding to the purple-fringed region; A first determination module is used to determine a target adjustment parameter corresponding to the mask image according to the first shooting scene feature, a preset shooting scene feature, and an adjustment parameter corresponding to the preset shooting scene feature; wherein the preset shooting scene feature includes at least two second shooting scene features, and the adjustment parameter corresponding to the preset shooting scene feature is obtained by photographing a red color card, a green color card, a blue color card, a cyan color card, a magenta color card, and a yellow color card respectively under the at least two second shooting scene features; The second determination module is used to perform purple fringing correction on the mask image based on the target adjustment parameter to obtain a second image.

9. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores a program or instruction that can be run on the processor, and when the program or instruction is executed by the processor, the steps of the image processing method according to any one of claims 1 to 7 are implemented.

10. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by a processor, the steps of the image processing method according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Multi-scene LED screen automatic calibration method and device and electronic equipment

    CN120452358A