Image processing method and device, equipment and storage medium
By receiving the image template trigger operation in image processing, obtaining and identifying the subject cutout of the image material and its display position information, the problem of subject position offset is solved, the alignment of the subject object in the target image is achieved, and the image editing effect is improved.
Patent Information
- Application Number
- CN202510900107.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-30
- Publication Date
- 2025-10-17
AI Technical Summary
When the template is used to process the original image, the position of the subject in the generated image is easily offset, affecting the editing effect of the image.
By receiving the application trigger operation of the image template, the image material input by the user is obtained, and the subject is identified to obtain the subject cutout and its display position information, the image material is processed based on the editing operation information, the target image is generated, and the display position information of the subject cutout is used to align the subject object to the edited image material.
The position offset of the main object in the target image is reduced, improving the image editing effect.
Smart Images

Figure CN120807710A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data processing, and in particular to an image processing method, apparatus, device, and storage medium. Background Art
[0002] With the continuous development of image processing technology, more and more users prefer to use templates to process images. For example, they use templates to perform style transfer on the background of an original image to obtain an image with a similar style to the template. However, when using templates to process the original image, the position of the subject in the generated image may be offset from that in the original image, thus affecting the image editing effect.
[0003] Therefore, how to reduce the displacement of the subject position in the generated image to improve the image editing effect is a technical problem that needs to be solved urgently. Summary of the Invention
[0004] In order to solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides an image processing method, apparatus, device and storage medium.
[0005] In a first aspect, an embodiment of the present disclosure provides an image processing method, the method comprising:
[0006] Receiving an application trigger operation for a first image template and obtaining a first image material input by a user; wherein the first image template includes at least one type of editing operation information;
[0007] By performing subject recognition on the first image material, a subject cutout of the first image material is obtained, and display position information corresponding to the subject cutout is obtained; wherein the display position information is used to represent the display position of the subject cutout relative to the first image material, and the subject cutout includes the subject object of the first image material;
[0008] Processing the first image material according to the at least one editing operation information to obtain a second image material;
[0009] A target image is generated based on the second image material, the subject cutout, and display position information corresponding to the subject cutout.
[0010] In an optional implementation, the display position information includes width and height information of the main body cutout, width and height information of the first image material, and distance information of a target point in the main body cutout relative to an adjacent side of the first image material.
[0011] In an optional implementation, the generating the target image based on the second image material, the subject cutout, and the display position information corresponding to the subject cutout comprises:
[0012] obtaining width and height information of the second image material, and determining a size ratio relationship between the first image material and the second image material according to the width and height information of the first image material and the width and height information of the second image material;
[0013] scaling the subject cutout according to the size ratio relationship to obtain a scaled subject cutout;
[0014] generating a target image based on the distance information of the target point in the subject cutout relative to the adjacent edge of the first image material, the scaled subject cutout, and the second image material.
[0015] In an optional implementation, before the generating the target image based on the distance information of the target point in the subject cutout relative to the adjacent edge of the first image material, the scaled subject cutout, and the second image material, the method further comprises:
[0016] obtaining rotation angle information of the second image material, and performing rotation processing on the scaled subject cutout according to the rotation angle information to obtain a rotated subject cutout;
[0017] the generating the target image based on the distance information of the target point in the subject cutout relative to the adjacent edge of the first image material, the scaled subject cutout, and the second image material comprises:
[0018] generating a target image based on the distance information of the target point in the subject cutout relative to the adjacent edge of the first image material, the rotated subject cutout, and the second image material.
[0019] In an optional implementation, the obtaining the display position information corresponding to the subject cutout comprises:
[0020] in response to the first image template carrying a subject alignment identifier, obtaining the display position information corresponding to the subject cutout; wherein the subject alignment identifier is used to identify subject alignment processing performed on the subject cutout.
[0021] In an optional implementation, before the obtaining the subject cutout of the first image material by performing subject recognition on the first image material, the method further comprises:
[0022] determining whether the subject cutout of the first image material and the display position information corresponding to the subject cutout are stored in a cache;
[0023] The subject recognition is performed on the first image material to obtain a subject cutout of the first image material, and display position information corresponding to the subject cutout is obtained.
[0024] In response to the subject cutout of the first image material or the display position information corresponding to the subject cutout not being stored in the cache, the subject recognition is performed on the first image material to obtain a subject cutout of the first image material, and display position information corresponding to the subject cutout is obtained.
[0025] In an optional implementation, after the determination of whether the subject cutout of the first image material and the display position information corresponding to the subject cutout are stored in the cache, the method further includes:
[0026] In response to the subject cutout of the first image material being stored in the cache and the display position information corresponding to the subject cutout not being stored in the cache, the subject cutout of the first image material is deleted from the cache.
[0027] After the subject recognition is performed on the first image material to obtain a subject cutout of the first image material, and display position information corresponding to the subject cutout is obtained, the method further includes:
[0028] The subject cutout of the first image material and the display position information corresponding to the subject cutout are stored in the cache.
[0029] In an optional implementation, the receiving of the application trigger operation for the first image template and the obtaining of the first image material input by a user include:
[0030] In response to the application trigger operation for the first image template, a material collection page is displayed; at least one image material is displayed on the material collection page.
[0031] In response to a selection operation on the first image material on the material collection page, the first image material is obtained.
[0032] In a second aspect, the present disclosure provides an image processing device, and the device includes:
[0033] A first obtaining module is configured to receive an application trigger operation for a first image template, and obtain a first image material input by a user; the first image template includes at least one kind of editing operation information.
[0034] The second acquisition module is configured to acquire a subject cutout of the first image material and acquire display position information corresponding to the subject cutout by subject recognition on the first image material, wherein the display position information is used to represent a display position of the subject cutout relative to the first image material, and the subject cutout includes a subject object of the first image material.
[0035] The editing processing module is configured to process the first image material according to the at least one editing operation information to obtain a second image material.
[0036] The generation module is configured to generate a target image based on the second image material, the subject cutout and the display position information corresponding to the subject cutout.
[0037] In a third aspect, the embodiments of the present disclosure further provide an electronic device, which comprises a processor, a memory for storing executable instructions of the processor, and the processor is configured to read the executable instructions from the memory and execute the instructions to implement the image processing method provided by the embodiments of the present disclosure.
[0038] In a fourth aspect, the embodiments of the present disclosure further provide a computer readable storage medium, which stores a computer program, and the computer program is used to execute the image processing method provided by the embodiments of the present disclosure.
[0039] In a fifth aspect, the present disclosure provides a computer program product, which comprises computer programs / instructions, and the computer programs / instructions are executed by a processor to implement the above method.
[0040] Compared with the prior art, the technical solutions provided by the embodiments of the present disclosure have at least the following advantages:
[0041] In the image processing method provided by the embodiments of the present disclosure, first, an application trigger operation for a first image template is received, and a first image material input by a user is acquired, wherein the first image template includes at least one editing operation information; then, subject recognition is performed on the first image material to acquire a subject cutout of the first image material and display position information corresponding to the subject cutout, wherein the display position information corresponding to the subject cutout can be used to represent a display position of the subject cutout relative to the first image material; then, the first image material is processed based on the at least one editing operation information included in the first image template to obtain a second image material; further, a target image is generated based on the second image material, the subject cutout and the display position information corresponding to the subject cutout.
[0042] In the embodiments of the present disclosure, in the process of processing the first image material by using the first image template, the display position information of the main body cutout of the first image material relative to the first image material is obtained, and a target image is generated based on the display position information corresponding to the main body cutout, so that the display effect of aligning the main body object in the main body cutout to the main body object in the second image material can be realized. It can be seen that the present disclosure can reduce the case that the position of the main body object in the target image is offset, thereby improving the editing effect of the image. BRIEF DESCRIPTION OF DRAWINGS
[0043] The above-described and other features and advantages of various embodiments of the present disclosure will be more apparent from the following detailed description taken in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals are used to refer to the same or similar elements. It should be understood that the drawings are schematic and elements and features are not necessarily to scale.
[0044] Figure 1 A flowchart of an image processing method provided by an embodiment of the present disclosure;
[0045] Figure 2 A flowchart of another image processing method provided by an embodiment of the present disclosure;
[0046] Figure 3 A schematic diagram of a main body alignment processing provided by an embodiment of the present disclosure;
[0047] Figure 4 A structural schematic diagram of an image processing device provided by an embodiment of the present disclosure;
[0048] Figure 5 A structural schematic diagram of an image processing device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0049] Embodiments of the present disclosure will be described in more detail by making reference to the drawings. Although some embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms, and should not be interpreted as being limited to the embodiments set forth herein, rather, these embodiments are provided to make the present disclosure more thorough and complete. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes, and are not intended to limit the scope of protection of the present disclosure.
[0050] It should be understood that the various steps recorded in the method embodiments of the present disclosure can be executed in different orders, and / or in parallel. In addition, the method embodiments can include additional steps and / or omit the execution of the steps shown. The scope of the present disclosure is not limited in this respect.
[0051] As used herein, the term "includes" and its variants are to be read to be analogous to "comprises," "comprising," "has," "having," "includes" or "including." The term "based on" is to be interpreted as "based, at least in part, on." The term "one embodiment" means "at least one embodiment." The term "another embodiment" means "at least one additional embodiment." The term "some embodiments" means "at least some embodiments." Related definitions will be given in the description below.
[0052] It should be noted that the terms "first", "second", and the like in the present disclosure are merely used to distinguish different devices, modules or units, and do not imply the order or interdependence of the functions performed by these devices, modules or units.
[0053] It should be noted that the terms "one", "multiple" in the present disclosure are illustrative and not restrictive, and those skilled in the art should understand that "one" or "multiple" should be understood as "one or more" unless otherwise explicitly indicated in the context.
[0054] The names of the messages or information exchanged between the devices in the embodiments of the present disclosure are only for illustrative purposes, and are not used to limit the scope of the messages or information.
[0055] With the continuous development of image processing technology, more and more users prefer to use templates to process images, for example, using templates to perform style conversion processing on the background of an original image, etc., to obtain an image with similar style to the template. However, in the process of processing the original image using the template, there may be a case that the position of the subject in the generated image is offset relative to the position of the subject in the original image, thereby affecting the editing effect of the image.
[0056] Therefore, how to reduce the case that the position of the subject in the generated image is offset, so as to improve the editing effect of the image, is a technical problem to be solved at present.
[0057] To this end, an image processing method is provided in the embodiments of the present disclosure. First, an application trigger operation for a first image template is received, and a first image material input by a user is acquired, wherein the first image template includes at least one editing operation information; then, subject recognition is performed on the first image material to obtain a subject cutout of the first image material and display position information corresponding to the subject cutout, wherein the display position information corresponding to the subject cutout can be used to represent the display position of the subject cutout relative to the first image material; next, the first image material is processed based on the at least one editing operation information included in the first image template to obtain a second image material; further, a target image is generated based on the second image material, the subject cutout and the display position information corresponding to the subject cutout.
[0058] In the embodiments of the present disclosure, in the process of processing the first image material by using the first image template, the display position information of the main body cutout of the first image material relative to the first image material is obtained, and the target image is generated based on the display position information corresponding to the main body cutout, so that the display effect of aligning the main body object in the main body cutout to the main body object in the second image material can be realized. It can be seen that the embodiments of the present disclosure can reduce the situation that the position of the main body object in the target image is offset, thereby improving the editing effect of the image.
[0059] For ease of understanding, the embodiments of the present disclosure provide an image processing method, which can be executed by an image processing device. The device can be implemented by software and / or hardware, and can be integrated in an electronic device. For example, the device can be integrated in a mobile phone, a tablet computer, a personal computer, a server, etc. Figure 1 The embodiments of the present disclosure provide a flowchart of an image processing method, and the method includes the following steps.
[0060] S101: receiving an application trigger operation for a first image template, and obtaining a first image material input by a user.
[0061] The first image template includes at least one kind of editing operation information.
[0062] The video processing method provided by the embodiments of the present disclosure can be applied to a client, for example, the client can include a client deployed on a smart phone, a client deployed on a tablet computer, etc.
[0063] In the embodiments of the present disclosure, the first image template can be any image template displayed on a template display page. When receiving an application trigger operation of any image template by a user, the image template is determined as the first image template, and the first image material input by the user is obtained. The first image material can be any image material imported based on a material collection page.
[0064] The first image template includes at least one kind of editing operation information. The editing operation refers to various processing performed on the image material in the first image template, for example, processing such as enlarging, reducing, translating, rotating, style converting, etc. on the image material, or adding editing effect resources such as filters, stickers, subtitles, etc. to the image material.
[0065] In an optional implementation, in response to the application trigger operation for the first image template, the material collection page can be displayed first. Then, in response to a selection operation for the first image material on the material collection page, the first image material is obtained.
[0066] In the embodiments of the present disclosure, the material collection page can include a local album page or the like, and at least one image material can be displayed on the material collection page. When receiving a selection operation of a user on any image material, the image material is determined as a first image material, and the first image material is acquired.
[0067] In S102, a subject of the first image material is identified, a subject cutout of the first image material is acquired, and display position information corresponding to the subject cutout is acquired.
[0068] The display position information is used to represent a display position of the subject cutout relative to the first image material, and the subject cutout includes a subject object of the first image material.
[0069] In the embodiments of the present disclosure, after acquiring the first image material input by the user, the first image material is first subjected to subject identification to acquire a subject cutout of the first image material and acquire display position information corresponding to the subject cutout.
[0070] In actual applications, the first image can be subjected to subject identification by using an image processing algorithm, a convolutional neural network in deep learning, or the like, to determine a subject object in the first image material and perform cutout processing on the subject object to obtain the subject cutout of the first image material. The subject object can include a person subject, an animal subject, a plant subject, a building subject, or the like. For example, for an image material of a photograph of a person and a landscape, the person subject can be distinguished from the landscape by subject identification on the image material, as the subject cutout of the image material.
[0071] In the embodiments of the present disclosure, the display position information corresponding to the subject cutout can be used to represent the display position of the subject cutout relative to the first image material. Specifically, distance information of a center point in the subject cutout relative to an adjacent edge of the first image material can be determined as the display position information corresponding to the subject cutout.
[0072] Obviously, the display position of the subject cutout relative to the first image material does not change with scaling or rotation of the image, and therefore, the display position of the subject cutout relative to the first image material can be used to align the subject cutout to the edited second image material.
[0073] In an optional implementation, after acquiring the first image material input by the user, the first image material can be subjected to subject identification to acquire a subject cutout of the first image material and acquire display position information corresponding to the subject cutout, in response to the first image template carrying a subject alignment identifier.
[0074] In the embodiments of the present disclosure, the subject alignment identifier can be used to identify subject alignment processing for subject matting, that is, in the process of editing the first image material using the first image template, if it is determined that the first image template carries the subject alignment identifier, it means that the subject matting needs to be subjected to subject alignment processing, at which time the steps of obtaining the subject matting of the first image material and displaying the position information are continued.
[0075] In actual application, the "whether to align the subject" control can be set on the template publishing page, and the template creator can trigger the opening operation of the control during the process of publishing the first image template, so that the first image template carries the subject alignment identifier when it is published. In the subsequent application process of the first image template, in response to the first image template carrying the subject alignment identifier, the subject matting is subjected to subject alignment processing.
[0076] It can be seen that, in the process of processing the first image material by using the first image template, the subject alignment identifier carried in the first image template can be used to trigger the alignment processing of the subject matting, so as to realize the display effect of aligning the subject object in the subject matting to the subject object in the second image material.
[0077] S103: processing the first image material according to the at least one editing operation information to obtain a second image material.
[0078] In the embodiments of the present disclosure, after obtaining the first image material, the first image material is processed by using the at least one editing operation information carried in the first image template to obtain the second image material after editing, wherein the second image material has the same or similar display effect as the first image template, that is, the first image material input by the user is processed by using the at least one editing operation information in the first image template, so as to obtain the second image material with the editing effect of the first image template.
[0079] For example, assuming that the editing operation information in the first image template includes a preset multiple magnification processing of the image material, the second image material which is magnified by a preset multiple compared with the first image material can be obtained after processing the first image material based on the editing operation information.
[0080] S104: generating a target image based on the second image material, the subject matting, and the display position information corresponding to the subject matting.
[0081] In the embodiments of the present disclosure, after obtaining the subject matting, the display position information corresponding to the subject matting, and the second image material, a target image subjected to subject alignment is generated based on the second image material, the display position information, and the subject matting.
[0082] Since the display position information corresponding to the subject matting in the embodiments of the present disclosure can represent the display position of the subject matting relative to the first image material input by the user, the subject matting can be aligned to the corresponding position in the second image material by using the display position information in the process of superimposing the subject matting on the edited second image material, so as to realize the display effect of aligning the subject object in the subject matting to the subject object in the second image material.
[0083] In the image processing method provided by the embodiments of the present disclosure, first, an application trigger operation for a first image template is received, and a first image material input by a user is acquired, wherein the first image template includes at least one kind of editing operation information; then, subject recognition is performed on the first image material to acquire a subject matting of the first image material and display position information corresponding to the subject matting, wherein the display position information corresponding to the subject matting can be used to represent the display position of the subject matting relative to the first image material; next, the first image material is processed based on the at least one kind of editing operation information included in the first image template to obtain a second image material; further, a target image is generated based on the second image material, the subject matting, and the display position information corresponding to the subject matting.
[0084] In the embodiments of the present disclosure, in the process of processing the first image material by using the first image template, the display position information of the subject matting relative to the first image material is acquired, and the target image is generated based on the display position information corresponding to the subject matting, so as to realize the display effect of aligning the subject object in the subject matting to the subject object in the second image material. It can be seen that the embodiments of the present disclosure can reduce the situation that the position of the subject object in the target image is deviated, thereby improving the editing effect of the image.
[0085] In actual application, the display position information corresponding to the subject matting can include width and height information of the subject matting, width and height information of the first image material, and distance information of a target point in the subject matting relative to an adjacent edge of the first image material.
[0086] The target point in the subject matting can be located at the center, the top-left corner vertex, or the like of the subject matting. The distance information of the target point in the subject matting relative to the adjacent edge of the first image material can be used to describe the relative position relationship between the subject matting and the first image material, so that the subject object in the subject matting can be aligned to the subject object in the second image material by using the distance information of the target point in the subject matting relative to the adjacent edge of the first image material, to obtain the target image with the subject alignment.
[0087] For example, Figure 2As shown, a flowchart of another image processing method provided by the embodiments of the present disclosure is provided, and the method comprises the following steps of:
[0088] S201: In response to an application trigger operation for a first image template, a first image material input by a user is acquired.
[0089] The first image template comprises at least one editing operation information.
[0090] S202: A subject cutout of the first image material is acquired by subject recognition on the first image material, and display position information corresponding to the subject cutout is acquired.
[0091] The display position information is used to represent a relative position relationship between the subject cutout and the first image material.
[0092] In the embodiments of the present disclosure, in the process of subject recognition on the first image material input by the user, the subject cutout of the first image material, the width and height information of the subject cutout, the width and height information of the first image material, and the distance information of a target point in the subject cutout relative to the adjacent edge of the first image material are acquired.
[0093] S203: The first image material is processed based on the at least one editing operation information to obtain a second image material.
[0094] S204: The width and height information of the second image material is acquired, and the size proportion relationship between the first image material and the second image material is determined according to the width and height information of the first image material and the width and height information of the second image material.
[0095] In the embodiments of the present disclosure, after the first image material is processed by using the editing operation information in the first image template to obtain the second image material, the width and height information of the second image material is first acquired, and the size proportion relationship between the first image material and the second image material is determined according to the width and height information of the first image material and the width and height information of the second image material. The size proportion relationship can be used to represent the magnification or reduction multiple of the second image material relative to the first image material.
[0096] For example, assuming that the width and height of the first image material are 600*800 pixels, and the width and height of the second image material are 720*960 pixels, the size proportion relationship between the first image material and the second image material can be determined as 1:1.2, that is, the second image material is the image after the first image material is magnified by 1.2 times.
[0097] S205: The subject cutout is scaled according to the size proportion relationship to obtain a scaled subject cutout.
[0098] In actual applications, since the editing operation information of the first image template may include information such as scaling and style conversion, the size and visual style of the second image material obtained after scaling and style conversion of the first image material have changed. If the original size of the main cutout and the second image material are directly used to generate the image, the display position of the main object in the main cutout on the target image will be offset, thereby affecting the editing effect of the image.
[0099] To reduce the possibility of positional offset of the main object in the target image, the disclosed embodiments may also adaptively adjust the size of the main subject cutout after processing the first image material based on at least one editing operation information to obtain the second image material. Specifically, the main subject image may be scaled based on the size ratio between the first and second image materials to obtain a scaled main subject cutout, so that the scaled main subject cutout and the second image material can be used to subsequently generate the target image with the main subject aligned.
[0100] It can be seen that the embodiment of the present disclosure can utilize the size ratio relationship between the first image material and the second image material to scale the subject cutout, so that the subject object in the scaled subject cutout can be aligned with the subject object in the second image material, thereby obtaining a subject-aligned target image, further improving the image editing effect.
[0101] S206: Generate a target image based on the distance information of the target point in the subject cutout relative to the adjacent edge of the first image material, the scaled subject cutout and the second image material.
[0102] In the disclosed embodiment, after obtaining a scaled subject cutout image whose size ratio matches that of the second image material, a target image is generated based on the distance information of the target point in the subject cutout image relative to the adjacent edges of the first image material, the scaled subject cutout image, and the second image material. Specifically, based on the distance information of the target point in the subject cutout image relative to the adjacent edges of the first image material, the scaled subject cutout image is superimposed on the second image material to obtain the target image.
[0103] In the embodiment of the present disclosure, in the process of processing the first image material using the first image template, the distance information of the target point in the subject cutout relative to the adjacent edge of the first image material is obtained, and the subject cutout is scaled, so as to use the distance information to align the subject object in the scaled subject cutout to the second image material, thereby obtaining a subject-aligned target image.
[0104] In an alternative embodiment, the editing operation information of the first image template can further include rotation processing information, so that the display angle of the second image material obtained after the rotation processing of the first image material based on the editing operation information will change, and if the zoomed subject matte and the second image material are directly used for image generation, the display angle of the subject object in the zoomed subject matte and the target image will be inconsistent, thereby affecting the generation effect of the target image.
[0105] Therefore, in order to keep the display angle of the subject object in the zoomed subject matte and the target image consistent, after obtaining the second image material, the rotation angle of the zoomed subject matte can be adjusted to keep consistent with the rotation angle of the second image material.
[0106] In the embodiments of the present disclosure, the rotation angle information of the second image material is first obtained, and the zoomed subject matte is rotated based on the rotation angle information to obtain a rotated subject matte; then, the target image is generated based on the distance information of the target point in the subject matte relative to the adjacent edge of the first image material, the rotated subject matte, and the second image material.
[0107] In the embodiments of the present disclosure, the rotation angle of the zoomed subject matte is adjusted to keep consistent with the rotation angle of the second image material, so as to further improve the generation effect of the image. It can be seen that the embodiments of the present disclosure can reduce the situation that the position of the subject object in the target image is offset, thereby improving the editing effect of the image.
[0108] In actual application, in order to improve the efficiency of image processing, whether the subject matte of the first image material and the display position information corresponding to the subject matte are stored in the cache before the subject recognition of the first image material can be determined. If it is determined that the subject matte of the first image material and the display position information corresponding to the subject matte are stored in the cache, the subject matte and the display position information corresponding to the subject matte are directly obtained from the cache, thereby improving the processing efficiency of the image.
[0109] In actual application, if it is determined that any of the subject matte of the first image material and the display position information corresponding to the subject matte is not stored in the cache, for example, the subject matte of the first image material and the display position information corresponding to the subject matte are not stored in the cache, it indicates that the content in the cache can have been invalidated, and at this time, the subject recognition of the first image material needs to be performed again to obtain the subject matte of the first image material and the display position information corresponding to the subject matte.
[0110] In an embodiment of the present disclosure, in response to the fact that the main body cutout of the first image material or the display position information corresponding to the main body cutout is not stored in the cache, the main body cutout of the first image material and the display position information corresponding to the main body cutout are obtained by performing subject identification on the first image material.
[0111] It can be seen that in the embodiment of the present disclosure, when it is determined that any information of the subject cutout of the first image material and the display position information corresponding to the subject cutout is not stored in the cache, the subject cutout of the first image material and the display position information corresponding to the subject cutout are obtained by performing subject identification on the first image material, so that the display position information corresponding to the subject cutout can be used subsequently to align the subject object in the subject cutout to the subject object in the second image material to obtain the target image with subject alignment.
[0112] In actual applications, when the subject cutout of the first image material is stored in the cache and the display position information corresponding to the subject cutout is not stored, if the subject cutout of the first image material in the cache is directly used and the subject of the first image material is re-identified, the display position information corresponding to the obtained subject cutout may not match the subject cutout in the cache, thereby affecting the subsequent subject alignment effect.
[0113] Therefore, when it is determined that the cache stores the main body cutout of the first image material and does not store the display position information corresponding to the main body cutout, the embodiment of the present disclosure can first delete the main body cutout of the first image material from the cache to prevent the old cache from interfering with the subsequent main body alignment processing; then, by performing subject recognition on the first image material, obtain the main body cutout of the first image material and the display position information corresponding to the main body cutout; then, store the main body cutout of the first image material and the display position information corresponding to the main body cutout in the cache.
[0114] In an optional embodiment, if it is determined that the main body cutout of the first image material and the display position information corresponding to the main body cutout are not stored in the cache, the first image material is subject to identification to obtain the main body cutout of the first image material and the display position information corresponding to the main body cutout, and then the main body cutout of the first image material and the display position information corresponding to the main body cutout are stored in the cache, so that the main body cutout of the first image material and the display position information corresponding to the main body cutout can be directly obtained from the cache for subject alignment processing, thereby improving the efficiency of image processing.
[0115] like Figure 3 The figure shows a schematic diagram of a subject alignment process provided by an embodiment of the present disclosure, wherein the first image template carries a subject alignment identifier. After receiving an application trigger operation for the first image template and obtaining the first image material input by the user, the subject alignment of the target image can be achieved through the following steps:
[0116] ①subject recognition is performed on the first image material to determine a subject object in the first image material.
[0117] ②obtain a subject cutout in the first image material and display position information corresponding to the subject cutout.
[0118] The display position information corresponding to the subject cutout includes width and height information of the subject cutout, width and height information of the first image material, and distance information of a target point in the subject cutout relative to an adjacent edge of the first image material.
[0119] Then, the first image material is processed according to at least one kind of editing operation information in the first image template to obtain a second image material.
[0120] ③generate a target image based on the second image material, the subject cutout, and the display position information corresponding to the subject cutout.
[0121] Specifically, first, the size ratio relationship between the first image material and the second image material is determined according to the width and height information of the first image material and the width and height information of the second image material; then, the subject cutout is scaled according to the size ratio relationship to obtain a scaled subject cutout; and then, the target image is generated based on the display position of the subject cutout relative to the first image material, the scaled subject cutout, and the second image material.
[0122] It can be seen that, by obtaining the subject cutout of the first image material and the display position information of the subject cutout relative to the first image material, and generating a target image based on the display position information corresponding to the subject cutout, the display effect of aligning the subject object in the subject cutout to the subject object in the second image material can be achieved.
[0123] To achieve the above-mentioned embodiments, the present disclosure further provides an image processing device. Figure 4 A structural diagram of an image processing device provided by the embodiment of the present disclosure is shown in FIG. 1. The device can be realized by software and / or hardware, and can be integrated in an electronic device. As shown in FIG. 1, the device includes: Figure 4
[0124] The first obtaining module 401 is configured to receive an application trigger operation for a first image template, and obtain a first image material input by a user; wherein the first image template includes at least one kind of editing operation information.
[0125] The second acquisition module 402 is configured to acquire a subject cutout of the first image material by subject recognition on the first image material, and acquire display position information corresponding to the subject cutout; the display position information is used to represent a display position of the subject cutout relative to the first image material, and the subject cutout includes a subject object of the first image material.
[0126] The editing processing module 403 is configured to process the first image material based on the at least one editing operation information to obtain a second image material.
[0127] The generation module 404 is configured to generate a target image based on the second image material, the subject cutout, and the display position information corresponding to the subject cutout.
[0128] In an optional implementation, the display position information includes width and height information of the subject cutout, width and height information of the first image material, and distance information of a target point in the subject cutout relative to an adjacent edge of the first image material.
[0129] In an optional implementation, the generation module includes:
[0130] The determination sub-module is configured to acquire width and height information of the second image material, and determine a size proportion relationship between the first image material and the second image material according to the width and height information of the first image material and the width and height information of the second image material.
[0131] The scaling processing sub-module is configured to perform scaling processing on the subject cutout according to the size proportion relationship to obtain a scaled subject cutout.
[0132] The generation sub-module is configured to generate a target image based on the distance information of the target point in the subject cutout relative to the adjacent edge of the first image material, the scaled subject cutout, and the second image material.
[0133] In an optional implementation, the generation module includes:
[0134] The rotation processing sub-module is configured to acquire rotation angle information of the second image material, and perform rotation processing on the scaled subject cutout according to the rotation angle information to obtain a rotated subject cutout.
[0135] The generation sub-module is specifically configured to:
[0136] generate a target image based on the distance information of the target point in the subject cutout relative to the adjacent edge of the first image material, the rotated subject cutout, and the second image material.
[0137] In an alternative implementation, the second obtaining module comprises:
[0138] a subject identifying sub-module, configured to, in response to the first image template carrying a subject alignment identifier, obtain a subject cutout of the first image material by subject identifying the first image material; wherein the subject alignment identifier is used to identify subject alignment processing for the subject cutout.
[0139] In an alternative implementation, the apparatus further comprises:
[0140] a determining module, configured to determine whether the subject cutout of the first image material and display position information corresponding to the subject cutout are stored in the cache;
[0141] the second obtaining module comprises:
[0142] a first obtaining sub-module, configured to, in response to the subject cutout of the first image material or the display position information corresponding to the subject cutout not being stored in the cache, obtain the subject cutout of the first image material by subject identifying the first image material, and obtain the display position information corresponding to the subject cutout.
[0143] In an alternative implementation, the second obtaining module further comprises:
[0144] a deleting sub-module, configured to, in response to the subject cutout of the first image material being stored in the cache and the display position information corresponding to the subject cutout not being stored in the cache, delete the subject cutout of the first image material from the cache;
[0145] the apparatus further comprises:
[0146] a storing module, configured to store the subject cutout of the first image material and the display position information corresponding to the subject cutout in the cache.
[0147] the second obtaining module comprises:
[0148] a displaying sub-module, configured to, in response to an application trigger operation for the first image template, display a material set page;
[0149] a second obtaining sub-module, configured to, in response to a selection operation for the first image material on the material set page, obtain the first image material.
[0150] In the image processing apparatus provided by the embodiment of the present disclosure, first, an application trigger operation for a first image template is received, and a first image material input by a user is acquired, wherein the first image template comprises at least one editing operation information; then, subject recognition is performed on the first image material to acquire a subject cutout of the first image material and display position information corresponding to the subject cutout, wherein the display position information corresponding to the subject cutout can be used to represent a display position of the subject cutout relative to the first image material; then, the first image material is processed based on the at least one editing operation information included in the first image template to obtain a second image material; further, a target image is generated based on the second image material, the subject cutout and the display position information corresponding to the subject cutout.
[0151] In the embodiment of the present disclosure, in the process of processing the first image material by using the first image template, the subject cutout of the first image material and the display position information of the subject cutout relative to the first image material are acquired, and the target image is generated based on the display position information corresponding to the subject cutout, so that the display effect of aligning the subject object in the subject cutout to the subject object in the second image material can be realized. It can be seen that the embodiment of the present disclosure can reduce the situation that the position of the subject object in the target image is deviated, thereby improving the editing effect of the image.
[0152] In addition to the above method and device, the embodiment of the present disclosure further provides a computer readable storage medium, wherein instructions are stored in the computer readable storage medium, and when the instructions are run on a terminal device, the terminal device implements the image processing method provided by the embodiment of the present disclosure.
[0153] The embodiment of the present disclosure further provides a computer program product, wherein the computer program product comprises computer programs / instructions, and the computer programs / instructions are executed by a processor to implement the image processing method provided by the embodiment of the present disclosure.
[0154] In addition, the embodiment of the present disclosure further provides an image processing device, as shown in Figure 5 may comprise:
[0155] The processor 501, the memory 502, the input device 503 and the output device 504. The number of processors 501 in the image processing device can be one or more, Figure 5 In some embodiments of the present disclosure, the processor 501, the memory 502, the input device 503 and the output device 504 can be connected through a bus or other means, wherein, Figure 5 In some embodiments of the present disclosure, the processor 501, the memory 502, the input device 503 and the output device 504 can be connected through a bus or other means, wherein,
[0156] The memory 502 can be used to store software programs and modules, and the processor 501 executes various functional applications and data processing of the image processing device by running the software programs and modules stored in the memory 502. The memory 502 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, application programs required by at least one function, and the like. In addition, the memory 502 can include a high-speed random access memory, and can also include a non-volatile memory such as at least one magnetic disk storage device, a flash memory device, or other volatile solid-state memory device. The input device 503 can be used to receive input digital or character information, and generate signal input related to user settings and function control of the image processing device.
[0157] In particular in the present embodiment, the processor 501 loads the executable file corresponding to the process of one or more application programs into the memory 502 according to the following instructions, and runs the application programs stored in the memory 502 by the processor 501, thereby realizing the various functions of the image processing device described above.
[0158] It should be noted that in this paper, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between the entities or operations. Moreover, the terms "include", "contain" 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 not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or device. Without more limitations, the element defined by the statement "including a" does not exclude the presence of another identical element in the process, method, article or device including the element.
[0159] The above is only a specific embodiment of the present disclosure, enabling those skilled in the art to understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to these embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. An image processing method, characterized in that: The method comprises: Receiving an application trigger operation for a first image template and obtaining a first image material input by a user; wherein the first image template includes at least one type of editing operation information; By performing subject recognition on the first image material, a subject cutout of the first image material is obtained, and display position information corresponding to the subject cutout is obtained; wherein the display position information is used to represent the display position of the subject cutout relative to the first image material, and the subject cutout includes the subject object of the first image material; Processing the first image material according to the at least one editing operation information to obtain a second image material; A target image is generated based on the second image material, the subject cutout, and display position information corresponding to the subject cutout.
2. The image processing method according to claim 1, wherein: The display position information includes width and height information of the main body cutout, width and height information of the first image material, and distance information of a target point in the main body cutout relative to an adjacent side of the first image material.
3. The image processing method according to claim 2, wherein: The generating of the target image based on the second image material, the subject cutout, and the display position information corresponding to the subject cutout includes: Obtaining width and height information of the second image material, and determining a size ratio relationship between the first image material and the second image material based on the width and height information of the first image material and the width and height information of the second image material; Scaling the subject cutout according to the size ratio to obtain a scaled subject cutout; A target image is generated based on distance information of a target point in the subject cutout relative to an adjacent edge of the first image material, the scaled subject cutout, and the second image material.
4. The image processing method according to claim 3, wherein: Before generating the target image based on the distance information of the target point in the subject cutout relative to the adjacent edge of the first image material, the scaled subject cutout and the second image material, the method further includes: Obtaining rotation angle information of the second image material, and rotating the scaled main body cutout according to the rotation angle information to obtain a rotated main body cutout; The generating of the target image based on the distance information of the target point in the subject cutout relative to the adjacent edge of the first image material, the scaled subject cutout and the second image material includes: A target image is generated based on distance information of a target point in the subject cutout relative to an adjacent edge of the first image material, the rotated subject cutout, and the second image material.
5. The image processing method according to claim 1, wherein: The obtaining of display position information corresponding to the subject cutout includes: In response to the first image template carrying a subject alignment identifier, display position information corresponding to the subject cutout is acquired; wherein the subject alignment identifier is used to identify subject alignment processing to be performed on the subject cutout.
6. The image processing method according to claim 1, wherein: Before obtaining a main body cutout of the first image material by performing subject recognition on the first image material, the method further includes: Determining whether a main body cutout of the first image material and display position information corresponding to the main body cutout are stored in a cache; The step of performing subject recognition on the first image material, obtaining a subject cutout of the first image material, and obtaining display position information corresponding to the subject cutout includes: In response to the fact that the main body cutout of the first image material or the display position information corresponding to the main body cutout is not stored in the cache, the main body cutout of the first image material is obtained by performing subject recognition on the first image material, and the display position information corresponding to the main body cutout is obtained.
7. The image processing method according to claim 6, characterized in that: After determining whether the cache stores the main body cutout of the first image material and the display position information corresponding to the main body cutout, the method further includes: In response to the cache storing the main body cutout of the first image material and not storing the display position information corresponding to the main body cutout, deleting the main body cutout of the first image material from the cache; After performing subject recognition on the first image material, obtaining a subject cutout of the first image material, and obtaining display position information corresponding to the subject cutout, the method further includes: The main body cutout of the first image material and the display position information corresponding to the main body cutout are stored in the cache.
8. The image processing method according to claim 1, wherein: The receiving of the application triggering operation for the first image template and obtaining the first image material input by the user includes: In response to an application triggering operation for the first image template, displaying a material collection page; wherein the material collection page displays at least one image material; In response to a selection operation on a first image material on the material collection page, the first image material is acquired.
9. An image processing device, characterized in that: The device comprises: A first acquisition module is configured to receive an application trigger operation for a first image template and acquire a first image material input by a user; wherein the first image template includes at least one type of editing operation information; a second acquisition module, configured to obtain a subject cutout of the first image material by performing subject recognition on the first image material, and obtain display position information corresponding to the subject cutout; wherein the display position information is used to represent a display position of the subject cutout relative to the first image material, and the subject cutout includes the subject object of the first image material; an editing processing module, configured to process the first image material according to the at least one editing operation information to obtain a second image material; A generation module is used to generate a target image based on the second image material, the subject cutout and the display position information corresponding to the subject cutout.
10. An electronic device, characterized in that: The electronic device comprises: processor; a memory for storing instructions executable by the processor; The processor is configured to read the executable instructions from the memory and execute the instructions to implement the method according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that The storage medium stores a computer program, and the computer program is used to execute the method according to any one of claims 1 to 8.
12. A computer program product, characterized in that The computer program product comprises a computer program / instructions, which implement the method according to any one of claims 1 to 8 when executed by a processor.