Image processing method, device and equipment, computer readable storage medium and product
By acquiring preview images and depth maps from terminal devices, the background is identified and blurred, solving the problem that existing technologies cannot achieve background blurring and highlighting of the main content in iOS systems, and enabling real-time viewing and acquisition of clear image effects in third-party applications.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-24
- Publication Date
- 2026-03-24
AI Technical Summary
Existing image processing applications cannot achieve the effect of blurring the background while highlighting the subject, especially since third-party applications on iOS cannot achieve portrait mode image capture.
By acquiring the preview image and associated depth map of the terminal device, the target area is identified and the background is blurred. The AVFoundation module of the iOS system is used to obtain the preview image, depth map and key point information, accurately identify the main content area, and perform background blur operation.
It enables real-time viewing and capture of images with blurred backgrounds and clear main content in third-party applications, improving the effectiveness and accuracy of image processing.
Smart Images

Figure CN121728341A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and in particular to an image processing method, apparatus, device, computer-readable storage medium, and product. Background Technology
[0002] Most current terminal devices are equipped with image acquisition units, allowing users to capture images. To improve the quality of captured images, terminal devices typically integrate image processing algorithms to process the images, achieving background blurring and highlighting the main subject.
[0003] With the gradual development of image processing technology, more and more image processing applications are entering users' lives. Users can use these applications to process and capture images. However, image processing applications cannot directly call the image processing algorithms inherited by the terminal device to process images. How to achieve image processing effects that blur the background while highlighting the main subject has become an urgent problem to be solved. Summary of the Invention
[0004] This disclosure provides an image processing method, apparatus, device, computer-readable storage medium, and product to solve the technical problem that existing image processing applications cannot achieve background blurring while highlighting the main content in image processing effects.
[0005] In a first aspect, embodiments of this disclosure provide an image processing method, including:
[0006] In response to a user's triggering operation in a target application, an image to be processed is acquired, wherein the image to be processed is acquired by an image acquisition device in a terminal device, and the image to be processed includes at least a preview image currently displayed in the viewfinder of the terminal device and a depth map associated with the preview image.
[0007] Based on the image to be processed, a target region in the preview image is determined, wherein the target region includes the main content of the preview image;
[0008] Blur the background of the preview image;
[0009] Based on the target area and the preview image with the background blurred, the target image is obtained;
[0010] The target image is displayed in the viewfinder.
[0011] In a second aspect, embodiments of this disclosure provide an image processing apparatus, comprising:
[0012] The acquisition module, in response to a user's trigger operation in the target application, acquires an image to be processed, wherein the image to be processed is acquired by an image acquisition device in the terminal device, and the image to be processed includes at least the preview image currently displayed in the viewfinder of the terminal device and the depth map associated with the preview image;
[0013] The determining module is used to determine a target region in the preview image based on the image to be processed, wherein the target region includes the main content of the preview image;
[0014] The processing module is used to blur the background of the preview image;
[0015] The generation module is used to obtain the target image based on the target area and the preview image after background blurring;
[0016] A display module for displaying the target image in the viewfinder.
[0017] Thirdly, embodiments of this disclosure provide an electronic device, including: a processor and a memory;
[0018] The memory stores computer-executed instructions;
[0019] The processor executes computer execution instructions stored in the memory, causing the at least one processor to perform the image processing method as described in the first aspect and various possible designs of the first aspect.
[0020] Fourthly, embodiments of this disclosure provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the image processing method described in the first aspect and various possible designs of the first aspect.
[0021] Fifthly, embodiments of this disclosure provide a computer program product, including a computer program that, when executed by a processor, implements the image processing method described in the first aspect and various possible designs of the first aspect.
[0022] The image processing method, apparatus, device, computer-readable storage medium, and product provided in this embodiment, in response to a user's preset trigger operation in a target application, acquire an image to be processed, including at least a preview image currently displayed in the viewfinder and a depth map associated with the preview image. Based on the image to be processed, a defined target region in the preview image is accurately identified. The preview image is then blurred to obtain a target image based on the target region and the blurred preview image, which is then displayed in the viewfinder. This allows users to view and capture images with blurred backgrounds and highlighted main content in real time within the target application, improving the image processing performance of the target application. Attached Figure Description
[0023] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0024] Figure 1 This is a schematic flowchart of the image processing method provided in the embodiments of this disclosure;
[0025] Figure 2 A schematic flowchart of an image processing method provided in yet another embodiment of this disclosure;
[0026] Figure 3 This is a schematic diagram of a preview image provided for an embodiment of this disclosure;
[0027] Figure 4 Another preview image schematic diagram provided for an embodiment of this disclosure;
[0028] Figure 5 A schematic flowchart of an image processing method provided in yet another embodiment of this disclosure;
[0029] Figure 6 A schematic flowchart of an image processing method provided in yet another embodiment of this disclosure;
[0030] Figure 7 This is a schematic diagram of the structure of the image processing apparatus provided in the embodiments of this disclosure;
[0031] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation
[0032] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. Based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.
[0033] It is understood that before using the technical solutions disclosed in the various embodiments of this disclosure, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in this disclosure in an appropriate manner in accordance with relevant laws and regulations, and user authorization should be obtained.
[0034] For example, upon receiving a user's active request, a prompt message is sent to the user to explicitly inform them that the requested operation will require the acquisition and use of the user's personal information. This allows the user to independently choose whether to provide personal information to the software or hardware, such as the electronic device, application, server, or storage medium performing the operations of this disclosed technical solution, based on the prompt message.
[0035] As an optional but non-limiting implementation, in response to a user's active request, sending a prompt message to the user can be done via a pop-up window, where the prompt message can be presented in text format. Furthermore, the pop-up window can also include a selection control allowing the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0036] It is understood that the above notification and user authorization process are merely illustrative and do not constitute a limitation on the implementation of this disclosure. Other methods that comply with relevant laws and regulations may also be applied to the implementation of this disclosure.
[0037] To address the technical problem that existing image processing applications cannot achieve background blurring while highlighting the main subject, this disclosure provides an image processing method, apparatus, device, computer-readable storage medium, and product.
[0038] It should be noted that the image processing methods, apparatus, devices, computer-readable storage media, and products provided in this disclosure can be applied to any image processing scenario that emphasizes the main content.
[0039] The iOS camera offers a Portrait mode, which captures images with a sharp subject and a blurred background. However, iOS currently does not provide an interface for Portrait mode to other third-party applications. Therefore, implementing Portrait mode image capture within applications has become a pressing issue.
[0040] In solving the aforementioned problems, the inventors discovered that the AVFoundation module provided by the iOS system can generate preview images, depth maps, and key point information of the main subject within the preview image. This main subject can be a person. Based on this depth map and key point information, the inventors can accurately identify the target area, which includes the main subject. Then, image processing is performed based on the target area and the preview image to achieve an image effect where the main subject is clear and the background is blurred. This allows users to capture images in portrait mode within third-party applications.
[0041] Figure 1 This is a schematic flowchart of the image processing method provided in the embodiments of this disclosure, as shown below. Figure 1 As shown, the method includes:
[0042] Step 101: In response to a user's trigger operation in the target application, acquire an image to be processed, wherein the image to be processed is acquired by an image acquisition device in the terminal device, and the image to be processed includes at least the preview image currently displayed in the viewfinder of the terminal device and the depth map associated with the preview image.
[0043] In this embodiment, the execution entity is an image processing device. This image processing device can be coupled to a server associated with the target application, thereby enabling it to acquire an image to be processed from a terminal device based on a preset trigger operation by the user in the target application, determine a target region based on the image to be processed, and perform background blurring image processing. Alternatively, the image processing device can also be coupled to the client of the target application, thereby enabling it to acquire an image to be processed based on a preset trigger operation by the user in the target application, and perform background blurring image processing based on the image to be processed.
[0044] In this embodiment, users can perform image processing operations such as image acquisition and image editing within the target application. During image processing, users can trigger preset actions within the target application according to actual needs to achieve image acquisition with a blurred background and a clear subject. These preset trigger actions can be either selection of preset image processing controls or state switching of preset processing controls.
[0045] For example, in a practical application, when a user performs image capture in a target application, the application can provide various image processing options, such as effects, filters, stickers, and portrait mode. Each image processing option is associated with an image processing control. The user can select the preset "portrait mode" control according to their needs to acquire an image in portrait mode. Alternatively, the image capture page can include a processing control associated with "portrait mode." During image capture, in response to the user's triggering of this control, the control's state can be switched to the active state. This allows the user to capture images in portrait mode within the image capture page.
[0046] Furthermore, in response to a user's preset trigger operation in the target application, an image to be processed can be acquired. This image to be processed includes at least a preview image captured by a preset image processing device in the terminal device and a depth map associated with the preview image.
[0047] The image processing device can be the original camera pre-installed in the terminal device. In addition, the terminal device is also pre-configured with a device that has depth capture capabilities.
[0048] One feasible approach is to install multiple devices with depth capture capabilities within the terminal device. When a user performs image acquisition operations in the target application, image acquisition parameters can be determined. Based on the user-determined parameters, a device matching those parameters is selected from among the multiple devices with depth capture capabilities to process the preview image and obtain a depth map.
[0049] Step 102: Based on the image to be processed, determine the target region in the preview image, wherein the target region includes the main content of the preview image.
[0050] In this embodiment, the depth map often includes depth information of each pixel in the preview image, which can characterize the distance between the pixel and the lens of the image acquisition device.
[0051] Understandably, in preview images, elements closer to the lens are more likely to be the main subject, while elements farther away are more likely to be the background. For example, when shooting portraits, the person in the photo is often closer to the lens than background elements such as buildings or scenery.
[0052] Therefore, in order to acquire an image with a blurred background and a clear subject, it is first necessary to identify the target area in the preview image. This target area includes the subject of the preview image. The subject can be content with prominent features in the preview image. For example, when the preview image is a portrait, the subject can be the person; when the preview image is a building image, the subject can be the most prominent building.
[0053] Therefore, after obtaining the image to be processed, the target region can be segmented based on the preview image and depth image in the image to be processed.
[0054] Step 103: Blur the background of the preview image.
[0055] Step 104: Obtain the target image based on the target area and the preview image after background blurring.
[0056] In this embodiment, to achieve a display effect of blurred background and clear main content, the preview image can be blurred. Any image blurring algorithm can be used to blur the background of the preview image; this disclosure does not impose any limitations on this.
[0057] Furthermore, a target image is obtained based on the target area and the preview image with a blurred background. Since the target area is a clear image and the preview image is a blurred image, by superimposing the target area and the preview image, a display effect with a blurred background and a clear main content can be obtained. Moreover, while ensuring background blurring, the target area can be prevented from being distorted or blurred, thus improving the display effect of the target image.
[0058] Step 105: Display the target image in the viewfinder.
[0059] In this embodiment, after obtaining the target image, it can be displayed in the viewfinder so that the user can view it in real time. This allows the user to perform image acquisition operations more accurately based on the display in the viewfinder.
[0060] Furthermore, based on any of the above embodiments, the method further includes:
[0061] In response to a user-triggered image acquisition operation, the target image displayed in the viewfinder is stored to a preset storage path.
[0062] In this embodiment, after the target image is displayed in the viewfinder, the user can view the image processing effect of the blurred background and clear subject in real time.
[0063] Optionally, users can trigger image acquisition operations according to their actual needs. The display page can include an image acquisition control, which users can activate to initiate the image acquisition operation.
[0064] In response to this image acquisition operation, the target image currently displayed in the viewfinder can be stored to a preset storage path.
[0065] The image processing method provided in this embodiment, in response to a user's preset trigger operation in a target application, acquires an image to be processed, including at least the currently displayed preview image in the viewfinder and a depth map associated with the preview image. Based on the image to be processed, the target region is accurately determined. A background blur operation is performed on the preview image, and a target image is obtained based on the target region and the background-blurred preview image, which is then displayed in the viewfinder. This allows users to view and capture images with a blurred background and highlighted main content in real time within the target application, improving the image processing performance of the target application.
[0066] Figure 2 This is a schematic flowchart illustrating an image processing method according to another embodiment of the present disclosure. Based on any of the above embodiments, the image to be processed further includes key point information associated with the display object in the preview image. For example... Figure 2 As shown, step 102 includes:
[0067] Step 201: Determine at least one content subject in the preview image based on the depth map and / or the key point information.
[0068] Step 202: Perform image segmentation on the preview image based on the display position of the main content to obtain the target area.
[0069] In this embodiment, the image acquisition device pre-installed in the terminal device can also perform key point information acquisition operations, which is used to represent the coordinate information of the displayed object. The preview image may include the displayed object, which includes, but is not limited to, people, animals, buildings, or specific locations of people, such as heads or limbs.
[0070] For example, when the displayed object is a person, the image processing device can identify the key points of the person, wherein the key point information of the person includes the coordinate information of each key point of the person.
[0071] Furthermore, the image to be processed may include a preview image, a depth map associated with the preview image, and key point information associated with the displayed objects in the preview image. After acquiring the image to be processed, at least one content subject in the preview image can be accurately determined based on the depth map and / or key point information.
[0072] After identifying at least one content subject, image segmentation can be performed on the preview image based on that content subject to obtain the target region.
[0073] The image processing method provided in this embodiment acquires key point information and a depth map associated with the displayed object, thereby accurately identifying the main content in the preview image based on the depth map and / or key point information, and then performing image segmentation based on the main content. This improves the accuracy of image processing.
[0074] Furthermore, based on any of the above embodiments, step 201 includes:
[0075] Based on the depth map, at least one display object in the preview image whose distance from the image acquisition device satisfies a first condition is determined.
[0076] Based on the key point information, the display size of each display object is determined, and among the at least one display object, a target object whose display size meets a preset second condition is identified.
[0077] The display size of the target object is compared with the display sizes of other objects in the preview image to obtain the comparison results.
[0078] The main content of the preview image is determined based on the comparison results.
[0079] In this embodiment, the identification of the main content in the preview image can be achieved by combining depth map and key point information.
[0080] Optionally, the depth map can represent the distance between each pixel and the camera lens. Therefore, at least one display object in the preview image whose distance from the image acquisition device satisfies a preset first condition can be determined based on the depth map. This first condition can be that the display content closest to the camera lens is identified as at least one display object.
[0081] Furthermore, in an image, the object closest to the lens and with the largest display size is generally the main content of the image. Therefore, when there are multiple display objects, the target object can be selected from among them based on its display size. Since keypoint information can characterize the coordinate information of multiple pixels of a display object, the display size of each display object can be determined based on the keypoint information, and the target object whose display size meets a preset second condition can be identified from at least one display object. This second condition can be that the display object with the largest display size among at least one display object can be selected as the target object.
[0082] The preview image can be a single person photo or a group photo. When the preview image is a single person photo, the display size of other objects in the preview image is much smaller than the display size of the target object. When the preview image is a group photo, the display size of the target object is similar to that of other objects.
[0083] Therefore, to accurately identify the main content element, the display size of the target object can be compared with the display sizes of other objects in the preview image to obtain the comparison results. The main content element in the preview image is then determined based on these comparison results.
[0084] Furthermore, based on any of the above embodiments, determining the main content element in the preview image according to the comparison result includes:
[0085] For each display object, if the size ratio between the display size of the target object and the display size of the display object is within a preset first range, then based on the depth map, it is determined whether the depth difference between the display object and the target object is within a preset second range.
[0086] If so, the target object and the display object are determined as the main content.
[0087] If not, then the target object is determined as the content subject.
[0088] In this embodiment, a first range can be preset. This first range can be a range close to 1. Users can set this first range according to their actual needs, and this disclosure does not impose any restrictions on it.
[0089] Furthermore, for each display object, if the size ratio between the display size of the target object and the display size of the display object is within a preset first range, it indicates that the display size of the display object is similar to that of the target object. The depth difference between the display object and the target object is determined based on the depth map to be within a preset second range. This depth difference can be a value set by the user according to actual needs.
[0090] If yes, it indicates that the displayed object and the target object are similar in size and similar in distance from the camera lens, suggesting a possible group photo scene. Therefore, both the target object and the displayed object can be identified as the main content. If no, it indicates that the displayed object and the target object are similar in size, but the displayed object is far from the camera lens, indicating a non-group photo scene. Therefore, the target object is identified as the main content.
[0091] Figure 3 These are schematic preview images provided for embodiments of this disclosure, such as... Figure 3As shown, the preview image 31 includes multiple display objects. After determining the target object 32, the display size ratio between the target object 32 and other display objects 33 can be determined. If the display ratio is within a preset first range and the depth difference is within a second range, it indicates that the target object 32 and other display objects 33 are close in distance from the shooting lens and have similar display sizes, suggesting that the target object 32 and other display objects 33 may be in a group photo relationship. Therefore, both the target object 32 and other display objects 33 can be identified as the main content.
[0092] The image processing method provided in this embodiment determines the distance between the displayed object and the image acquisition device based on the depth map, determines the display size of the displayed object in the preview image based on key point information, and pre-sets a first condition and a second condition. This enables accurate identification of content subjects that are close to the image acquisition device and have a large display size. Subsequently, image segmentation operations can be accurately performed based on the content subject, thereby improving the display effect of the processed image.
[0093] Furthermore, based on any of the above embodiments, determining the main content element in the preview image according to the comparison result includes:
[0094] For each display object, if the size ratio between the display size of the target object and the display size of the display object is not within a preset first range, then the target object is determined as the content subject.
[0095] In this embodiment, for each display object, if the size ratio between the display size of the target object and the display size of the display object is not within a preset first range, it indicates that the display size difference between the target object and the display object is large. Therefore, the possibility that the preview image is a group photo is low, so the target object can be identified as the main content.
[0096] Figure 4 Another preview image schematic diagram provided for an embodiment of this disclosure, such as Figure 4 As shown, the preview image 41 includes multiple display objects. After determining the target object 42, the display size ratio between the target object 42 and other display objects 43 can be determined. If this size ratio is not within a preset first range, it indicates that the other display objects 43 in the preview image 41 may be the shooting background of the target object 42. Taking the target object 42 as a person as an example, the other display objects could be passersby passing by the shooting location, etc.
[0097] The image processing method provided in this embodiment determines the distance between the displayed object and the image acquisition device based on the depth map, determines the display size of the displayed object in the preview image based on key point information, and presets a first condition, thereby accurately distinguishing the main content and the shooting background in the preview image and improving the accuracy of the main content recognition.
[0098] Optionally, based on any of the above embodiments, step 201 includes:
[0099] The depth information corresponding to each displayed object in the preview image is determined based on the depth map.
[0100] At least one display object whose depth information falls within a preset depth range is identified as the at least one content subject.
[0101] In this embodiment, since depth information can characterize the distance between pixels in the preview image and the camera lens, the subject of the content can be determined solely based on the depth information.
[0102] Optionally, a preset depth range associated with the preview image can be predetermined. Specifically, the maximum and minimum depth values associated with the preview image can be determined based on a depth map, and the preset depth range can be determined based on the maximum and minimum depth values and a preset ratio. For example, the preset ratio can be 80%, or the user can adjust the preset ratio according to actual needs; this disclosure does not impose any limitations on this.
[0103] Furthermore, the displayed object can be defined as a subject, and the depth information corresponding to each displayed object in the preview image can be determined according to the depth map. At least one displayed object whose depth information is within a preset depth range is defined as at least one content subject.
[0104] The image processing method provided in this embodiment, by pre-setting a depth range, can accurately identify the main content subject based on the depth map associated with the preview image after obtaining the depth map, thereby improving the accuracy and efficiency of the main content subject identification.
[0105] Figure 5 This is a schematic flowchart of an image processing method provided in another embodiment of the present disclosure. Based on any of the above embodiments, such as... Figure 5 As shown, step 202 includes:
[0106] Step 501: Determine the key information related to each content subject.
[0107] Step 502: Determine the target mask corresponding to the main content based on the key point information.
[0108] Step 503: Perform image segmentation on the preview image using the target mask to obtain the target region.
[0109] In this embodiment, after determining at least one content subject in the preview image, key point information of each content subject can be determined based on the image to be processed. A target mask corresponding to the content subject is then determined based on the key point information. In this target mask, the pixel value of the target area can be 1, and the pixel value of other areas can be 0. Therefore, multiplying the target mask by the preview image accurately yields the target subject area.
[0110] For example, in a practical application, the image to be processed may include facial key point information. The main content can be the human body region corresponding to the face. Therefore, the facial key point information can be used as an index to further determine the key point information of all human body regions corresponding to the face. Any key point recognition algorithm can be used to identify key points in the human body region; this disclosure does not impose any restrictions on this.
[0111] The image processing method provided in this embodiment determines the mask of the main content based on key point information, thereby enabling accurate segmentation of the main content based on the target mask.
[0112] Optionally, based on any of the above embodiments, step 102 includes:
[0113] The preview image is segmented using a preset foreground / background segmentation algorithm in the terminal device to obtain the target region in the preview image.
[0114] In this embodiment, the preview image may not include the displayed object. For example, the preview image may be a landscape image that does not include human figures.
[0115] For preview images that do not include the displayed object, the preview image can be segmented using a preset foreground / background segmentation algorithm in the terminal device to obtain the target area in the preview image.
[0116] The image processing method provided in this embodiment can improve the accuracy and efficiency of target area segmentation by using a foreground and background segmentation algorithm to segment the main content when the preview image does not include people.
[0117] Figure 6 This is a schematic flowchart of an image processing method provided in another embodiment of the present disclosure. Based on any of the above embodiments, such as... Figure 6 As shown, step 103 includes:
[0118] Step 601: Perform a Gaussian blur operation on the preview image to obtain a preview image with a blurred background.
[0119] Step 104 includes:
[0120] Step 602: Overlay the segmented target region onto the corresponding position in the background-blurred preview image to obtain the target image.
[0121] In this embodiment, to achieve a display effect where the main content is clear and the background is blurred, a Gaussian blur operation can be performed on the preview image to obtain a preview image with a blurred background. Alternatively, any other image blurring algorithm can be used to blur the preview image; this disclosure does not limit this approach.
[0122] Furthermore, the target region obtained from image segmentation can be overlaid on the corresponding position in the preview image after background blurring to obtain the target image. This ensures background blurring while avoiding distortion or blurring of the target region, thus improving the display effect of the target image.
[0123] The image processing method provided in this embodiment segments the target area, blurs the preview image, and overlays the target area onto the preview image after the background is blurred. This ensures that the target area has clear boundaries and does not deform while achieving background blurring.
[0124] Figure 7 This is a schematic diagram of the structure of the image processing apparatus provided in the embodiments of this disclosure, such as... Figure 7 As shown, the device includes: an acquisition module 71, a determination module 72, a processing module 73, and a display module 74. The acquisition module 71, in response to a user's trigger operation in the target application, acquires an image to be processed. The image to be processed is acquired by an image acquisition device in the terminal device, and includes at least a preview image currently displayed in the viewfinder of the terminal device and a depth map associated with the preview image. The determination module 72 is used to determine a target region in the preview image based on the image to be processed, wherein the target region includes the main content of the preview image. The processing module 73 is used to blur the background of the preview image. The generation module 74 is used to obtain a target image based on the target region and the background-blurred preview image. The display module 75 is used to display the target image in the viewfinder.
[0125] Furthermore, based on any of the above embodiments, the image to be processed also includes key point information associated with the displayed object in the preview image. The determining module is configured to: determine at least one content subject in the preview image based on the depth map and / or the key point information; and perform image segmentation on the preview image based on the display position of the content subject to obtain the target region.
[0126] Further, based on any of the above embodiments, the determining module is configured to: determine at least one display object in the preview image whose distance from the image acquisition device satisfies a first condition based on the depth map; determine the display size of each display object based on the key point information; and determine a target object whose display size satisfies a preset second condition among the at least one display object; compare the display size of the target object with the display sizes of other display objects in the preview image to obtain comparison results; and determine the main content of the preview image based on the comparison results.
[0127] Further, based on any of the above embodiments, the determining module is configured to: for each display object, if the size ratio between the display size of the target object and the display size of the display object is within a preset first range, then determine, based on the depth map, whether the depth difference between the display object and the target object is within a preset second range. If yes, then the target object and the display object are determined as the content subject. If no, then the target object is determined as the content subject.
[0128] Furthermore, based on any of the above embodiments, the determining module is configured to: for each display object, if the size ratio between the display size of the target object and the display size of the display object is not within a preset first range, then determine the target object as the content subject.
[0129] Furthermore, based on any of the above embodiments, the determining module is configured to: determine the depth information corresponding to each display object in the preview image according to the depth map; and determine at least one display object whose depth information is within a preset depth range as the at least one content subject.
[0130] Furthermore, based on any of the above embodiments, the determining module is configured to: determine key point information associated with each content subject; determine a target mask corresponding to the content subject based on the key point information; and perform image segmentation on the preview image using the target mask to obtain the target region.
[0131] Furthermore, based on any of the above embodiments, the determining module is used to: perform image segmentation on the preview image using a preset foreground / background segmentation algorithm in the terminal device to obtain the target region in the preview image.
[0132] Furthermore, based on any of the above embodiments, the processing module is configured to: perform a Gaussian blur operation on the preview image to obtain a preview image with a blurred background. The generation module is configured to: overlay the segmented target region onto the corresponding position in the preview image with a blurred background to obtain the target image.
[0133] Furthermore, based on any of the above embodiments, the method further includes: an acquisition module, configured to, in response to an image acquisition operation triggered by a user, store the target image displayed in the viewfinder to a preset storage path.
[0134] The device provided in this embodiment can be used to execute the technical solutions of the above method embodiments. Its implementation principle and technical effect are similar, and will not be described again here.
[0135] To implement the above embodiments, this disclosure also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the image processing method as described in any of the above embodiments.
[0136] To implement the above embodiments, this disclosure also provides a computer program product, including a computer program that, when executed by a processor, implements the image processing method as described in any of the above embodiments.
[0137] To implement the above embodiments, this disclosure also provides an electronic device, including: a processor and a memory;
[0138] The memory stores computer-executed instructions;
[0139] The processor executes computer execution instructions stored in the memory, causing the processor to perform the image processing method as described in any of the above embodiments.
[0140] Figure 8This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. The electronic device 800 can be a terminal device or a server. The terminal device can include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, personal digital assistants (PDAs), portable Android devices (PADs), portable media players (PMPs), and in-vehicle terminals (e.g., in-vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. Figure 8 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0141] like Figure 8 As shown, the electronic device 800 may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage device 808 into a random access memory (RAM) 803. The RAM 803 also stores various programs and data required for the operation of the electronic device 800. The processing unit 801, ROM 802, and RAM 803 are interconnected via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0142] Typically, the following devices can be connected to I / O interface 805: input devices 806 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 807 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 808 including, for example, magnetic tapes, hard disks, etc.; and communication devices 809. Communication device 809 allows electronic device 800 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 8 An electronic device 800 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0143] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 809, or installed from a storage device 808, or installed from a ROM 802. When the computer program is executed by a processing device 801, it performs the functions defined in the methods of embodiments of this disclosure.
[0144] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0145] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0146] The aforementioned computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to perform the methods shown in the above embodiments.
[0147] Computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0148] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0149] The units described in the embodiments of this disclosure can be implemented in software or in hardware. The name of a unit does not necessarily limit the unit itself; for example, the first acquisition unit can also be described as "a unit that acquires at least two Internet Protocol addresses".
[0150] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0151] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0152] In a first aspect, according to one or more embodiments of the present disclosure, an image processing method is provided, comprising:
[0153] In response to a user's triggering operation in a target application, an image to be processed is acquired, wherein the image to be processed is acquired by an image acquisition device in a terminal device, and the image to be processed includes at least a preview image currently displayed in the viewfinder of the terminal device and a depth map associated with the preview image.
[0154] Based on the image to be processed, a target region in the preview image is determined, wherein the target region includes the main content of the preview image;
[0155] Blur the background of the preview image;
[0156] Based on the target area and the preview image with the background blurred, the target image is obtained;
[0157] The target image is displayed in the viewfinder.
[0158] According to one or more embodiments of this disclosure, the image to be processed further includes key point information associated with the display object in the preview image;
[0159] The step of determining the target region in the preview image based on the image to be processed includes:
[0160] At least one content subject in the preview image is determined based on the depth map and / or the key point information;
[0161] The preview image is segmented based on the display position of the main content to obtain the target area.
[0162] According to one or more embodiments of this disclosure, determining at least one content subject in the preview image based on the depth map and / or the key point information includes:
[0163] Based on the depth map, at least one display object in the preview image whose distance from the image acquisition device satisfies a first condition is determined.
[0164] Based on the key point information, the display size of each display object is determined, and among the at least one display object, a target object whose display size meets the preset second condition is determined.
[0165] The display size of the target object is compared with the display sizes of other display objects in the preview image to obtain the comparison results;
[0166] The main content of the preview image is determined based on the comparison results.
[0167] According to one or more embodiments of this disclosure, determining the main content element in the preview image based on the comparison result includes:
[0168] For each display object, if the size ratio between the display size of the target object and the display size of the display object is within a preset first range, then based on the depth map, it is determined whether the depth difference between the display object and the target object is within a preset second range;
[0169] If so, then the target object and the display object are determined as the main content;
[0170] If not, then the target object is determined as the content subject.
[0171] According to one or more embodiments of this disclosure, determining the main content element in the preview image based on the comparison result includes:
[0172] For each display object, if the size ratio between the display size of the target object and the display size of the display object is not within a preset first range, then the target object is determined as the content subject.
[0173] According to one or more embodiments of this disclosure, determining at least one content subject in the preview image based on the depth map and / or the key point information includes:
[0174] Determine the depth information corresponding to each displayed object in the preview image based on the depth map;
[0175] At least one display object whose depth information falls within a preset depth range is identified as the at least one content subject.
[0176] According to one or more embodiments of this disclosure, the step of performing image segmentation on the preview image based on the display position of the content subject to obtain the target region includes:
[0177] Identify the key information linking the various content subjects;
[0178] Determine the target mask corresponding to the main content based on the key point information;
[0179] The target region is obtained by performing image segmentation on the preview image using the target mask.
[0180] According to one or more embodiments of this disclosure, determining the target region in the preview image based on the image to be processed includes:
[0181] The preview image is segmented using a preset foreground / background segmentation algorithm in the terminal device to obtain the target region in the preview image.
[0182] According to one or more embodiments of this disclosure, the step of performing a background blurring operation on the preview image and obtaining a target image based on the target region and the background-blurred preview image includes:
[0183] Apply a Gaussian blur operation to the preview image to obtain a preview image with a blurred background;
[0184] The process of obtaining the target image based on the target region and the background-blurred preview image includes:
[0185] The segmented target region is overlaid on the corresponding position in the background-blurred preview image to obtain the target image.
[0186] According to one or more embodiments of this disclosure, the method further includes:
[0187] In response to a user-triggered image acquisition operation, the target image displayed in the viewfinder is stored to a preset storage path.
[0188] Secondly, according to one or more embodiments of the present disclosure, an image processing apparatus is provided, comprising:
[0189] The acquisition module, in response to a user's trigger operation in the target application, acquires an image to be processed, wherein the image to be processed is acquired by an image acquisition device in the terminal device, and the image to be processed includes at least the preview image currently displayed in the viewfinder of the terminal device and the depth map associated with the preview image;
[0190] The determining module is used to determine a target region in the preview image based on the image to be processed, wherein the target region includes the main content of the preview image;
[0191] The processing module is used to blur the background of the preview image;
[0192] The generation module is used to obtain the target image based on the target area and the preview image after background blurring;
[0193] A display module for displaying the target image in the viewfinder.
[0194] According to one or more embodiments of this disclosure, the image to be processed further includes key point information associated with the display object in the preview image;
[0195] The determining module is used for:
[0196] At least one content subject in the preview image is determined based on the depth map and / or the key point information;
[0197] The preview image is segmented based on the display position of the main content to obtain the target area.
[0198] According to one or more embodiments of this disclosure, the determining module is configured to:
[0199] Based on the depth map, at least one display object in the preview image whose distance from the image acquisition device satisfies a first condition is determined.
[0200] Based on the key point information, the display size of each display object is determined, and among the at least one display object, a target object whose display size meets the preset second condition is determined.
[0201] The display size of the target object is compared with the display sizes of other display objects in the preview image to obtain the comparison results;
[0202] The main content of the preview image is determined based on the comparison results.
[0203] According to one or more embodiments of this disclosure, the determining module is configured to:
[0204] For each display object, if the size ratio between the display size of the target object and the display size of the display object is within a preset first range, then based on the depth map, it is determined whether the depth difference between the display object and the target object is within a preset second range;
[0205] If so, then the target object and the display object are determined as the main content;
[0206] If not, then the target object is determined as the content subject.
[0207] According to one or more embodiments of this disclosure, the determining module is configured to:
[0208] For each display object, if the size ratio between the display size of the target object and the display size of the display object is not within a preset first range, then the target object is determined as the content subject.
[0209] According to one or more embodiments of this disclosure, the determining module is configured to:
[0210] Determine the depth information corresponding to each displayed object in the preview image based on the depth map;
[0211] At least one display object whose depth information falls within a preset depth range is identified as the at least one content subject.
[0212] According to one or more embodiments of this disclosure, the determining module is configured to:
[0213] Identify the key information linking the various content subjects;
[0214] Determine the target mask corresponding to the main content based on the key point information;
[0215] The target region is obtained by performing image segmentation on the preview image using the target mask.
[0216] According to one or more embodiments of this disclosure, the determining module is configured to:
[0217] The preview image is segmented using a preset foreground / background segmentation algorithm in the terminal device to obtain the target region in the preview image.
[0218] According to one or more embodiments of this disclosure, the processing module is configured to:
[0219] Apply a Gaussian blur operation to the preview image to obtain a preview image with a blurred background;
[0220] The generation module is used for:
[0221] The segmented target region is overlaid on the corresponding position in the background-blurred preview image to obtain the target image.
[0222] According to one or more embodiments of this disclosure, the method further includes:
[0223] The acquisition module is used to respond to the image acquisition operation triggered by the user and store the target image displayed in the viewfinder to a preset storage path.
[0224] Thirdly, according to one or more embodiments of the present disclosure, an electronic device is provided, comprising: at least one processor and a memory;
[0225] The memory stores computer-executed instructions;
[0226] The at least one processor executes computer execution instructions stored in the memory, causing the at least one processor to perform the image processing method as described in the first aspect and various possible designs of the first aspect.
[0227] Fourthly, according to one or more embodiments of the present disclosure, a computer-readable storage medium is provided, wherein computer-executable instructions are stored therein, which, when executed by a processor, implement the image processing method described in the first aspect and various possible designs of the first aspect.
[0228] Fifthly, according to one or more embodiments of the present disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements the image processing method as described in the first aspect and various possible designs of the first aspect.
[0229] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.
[0230] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0231] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.
Claims
1. An image processing method, characterized in that, include: In response to a user's triggering operation in a target application, an image to be processed is acquired, wherein the image to be processed is acquired by an image acquisition device in a terminal device, and the image to be processed includes at least a preview image currently displayed in the viewfinder of the terminal device and a depth map associated with the preview image. Based on the image to be processed, a target region in the preview image is determined, wherein the target region includes the main content of the preview image; Blur the background of the preview image; Based on the target area and the preview image with the background blurred, the target image is obtained; The target image is displayed in the viewfinder.
2. The method according to claim 1, characterized in that, The image to be processed also includes key point information associated with the display object in the preview image; The step of determining the target region in the preview image based on the image to be processed includes: At least one content subject in the preview image is determined based on the depth map and / or the key point information; The preview image is segmented based on the display position of the main content to obtain the target area.
3. The method according to claim 2, characterized in that, Determining at least one content subject in the preview image based on the depth map and / or the key point information includes: Based on the depth map, at least one display object in the preview image whose distance from the image acquisition device satisfies a first condition is determined. Based on the key point information, the display size of each display object is determined, and among the at least one display object, a target object whose display size meets the preset second condition is determined. The display size of the target object is compared with the display sizes of other display objects in the preview image to obtain the comparison results; The main content of the preview image is determined based on the comparison results.
4. The method according to claim 3, characterized in that, Determining the main content of the preview image based on the comparison result includes: For each display object, if the size ratio between the display size of the target object and the display size of the display object is within a preset first range, then based on the depth map, it is determined whether the depth difference between the display object and the target object is within a preset second range; If so, then the target object and the display object are determined as the main content; If not, then the target object is determined as the content subject.
5. The method according to claim 3, characterized in that, Determining the main content of the preview image based on the comparison result includes: For each display object, if the size ratio between the display size of the target object and the display size of the display object is not within a preset first range, then the target object is determined as the content subject.
6. The method according to claim 2, characterized in that, Determining at least one content subject in the preview image based on the depth map and / or the key point information includes: Determine the depth information corresponding to each displayed object in the preview image based on the depth map; At least one display object whose depth information falls within a preset depth range is identified as the at least one content subject.
7. The method according to any one of claims 2-6, characterized in that, The step of performing image segmentation on the preview image based on the display position of the main content to obtain the target region includes: Identify the key information linking the various content subjects; Determine the target mask corresponding to the main content based on the key point information; The target region is obtained by performing image segmentation on the preview image using the target mask.
8. The method according to claim 1, characterized in that, The step of determining the target region in the preview image based on the image to be processed includes: The preview image is segmented using a preset foreground / background segmentation algorithm in the terminal device to obtain the target region in the preview image.
9. The method according to any one of claims 1-6 or 8, characterized in that, The step of blurring the background of the preview image includes: Apply a Gaussian blur operation to the preview image to obtain a preview image with a blurred background; The process of obtaining the target image based on the target region and the background-blurred preview image includes: The segmented target region is overlaid on the corresponding position in the background-blurred preview image to obtain the target image.
10. The method according to any one of claims 1-6 or 8, characterized in that, The method further includes: In response to a user-triggered image acquisition operation, the target image displayed in the viewfinder is stored to a preset storage path.
11. An image processing apparatus, characterized in that, include: The acquisition module, in response to a user's trigger operation in the target application, acquires an image to be processed, wherein the image to be processed is acquired by an image acquisition device in the terminal device, and the image to be processed includes at least the preview image currently displayed in the viewfinder of the terminal device and the depth map associated with the preview image; The determining module is used to determine a target region in the preview image based on the image to be processed, wherein the target region includes the main content of the preview image; The processing module is used to blur the background of the preview image; The generation module is used to obtain the target image based on the target area and the preview image after background blurring; A display module for displaying the target image in the viewfinder.
12. An electronic device, characterized in that, include: Processor and memory; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory, causing the processor to perform the image processing method as described in any one of claims 1 to 10.
13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, implement the image processing method as described in any one of claims 1 to 10.
14. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the image processing method as described in any one of claims 1 to 10.