Image processing method, device and equipment and computer readable storage medium

By stretching and interactively operating the image background area, the existing technology solves the problems of a single image processing method and difficult processing of complex special effects, improves the efficiency of image processing and user experience, and enhances the stickiness of social applications.

CN118625982APending Publication Date: 2024-09-10XIAOHONGSHU TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410664555.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-27
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

Existing image processing technology has a single special effect template method in social applications, and the image processing effect is poor. The threshold for non-professional users to adjust pixel parameters and add complex special effects is high and the efficiency is low, resulting in low user stickiness and poor traffic drainage.

Method used

By stretching the background area of ​​the image to be processed, the target image is generated, and interactive methods such as voice input and gesture operations are used to enhance the interactivity and richness of image processing, avoid stretching the subject, retain subject characteristics, and improve processing efficiency.

Benefits of technology

It improves the display effect and user experience of image processing, reduces the dependence on professional tools, improves the success rate and efficiency of image processing, and enhances user interaction perception and stickiness.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118625982A
    Figure CN118625982A
Patent Text Reader

Abstract

The embodiment of the invention discloses an image processing method and device, equipment and a computer readable storage medium. The method comprises the steps of receiving a to-be-processed image; the to-be-processed image comprises a first main body region and a first background region; in response to a target operation for the to-be-processed image, performing stretching processing on the first background region to obtain a first target image; a second main body region in the first target image is the same as a first main body region in the to-be-processed image, a second background region in the first target image is a stretched first background region, the second background region comprises a target pixel group, and the target pixel group is pixel points in any row or any column in the second background region; and if the pixel points associated with the main body in the first main body region exist in the extension direction of the target pixel group, the pixel value corresponding to the target pixel group is associated with the pixel value of the main body or the adjacent region of the main body in the to-be-processed image, so that the image processing modes can be enriched, and the image processing efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to an image processing method, apparatus, device and computer-readable storage medium. Background Art

[0002] Posting images in social applications has become a very common form of entertainment. In social applications, different special effects can be added to images according to different special effect templates to show different display effects. However, the special effect templates of existing images are to add new content to the original image, which is a single method and has poor image processing effects. At the same time, when users want to adjust the pixel parameters of the original image, or add more complex special effects to the image, more professional image processing tools are required. For ordinary non-professional users, the threshold is high, and the image processing efficiency and success rate are low. In addition, a single special effect template cannot meet the needs of users, resulting in poor drainage effect of social applications and low user stickiness to social applications. Summary of the invention

[0003] The embodiments of the present application provide an image processing method, apparatus, device, and computer-readable storage medium, which can enrich image processing methods and improve image processing efficiency.

[0004] The present application provides an image processing method, which includes:

[0005] Receive an image to be processed; the image to be processed includes a first main body area and a first background area; the first background area is an area of ​​the image to be processed other than the first main body area;

[0006] In response to a target operation on an image to be processed, a first background area is stretched to obtain a first target image; a second subject area in the first target image is the same as the first subject area in the image to be processed, the second background area in the first target image is the first background area after the stretching process, and the second background area includes a target pixel group, which is a pixel point in any row or any column in the second background area; if there are pixel points associated with a subject in the first subject area in an extension direction of the target pixel group, then the pixel value corresponding to the target pixel group is associated with the pixel value of the subject or an adjacent area of ​​the subject in the image to be processed.

[0007] An embodiment of the present application provides an image processing device, including:

[0008] The acquisition module is used to receive the image to be processed; the image to be processed includes a first main body area and a first background area; the first background area is the area of ​​the image to be processed except the first main body area;

[0009] A processing module is used to stretch a first background area in response to a target operation on an image to be processed to obtain a first target image; a second subject area in the first target image is the same as the first subject area in the image to be processed, the second background area in the first target image is the first background area after the stretching process, and the second background area includes a target pixel group, which is a pixel point in any row or any column in the second background area; if there are pixel points associated with a subject in the first subject area in an extension direction of the target pixel group, then the pixel value corresponding to the target pixel group is associated with the pixel value of the subject or an adjacent area of ​​the subject in the image to be processed.

[0010] Among them, the above-mentioned subjects include first-type subjects and second-type subjects; if there are pixel points associated with the first-type subjects in the first subject area in the extension direction of the target pixel group, the pixel values ​​corresponding to the target pixel group are associated with the pixel values ​​of the adjacent areas of the first-type subjects in the image to be processed; if there are pixel points associated with the second-type subjects in the first subject area in the extension direction of the target pixel group, the pixel values ​​corresponding to the target pixel group are associated with the pixel values ​​of the second-type subjects.

[0011] The processing module is used to display a template selection interface for the image to be processed, and to display a voice input control in the template selection interface;

[0012] The processing module is further used to obtain the voice data of the target operation object in response to the trigger operation on the voice input control, and obtain the recognition result based on the voice data; the recognition result includes the key information of the target operation, and the target operation object is the object that triggers the voice input control;

[0013] The processing module is further configured to perform stretching processing on the first background area in response to a recognition result containing key information of the target operation, so as to obtain a first target image.

[0014] Among them, the above-mentioned processing module is used to display a template selection interface for the image to be processed. When the template selection interface recognizes a gesture operation corresponding to the target operation, the first background area is stretched in response to the gesture operation to obtain the first target image.

[0015] The processing module is used to display a template selection interface for the image to be processed, and to display a target template corresponding to the target operation in the template selection interface;

[0016] The processing module is further configured to perform stretching processing on the first background area in response to a selection operation on the target template to obtain a first target image.

[0017] The above device further comprises:

[0018] A display module, used for displaying a template selection interface for the image to be processed, and displaying a restoration control in the template selection interface;

[0019] The processing module is used to restore the first target image in response to a trigger operation on the restoration control to obtain an image to be processed.

[0020] The display module is used to display a template selection interface for the image to be processed, and to display a switching control in the template selection interface;

[0021] The processing module is used to restore the second background area in the first target image and stretch the second main area in the first target image in response to a trigger operation on the switching control to obtain the second target image.

[0022] The acquisition module is used to acquire a mask image corresponding to the image to be processed; the mask image includes a third main body area and a third background area;

[0023] The processing module is used to determine the target pixel group to be sampled corresponding to the image to be processed based on the third main area and the third background area; the target pixel group to be sampled includes the position coordinates of N pixel points to be sampled, where N is a positive integer;

[0024] The processing module is further used to determine the pixel values ​​of the N pixels to be sampled based on the position coordinates of the N pixels to be sampled, and to stretch the image to be processed based on the pixel values ​​of the N pixels to be sampled to obtain a target effect image;

[0025] The above-mentioned processing module is also used to generate a first target image based on the image to be processed and the target effect image.

[0026] The acquisition module is used to perform subject recognition on the image to be processed to obtain a first subject area and a first background area;

[0027] The acquisition module is further used to set all pixel points in the first main body area to the first pixel value to obtain a third main body area;

[0028] The acquisition module is further used to set all pixel points in the first background area to the second pixel value to obtain a third background area;

[0029] The acquisition module is further used to determine the image to be processed including the third main body area and the third background area as a mask image.

[0030] The processing module is used to determine a target bounding box corresponding to the third subject area based on the third subject area and the third background area;

[0031] The above-mentioned processing module is further used to determine the target center point in the first main body area based on the target bounding box and the mask image;

[0032] The above processing module is further used to determine a target pixel group to be sampled corresponding to the image to be processed based on the target center point; the N pixel points to be sampled in the target pixel group to be sampled include the target center point.

[0033] Wherein, the first subject region includes the first type of subject;

[0034] The processing module is used to determine the initial center point corresponding to the third main body area based on the target bounding box, and obtain the initial position coordinates of the initial center point in the mask image;

[0035] The above-mentioned processing module is also used to determine the pixel point with the same position coordinates as the initial position coordinates in the image to be processed as the target pixel point, and offset the target pixel point by the target step size to obtain the target center point.

[0036] Wherein, the first subject region contains the second type of subject;

[0037] The processing module is used to determine the initial center point corresponding to the third main body area based on the target bounding box, and obtain the initial position coordinates of the initial center point in the mask image;

[0038] The above-mentioned processing module is also used to determine the pixel point with the same position coordinates as the initial position coordinates in the image to be processed as the target center point.

[0039] The processing module is used to determine the contour line of the third main body area based on the third main body area and the third background area, and determine the target pixel group to be sampled based on the contour line of the third main body area.

[0040] Wherein, the target rendering includes the fourth main body area;

[0041] The processing module is used to perform transparency processing on the first background area of ​​the image to be processed to obtain the image to be processed after transparency processing, and perform transparency processing on the fourth main area of ​​the target effect image to obtain the target effect image after transparency processing;

[0042] The processing module is further used to superimpose the image to be processed after the transparency processing and the target effect image after the transparency processing to obtain the first target image.

[0043] On the one hand, an embodiment of the present application provides a computer device, including: a processor, a transceiver, a memory, and a network interface;

[0044] The above-mentioned processor is connected to the transceiver, the memory, and the network interface, wherein the network interface is used to provide data communication function, the memory is used to store program code, and the processor and the transceiver are used to call the above-mentioned program code to execute the method provided in the embodiment of the present application.

[0045] On the one hand, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. The computer program is suitable for being loaded and executed by a processor so that a computer device having the processor executes the method provided by the embodiment of the present application.

[0046] In an embodiment of the present application, an image to be processed can be received, and the image to be processed includes a first main body area and a first background area, and the first background area is an area other than the first main body area in the image to be processed. Further, the first background area can be stretched in response to a target operation on the image to be processed to obtain a first target image. Among them, the second main body area in the first target image is the same as the first main body area in the image to be processed, the second background area in the first target image is the first background area after stretching, and the second background area includes a target pixel group, and the target pixel group is a pixel point in any row or any column in the second background area; if there are pixels associated with the subject in the first main body area in the extension direction of the target pixel group, the pixel value corresponding to the target pixel group is associated with the pixel value of the subject or the adjacent area of ​​the subject in the image to be processed. It can be seen that by the image processing method of stretching the first background area, the display effect of image processing can be increased and the image processing method can be enriched. In addition, the above-mentioned stretching process can avoid stretching the subject, so as to achieve the effect of retaining the subject and stretching the background, and the observability is better, and there is no need to repeatedly debug with the help of other image processing tools, which improves the success rate of image processing and thus improves the efficiency of image processing. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] Figure 1 It is a structural diagram of a network architecture provided by an embodiment of the present application;

[0048] Figure 2 is a schematic diagram of a scenario of the image processing method provided by an embodiment of the present application;

[0049] Figure 3 is a flow chart of an image processing method provided by an embodiment of the present application;

[0050] Figure 4 is a schematic diagram of an image to be processed provided by an embodiment of the present application;

[0051] Figure 5 is another flowchart of the image processing method provided by an embodiment of the present application;

[0052] Figure 6 is a schematic diagram of a mask image provided in an embodiment of the present application;

[0053] Figure 7 is another schematic diagram of a scenario of the image processing method provided in an embodiment of the present application;

[0054] Figure 8 is a structural schematic diagram of an image processing device provided in an embodiment of the present application;

[0055] Fig. 9 It is a structural schematic diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0056] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0057] The implementation of the technical solution of the present application is further described in detail below in conjunction with the accompanying drawings.

[0058] See also Figure 1 , Figure 1 Schematic diagram of a network architecture provided by an embodiment of the present application. Figure 1 As shown, the system architecture may include a business server 100 and a terminal cluster, and the terminal cluster may include: terminal devices 200a, terminal device 200b, terminal device 200c, ..., terminal device 200n, etc. Among them, the above-mentioned business server 100 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud database, cloud service, cloud computing, cloud function, cloud storage, network service, cloud communication, middleware service, domain name service, security service, CDN, and big data and artificial intelligence platform.

[0059] Among them, the above-mentioned business server 100 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud database, cloud service, cloud computing, cloud function, cloud storage, network service, cloud communication, middleware service, domain name service, security service, CDN, as well as big data and artificial intelligence platform.

[0060] Among them, the terminal device (including terminal device 200a, terminal device 200b, terminal device 200c, ..., terminal device 200n) can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a PDA, a wearable device (such as a smart watch, a smart bracelet, etc.), a smart TV, a smart car and other smart terminals. Among them, the business server 100 can establish a communication connection with each terminal device in the terminal cluster, and a communication connection can also be established between each terminal device in the terminal cluster. In other words, the business server 100 can establish a communication connection with each terminal device in the terminal device 200a, terminal device 200b, terminal device 200c, ..., terminal device 200n, for example, a communication connection can be established between the terminal device 200a and the business server 100. A communication connection can be established between the terminal device 200a and the terminal device 200b, and a communication connection can also be established between the terminal device 200a and the terminal device 200c. Among them, the above-mentioned communication connection does not limit the connection method, and can be directly or indirectly connected through a wired communication method, or directly or indirectly connected through a wireless communication method, etc. The specific method can be determined according to the actual application scenario, and this application does not make any restrictions here.

[0061] It should be understood that Figure 1 Each terminal device in the terminal cluster shown may be installed with an application client, and when the application client runs in each terminal device, the service server 100 may exchange data with each terminal device. For example, the terminal device may send service data, such as an image to be processed, to the service server 100, and the service server 100 may identify the first subject area and the first background area included in the image to be processed, and then the service server 100 may perform subsequent processing on the first subject area and the first background area (for example, stretching the first background area, etc.).

[0062] Among them, the application client can be an application client with the function of displaying data information such as text, images, audio and video, such as a picture beautification application, a live broadcast application, a social application, an instant messaging application, a game application, a short video application, a video application, a music application, a shopping application, a novel application, a payment application, a browser, etc. For example, the application client can be an entertainment application, which can be used by users to upload pictures or videos and obtain special effect pictures or special effect videos with special effects (for example, sticker effects, animation effects, magnification effects, etc.), and the application client can also be a picture beautification application, which can be used by users to upload pictures or videos and obtain beautified pictures or beautified videos with beautification effects (for example, face-lifting effects, etc.). The business server 100 in this application can collect business data from the terminal device, such as the business data can be pictures uploaded by users, etc. The business server 100 can identify the first main area and the first background area of ​​the image to be processed from these business data, and the business server 100 can perform subsequent processing on the first main area and the first background area (for example, stretching the first background area, etc.).

[0063] Optionally, the data involved in the embodiments of the present application can be stored in a computer device, or the data can be stored based on cloud storage technology, which is not limited here. The above data can be used to store application data generated by the application client, business data uploaded by the user through the application client, and various configuration information set by the user for the personal account, etc., which is not limited here.

[0064] See also Figure 2 , Figure 2 1 is a schematic diagram of a scenario of the image processing method provided by the embodiment of the present application. The implementation process of the image processing method can be performed in a service server, in a terminal device, or interactively in a terminal device and a service server, which is not limited here.

[0065] like Figure 2As shown, the target operation object has a binding relationship with the terminal device 200b. For example, the target operation object can log in to a personal account through an application client loaded on the terminal device 200b. After logging in to the personal account, the target operation object can upload the image to be processed through the application client. The terminal device 200b can receive the image to be processed and upload the image to be processed to the business server 100. The business server 100 can input the image to be processed into the subject segmentation model, and identify the first subject area and the first background area of ​​the image to be processed through the subject segmentation model, so as to obtain a mask image corresponding to the image to be processed. Among them, the first background area is the area other than the first subject area in the image to be processed. Further, the business server 100 can no longer consider the first subject area, and only process the first background area, such as stretching, to obtain the first target image. Further, the business server 100 can return the first target image to the terminal device 200b, and the target operation object can view the first target image obtained after the first background area is stretched in the display interface of the terminal device 200b.

[0066] See also Figure 3 , Figure 3 1 is a flow chart of an image processing method provided in an embodiment of the present application. For ease of understanding, the present application embodiment is described by taking a terminal device as an example. Figure 1 The terminal device 200b in the example is described. The embodiments of the present application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, software development, etc. Figure 2 In the image processing method shown in FIG. 1 , each step of the plug-in generation method can be performed by Figure 1 The terminal device 200b in the embodiment is used to execute, for example Figure 3 As shown, the image processing method may at least include the following steps S101-S102.

[0067] Step S101, receiving an image to be processed; the image to be processed includes a first main body area and a first background area; the first background area is an area of ​​the image to be processed other than the first main body area.

[0068] In some possible implementations, Figure 2 The terminal device 200b shown may store some image files in advance, and may select an image file from the pre-stored image files as the image to be processed. For example, the terminal device 200b may run a photo application, and thus select an image file in the photo application as the image to be processed.

[0069] Optionally, the image to be processed may also be a terminal object (i.e., a user, such as Figure 2The target operation object shown in the figure) is an image file uploaded or photographed in real time by an application client loaded on the terminal device 200b.

[0070] Optionally, the terminal device 200b can obtain an image file stored in the cloud as the initial image through the application client. Exemplarily, the terminal device 200b can run a web browsing application, which can have an image file. Thus, the terminal device 200b can obtain the image file in the web browsing application as the image to be processed.

[0071] Optionally, the image to be processed may be a file in png format, jepg format or png format, etc., or may be a file in gif format, which is not specifically limited in the embodiment of the present application.

[0072] Furthermore, if Figure 2 As shown, the terminal device 200b can detect and collect the image uploaded by the target operation object through the business server 100, and then identify the area to which the subject belongs in the image to be processed, that is, the first subject area, and the area other than the first subject area, that is, the first background area, through the business server 100. Subsequently, the terminal device 200b can stretch the first background area through the business server 100, so as to obtain the first target image.

[0073] Step S102, in response to the target operation on the image to be processed, stretching the first background area to obtain the first target image; the second subject area in the first target image is the same as the first subject area in the image to be processed, the second background area in the first target image is the first background area after the stretching process, and the second background area includes a target pixel group, and the target pixel group is the pixel points of any row or any column in the second background area; if there are pixel points associated with the subject in the first subject area in the extension direction of the target pixel group, then the pixel value corresponding to the target pixel group is associated with the pixel value of the subject or the adjacent area of ​​the subject in the image to be processed.

[0074] In some feasible embodiments, the subject includes a first type of subject and a second type of subject; if there are pixel points associated with the first type of subject in the first subject area in the extension direction of the target pixel group, the pixel value corresponding to the target pixel group is associated with the pixel value of the adjacent area of ​​the first type of subject in the image to be processed; if there are pixel points associated with the second type of subject in the first subject area in the extension direction of the target pixel group, the pixel value corresponding to the target pixel group is associated with the pixel value of the second type of subject.

[0075] Among them, the pixel value can represent the color corresponding to the pixel. Optionally, the pixel value can include the color values ​​of the red (Red), green (Green), blue (Blue) and transparency (Alpha) channels. Among them, transparency can represent the transparency of each pixel. In an example, the value range of transparency is [0, 1]. The larger the transparency value, the lower the transparency it represents. For example, a transparency value of 0 indicates complete transparency, a transparency value of 1 indicates complete opacity, and a transparency value greater than 0 and less than 1 indicates semi-transparency.

[0076] In order to distinguish from the following text, the subject area and the background area in the image to be processed are respectively recorded as the first subject area and the first background area. The first subject area refers to the area corresponding to the subject in the image to be processed, and the first background area refers to the other areas in the image to be processed except the first subject area.

[0077] It should be understood that, in order to distinguish from the image to be processed, the subject area and the background area of ​​the first target image are respectively recorded as the second subject area and the second background area. The second subject area is the same as the first subject area in the image to be processed, and the second background area in the first target image is the first background area after stretching.

[0078] In order to distinguish the subject, the subject can be divided into a first type of subject and a second type of subject. The first type of subject can be a human figure, and the second type of subject can be an object, or the first type of subject can be an object, and the second type of subject can be a human figure. For the convenience of description, the first type of subject mentioned below is a human figure, and the second type of subject is an object.

[0079] For example, see Figure 4 , Figure 4 It is a schematic diagram of an image to be processed provided in an embodiment of the present application. Figure 4 3a in FIG. 3 includes a first subject area 301 and a first background area 302. The first background area 302 is an area other than the first subject area 301 in the image to be processed. Figure 4 3b in FIG. 3 includes a first subject area 303 and a first background area 304. The first background area 304 is an area other than the first subject area 303 in the image to be processed.

[0080] It should be understood that the second type of subject can be Figure 4 The first type of subject can be the object shown in 3a of Figure 4 The portrait shown in 3b is not specifically limited in this embodiment of the application.

[0081] It should be understood that the embodiment of the present application does not limit the number of the first body regions. In other words, the embodiment of the present application does not limit the number of the body. Exemplarily, the number of the first body regions can be multiple, that is, the body can be multiple first-type bodies, or multiple second-type bodies, or multiple first-type bodies and multiple second-type bodies, and the embodiment of the present application does not make specific limitations.

[0082] For example, see Figure 4 3c and 3d shown, Figure 4 3c in FIG. 3 is the first target image obtained after the first background area 302 in the image to be processed 3a is stretched. Figure 4 The first target image shown in 3 c includes a second subject area 305 and a second background area 306 . Figure 4 The second background area 306 in the first target image shown in 3c in FIG. 3 includes a target pixel group, and the target pixel group can be pixel points in any row or any column in the second background area 306, such as Figure 4 The target pixel group 309 is shown in 3c.

[0083] The extension direction of the target pixel group 309 may be a straight line formed by the pixels included in the target pixel group 309, such as Figure 4 As shown in 3c, pixel A and pixel B are pixel points existing in the extension direction of the target pixel group, and pixel B is a pixel point associated with the subject in the first subject area, that is, pixel points associated with the second type of subject (such as an object) in the first subject area exist in the extension direction of the target pixel group 309. At this time, the pixel value corresponding to the target pixel group 309 is associated with the pixel value of the second type of subject in the image to be processed 3a.

[0084] Similarly, Figure 4 The 3D in the Figure 4 The first target image is obtained after the first background area 304 in 3b is stretched. Figure 4 The first target image shown in 3d in FIG. 3 includes a second subject area 307 and a second background area 308 . Figure 4 The second background area 308 in the first target image shown in 3d in FIG. 3 includes a target pixel group, and the target pixel group can be pixel points in any row or any column in the second background area 308, such as Figure 4 The target pixel group 310 is shown in 3d.

[0085] The extension direction of the target pixel group 310 may be a straight line formed by the pixels included in the target pixel group 310, such as Figure 4As shown in 3d in FIG. 3, pixel point C and pixel point D are pixel points existing in the extension direction of the target pixel group, and pixel point D is a pixel point associated with the subject in the first subject area, that is, there are pixel points associated with the first type of subject (such as a portrait) in the first subject area in the extension direction of the target pixel group 310. At this time, the pixel value corresponding to the target pixel group 310 is Figure 4 The pixel values ​​of the neighboring areas of the first type of subject in 3b are associated.

[0086] Optionally, if there are no pixels associated with the subject in the first subject area in the extension direction of the target pixel group, the pixel values ​​corresponding to the target pixel group are associated with the pixel values ​​of the subject or an adjacent area of ​​the subject in the image to be processed.

[0087] Specifically, if there are no pixel points associated with the first type of subject in the first body area in the extension direction of the target pixel group, the pixel values ​​corresponding to the target pixel group are associated with the pixel values ​​of the adjacent area of ​​the first type of subject in the image to be processed; if there are no pixel points associated with the second type of subject in the first body area in the extension direction of the target pixel group, the pixel values ​​corresponding to the target pixel group are associated with the pixel values ​​of the second type of subject.

[0088] It can be seen that when performing the stretching operation, the stretching is performed based on the pixel value of the subject in the first subject area or the adjacent area of ​​the subject, so it has the advantage of color harmony and can ensure the stretching effect of the first target image.

[0089] The specific steps of obtaining the first target image can be found in Figure 5 , Figure 5 is another flow chart of the image processing method provided in the embodiment of the present application. The image processing method can be applied to Figure 2 The terminal device shown, for example, the terminal device 200b can be used as the execution subject of the image processing method, as shown in steps S201 to S204.

[0090] Step S201, obtaining a mask image corresponding to the image to be processed; the mask image includes a third main body area and a third background area.

[0091] In some possible implementations, such as Figure 2 The terminal device 200b shown can perform subject recognition on the image to be processed through the service server 100 to obtain the first subject area and the first background area. Further, the terminal device 200b can set all the pixels in the first subject area to the first pixel value to obtain the third subject area, and set all the pixels in the first background area to the second pixel value to obtain the third background area. Further, the terminal device 200b can determine the image to be processed including the third subject area and the third background area as a mask image.

[0092] It should be understood that in order to facilitate the subsequent stretching of the background area, the mask image corresponding to the image to be processed can be first obtained, so that the mask image can be directly called later. Among them, the mask image can be used to operate the specified area in the image without affecting the area other than the specified area in the image.

[0093] In some feasible implementations, a mask image corresponding to the image to be processed may be obtained through a subject segmentation model, wherein the subject segmentation model may identify the region to which the subject belongs in the input image to be processed, and segment the image to be processed into a first subject region and a first background region based on the region to which the subject belongs, thereby obtaining a mask image corresponding to the image to be processed.

[0094] It should be understood that in the embodiment of the present application, the subject segmentation model can be trained in advance with sample images to optimize the subject segmentation model and increase the accuracy of the prediction results output by the subject segmentation model. Wherein, the sample image may include a sample object (e.g., a portrait, an animal, etc.), then the first subject area may be the area where the sample object is located in the sample image identified by the subject segmentation model, that is, the first subject area may be the area surrounded by the boundary of the sample object. For example, Figure 4 At this time, the area other than the area surrounded by the boundary of the sample object in the image to be processed can be the background area, that is, Figure 4 The first background area 302 is shown in 3a in FIG.

[0095] In some embodiments, the subject segmentation model can be implemented based on the u2net algorithm, or the subject segmentation model can be a fully convolutional network (FCN), or a SegNet model, which is not limited in the embodiments of the present application. Among them, the u2net algorithm is an image segmentation network algorithm based on the UNet structure.

[0096] In some embodiments, the subject of the image to be processed can be identified by using a target detection algorithm to obtain subject position information, and the image to be processed can be segmented into a first subject area and a first background area based on the subject position information, thereby obtaining a mask image corresponding to the image to be processed.

[0097] It should be understood that the embodiment of the present application does not limit the method of identifying the first main area and the first background area of ​​the image to be processed.

[0098] In some embodiments, the mask image can be a binary or Boolean image of the same size as the image to be processed. The terminal device 200b can determine the area to which the subject belongs as the selected area through the business server 100, that is, set all pixels in the first subject area to the first pixel value to obtain the third subject area, and set all pixels in the first background area to the second pixel value to obtain the third background area.

[0099] For example, the terminal device 200b can set all pixels in the first main area to 1 (or True) and all pixels in the first background area to 0 (or False) through the service server 100. At this time, the selected area can be processed without affecting other areas.

[0100] In order to distinguish it from the image to be processed, the area to which the subject belongs in the mask image can be recorded as the third subject area, and the remaining area (i.e., the area other than the first subject area in the image to be processed) can be recorded as the third background area. It can be understood that visually, the third subject area in the mask image can be one color, and the third background area can be another color.

[0101] Further, the terminal device 200 b may determine the image to be processed including the third subject area and the third background area as a mask image through the service server 100 .

[0102] For example, see Figure 6 , Figure 6 is a schematic diagram of a mask image provided in an embodiment of the present application. Figure 6 The 4a in Figure 4 The mask image corresponding to 3a in , Figure 6 The 4b in is Figure 4 The mask image corresponding to 3b in .

[0103] in, Figure 6 4a in the figure includes a third main body area 401 and a third background area 402, Figure 6 4b in FIG. 4 includes a third main body area 403 and a third background area 404 .

[0104] It should be understood that when the image to be processed includes multiple subjects, that is, when the image to be processed includes multiple first subject areas, the mask image corresponding to the image to be processed also includes multiple subjects. In other words, the mask image corresponding to the image to be processed also includes multiple third subject areas.

[0105] Step S202: determining a target pixel group to be sampled corresponding to the image to be processed based on the third main area and the third background area; the target pixel group to be sampled includes position coordinates of N pixel points to be sampled, where N is a positive integer.

[0106] Specifically, Figure 2 The terminal device 200b can determine the target bounding box corresponding to the third subject area based on the third subject area and the third background area through the service server 100.

[0107] For details, please refer to Figure 6 As shown in 4c and 4d, the terminal device 200b can determine the contour of the subject based on the third subject area and the third background area through the service server 100, and then determine the target bounding box according to the contour. It should be understood that the target bounding box can be the minimum rectangle containing all pixels in the third subject area.

[0108] Further, the terminal device 200b may determine the target center point in the first subject area based on the target bounding box and the mask image through the service server 100 .

[0109] Among them, the terminal device 200b can also identify the subject included in the first subject area in the image to be processed based on the subject segmentation model through the business server 100. If the first subject area contains the first type of subject, the subject in the first subject area is a portrait; if the first subject area contains the second type of subject, the subject in the first subject area is an object.

[0110] It can be seen that according to the subjects contained in the first subject area, it can be divided into manned scenes and unmanned scenes, that is, when the first subject area contains the first type of subject, it is a manned scene, and when the first subject area does not contain the first subject type, that is, when the first subject area contains the second type of subject, it is an unmanned scene.

[0111] In some feasible implementations, when the first subject area includes the first type of subject, the terminal device 200b can determine the initial center point corresponding to the third subject area based on the target bounding box through the business server 100, and obtain the initial position coordinates of the initial center point in the mask image.

[0112] Specifically, Figure 6 As shown in 4d, when the position coordinates of the pixel point corresponding to any vertex of the target bounding box and the length and width of the target bounding box are known, the initial center point corresponding to the third main area can be determined, and then the terminal device 200b can obtain the initial position coordinates of the initial center point in the mask image through the business server 100.

[0113] For example, if the position coordinates of the pixel point in the lower left corner of the target bounding box are (a, b), and the length and width of the target bounding box are c and d respectively, then the initial position coordinates of the initial center point are

[0114] It should be understood that since the mask image is a binary or Boolean image of the same size as the image to be processed, the pixels in the mask image have a one-to-one correspondence with the pixels in the image to be processed. It can be seen that when the position coordinates of any pixel in the mask image are known, the corresponding position of the pixel in the image to be processed can be determined.

[0115] Please also see Figure 4 3b and Figure 6 In 4d, the terminal device 200b can determine through the business server 100 that the initial center point corresponding to the third main body area based on the target bounding box is located on the torso of the portrait. Therefore, when the image to be processed is subsequently stretched, the color on the torso will be used for stretching. This will cause a large area in the background area of ​​the first target image to have the same color as the torso, making it impossible to distinguish between the main body area and the background area, resulting in a poor stretching effect.

[0116] Therefore, the terminal device 200b can determine the pixel point with the same position coordinates as the initial position coordinates in the image to be processed as the target pixel point through the service server 100, and offset the target pixel point by the target step length to obtain the target center point.

[0117] For example, in a human scene, that is, when the first subject area includes the first type of subject, the terminal device 200b can shift the target pixel point to the right by the first step length through the service server 100. At this time, the target step length is the first step length, such as 20 pixels. If the target pixel point after the first step length shift has avoided the human portrait and does not exceed the right boundary of the image to be processed, the target pixel point after the first step length shift can be determined as the target center point.

[0118] Optionally, when the target pixel point after the first step of shifting exceeds the right boundary of the image to be processed, the target pixel point can be shifted to the left by the second step, and at this time, the target step is the second step, such as 10 pixels. If the target pixel point after the second step of shifting has avoided the portrait and does not exceed the left boundary of the image to be processed, the target pixel point after the second step of shifting can be determined as the target center point.

[0119] Optionally, when the target pixel point after the second step shift exceeds the left boundary of the image to be processed, the position coordinate corresponding to the target pixel point after the second step shift is marked as pos_x, and the absolute value of pos_x can be taken, and pos_x after taking the absolute value is used as the target center point.

[0120] For example, see Figure 43a in the figure, take the lower left corner of the image to be processed as the origin of the coordinates, record it as the origin O, start from the origin of the image to be processed, take the horizontal right direction as the positive direction of the x-axis, take the vertical upward direction as the positive direction of the y-axis, and you can get the coordinate system for the image to be processed. At this time, if the position coordinate pos_x corresponding to the target pixel point after the second step is offset is (-3, 6), the absolute value of pos_x can be taken to get (3, 6), and the pixel point with the position coordinate (3, 6) is determined as the target center point.

[0121] It should be understood that the embodiments of the present application do not limit the direction and value of the target step size, nor do they limit the number of times the target pixel point is offset.

[0122] In some feasible implementations, when the first subject area includes the second type of subject and in an unmanned scene, the terminal device 200b can determine the initial center point corresponding to the third subject area based on the target bounding box through the service server 100, and obtain the initial position coordinates of the initial center point in the mask image. Further, the terminal device 200b can determine the pixel point in the image to be processed that has the same position coordinates as the initial position coordinates as the target center point through the service server 100.

[0123] It should be understood that when the first subject area includes the second type of subject and there is no human scene, the pixel point having the same position coordinates as the initial position coordinates can be directly determined as the target center point.

[0124] Optionally, when the stretching effect of the first target image does not meet expectations, the pixel points in the image to be processed that have the same position coordinates as the initial position coordinates can be determined as target pixel points, and the target pixel points offset by the target step can be used as target center points to adjust the stretching effect of the first target image. The specific process can be found in the process of determining the target center point in the presence of a person, which will not be elaborated here.

[0125] Furthermore, the terminal device 200b can determine the target pixel group to be sampled corresponding to the image to be processed based on the target center point through the service server 100. The N pixel points to be sampled in the target pixel group to be sampled include the target center point.

[0126] For example, when the position coordinates of the target center point are (e, f), the terminal device 200b can determine the target pixel group to be sampled as x=e based on the target center point (e, f) through the service server 100. At this time, the stretching effect of the image to be processed can be seen in Figure 4 As shown in Figure 3c, when the target pixel group to be sampled is a vertical line, the stretching effect of the image to be processed is horizontal stretching.

[0127] Exemplarily, when the position coordinates of the target center point are (e, f), the terminal device 200b can determine the target pixel group to be sampled as y=f based on the target center point (e, f) through the service server 100. At this time, the stretching effect of the image to be processed is vertical stretching.

[0128] It should be understood that in order to ensure the diversity of stretching effects, the target pixel group to be sampled can also be a slant line, a curve, or a fitting curve, etc., and this application does not limit this.

[0129] Optionally, the terminal device 200b may determine the contour line of the third subject area based on the third subject area and the third background area through the service server 100, and determine the target pixel group to be sampled based on the contour line of the third subject area.

[0130] It should be understood that the terminal device 200b can determine the contour line of the third body area based on the body segmentation model through the business server 100, and then determine the target pixel group to be sampled based on the contour line that divides the third body area and the third background area, such as determining part of the contour line as the target pixel group to be sampled, or determining the contour line after offsetting the target step size as the target pixel group to be sampled. The present application does not impose any restrictions on this.

[0131] Step S203: Determine the pixel values ​​of the N pixels to be sampled based on their position coordinates, and perform stretching processing on the image to be processed based on the pixel values ​​of the N pixels to be sampled to obtain a target effect image.

[0132] Specifically, the terminal device 200b can sample the image to be processed through the service server 100 to obtain the position coordinates (u, v) and pixel values ​​of each pixel in the image to be processed. The pixel values ​​can be RGB values, and different pixel values ​​will display different colors.

[0133] Furthermore, the terminal device 200b can fill the background area of ​​the image to be processed according to the pixel values ​​of the N pixels to be sampled through the service server 100 to obtain a stretching effect.

[0134] For example, Figure 4 The lateral stretching effect shown in 3c in FIG. 3c can be seen. If the position coordinates of the target center point are (e, f), and the target pixel group to be sampled is a vertical line, such as the target pixel group to be sampled can be a pixel point on the straight line where x=e, then the terminal device 200b can obtain the pixel values ​​of the N pixel points to be sampled included in the target pixel group to be sampled according to the texture2D function through the business server 100, and fill the first background area in the image to be processed according to the pixel values ​​of the N pixel points to be sampled to obtain the target effect diagram.

[0135] For example, the horizontal coordinate of the target center point is marked as bodyCenter.x, the image to be processed is recorded as srcImg, and the target effect image is recorded as res=texture2D(srcImg, vec2(bodyCenter.x, uv.y)). Among them, texture2D(srcImg, vec2(bodyCenter.x, uv.y)) can represent obtaining the pixel value from the position (bodyCenter.x, uv.y) of the image to be processed srcImg. Among them, uv.y represents the vertical coordinate of the pixel point, and (bodyCenter.x, uv.y) represents a vertical line obtained with the horizontal coordinate of the target center point as a fixed value. If the position coordinates of the target center point are (e, f), then the target pixel group to be sampled can be the pixel points on the straight line where x=e is located. In other words, the terminal device 200b can sample the pixel values ​​of N pixel points to be sampled on the straight line where x=e is located through the business server 100.

[0136] Further, if the first background area includes pixel points (a, b), the terminal device 200b can fill the pixel points (a, b) according to the pixel values ​​of the pixel points (e, b) included in the target pixel group to be sampled through the business server 100 to obtain the target effect image res.

[0137] For example, if the first background area includes pixel points (1, 1), pixel point (2, 1), and pixel point (1, 2), pixel point (1, 1) and pixel point (2, 1) may be filled according to the pixel value of pixel point (e, 1) included in the target pixel group to be sampled, and pixel point (1, 2) may be filled according to the pixel value of pixel point (e, 2) included in the target pixel group to be sampled, thereby achieving the following: Figure 4 The transverse stretching effect shown in 3c.

[0138] Exemplarily, the stretching effect may also include a longitudinal stretching effect. If the position coordinates of the target center point are (e, f), and the target pixel group to be sampled is a horizontal line, such as the target pixel group to be sampled may be a pixel point on the straight line where y=f is located, then the terminal device 200b may obtain the pixel values ​​of the N pixel points to be sampled included in the target pixel group to be sampled according to the texture2D function through the business server 100, and fill the first background area in the processed image according to the pixel values ​​of the N pixel points to be sampled to obtain the target effect diagram.

[0139] At this time, the vertical coordinate of the target center point is marked as bodyCenter.y, and the target effect image can be res=texture2D(srcImg, vec2(bodyCenter.y, uv.x)). Among them, texture2D(srcImg, vec2(bodyCenter.y, uv.x)) can represent obtaining pixel values ​​from the position (bodyCenter.y, uv.x) of the image to be processed srcImg. Among them, uv.x represents the horizontal coordinate of the pixel point, and (bodyCenter.y, uv.x) represents a horizontal line obtained with the vertical coordinate of the target center point as a fixed value. If the position coordinate of the target center point is (e, f), the target pixel group to be sampled can be the pixel points on the straight line where y=f is located. In other words, the terminal device 200b can sample the pixel values ​​of N pixel points to be sampled on the straight line where y=f is located through the business server 100.

[0140] Further, if the first background area includes pixel points (a, b), the terminal device 200b can fill the pixel points (a, b) according to the pixel values ​​of the pixel points (a, f) included in the target pixel group to be sampled through the business server 100 to obtain the target effect image res.

[0141] For example, if the first background area includes pixel point (1, 1), pixel point (2, 1) and pixel point (1, 2), pixel point (1, 1) and pixel point (1, 2) can be filled according to the pixel value of pixel point (1, f) included in the target pixel group to be sampled, and pixel point (2, 1) can be filled according to the pixel value of pixel point (2, f) included in the target pixel group to be sampled, thereby achieving a vertical stretching effect.

[0142] Exemplarily, the stretching effect may also include an oblique stretching effect. If the position coordinates of the target center point are (e, f), and the target pixel group to be sampled is an oblique line, such as the target pixel group to be sampled may be a pixel point on the straight line where y=k*x+g is located, then the terminal device 200b may obtain the pixel values ​​of the N pixel points to be sampled included in the target pixel group to be sampled according to the texture2D function through the business server 100, and fill the first background area in the processed image according to the pixel values ​​of the N pixel points to be sampled to obtain the target effect diagram.

[0143] It should be understood that k and g in the target pixel group to be sampled y=k*x+g can be determined according to the subject segmentation result of the image to be processed.

[0144] At this time, the vertical coordinate of the target center point is marked as bodyCenter.y, and the target effect image can be res=texture2D(srcImg, vec2(uv.x, k*uv.x+g)). Among them, texture2D(srcImg, vec2(uv.x, k*uv.x+g)) can represent obtaining the pixel value from the position (uv.x, k*uv.x+g) of the image to be processed srcImg. Among them, uv.x represents the horizontal coordinate of the pixel point, and (uv.x, k*uv.x+g) represents the straight line y=k*x+g.

[0145] It should be understood that the straight line y=k*x+g includes the target center point. If the position coordinates of the target center point are (e, f), the target pixel group to be sampled may be the pixel points on the straight line y=k*x+g. In other words, the terminal device 200b may sample the pixel values ​​of the N pixel points to be sampled on the straight line y=k*x+g through the service server 100.

[0146] Further, if the first background area includes pixel points (a, b), the terminal device 200b can fill the pixel points (a, b) through the business server 100 according to the pixel values ​​of the pixel points (a, k*a+g) included in the target pixel group to be sampled to obtain the target effect image res.

[0147] In some feasible cases, part of the first background area of ​​the processed image can also be stretched. For example, when y<k*x+g, the lower half of y=k*x+g can be stretched, and when y>k*x+g, the upper half of y=k*x+g can be stretched to achieve different stretching effects.

[0148] Step S204: Generate a first target image based on the image to be processed and the target effect image.

[0149] Specifically, for ease of description, the target effect image includes a fourth main body area. The terminal device 200b can perform transparency processing on the first background area of ​​the image to be processed through the business server 100 to obtain the image to be processed after transparency processing, and perform transparency processing on the fourth main body area of ​​the target effect image to obtain the target effect image after transparency processing. Further, the terminal device 200b can superimpose the image to be processed after transparency processing and the target effect image after transparency processing through the business server 100 to obtain the first target image.

[0150] Exemplarily, the terminal device 200b can adjust the transparency of the first background area of ​​the image to be processed and the fourth main area of ​​the target effect image based on the blending factor α through the service server 100. Wherein α belongs to [0, 1]. For the convenience of description, the mask image of the image to be processed is recorded as segmentColor, and the first target image is recorded as finalColor. Then, the first target image can be obtained according to the following formula, that is,

[0151] finalColor=mix(β,γ,α) (1)

[0152] Among them, β and γ are the images to be mixed, and α is the mixing factor.

[0153] Optionally, if β is the image to be processed srcImg, γ is the target effect image res, and because the pixel points in the first main area of ​​the mask image are 1 (or True), and the pixel points in the first background area are 0 (or False), the blending factor α=1-segmentColor, which can be specifically referred to in the following formula:

[0154] finalColor=srcImg*(1-α)+res*α (2)

[0155] Specifically, since all pixels in the first main area are set to 1 and all pixels in the first background area are set to 0, it can be seen that srcImg*(1-α) can indicate that the transparency of the first main area of ​​the image to be processed is 1, and the transparency of the first background area is 0, and the image to be processed after transparency processing is obtained. res*α can indicate that the transparency of the fourth main area of ​​the target effect image is 0, and the transparency of the area other than the fourth main area in the target effect image is 0, and the target effect image after transparency processing is obtained.

[0156] Furthermore, the terminal device 200b can superimpose the target effect image after the transparency processing on the image to be processed after the transparency processing through the service server 100 to obtain the first target image.

[0157] Optionally, when the image in the first position in the mix() function changes, that is, when the order of the superimposed images β and γ changes, the mixing factor α will also change. If β is the target effect image res, γ is the image to be processed srcImg, and because the pixels in the first main area of ​​the mask image are 1 (or True), and the pixels in the first background area are 0 (or False), the mixing factor α = segmentColor, which can be specifically referred to in the following formula:

[0158] finalColor=res*(1-α)+srcImg*α (3)

[0159] Specifically, since all pixels in the first main area are set to 1 and all pixels in the first background area are set to 0, res*(1-α) can indicate that the transparency of the fourth main area of ​​the target effect image is 0, and the transparency of the area other than the fourth main area in the target effect image is 0, and the target effect image after transparency processing is obtained. srcImg*α can indicate that the transparency of the first main area of ​​the image to be processed is 1, and the transparency of the first background area is 0, and the image to be processed after transparency processing is obtained.

[0160] Furthermore, the terminal device 200b can superimpose the image to be processed after transparency processing on the target effect image after transparency processing through the business server 100 to obtain the first target image, and then the terminal device 200b can display the first target image received from the business server 100.

[0161] In some feasible implementations, the terminal device 200b may display a template selection interface for the image to be processed, and display a voice input control in the template selection interface. The terminal device 200b may obtain voice data of the target operation object in response to a trigger operation for the voice input control, and obtain a recognition result based on the voice data. The recognition result includes key information of the target operation, and the target operation object is the object that triggers the voice input control. Further, the terminal device 200b may perform a stretching process on the first background area in response to the recognition result containing the key information of the target operation to obtain a first target image.

[0162] Specifically, see Figure 7 , Figure 7 FIG. 1 is another schematic diagram of the image processing method provided in the embodiment of the present application. Figure 2 The terminal device 200b shown can display the following Figure 7 The operation interface is shown in interface 500a. When the target operation object triggers control 501 as shown in interface 500a, terminal device 200b can respond to the trigger operation on control 501 and display an album interface as shown in interface 501a. The target operation object can select an image in the album interface shown in interface 501a. At this time, the image selected by the target operation object is the image to be processed.

[0163] Exemplarily, when the target operation object triggers the selection control 502 corresponding to the image 1, the terminal device 200b can select the image 1 in response to the triggering operation on the selection control 502, and determine the image 1 as the image to be processed. Further, when the target operation object triggers the "next step" control shown in the interface 501a, the terminal device 200b can display the interface 502a in response to the triggering operation on the "next step" control.

[0164] In some feasible implementations, the stretching operation on the image to be processed can also be implemented through voice interaction. Figure 2 The target operation object shown in the figure) sends instructions to the machine through voice, and the machine recognizes the voice and feeds back the results.

[0165] Exemplarily, as shown in interface 502a, a voice input control 503 is displayed in interface 502a. When the target operation object triggers the voice input control 503, the target operation object can issue a voice command through the voice input control 503, such as "select a stretching template", and the terminal device 200b can collect the voice command through the microphone to obtain the voice data of the target operation object.

[0166] Furthermore, the terminal device 200b may convert the voice data into text information, and the text information may include key information of the target operation.

[0167] Among them, the voice data can be converted into text information through automatic voice recognition technology. It should be understood that training can be performed in advance through voice samples to improve the efficiency of voice-to-text conversion.

[0168] For example, multiple voice samples and text information corresponding to the multiple voice samples can be obtained in advance, sample parameters corresponding to each voice sample can be determined, and all determined sample parameters can be stored in a voice parameter library. After receiving the voice data to be recognized, the voice data is analyzed to obtain the voice parameters corresponding to the voice data, the voice parameters are compared with all sample parameters in the voice database, the sample parameters closest to the voice parameters are determined, the text corresponding to the sample parameters is used as the text corresponding to the voice data, and the text information corresponding to the voice data is determined according to the texts corresponding to all voice parameters.

[0169] Furthermore, the text information may be analyzed through a natural language processing model to determine whether the text information corresponds to key information.

[0170] For example, if the key information corresponding to "select stretch template" is "stretch" and "template", the recognition result obtained based on the voice data "select stretch template" is "stretch" and "template", and therefore, the target operation can be determined to be a stretch operation based on "stretch" and "template". Further, the terminal device 200b can perform stretch processing on the first background area of ​​the image to be processed in response to the recognition result containing the key information of the stretch operation to obtain the first target image shown in the interface 503a.

[0171] In some feasible implementations, the terminal device 200b may display a template selection interface for the image to be processed. When the template selection interface recognizes a gesture operation corresponding to the target operation, the first background area is stretched in response to the gesture operation to obtain the first target image.

[0172] For example, in Figure 2 After the target operation object shown selects image 1 as the image to be processed, the terminal device 200b can display a template selection interface as shown in interface 502a. When the target operation object performs a "V-shaped gesture" as shown in interface 502a, that is, when the terminal device 200b recognizes the "V-shaped gesture" in the template selection interface, the terminal device 200b can respond to the gesture operation of the "V-shaped gesture" and stretch the first background area of ​​the image to be processed to obtain a first target image as shown in interface 503a.

[0173] It should be understood that the embodiments of the present application do not limit the gesture type of the target operation. For example, the gesture type of the target operation can also be a "slide down" gesture, a "double-click" operation, a "three-finger slide down", etc.

[0174] In some feasible implementations, the terminal device 200b may display a template selection interface for the image to be processed, and display a target template corresponding to the target operation in the template selection interface. Further, the terminal device 200b may stretch the first background area in response to the selection operation for the target template to obtain the first target image.

[0175] Specifically, Figure 7 As shown in interface 502a, a template selection interface 504 is displayed in interface 502a. When the target operation object triggers the "stretch template" in the template selection interface 504, the terminal device 200b can respond to the selection operation of the "stretch template" and stretch the first background area of ​​the image to be processed to obtain the first target image as shown in interface 503a.

[0176] In some feasible implementations, the terminal device 200b may display a template selection interface for the image to be processed, and display a restoration control in the template selection interface. Further, in response to a trigger operation on the restoration control, the first target image is restored to obtain the image to be processed.

[0177] Specifically, Figure 7 As shown in interface 503a, a restoration control 505 is displayed in interface 503a. When the target operation object triggers the restoration control 505, the terminal device 200b can respond to the triggering operation on the restoration control 505 and restore the first target image shown in interface 503a to obtain the image to be processed as shown in interface 504a.

[0178] In some feasible implementations, the terminal device 200b may display a template selection interface for the image to be processed, and display a switching control in the template selection interface. Further, in response to a trigger operation on the switching control, a restoration operation is performed on the second background area in the first target image, and a stretching operation is performed on the second main body area in the first target image to obtain a second target image.

[0179] Specifically, Figure 7 As shown in interface 504a, a "switch" control is displayed in interface 504a. When the target operation object triggers the "switch" control, the terminal device 200b can respond to the trigger operation of the "switch" control, restore the second background area in the first target image shown in interface 503a, and stretch the second main area in the first target image shown in interface 503a to obtain the second target image.

[0180] In an embodiment of the present application, the subject in the first subject area of ​​the image to be processed can be identified by acquiring the mask image corresponding to the image to be processed. Further, the target pixel group to be sampled can be determined based on the third subject area and the third background area of ​​the mask image. Still further, the image to be processed can be stretched based on the pixel values ​​of the N pixels to be sampled included in the target pixel group to be sampled to obtain a target effect diagram. It can be seen that since the N pixels to be sampled are pixel points in the image to be processed, when performing the stretching operation, it can be ensured that the pixel values ​​of the first target image obtained after the stretching process are unified, that is, the color harmony is high, thereby improving the image processing effect and the success rate of image processing is high.

[0181] In addition, when determining the target pixel group to be sampled, the target bounding box corresponding to the third main area can be determined based on the third main area and the third background area of ​​the mask image, and then the target center point can be determined based on the target bounding box, and then the target pixel group to be sampled corresponding to the image to be processed can be determined based on the target center point, or the contour line of the third main area can be determined based on the third main area and the third background area, and the target pixel group to be sampled can be determined based on the contour line of the third main area. It can be seen that the stretching effect of the first target image obtained by different methods of determining the target pixel points to be sampled is also different, which not only enriches the stretching display effect, but also enriches the image processing method, and at the same time does not need to use image processing tools, thereby improving the image processing efficiency.

[0182] See also Figure 8 , Figure 8is a structural diagram of an image processing device provided in an embodiment of the present application. The above-mentioned image processing device can be a computer program (including program code) running on a computer device, for example, the image processing device is an application software; the device can be used to execute the corresponding steps of the image processing method provided in an embodiment of the present application; the device can be applied to Figure 1 Each terminal device shown in FIG. Figure 8 As shown, the image processing device 1 may include: an acquisition module 11 and a processing module 12;

[0183] The acquisition module 11 is used to receive the image to be processed; the image to be processed includes a first main body area and a first background area; the first background area is the area of ​​the image to be processed except the first main body area;

[0184] The processing module 12 is used to stretch the first background area in response to the target operation on the image to be processed to obtain the first target image; the second subject area in the first target image is the same as the first subject area in the image to be processed, the second background area in the first target image is the first background area after the stretching process, and the second background area includes a target pixel group, which is the pixel points of any row or any column in the second background area; if there are pixel points associated with the subject in the first subject area in the extension direction of the target pixel group, then the pixel value corresponding to the target pixel group is associated with the pixel value of the subject or the adjacent area of ​​the subject in the image to be processed.

[0185] Among them, the above-mentioned subjects include first-type subjects and second-type subjects; if there are pixel points associated with the first-type subjects in the first subject area in the extension direction of the target pixel group, the pixel values ​​corresponding to the target pixel group are associated with the pixel values ​​of the adjacent areas of the first-type subjects in the image to be processed; if there are pixel points associated with the second-type subjects in the first subject area in the extension direction of the target pixel group, the pixel values ​​corresponding to the target pixel group are associated with the pixel values ​​of the second-type subjects.

[0186] The processing module 12 is used to display a template selection interface for the image to be processed, and to display a voice input control in the template selection interface;

[0187] The processing module 12 is further used to obtain the voice data of the target operation object in response to the trigger operation on the voice input control, and obtain the recognition result based on the voice data; the recognition result includes the key information of the target operation, and the target operation object is the object that triggers the voice input control;

[0188] The processing module 12 is further configured to perform stretching processing on the first background area in response to the recognition result containing the key information of the target operation, so as to obtain the first target image.

[0189] The processing module 12 is used to display a template selection interface for the image to be processed. When the template selection interface recognizes a gesture operation corresponding to the target operation, the first background area is stretched in response to the gesture operation to obtain the first target image.

[0190] The processing module 12 is used to display a template selection interface for the image to be processed, and to display a target template corresponding to the target operation in the template selection interface;

[0191] The processing module 12 is further configured to perform stretching processing on the first background area in response to a selection operation on the target template to obtain a first target image.

[0192] The above device further comprises:

[0193] A display module 13, used to display a template selection interface for the image to be processed, and to display a restoration control in the template selection interface;

[0194] The processing module 12 is used to restore the first target image in response to a trigger operation on the restoration control to obtain an image to be processed.

[0195] The display module 13 is used to display a template selection interface for the image to be processed, and to display a switching control in the template selection interface;

[0196] The processing module 12 is used to restore the second background area in the first target image and stretch the second main area in the first target image in response to the trigger operation on the switching control to obtain the second target image.

[0197] The acquisition module 11 is used to acquire a mask image corresponding to the image to be processed; the mask image includes a third main body area and a third background area;

[0198] The processing module 12 is used to determine a target pixel group to be sampled corresponding to the image to be processed based on the third main area and the third background area; the target pixel group to be sampled includes position coordinates of N pixel points to be sampled, where N is a positive integer;

[0199] The processing module 12 is further used to determine the pixel values ​​of the N pixels to be sampled based on the position coordinates of the N pixels to be sampled, and to stretch the image to be processed based on the pixel values ​​of the N pixels to be sampled to obtain a target effect image;

[0200] The processing module 12 is further configured to generate a first target image based on the image to be processed and the target effect image.

[0201] The acquisition module 11 is used to perform subject recognition on the image to be processed to obtain a first subject area and a first background area;

[0202] The acquisition module 11 is further configured to set all pixel points in the first main body region to the first pixel value to obtain a third main body region;

[0203] The acquisition module 11 is further configured to set all pixel points in the first background area to the second pixel value to obtain a third background area;

[0204] The acquisition module 11 is further configured to determine the image to be processed including the third main body region and the third background region as a mask image.

[0205] The processing module 12 is used to determine a target bounding box corresponding to the third subject area based on the third subject area and the third background area;

[0206] The processing module 12 is further configured to determine a target center point in the first main body area based on the target bounding box and the mask image;

[0207] The processing module 12 is further configured to determine a target pixel group to be sampled corresponding to the image to be processed based on the target center point; the N pixel points to be sampled in the target pixel group to be sampled include the target center point.

[0208] Wherein, the first subject region includes the first type of subject;

[0209] The processing module 12 is used to determine the initial center point corresponding to the third main body area based on the target bounding box, and obtain the initial position coordinates of the initial center point in the mask image;

[0210] The processing module 12 is further used to determine the pixel points in the image to be processed that have the same position coordinates as the initial position coordinates as the target pixel points, and offset the target pixel points by the target step length to obtain the target center point.

[0211] Wherein, the first subject region contains the second type of subject;

[0212] The processing module 12 is used to determine the initial center point corresponding to the third main body area based on the target bounding box, and obtain the initial position coordinates of the initial center point in the mask image;

[0213] The processing module 12 is further configured to determine the pixel point in the image to be processed that has the same position coordinates as the initial position coordinates as the target center point.

[0214] The processing module 12 is used to determine the contour of the third main area based on the third main area and the third background area, and determine the target pixel group to be sampled based on the contour of the third main area.

[0215] Wherein, the target rendering includes the fourth main body area;

[0216] The processing module 12 is used to perform transparency processing on the first background area of ​​the image to be processed to obtain the image to be processed after transparency processing, and perform transparency processing on the fourth main area of ​​the target effect image to obtain the target effect image after transparency processing;

[0217] The processing module 12 is further used to superimpose the image to be processed after the transparency processing and the target effect image after the transparency processing to obtain a first target image.

[0218] According to the above Figure 3 The corresponding embodiment, Figure 3 The implementation method described in steps S101 to S102 in the image processing method shown in FIG. Figure 8 Each module of the device shown in the figure is executed. For example, the above Figure 3 The implementation method described in step S101 of the image processing method shown in FIG. Figure 8 The acquisition module 11 in the device shown in the figure is executed, and the implementation method described in step S102 can be executed by the processing module 12. Among them, the implementation method executed by the above acquisition module 11 and the processing module 12 can refer to the above Figure 3 The implementation methods provided in each step of the corresponding embodiment will not be repeated here.

[0219] In the embodiment of the present application, the functional implementation of each unit in the image processing device 1 can improve the perception efficiency of the target operation object on the image to be processed, enrich the interactive mode of the target operation object for image processing, and enhance the interactive visualization effect.

[0220] See also Fig. 9 , Fig. 9 Schematic diagram of a computer device provided in an embodiment of the present application. Fig. 9 As shown, the computer device 1000 may include: at least one processor 1001, such as a CPU, at least one communication bus 1002, at least one network interface 1004, and at least one memory 1005. In a feasible implementation, the computer device 1000 may also include at least one transceiver 1003. The communication bus 1002 is used to achieve connection and communication between these components. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or a non-volatile memory (non-volatile memory), such as at least one disk storage. The memory 1005 may optionally also be at least one storage device located away from the aforementioned processor 1001. As Fig. 9As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a device control application.

[0221] exist Fig. 9 In the computer device 1000 shown, the network interface 1004 can provide a network communication function; and the transceiver 1003 and the processor 1001 can be used to call the device control application stored in the memory 1005 for application Figure 1 The terminal devices shown are used to achieve:

[0222] Receive an image to be processed; the image to be processed includes a first main body area and a first background area; the first background area is an area of ​​the image to be processed other than the first main body area;

[0223] In response to a target operation on an image to be processed, a first background area is stretched to obtain a first target image; a second subject area in the first target image is the same as the first subject area in the image to be processed, the second background area in the first target image is the first background area after the stretching process, and the second background area includes a target pixel group, which is a pixel point in any row or any column in the second background area; if there are pixel points associated with a subject in the first subject area in an extension direction of the target pixel group, then the pixel value corresponding to the target pixel group is associated with the pixel value of the subject or an adjacent area of ​​the subject in the image to be processed.

[0224] In addition, it should be pointed out here that: the embodiment of the present application also provides a computer-readable storage medium, and the computer-readable storage medium stores a computer program executed by the image processing device mentioned above, and when the processor executes the computer program, it can execute the above-mentioned Figure 3 The description of the image processing method in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of the same method will not be repeated here either.

[0225] For technical details not disclosed in the computer-readable storage medium embodiments involved in this application, please refer to the description of the method embodiments of this application. As an example, the computer program can be deployed on a computer device for execution, or on multiple computer devices located at one location, or on multiple computer devices distributed at multiple locations and interconnected by a communication network. Multiple computer devices distributed at multiple locations and interconnected by a communication network can form a communication system.

[0226] In addition, it should be noted that: the embodiment of the present application also provides a computer program product, which may include a computer program, and the computer program may be stored in a computer-readable storage medium. The processor of the computer device reads the computer program from the computer-readable storage medium, and the processor may execute the computer program, so that the computer device can execute the above Figure 3 The description of the image processing method in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of adopting the same method will not be repeated here. For technical details not disclosed in the computer program product embodiment involved in this application, please refer to the description of the method embodiment of this application.

[0227] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.

[0228] The terms "first", "second", etc. in the description, claims, and drawings of the embodiments of the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the term "comprising" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, device, product, or equipment that includes a series of steps or units is not limited to the listed steps or modules, but optionally includes steps or modules that are not listed, or optionally includes other step units inherent to these processes, methods, devices, products, or equipment.

[0229] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. 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.

[0230] The method and related apparatus provided by the embodiment of the present application are described with reference to the method flow chart and / or structural diagram provided by the embodiment of the present application. Specifically, each process and / or box in the method flow chart and / or structural diagram, as well as the combination of the processes and / or boxes in the flow chart and / or block diagram, can be implemented by a computer program. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the process in the process. Figure 1 A process or multiple processes and / or structures Figure 1 These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 A process or multiple processes and / or structures Figure 1 These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process in the process. Figure 1 A flow or multiple flows and / or structures illustrate the steps of the functions specified in one block or multiple blocks.

[0231] The above disclosure is only the preferred embodiment of the present application, which certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.

Claims

1. An image processing method, characterized in that: The method comprises: Receive an image to be processed; the image to be processed includes a first main body area and a first background area; the first background area is an area of ​​the image to be processed other than the first main body area; In response to a target operation on the image to be processed, the first background area is stretched to obtain a first target image; the second subject area in the first target image is the same as the first subject area in the image to be processed, the second background area in the first target image is the first background area after the stretching process, and the second background area includes a target pixel group, which is a pixel point in any row or any column in the second background area; if there are pixel points associated with the subject in the first subject area in the extension direction of the target pixel group, then the pixel value corresponding to the target pixel group is associated with the pixel value of the subject or the adjacent area of ​​the subject in the image to be processed.

2. The method according to claim 1, characterized in that The subject includes a first type of subject and a second type of subject; if there are pixel points associated with the first type of subject in the first subject area in the extension direction of the target pixel group, the pixel value corresponding to the target pixel group is associated with the pixel value of the adjacent area of ​​the first type of subject in the image to be processed; if there are pixel points associated with the second type of subject in the first subject area in the extension direction of the target pixel group, the pixel value corresponding to the target pixel group is associated with the pixel value of the second type of subject.

3. The method according to claim 1, characterized in that In response to the target operation on the image to be processed, stretching the first background area to obtain a first target image includes: Displaying a template selection interface for the image to be processed, and displaying a voice input control in the template selection interface; In response to a trigger operation on the voice input control, voice data of a target operation object is acquired, and a recognition result is obtained based on the voice data; the recognition result includes key information of the target operation, and the target operation object is the object that triggers the voice input control; In response to the recognition result including the key information of the target operation, the first background area is stretched to obtain a first target image.

4. The method according to claim 1, characterized in that In response to the target stretching operation on the image to be processed, stretching the first background area to obtain a first target image includes: A template selection interface for the image to be processed is displayed. When a gesture operation corresponding to the target operation is recognized on the template selection interface, the first background area is stretched in response to the gesture operation to obtain a first target image.

5. The method according to claim 1, characterized in that In response to the target stretching operation on the image to be processed, stretching the first background area to obtain a first target image includes: Displaying a template selection interface for the image to be processed, wherein a target template corresponding to the target operation is displayed in the template selection interface; In response to a selection operation on a target template, the first background area is stretched to obtain a first target image.

6. The method according to claim 1, characterized in that The method further comprises: Displaying a template selection interface for the image to be processed, and displaying a restoration control in the template selection interface; In response to a triggering operation on the restoration control, the first target image is restored to obtain the image to be processed.

7. The method according to claim 1, characterized in that The method further comprises: Displaying a template selection interface for the image to be processed, and displaying a switching control in the template selection interface; In response to a trigger operation on the switching control, a restoration operation is performed on a second background area in the first target image, and a stretching operation is performed on a second main body area in the first target image to obtain a second target image.

8. The method according to claim 1, characterized in that In response to the target operation on the image to be processed, stretching the first background area to obtain a first target image includes: Acquire a mask image corresponding to the image to be processed; the mask image includes a third main body area and a third background area; Determine a target pixel group to be sampled corresponding to the image to be processed based on the third main area and the third background area; the target pixel group to be sampled includes position coordinates of N pixel points to be sampled, where N is a positive integer; Determine the pixel values ​​of the N pixels to be sampled based on the position coordinates of the N pixels to be sampled, and perform stretching processing on the image to be processed based on the pixel values ​​of the N pixels to be sampled to obtain a target effect image; Based on the image to be processed and the target effect image, the first target image is generated.

9. The method according to claim 8, characterized in that The step of obtaining a mask image corresponding to the image to be processed includes: Performing subject recognition on the image to be processed to obtain a first subject area and a first background area; Setting all pixels in the first main body area to a first pixel value to obtain a third main body area; Setting all pixel points in the first background area to second pixel values ​​to obtain a third background area; The image to be processed including the third main body area and the third background area is determined as a mask image.

10. The method according to claim 8, characterized in that The step of determining a target pixel group to be sampled corresponding to the image to be processed based on the third main area and the third background area includes: Determine a target bounding box corresponding to the third subject area based on the third subject area and the third background area; Determine a target center point in the first subject area based on the target bounding box and the mask image; A target pixel group to be sampled corresponding to the image to be processed is determined based on the target center point; the N pixel points to be sampled in the target pixel group to be sampled include the target center point.

11. The method according to claim 10, characterized in that The first subject area includes a first type of subject; and determining the target center point in the first subject area based on the target bounding box and the mask image includes: Determine an initial center point corresponding to the third main body area based on the target bounding box, and obtain initial position coordinates of the initial center point in the mask image; A pixel point in the image to be processed that has the same position coordinates as the initial position coordinates is determined as a target pixel point, and the target pixel point is offset by a target step length to obtain the target center point.

12. The method according to claim 10, characterized in that The first subject area includes a second type of subject; and determining the target center point in the first subject area based on the target bounding box and the mask image includes: Determine an initial center point corresponding to the third main body area based on the target bounding box, and obtain initial position coordinates of the initial center point in the mask image; A pixel point in the image to be processed that has the same position coordinates as the initial position coordinates is determined as the target center point.

13. The method according to claim 8, characterized in that The step of determining a target pixel group to be sampled corresponding to the image to be processed based on the third main area and the third background area includes: A contour line of the third main body area is determined based on the third main body area and the third background area, and the target pixel group to be sampled is determined based on the contour line of the third main body area.

14. The method according to claim 8, characterized in that The target effect image includes a fourth main body area; and generating the first target image based on the image to be processed and the target effect image includes: Performing transparency processing on the first background area of ​​the image to be processed to obtain the image to be processed after transparency processing, and performing transparency processing on the fourth main area of ​​the target effect image to obtain the target effect image after transparency processing; The image to be processed after the transparency processing and the target effect image after the transparency processing are superimposed to obtain the first target image.

15. An image processing device, characterized in that: include: An acquisition module, configured to receive an image to be processed; the image to be processed includes a first main body area and a first background area; The first background area is an area of ​​the image to be processed except the first main area; A processing module, configured to perform stretching processing on the first background area in response to a target operation on the image to be processed, so as to obtain a first target image; The second main area in the first target image is the same as the first main area in the image to be processed, the second background area in the first target image is the first background area after stretching, the second background area includes a target pixel group, and the target pixel group is a pixel point in any row or any column in the second background area; If there are pixels associated with the subject in the first subject area in the extension direction of the target pixel group, the pixel values ​​corresponding to the target pixel group are associated with the pixel values ​​of the subject or the adjacent area of ​​the subject in the image to be processed.

16. A computer device, characterized in that: include: Processors, transceivers, memory, and network interfaces; The processor is connected to the transceiver, the memory, and the network interface, wherein the network interface is used to provide a data communication function, the memory is used to store program code, and the processor and the transceiver are used to call the program code to execute the method described in any one of claims 1-14.

17. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is suitable for being loaded and executed by a processor, so that a computer device having the processor executes the method according to any one of claims 1 to 14.