Image processing method, electronic device and storage medium
By applying the target detection and layout adjustment prediction model in image processing, the problem of being unable to adjust the target layout after shooting is solved, and the image layout is optimized and the user experience is improved.
Patent Information
- Application Number
- CN202311764839.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-21
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2043-12-21
AI Technical Summary
In the existing technology, the target layout in the image cannot be adjusted again after the shooting is completed, resulting in poor user experience.
By performing target detection in the image to be processed, the target picture is obtained, and input into the layout adjustment prediction model to obtain the layout adjustment strategy. The target picture is adjusted according to the strategy, including the adjustment of the canvas and the target picture. If there is a blank area, Fill processing, combining noise and denoising to optimize images.
It realizes the layout optimization of the target in the image, improves the user experience, avoids the impact of blank areas, and ensures the quality of the processed image.
Smart Images

Figure CN117455799B
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to an image processing method, an electronic device and a storage medium. Background Art
[0002] With the popularity of terminal devices with shooting functions in life, people use terminal devices to shoot has become a daily behavior, and people have higher and higher requirements for the images taken. It is understandable that the quality of the captured image is usually affected by multiple factors such as light, shooting distance, shooting angle, etc. In the actual shooting process, it may happen that the shooting effect of the photographed target (for example, people, animals or other photographed objects, etc.) is good, but the layout of the target in the image is not coordinated. At this time, since the image has been shot, it is usually impossible to adjust the layout of the target in the image again, resulting in a poor user experience. Summary of the invention
[0003] The present application provides an image processing method, an electronic device and a storage medium, so as to solve the problem in the prior art that after the image is taken, the layout of the target in the image cannot be readjusted, resulting in a poor user experience.
[0004] In a first aspect, an embodiment of the present application provides an image processing method, comprising:
[0005] Perform target detection in the image to be processed to obtain the target image;
[0006] Inputting the image to be processed and the target picture into a layout adjustment prediction model to obtain a layout adjustment strategy of the target picture in the image to be processed;
[0007] The layout of the target picture in the image to be processed is adjusted according to the layout adjustment strategy to obtain a processed image.
[0008] In the embodiment of the present application, target detection is performed in the image to be processed to obtain a target picture; the image to be processed and the target picture are input into a layout adjustment prediction model to obtain a layout adjustment strategy for the target picture in the image to be processed; the layout of the target picture in the image to be processed is adjusted according to the layout adjustment strategy to obtain a processed image, thereby optimizing the layout of the target in the image and improving the user experience.
[0009] In some possible implementations, adjusting the layout of the target picture in the image to be processed according to the layout adjustment strategy to obtain a processed image includes:
[0010] Adjusting the layout of the target picture in the image to be processed according to the layout adjustment strategy to obtain an adjusted image;
[0011] If there is a blank area in the adjusted image, the blank area in the adjusted image is filled to obtain a processed image.
[0012] In an embodiment of the present application, when there are blank areas in the adjusted image, the blank areas are filled to avoid the blank areas in the processed image affecting the user experience.
[0013] In some possible implementations, filling the blank area in the adjusted image to obtain a processed image includes:
[0014] Performing noise processing on the adjusted image to obtain a noisy image;
[0015] The noisy image is subjected to denoising processing to obtain a processed image.
[0016] In the embodiment of the present application, the empty area is filled by adding noise to the adjusted image and then denoising it, and the filling effect is better.
[0017] In some possible implementations, the denoising the noisy image to obtain a processed image includes:
[0018] Performing denoising on the noisy image to obtain a denoised image;
[0019] The denoised image and the adjusted image are subjected to image fusion processing to obtain a processed image.
[0020] In the embodiment of the present application, the denoised image and the adjusted image are subjected to image fusion processing, which can avoid losing too much information in the original image during the denoising and denoising process and improve the quality of the processed image.
[0021] In some possible implementations, the layout adjustment strategy includes a canvas adjustment parameter and / or a target picture adjustment parameter, and adjusting the layout of the target picture in the image to be processed according to the layout adjustment strategy includes:
[0022] Adjusting the canvas of the image to be processed according to the canvas adjustment parameter;
[0023] And / or, adjusting the target picture in the image to be processed according to the target picture adjustment parameter.
[0024] In some possible implementations, the canvas adjustment parameter includes a canvas size adjustment parameter and / or a canvas shape adjustment parameter, and adjusting the canvas of the image to be processed according to the canvas adjustment parameter includes:
[0025] Adjusting the canvas size of the image to be processed according to the canvas size adjustment parameter;
[0026] And / or, adjusting the canvas shape of the image to be processed according to the canvas shape adjustment parameter.
[0027] In some possible implementations, the target picture adjustment parameter includes a target picture posture adjustment parameter and / or a target picture position adjustment parameter, and adjusting the target picture in the image to be processed according to the target picture adjustment parameter includes:
[0028] Adjusting the posture of the target picture according to the target picture posture adjustment parameter;
[0029] And / or, adjusting the position of the target picture in the image to be processed according to the target picture position adjustment parameter.
[0030] In some possible implementations, the target picture posture adjustment parameter includes a target picture scaling ratio and / or a target picture rotation angle, and adjusting the posture of the target picture according to the target picture posture adjustment parameter includes:
[0031] Scaling the target image according to the scaling ratio of the target image;
[0032] And / or rotating the target picture according to the rotation angle of the target picture.
[0033] In some possible implementations, after adjusting the target picture in the to-be-processed image according to the target picture adjustment parameter, the method further includes:
[0034] Erasing pixels located at the edge of the target image in the image to be processed.
[0035] In the embodiment of the present application, erasing pixels located at the edge of the target picture can better integrate the moved target picture with the image to be processed.
[0036] In a second aspect, an embodiment of the present application provides an electronic device, including:
[0037] processor;
[0038] Memory;
[0039] And a computer program, wherein the computer program is stored in the memory, and the computer program includes instructions, and when the instructions are executed by the processor, the electronic device executes any one of the methods described in the first aspect.
[0040] In a third aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium includes a stored program, wherein when the program is running, the device where the computer-readable storage medium is located is controlled to execute any one of the methods described in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0042] Figure 1A A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0043] Figure 1B A schematic diagram of the structure of another electronic device provided in an embodiment of the present application;
[0044] Figure 2A A schematic diagram of an image to be processed provided in an embodiment of the present application;
[0045] Figure 2B A schematic diagram of a processed image provided in an embodiment of the present application;
[0046] Figure 3A A schematic diagram of another image to be processed provided in an embodiment of the present application;
[0047] Figure 3B A schematic diagram of another processed image provided in an embodiment of the present application;
[0048] Figure 4 A schematic diagram of an image processing scenario provided in an embodiment of the present application;
[0049] Figure 5 A flowchart of an image processing method provided in an embodiment of the present application;
[0050] Figure 6 A schematic diagram of a target detection scenario provided in an embodiment of the present application;
[0051] Figure 7 A schematic diagram of a layout adjustment strategy prediction scenario provided in an embodiment of the present application;
[0052] Figure 8 A schematic diagram of the structure of a layout adjustment prediction model provided in an embodiment of the present application;
[0053] Fig. 9A schematic diagram of a target screen distribution heat map provided in an embodiment of the present application;
[0054] Fig.10 A schematic diagram of a canvas size adjustment scenario provided in an embodiment of the present application;
[0055] Fig.11 A schematic diagram of another canvas size adjustment scenario provided in an embodiment of the present application;
[0056] Fig.12 A schematic diagram of another canvas size adjustment scenario provided in an embodiment of the present application;
[0057] Fig.13 A schematic diagram of another canvas size adjustment scenario provided in an embodiment of the present application;
[0058] Fig.14 A schematic diagram of a target screen size adjustment scenario provided in an embodiment of the present application;
[0059] Fig.15 A schematic diagram of another target screen size adjustment scenario provided in an embodiment of the present application;
[0060] Fig.16 A schematic diagram of a target picture angle adjustment scenario provided in an embodiment of the present application;
[0061] Fig.17 A schematic diagram of a target picture angle adjustment scenario provided in an embodiment of the present application;
[0062] Fig.18 A schematic diagram of a target image position adjustment scenario provided in an embodiment of the present application;
[0063] Fig.19 A schematic diagram of another target image position adjustment scenario provided in an embodiment of the present application;
[0064] Fig. 20 A schematic diagram of an edge pixel erasing scenario provided in an embodiment of the present application;
[0065] Fig.21 A schematic diagram of another edge pixel erasing scenario provided in an embodiment of the present application;
[0066] Fig. 22 A schematic diagram of a blank area filling scenario provided in an embodiment of the present application;
[0067] Fig.23 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0068] In order to better understand the technical solution of the present application, the embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0069] It should be clear that the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0070] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the present application. The singular forms "a", "said" and "the" used in the embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.
[0071] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0072] See also Figure 1A , is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 1A As shown, the electronic device is a terminal device 110, specifically, the terminal device 110 is a mobile phone. Of course, in addition to the mobile phone, the terminal device 110 can also be a tablet computer, a personal computer (PC), a personal digital assistant (PDA), a smart watch, a netbook, a wearable electronic device, an augmented reality (AR) device, a virtual reality (VR) device, a vehicle-mounted device, a robot, smart glasses, etc., and the present application embodiment does not specifically limit this.
[0073] See also Figure 1B , is a schematic diagram of the structure of another electronic device provided in an embodiment of the present application. Figure 1B As shown, the electronic device is a server device 120. It should be noted that Figure 1B This is only an exemplary description of the server device 120 and should not be used as a limitation on the scope of protection of this application. For example, in some possible implementations, the server device 120 is a distributed architecture, and a cloud computing service is installed in the server device 120 of the distributed architecture to perform corresponding data processing through the cloud computing service.
[0074] With the popularity of terminal devices with shooting functions in life, people use terminal devices to shoot has become a daily behavior, and people have higher and higher requirements for the images taken. It is understandable that the quality of the captured image is usually affected by multiple factors such as light, shooting distance, shooting angle, etc. In the actual shooting process, it may happen that the shooting effect of the photographed target (for example, people, animals or other photographed objects, etc.) is good, but the layout of the target in the image is not coordinated. At this time, since the image has been shot, it is usually impossible to adjust the layout of the target in the image again, resulting in a poor user experience.
[0075] For example, Figure 2A The image to be processed is a photo taken by a user. The target in the photo is a seabird and the background is the sea. After taking the photo, the user finds that the target is well photographed. However, due to inappropriate shooting distance or focal length setting, the target almost fills the entire canvas of the image, resulting in an uncoordinated layout of the target in the image. For example, Figure 3A The image to be processed is another photo taken by the user. The target in the photo is also "a seabird" and the background is "sea". After the photo is taken, the user finds that the photo of the target is good, but because the target is too close to the left side of the image, the layout of the target in the image is not coordinated.
[0076] In the related art, after the image is taken, it is usually impossible to adjust the layout of the target in the image again. Figure 2A and Figure 3A In the images shown, even if the layout of the target in the entire image is not coordinated, it is usually impossible to readjust it, resulting in a poor user experience.
[0077] In view of the above problems, the embodiment of the present application provides an image processing method, which performs target detection in the image to be processed to obtain a target screen; inputs the image to be processed and the target screen into a layout adjustment prediction model to obtain a layout adjustment strategy for the target screen in the image to be processed; adjusts the layout of the target screen in the image to be processed according to the layout adjustment strategy to obtain a processed image, thereby optimizing the layout of the target in the image and improving the user experience. Figure 2A After processing the image to be processed, we can obtain Figure 2B The processed image shown. Figure 2B In the processed image shown in the figure, the image canvas is expanded, so that the target has a moderate proportion in the entire image and a coordinated layout. Figure 3A After processing the image to be processed, we can obtain Figure 3B The processed image shown. Figure 3BIn the processed image shown, the position of the target in the canvas is moved so that the target is close to the middle of the image and the layout is coordinated.
[0078] For ease of understanding, the image processing process provided in the embodiment of the present application is exemplarily described below in conjunction with a specific application scenario.
[0079] See also Figure 4 , is a schematic diagram of an image processing scenario provided in an embodiment of the present application. Figure 4 The images in different processing stages are marked as 4A-4F. Specifically, 4A is an image to be processed, in which the target is "a seabird" and the background is "the sea". Target detection is performed on the image to be processed to obtain a target screen, such as the range indicated by the dotted line in 4B. It can be understood that the target screen is the screen corresponding to the target in the image to be processed. Further, according to the image to be processed and the target screen, the layout adjustment strategy is predicted to obtain canvas adjustment parameters, target screen position adjustment parameters and target screen scaling ratio. Among them, the canvas adjustment parameter is used to indicate the adjustment of the size of the canvas; the target screen position adjustment parameter is used to indicate the adjustment of the position of the target screen, and the adjusted target screen position is shown in 4C; the target screen scaling ratio is used to indicate the zooming in or out of the target screen. Further, the canvas is expanded according to the canvas adjustment parameter; after the target screen is scaled according to the target screen scaling ratio, the target screen is moved to the position indicated by the target screen position adjustment parameter, as shown in 4D. It can be understood that after the canvas is expanded, a certain blank area will be generated, namely the "first blank area" marked in 4D; after the target picture is moved, a certain blank area will be generated at the initial position of the target picture, namely the "second blank area" marked in 4D. Usually, after the target picture is moved, there will be an obvious separation between the edge of the target picture and the background in the image to be processed. In order to better integrate the moved target picture with the image to be processed, the pixels at the edge of the target picture in the image to be processed can be erased (it should be pointed out that the pixels erased here are the pixels in the image to be processed, not the pixels in the target picture), forming a third blank area, as shown in 4E. Further, the blank areas (first blank area, first blank area and third blank area) are filled to obtain a processed image, as shown in 4F. In the processed image shown in 4F, the target is close to the middle of the image, and the layout of the target in the entire image is more coordinated.
[0080] See also Figure 5 , is a flow chart of an image processing method provided in an embodiment of the present application. The method can be applied to Figure 1A and Figure 1B The electronic equipment shown, such as Figure 5 As shown, it mainly includes the following steps.
[0081] Step S501: Detect a target in the image to be processed to obtain a target image.
[0082] The "target" involved in the embodiments of the present application is usually an object photographed by a user, such as a person, an animal, an object, etc. In the image to be processed, it usually includes a target picture and a background picture, wherein the target picture is usually the foreground picture in the image to be processed; the background picture is usually the background picture of the image to be processed.
[0083] The "image to be processed" involved in the embodiments of the present application may be an image taken by a user through an electronic device, an image stored in an electronic device, or an image obtained by the electronic device in other storage devices or databases, and the embodiments of the present application do not impose specific restrictions on this. For example, when the electronic device is a terminal device with a shooting function, the image to be processed may be an image taken by the user through the terminal device; when the electronic device is a server device, the image to be processed may be an image uploaded by the terminal device to the server device.
[0084] In the specific implementation, the image to be processed can be input into the target detection model to obtain the target image, such as Figure 6 The target detection model may adopt an R-CNN model, a Fast R-CNN model, a Faster R-CNN model or other models that can perform target detection, and the embodiments of the present application do not impose specific restrictions on this.
[0085] Step S502: inputting the image to be processed and the target picture into a layout adjustment prediction model to obtain a layout adjustment strategy of the target picture in the image to be processed.
[0086] See also Figure 7 , is a schematic diagram of a layout adjustment strategy prediction scenario provided by an embodiment of the present application. Figure 7 As shown, after the image to be processed and the target screen are input into the layout adjustment prediction model, the layout adjustment strategy can be obtained. Specifically, the layout adjustment strategy includes canvas adjustment parameters and / or target screen adjustment parameters. Among them, the canvas adjustment parameters are used to indicate that the canvas of the image to be processed is adjusted; the target screen adjustment parameters are used to indicate that the target screen in the image to be processed is adjusted.
[0087] In some possible implementations, the canvas adjustment parameter includes a canvas size adjustment parameter and / or a canvas shape adjustment parameter. The canvas size adjustment parameter is used to indicate that the size of the canvas of the image to be processed is adjusted. For example, the side (left side, right side, top side and / or bottom side) of the canvas is cut and / or extended. The canvas shape adjustment parameter is used to indicate that the shape of the canvas of the image to be processed is adjusted. For example, a rectangular canvas is adjusted to a diamond; or an elliptical canvas is adjusted to a circle, etc.
[0088] In some possible implementations, the target picture adjustment parameter includes a target picture posture adjustment parameter and / or a target picture position adjustment parameter. Wherein, the target picture posture adjustment parameter is used to indicate that the posture of the target picture is adjusted. Further, the target picture posture adjustment parameter includes a target picture scaling ratio and / or a target picture rotation angle. The target picture scaling ratio is used to indicate that the size of the target picture is scaled. The target picture rotation angle is used to indicate that the target picture is rotated. In addition, the target picture position adjustment parameter is used to indicate that the position of the target picture in the image to be processed is adjusted.
[0089] It should be pointed out that the layout adjustment strategy involved in the embodiments of the present application may include only part of the above parameters. For example, the layout adjustment strategy only includes canvas adjustment parameters, which means that only the canvas of the image to be processed needs to be adjusted; or, the layout adjustment strategy only includes target screen adjustment parameters, which means that only the target screen in the image to be processed needs to be adjusted; or, the layout adjustment strategy only includes canvas size adjustment parameters and target screen position adjustment parameters, which means that only the canvas size of the image to be processed and the position of the target screen in the image to be processed need to be adjusted. It is understandable that the above parameters include a variety of combinations, which will not be described in detail in the embodiments of the present application.
[0090] See also Figure 8 , is a schematic diagram of the structure of a layout adjustment prediction model provided in an embodiment of the present application. Figure 8 As shown, the layout adjustment prediction model includes an encoding module, a conversion module and a decoding module. Among them, the encoding module includes a first encoding module and a second encoding module. The first encoding module is used to input the image to be processed, and after encoding the image to be processed, obtain the feature vector of the image to be processed, and transmit the feature vector of the image to be processed to the conversion module; the second encoding module is used to input the target picture, and after encoding the target picture, obtain the target picture feature vector, and transmit the target picture feature vector to the conversion module. The conversion module is used to convert the feature vector of the image to be processed and the feature vector of the target picture into a combined feature vector, and transmit the combined feature vector to the decoding module. The decoding module is used to decode the combined feature vector to obtain the layout adjustment strategy.
[0091] Among them, the target screen position adjustment parameters in the layout adjustment strategy can be determined by the target screen distribution heat map obtained after decoding by the decoding module. Fig. 9 , is a schematic diagram of a target screen distribution heat map provided in an embodiment of the present application. The target screen distribution heat map is used to characterize the distribution probability of the target screen at different positions in the image to be processed. Generally, the position with the highest distribution probability (for example, Fig. 9The point P in the image is used as the adjusted target image position, and then the target image position adjustment parameters can be determined.
[0092] In a specific implementation, the first encoding module, the second encoding module and the decoding module may adopt a CNN model or a ViT model; the conversion module may adopt a Transformer model. For the specific contents of the CNN model, the ViT model and the Transformer model, reference may be made to the existing relevant literature descriptions. For the sake of brevity, they will not be repeated here. In addition, those skilled in the art may also adopt other network models to implement the relevant functions of the encoding module, the conversion module and the decoding module according to actual needs, and the embodiments of the present application do not impose specific restrictions on this.
[0093] In an embodiment of the present application, the layout effect of the target picture in the image to be processed is affected by both the local features in the image to be processed and the global features of the target picture. Predicting the layout adjustment strategy based on the Transformer model can take into account the local features in the image to be processed and the global features of the target picture, thereby obtaining a better prediction effect.
[0094] Step S503: adjusting the layout of the target picture in the image to be processed according to the layout adjustment strategy to obtain a processed image.
[0095] In a possible implementation, the layout adjustment strategy includes a canvas adjustment parameter and / or a target picture adjustment parameter. The layout of the target picture in the image to be processed is adjusted according to the layout adjustment strategy, specifically including: adjusting the canvas of the image to be processed according to the canvas adjustment parameter; and / or adjusting the target picture in the image to be processed according to the target picture adjustment parameter.
[0096] Furthermore, the canvas adjustment parameters include canvas size adjustment parameters and / or canvas shape adjustment parameters. Adjusting the canvas of the image to be processed according to the canvas adjustment parameters specifically includes: adjusting the canvas size of the image to be processed according to the canvas size adjustment parameters; and / or adjusting the canvas shape of the image to be processed according to the canvas shape adjustment parameters. Specifically, adjusting the canvas size may include cutting and / or extending the sides of the canvas. For ease of understanding, an exemplary description is given below in conjunction with a specific application scenario.
[0097] See also Fig.10, is a schematic diagram of a canvas resizing scenario provided in an embodiment of the present application. In the embodiment of the present application, the canvas resizing parameter indicates that the left side and the right side of the canvas are expanded by a1 column of pixels and b1 column of pixels, respectively, and the upper side and the lower side of the canvas are expanded by c1 row of pixels and d1 row of pixels, respectively. After the canvas of the image to be processed shown in 10A is expanded according to the canvas resizing parameter, an image after the canvas expansion is obtained, as shown in 10B.
[0098] See also Fig.11 , which is another schematic diagram of a canvas resizing scenario provided in an embodiment of the present application. In an embodiment of the present application, the canvas resizing parameters indicate that a2 columns of pixels and b2 columns of pixels are cut off on the left and right sides of the canvas, respectively, and c2 rows of pixels and d2 rows of pixels are cut off on the top and bottom sides of the canvas, respectively. After the canvas of the image to be processed shown in 11A is cut off according to the canvas resizing parameters, an image after the canvas is cut off is obtained, as shown in 11B.
[0099] See also Fig.12 , which is another schematic diagram of a canvas resizing scenario provided in an embodiment of the present application. In an embodiment of the present application, the canvas resizing parameters indicate that the left and right sides of the canvas are expanded by a3 columns of pixels and b3 columns of pixels, respectively, and the upper and lower sides of the canvas are cut by c3 rows of pixels and d3 rows of pixels, respectively. After the canvas of the image to be processed shown in 12A is expanded and cut according to the canvas resizing parameters, an image after the canvas expansion and cutting is obtained, as shown in 12B.
[0100] See also Fig.13 , which is another schematic diagram of a canvas resizing scenario provided in an embodiment of the present application. In an embodiment of the present application, the canvas resizing parameter indicates that a4 columns of pixels and b4 columns of pixels are cut off on the left and right sides of the canvas, respectively, and c4 rows of pixels and d4 rows of pixels are expanded on the upper and lower sides of the canvas, respectively. After the canvas of the image to be processed shown in 13A is expanded and cropped according to the canvas resizing parameter, an image after the canvas expansion and cropping is obtained, as shown in 13B.
[0101] It should be pointed out that when the canvas needs to be expanded and cropped at the same time, it can be expanded first and then cropped, or it can be cropped first and then expanded. The embodiments of the present application do not impose specific restrictions on this.
[0102] It is understood that in the above example, the left side, right side, top side and bottom side of the canvas are adjusted respectively. In practical applications, it is also possible to adjust only some of the four sides (left side, right side, top side and bottom side) of the canvas. For example, any one of the four sides is adjusted; or any two of the four sides are adjusted; or any three of the four sides are adjusted, and the embodiments of the present application do not impose specific restrictions on this.
[0103] Further, the target picture adjustment parameter includes a target picture posture adjustment parameter and / or a target picture position adjustment parameter. Adjusting the target picture in the image to be processed according to the target picture adjustment parameter specifically includes: adjusting the posture of the target picture according to the target picture posture adjustment parameter; and / or adjusting the position of the target picture in the image to be processed according to the target picture position adjustment parameter.
[0104] In some possible implementations, the target screen posture adjustment parameter includes a target screen scaling ratio and / or a target screen rotation angle. The target screen scaling ratio is used to indicate scaling the size of the target screen, and the target screen rotation angle is used to indicate rotating the target screen. For ease of understanding, an exemplary description is given below in conjunction with a specific application scenario.
[0105] See also Fig.14 , is a schematic diagram of a target screen size adjustment scenario provided in an embodiment of the present application. In the embodiment of the present application, the target screen scaling ratio is 0.5. After the target screen in the image to be processed shown in 14A is reduced by 0.5 times according to the target screen scaling ratio, a target screen reduced by 0.5 times is obtained, as shown in 14B.
[0106] See also Fig.15 , is another schematic diagram of a target screen size adjustment scenario provided in an embodiment of the present application. In the embodiment of the present application, the target screen scaling ratio is 2. After the target screen in the image to be processed shown in 15A is enlarged by 2 times according to the target screen scaling ratio, the target screen enlarged by 2 times is obtained, as shown in 15B.
[0107] See also Fig.16 , is a schematic diagram of a target image angle adjustment scenario provided in an embodiment of the present application. In the embodiment of the present application, the target image rotation angle is +30°. After the target image in the image to be processed shown in 16A is rotated 30° clockwise according to the target image rotation angle, the target image rotated +30° is obtained, as shown in 16B.
[0108] See also Fig.17 , is a schematic diagram of a target image angle adjustment scenario provided in an embodiment of the present application. In the embodiment of the present application, the target image rotation angle is -15°. After the target image in the image to be processed shown in 17A is rotated counterclockwise by 15° according to the target image rotation angle, the target image rotated by -15° is obtained, as shown in 17B.
[0109] In some possible implementations, the target screen position adjustment parameter may be the coordinates of the target screen after the move, that is, the position of the target screen after the move. Fig.18, is a schematic diagram of a target screen position adjustment scenario provided in an embodiment of the present application. In the embodiment of the present application, according to the adjusted target screen coordinates (x1, y1), the target screen in the image to be processed is adjusted from the initial position (x0, y0) shown in 18A to the moved target screen position (x1, y1) shown in 18B.
[0110] In some possible implementations, the target picture position adjustment parameter may be a target picture movement vector, that is, a distance and direction in which the target picture needs to move. Fig.19 , is another schematic diagram of a target picture position adjustment scenario provided in an embodiment of the present application. In the embodiment of the present application, according to the target picture movement vector (Δx, Δy), the target picture in the image to be processed is moved from the initial position shown in 19A by Δx in the x direction and by Δy in the y direction, so that the target picture moves to the moved target picture position shown in 19B.
[0111] It should be noted that, for ease of understanding, each adjustment type is described above separately. However, those skilled in the art should understand that in practical applications, a combination of multiple adjustment types is usually involved. For example, scaling, position adjustment, and canvas expansion of the target screen are performed simultaneously, and the embodiments of the present application do not specifically limit this.
[0112] Please continue reading Figure 10-13 After the canvas is expanded, a certain blank area (black area) will be generated at the expanded position of the canvas. For the sake of convenience, this blank area is called the first blank area. Figure 14-Figure 19 After the target picture is adjusted, a certain blank area will be generated at the initial position of the target picture. For the sake of convenience, the blank area is called the second blank area.
[0113] In addition, after the target image is adjusted, there will be an obvious dividing line between the edge of the target image and the background of the image to be processed. In order to better integrate the adjusted target image with the image to be processed, in a possible implementation, after the target image is adjusted, the pixels located at the edge of the target image in the image to be processed are erased (it should be noted that the pixels erased here are the pixels in the image to be processed, not the pixels in the target image), forming a blank area around the edge of the target image, such as Fig. 20 For the sake of convenience, the blank area is referred to as the third blank area. It should be noted that those skilled in the art can adjust the number of pixels to be erased according to actual needs, and the present application embodiment does not impose any specific restrictions on this. Fig.21 The number of pixels erased in Fig. 20 The number of pixels to erase in .
[0114] It is understandable that when there are blank areas in the image to be processed, the blank areas in the image to be processed need to be filled. The above step S503 specifically includes: adjusting the layout of the target screen in the image to be processed according to the layout adjustment strategy to obtain an adjusted image; if there are blank areas in the adjusted image, filling the blank areas (first blank areas, second blank areas and / or third blank areas) in the adjusted image to obtain a processed image.
[0115] It should be noted that in some application scenarios, after adjusting the layout of the target screen in the image to be processed, no blank area may be generated. Fig.11 ), or only enlarge the target image in the image to be processed (as shown in Fig.15 In this case, after adjusting the layout of the target screen in the image to be processed, the processed image is directly obtained, that is, there is no need to perform the filling step.
[0116] See also Fig. 22 , is a schematic diagram of a blank area filling scenario provided in an embodiment of the present application. Fig. 22 As shown, the adjusted image shown in 22A (the adjusted image obtained by adjusting the layout of the target screen in the image to be processed according to the layout adjustment strategy) includes a first blank area, a second blank area and a third blank area. The adjusted image is subjected to noise processing to obtain an adjusted image, as shown in 22B. Further, the noisy image is subjected to denoising processing to obtain a denoised image, as shown in 22C. It can be understood that in the denoised image, the filling of the blank area has been completed. In a possible implementation, in order to avoid losing too much information in the original image during the above-mentioned denoising and denoising process, the adjusted image in 22A and the denoised image in 22C are subjected to image fusion processing to obtain a processed image.
[0117] It should be noted that in some possible implementations, the "image fusion processing" step may be omitted, that is, after the noise-added image is denoised, the final processed image is directly obtained, and the embodiments of the present application do not impose specific restrictions on this. In addition, the specific contents of the "noise-added processing", "denoising processing" and "image fusion processing" involved in the embodiments of the present application can be described in the existing relevant literature, and for the sake of brevity, they will not be repeated here.
[0118] Corresponding to the above embodiment, an embodiment of the present application further provides an electronic device.
[0119] See also Fig.23 , is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Fig.23As shown, the electronic device 2300 may include: a processor 2301, a memory 2302 and a communication unit 2303. These components communicate through one or more buses. Those skilled in the art can understand that the electronic device structure shown in the figure does not constitute a limitation on the embodiments of the present application. It can be a bus structure or a star structure, and can also include more or fewer components than shown in the figure, or combine certain components, or arrange components differently.
[0120] The communication unit 2303 is used to establish a communication channel so that the electronic device can communicate with other devices.
[0121] The processor 2301 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. It runs or executes software programs and / or modules stored in the memory 2302, and calls data stored in the memory to perform various functions of the electronic device and / or process data. The processor can be composed of an integrated circuit (IC), for example, it can be composed of a single packaged IC, or it can be composed of multiple packaged ICs with the same or different functions. For example, the processor 2301 can include only a central processing unit (CPU). In the embodiment of the present application, the CPU can be a single computing core or multiple computing cores.
[0122] Memory 2302 is used to store execution instructions of processor 2301. Memory 2302 can be implemented by any type of volatile or non-volatile storage device or a combination of them, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0123] When the execution instructions in the memory 2302 are executed by the processor 2301, the electronic device 2300 is enabled to execute part or all of the steps in the above method embodiments.
[0124] Corresponding to the above embodiment, the embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium may store a program, wherein when the program is running, the device where the computer-readable storage medium is located may be controlled to execute some or all of the steps in the above method embodiment. In a specific implementation, the computer-readable storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM).
[0125] Corresponding to the above-mentioned embodiment, the embodiment of the present application further provides a computer program product, which includes executable instructions. When the executable instructions are executed on a computer, the computer executes some or all of the steps in the above-mentioned method embodiment.
[0126] In the embodiments of the present application, "at least one" refers to one or more, and "plurality" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent the existence of A alone, the existence of A and B at the same time, and the existence of B alone. Among them, A and B can be singular or plural. The character " / " generally indicates that the previous and subsequent associated objects are in an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b and c can be represented by: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple.
[0127] Those of ordinary skill in the art will appreciate that the various units and algorithm steps described in the embodiments disclosed herein can be implemented in a combination of electronic hardware, computer software, and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0128] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0129] In several embodiments provided in the present application, if any function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc., various media that can store program codes.
[0130] The above is only a specific implementation of the present application. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. The protection scope of the present application should be based on the protection scope of the claims.
Claims
1. An image processing method, characterized in that: include: Perform target detection in the image to be processed to obtain the target image; Inputting the image to be processed and the target picture into a layout adjustment prediction model to obtain a layout adjustment strategy of the target picture in the image to be processed; Adjusting the layout of the target picture in the image to be processed according to the layout adjustment strategy to obtain a processed image; The layout adjustment strategy includes a canvas adjustment parameter and a target picture adjustment parameter, and adjusting the layout of the target picture in the image to be processed according to the layout adjustment strategy includes: Adjusting the canvas of the image to be processed according to the canvas adjustment parameter; Adjusting the target picture in the image to be processed according to the target picture adjustment parameter; After adjusting the target picture, erasing pixels located at the edge of the target picture in the image to be processed; Fill the blank areas in the adjusted image; The layout adjustment prediction model includes: A first encoding module, used for inputting the image to be processed, encoding the image to be processed, and obtaining a feature vector of the image to be processed; A second encoding module, used for inputting the target picture, encoding the target picture, and obtaining a target picture feature vector; A conversion module, used for converting the feature vector of the image to be processed and the feature vector of the target picture into a combined feature vector; A decoding module is used to decode the combined feature vector to obtain the layout adjustment strategy.
2. The method according to claim 1, characterized in that Fill the blank area in the adjusted image to obtain a processed image, including: Performing noise processing on the adjusted image to obtain a noisy image; The noisy image is subjected to denoising processing to obtain a processed image.
3. The method according to claim 2, characterized in that The denoising process is performed on the noisy image to obtain a processed image, including: Performing denoising on the noisy image to obtain a denoised image; The denoised image and the adjusted image are subjected to image fusion processing to obtain a processed image.
4. The method according to any one of claims 1 to 3, characterized in that: The canvas adjustment parameters include canvas size adjustment parameters and / or canvas shape adjustment parameters, and adjusting the canvas of the image to be processed according to the canvas adjustment parameters includes: Adjusting the canvas size of the image to be processed according to the canvas size adjustment parameter; And / or, adjusting the canvas shape of the image to be processed according to the canvas shape adjustment parameter.
5. The method according to any one of claims 1 to 3, characterized in that: The target picture adjustment parameters include target picture posture adjustment parameters and / or target picture position adjustment parameters, and adjusting the target picture in the to-be-processed image according to the target picture adjustment parameters includes: Adjusting the posture of the target picture according to the target picture posture adjustment parameter; And / or, adjusting the position of the target picture in the image to be processed according to the target picture position adjustment parameter.
6. The method according to claim 5, characterized in that The target picture posture adjustment parameter includes a target picture scaling ratio and / or a target picture rotation angle, and adjusting the target picture posture according to the target picture posture adjustment parameter includes: Scaling the target image according to the scaling ratio of the target image; And / or rotating the target picture according to the rotation angle of the target picture.
7. An electronic device, characterized in that: include: processor; Memory; And a computer program, wherein the computer program is stored in the memory, and the computer program includes instructions, and when the instructions are executed by the processor, the electronic device executes the method according to any one of claims 1 to 6.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the method according to any one of claims 1 to 6.
