Image Generation Method, Apparatus and Device

Generate depth of field images through a single camera to control the focus distance and blur rules, solving the cost and volume problems brought by multiple cameras and achieving high-quality depth of field effects.

CN116208850BActive Publication Date: 2025-07-25SHENZHEN JINXUN SOFTWARE CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310126071.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-07
Publication Date
2025-07-25
Estimated Expiration
2043-02-07

AI Technical Summary

Technical Problem

In the prior art, generating depth of field images requires at least two cameras, which increases the cost and volume of equipment. At the same time, the depth of field images generated based on one image are poor in effect and are prone to problems such as false imaginary subjects and false backgrounds.

Method used

By controlling a single camera motor to move to different focus distances, multiple images are acquired, and planes are built in one image to blur, depth of field images are generated, and image effects are optimized using artificial intelligence models to extract object outlines and blur rules.

Benefits of technology

It realizes the generation of high-quality depth of field images using a single camera, with clear front and rear view edges, solving the cost and volume problems brought by multiple cameras, and improving the depth of field effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116208850B_ABST
    Figure CN116208850B_ABST
Patent Text Reader

Abstract

The present application relates to the field of image processing technology, and provides an image generation method, apparatus and device. The method includes: in the depth-of-field image shooting mode, controlling the movement of the camera motor to obtain the focusing distance that makes the selected object the clearest; acquiring the image captured by the camera at this focusing distance; determining a second target object in the first image whose sharpness is less than that of the first target object; controlling the camera motor to move again to obtain the focusing distance that makes the second target object the clearest as the second focusing distance; acquiring the image captured by the camera at the second focusing distance as the second image; based on the first target object, constructing a first plane in the second image and blurring the image outside the first plane to obtain a third image. The embodiment of the present invention realizes the generation of a depth-of-field image through a single camera, and the generated depth-of-field effect is better than that of generating a depth-of-field image based on a single image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technologies, and in particular, to an image generation method, apparatus, and device. Background Art

[0002] Depth of field refers to the range of the front and rear distances of an object to be photographed measured by the imaging that can obtain a clear image at the front edge of a camera lens or other imager. The inventor found that the depth-of-field images on the market are all realized based on dual cameras, that is, the number of cameras is at least two. If a wide-angle camera and a macro camera are added, then at least four rear cameras are required. Coupled with a front camera, then five cameras are required. Therefore, mobile phones with relatively complete functions on the market generally have five cameras configured, which not only increases the cost but also increases the weight and volume of the mobile phone, affecting the aesthetics. In addition, existing beauty picture software generates a depth-of-field image based on an image, but the generated depth-of-field image has a poor effect and is prone to problems such as incorrect blurring of the main object (target object) and missed blurring of the background. Summary of the Invention

[0003] Aiming at the above technical problems, the purpose of the present application is to provide an image generation method, apparatus, and device, aiming to solve the technical problems that generating a depth-of-field image requires two cameras and the depth-of-field image generated based on an image has a poor effect.

[0004] In a first aspect, an embodiment of the present invention provides an image generation method, including:

[0005] In the depth-of-field image shooting mode, if a shooting instruction is received, control the camera motor to move to obtain the focusing distance that makes the selected object the clearest, and use the clearest focusing distance as the first focusing distance;

[0006] Obtain the image captured by the camera at the first focusing distance as the first image;

[0007] Extract the selected object from the first image as the first target object;

[0008] Select a second target object in the first image; wherein, the clarity of the second target object is less than that of the first target object;

[0009] Control the camera motor to move again to obtain the focusing distance that makes the second target object the clearest as the second focusing distance;

[0010] Obtain the image captured by the camera at the second focusing distance as the second image;

[0011] Based on the first target object, construct a first plane in the second image, and blur the image outside the first plane according to a preset rule.

[0012] Further, the method further includes:

[0013] Store the first image, the second image, and the third image in a memory;

[0014] Associate the storage path of the third image with the storage paths of the first image and the second image.

[0015] Further, the method further includes:

[0016] In the depth-of-field object switching mode, based on the object selected by the user in the third image, regenerate a fourth image using the first image and the second image to achieve depth-of-field object switching.

[0017] Further, the step of, in the depth-of-field object switching mode, based on the object selected by the user in the third image, regenerating a fourth image using the first image and the second image to achieve depth-of-field object switching includes:

[0018] In the depth-of-field object switching mode, if it is detected that the user clicks on the third image, obtain the click position;

[0019] Determine whether the click position is on the first plane of the third image or outside the first plane of the third image;

[0020] If the click position is on the first plane of the third image, retrieve the first image corresponding to the third image from the memory;

[0021] Extract the object corresponding to the click position in the retrieved first image as the third target object;

[0022] Retrieve the second image corresponding to the third image from the memory;

[0023] Based on the third target object, construct a second plane in the retrieved second image, and blur the image outside the second plane in the second image to obtain a fourth image;

[0024] If the click position is outside the first plane of the third image, retrieve the second image corresponding to the third image from the memory;

[0025] Extract the object corresponding to the click position in the retrieved second image as the fourth target object;

[0026] Retrieve the first image corresponding to the third image from the memory;

[0027] Based on the fourth target object, construct a third plane in the retrieved first image, and blur the image outside the third plane in the first image to obtain a fourth image.

[0028] Further, the controlling the camera motor to move to obtain the focusing distance at which the selected object is clearest, and taking the clearest focusing distance as the first focusing distance includes:

[0029] Control the camera motor to move to the farthest position, and then move from the farthest position to the nearest position to obtain the field of view content;

[0030] Or,

[0031] Control the camera motor to move to the nearest position, and then move from the nearest position to the farthest position to obtain the field of view content;

[0032] Based on the field of view content, calculate the focusing distance at which the selected object is clearest using the dichotomy method as the first focusing distance.

[0033] Further, before the step of receiving the shooting instruction, it further includes:

[0034] Perform scene detection on the selected object to obtain the scene corresponding to the selected object;

[0035] The extracting the selected object from the first image includes:

[0036] Call the artificial intelligence model corresponding to the scene from the preset database;

[0037] Use the artificial intelligence model to estimate the contour edge of the selected object to obtain a first contour edge;

[0038] Adjust the first contour edge according to the color comparison of the contour edge to obtain a second contour edge;

[0039] Extract the selected object based on the second contour edge.

[0040] Further, the blurring the image outside the first plane according to a preset rule to obtain a third image includes:

[0041] Determine whether the user moves the slider on the blurring progress bar;

[0042] If so, determine the first target blurring degree according to the position of the slider on the progress bar;

[0043] Blur the image outside the first plane according to the first target blurring degree and a preset rule to obtain a third image;

[0044] If not, determine the default blurring degree according to the position where the slider defaults to appear on the blurring progress bar;

[0045] Blur the image outside the first plane according to the default blurring degree and a preset rule to obtain a third image.

[0046] Further, after the step of obtaining the third image, the method further includes

[0047] When a compilation instruction for the third image is received, display a blurring progress bar;

[0048] Determine whether the user moves the slider on the blurring progress bar;

[0049] If so, determine a second target blurring degree according to the position of the slider on the blurring progress bar;

[0050] Adjust the blurring degree of the image outside the first plane in the third image according to the second target blurring degree.

[0051] In a second aspect, an embodiment of the present invention provides an image generation device, including:

[0052] A first control module, configured to, in a depth-of-field image shooting mode, if a shooting instruction is received, control a camera motor to move to obtain a focusing distance at which a selected object is clearest, and use the clearest focusing distance as a first focusing distance;

[0053] A first image acquisition module, configured to acquire an image captured by the camera at the first focusing distance as a first image;

[0054] An extraction module, configured to extract the selected object from the first image as a first target object

[0055] A selection module, configured to select a second target object in the first image; wherein, the clarity of the second target object is less than that of the first target object;

[0056] A second control module, configured to control the camera motor to move again to obtain a focusing distance at which the second target object is clearest as a second focusing distance;

[0057] A second image acquisition module, configured to acquire an image captured by the camera at the second focusing distance as a second image;

[0058] An image processing module, configured to construct a first plane in the second image based on the first target object, and blur the image outside the first plane according to a preset rule to obtain a third image.

[0059] In a third aspect, an embodiment of the present invention provides a computer device, including a memory and a processor. A computer program is stored in the memory, and when the processor executes the computer program, the steps of the image generation method as described in any one of the above are implemented.

[0060] In the depth-of-field image shooting mode, if a shooting instruction is received, the embodiment of the present invention controls the camera motor to move to obtain the focus distance that makes the selected object the clearest, and uses the clearest focus distance as the first focus distance; obtains the image captured by the camera at the first focus distance as the first image; extracts the selected object from the first image as the first target object; selects a second target object in the first image, where the clarity of the second target object is less than that of the first target object; controls the camera motor to move again to obtain the focus distance that makes the second target object the clearest as the second focus distance; obtains the image captured by the camera at the second focus distance as the second image; constructs a first plane in the second image based on the first target object, and blurs the image outside the first plane according to a preset rule to obtain a third image. In this way, the edges of the foreground and background are clearer, and the depth-of-field effect is better. In addition, since all the cameras described above in the present invention refer to the same camera, that is, the embodiment of the present invention can generate a depth-of-field image through one camera, thus solving the technical problem that two cameras are required to generate a depth-of-field image. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] In order to more clearly illustrate the technical solutions of the present application, the drawings required for the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0062] Figure 1 is a flowchart of the image generation method provided by an embodiment of the present application;

[0063] Figure 2 is a schematic diagram of the first image provided by an embodiment of the present application;

[0064] Figure 3 is a flowchart of blurring the image outside the first plane according to a preset rule to obtain a third image provided by an embodiment of the present application;

[0065] Figure 4 It is a schematic structural diagram of an image generation device provided by an embodiment of the present application;

[0066] Figure 5 It is a schematic block diagram of the structure of a computer device provided by an embodiment of the present application. Specific embodiments

[0067] In order to make the purpose, technical solutions and advantages of the present application clearer, the following further details the present application in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0068] Those skilled in the art of the present technology can understand that unless specifically stated, the singular forms "a", "an", "the above" and "the" used herein may also include the plural forms. It should be further understood that the term "including" used in the description of the present invention means the presence of features, integers, steps, operations, elements, modules, modules and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, modules, components and / or their groups. It should be understood that when we say that an element is "connected" or "coupled" to another element, it can be directly connected or coupled to other elements, or there may also be intermediate elements. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The phrase "and / or" used herein includes all or any module and all combinations of one or more related listed items.

[0069] Those skilled in the art of the present technology can understand that unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meaning as the general understanding of those of ordinary skill in the art to which the present invention belongs. It should also be understood that terms such as those defined in a general dictionary should be understood to have a meaning consistent with the meaning in the context of the prior art, and will not be interpreted with an idealized or overly formal meaning unless specifically defined as here.

[0070] Embodiment 1:

[0071] Please refer to Figure 1 , an embodiment of the present application provides an image generation method, including steps S1-S8:

[0072] S1. In the depth-of-field image shooting mode, if a shooting instruction is received, control the camera motor to move to obtain the focus distance that makes the selected object the clearest, and use the clearest focus distance as the first focus distance.

[0073] The method of the present invention can be applied to electronic devices with a shooting function such as mobile phones and tablet computers. Assuming that this method is applied to a mobile phone, the image generation method of the present invention provides a function of generating a depth-of-field image, which can be popularly understood as the function of taking a depth-of-field photo. When the user switches from conventional shooting to the function of taking a depth-of-field photo, in the depth-of-field image shooting mode, the content within the camera's field of view will be displayed on the mobile phone interface. The user clicks on an object by tapping the screen. When the mobile phone detects that the user clicks on an object, it will control the camera motor to move and automatically capture the object in a way such as using a rectangular frame, and take the captured object as the selected object. For example, suppose there is a photo with user Xiaoming and other scenery in it. Assuming that user Xiaoming clicks on himself, the mobile phone will automatically capture Xiaoming as the selected object. It should be noted that in the case where the user does not click on an object, the mobile phone will also analyze the image and capture an object as the selected object according to the priority of the object type. For example, the priority of a person is greater than that of a pet, and the priority of a pet is greater than that of scenery. Suppose there is a person and scenery in a picture. Then, the mobile phone will capture this person. Suppose there are multiple people in the picture. Then, these people will be captured as one object, or a person will be randomly captured as an object, or the object will be captured according to the distance of the object from the lens. In addition, the object in the middle of the image can also be defaulted as the selected object. It should be noted that there are various ways to select an object, and the embodiments of the present invention do not limit this here.

[0074] In addition, in the embodiments of the present invention, when the user clicks the shooting button, the mobile phone will control the camera motor to move to obtain the focusing distance that makes the selected object the clearest. It should be understood that the camera module usually uses a camera motor to drive the lens to achieve the focusing function.

[0075] S2. Obtain the image captured by the camera at the first focusing distance as the first image.

[0076] In the embodiments of the present invention, after obtaining the first focusing distance, the mobile phone will adjust the original focusing distance to the first focusing distance, and then control the camera to take a picture, and take the captured image as the first image.

[0077] S3. Extract the selected object from the first image as the first target object.

[0078] By extracting the selected object from the first image as the first target object, it is convenient for the subsequent generation of the depth-of-field picture.

[0079] S4. Select a second target object in the first image; wherein, the clarity of the second target object is less than that of the first target object.

[0080] In an embodiment of the present invention, assume that the first image is as follows Figure 2 shown. The object enclosed by the solid line is taken as the first target object, which is the clearest area in the first image. The object enclosed by the dashed line is taken as the second target object, and the clarity of the second target object is less than that of the first target object.

[0081] S5. Control the camera motor to move again to obtain the focusing distance that makes the second target object the clearest, which is used as the second focusing distance.

[0082] S6. Obtain the image captured by the camera at the second focusing distance, which is used as the second image.

[0083] S7. Based on the first target object, construct a first plane in the second image, and blur the image outside the first plane according to a preset rule to obtain a third image.

[0084] In an embodiment of the present invention, when the first target object is captured at the first focusing distance, the plane position where it is located in the three-dimensional space is the first plane, and this plane position is perpendicular to the principal optical axis of the lens, that is, the first plane includes the extracted first target object. It should be understood that the extracted first target object is an image. After constructing the first plane in the second image, relatively clear edges of the foreground and background can be obtained through Gaussian filtering. It should be noted that the first plane is a component part of the third image.

[0085] In an embodiment of the present invention, if the first image is used as the close-up image and the second image is used as the long-shot image, then first, the first target object needs to be cut out from the close-up image according to a preset algorithm, and then the outline of the first target object is outlined in the long-shot image. The image within the outline, that is, the first target object in the long-shot image, is deleted, and the cut-out first target object is stacked into the outline in the long-shot image, and the image outside the outline in the long-shot image is blurred. In this way, a depth-of-field image is obtained, that is, the generated third image is a depth-of-field image, and the foreground and background edges of the generated depth-of-field image are distinguished relatively clearly. Therefore, the depth-of-field effect is better, while the existing single-plane beauty software processing will have the situations of incorrect blurring of the main body and missed blurring of the background.

[0086] In an embodiment of the present invention, in the depth-of-field image shooting mode, if a shooting instruction is received, the camera motor is controlled to move to obtain the focusing distance at which the selected object is the clearest, and the clearest focusing distance is used as the first focusing distance; the image captured by the camera at the first focusing distance is obtained as the first image; the selected object is extracted from the first image as the first target object; a second target object is selected in the first image; wherein the clarity of the second target object is less than that of the first target object; the camera motor is controlled to move again to obtain the focusing distance at which the second target object is the clearest as the second focusing distance; the image captured by the camera at the second focusing distance is obtained as the second image; based on the first target object, a first plane is constructed in the second image, and the image outside the first plane is blurred according to a preset rule to obtain a third image. In this way, the edges of the foreground and background are clearer and the depth-of-field effect is better. In addition, since all the cameras described above in the present invention refer to the same camera, that is, in an embodiment of the present invention, a depth-of-field image can be generated by one camera, thus solving the technical problem that two cameras are required to generate a depth-of-field image.

[0087] In one embodiment, multiple second target objects can be selected, that is, multiple second images can be obtained, and the depth-of-field image is obtained by stacking multiple images (including the first image and multiple second images) using the image stacking technology.

[0088] In one embodiment, the image generation method further includes:

[0089] Store the first image, the second image, and the third image in a memory;

[0090] Associate the storage path of the third image with the storage paths of the first image and the second image.

[0091] In the present invention, by storing the first image, the second image, and the third image in a memory and associating the storage path of the third image with the storage paths of the first image and the second image, the depth-of-field object of the third image can be switched by calling the first image and the second image.

[0092] In one embodiment, the image generation method further includes:

[0093] In the depth-of-field object switching mode, based on the object selected by the user in the third image, the first image and the second image are reused to generate a fourth image to achieve the switching of the depth-of-field object.

[0094] In an embodiment of the present invention, since the third image is a synthesized image, when implementing depth-of-field object switching, it is necessary to call the first image and the second image from the memory, and use the first image and the second image to implement depth-of-field object switching. After generating the fourth image, store the fourth image in the memory, and associate the storage path of the fourth image with the storage paths of the first image and the second image.

[0095] In one embodiment, the step of, in the depth-of-field object switching mode, reusing the first image and the second image to generate a fourth image based on the object selected by the user in the third image to implement depth-of-field object switching includes:

[0096] In the depth-of-field object switching mode, if it is detected that the user clicks on the third image, obtain the click position;

[0097] Determine whether the click position is on the first plane of the third image or outside the first plane of the third image;

[0098] If the click position is on the first plane of the third image, call out the first image corresponding to the third image from the memory;

[0099] Extract the object corresponding to the click position in the called-out first image as the third target object;

[0100] Call out the second image corresponding to the third image from the memory;

[0101] Based on the third target object, construct a second plane in the called-out second image, and blur the image outside the second plane in the second image to obtain a fourth image;

[0102] If the click position is outside the first plane of the third image, call out the second image corresponding to the third image from the memory;

[0103] Extract the object corresponding to the click position in the called-out second image as the fourth target object;

[0104] Call out the first image corresponding to the third image from the memory;

[0105] Based on the fourth target object, construct a third plane in the called-out first image, and blur the image outside the third plane in the first image to obtain a fourth image.

[0106] In an embodiment of the present invention, the third image may be a directly generated third image or a third image retrieved from a memory. The object clicked by the user is the prominent object, i.e., the clear object, in the depth-of-field image desired by the user. Therefore, when the clicked position is on the first plane of the third image, the first image corresponding to the third image needs to be retrieved from the memory (because the clear image of the object clicked by the user is in the first image), and the object corresponding to the clicked position is extracted from the retrieved first image as the third target object. Then, the second image corresponding to the third image is retrieved from the memory, and based on the third target object, a second plane is constructed in the retrieved second image, and the image outside the second plane in the second image is blurred to obtain a fourth image. Similar to the relationship between the first plane and the first target object, the second plane includes the extracted third target object. It should be understood that the third target object is an image. It should be noted that the second plane is a component of the third image.

[0107] When the clicked position is outside the first plane of the third image, the second image corresponding to the third image needs to be retrieved from the memory (because the clear image of the object clicked by the user is in the second image), and the object corresponding to the clicked position is extracted from the retrieved second image as the fourth target object. Then, the first image corresponding to the third image is retrieved from the memory, and based on the fourth target object, a third plane is constructed in the retrieved first image, and the image outside the third plane in the first image is blurred to obtain a fourth image. Similar to the relationship between the first plane and the first target object, the third plane also includes the extracted fourth target object. It should be understood that the fourth target object is an image. It should be noted that the third plane is a component of the fourth image.

[0108] In one embodiment, controlling the camera motor to move to obtain the focusing distance that makes the selected object clearest, and taking the clearest focusing distance as the first focusing distance includes:

[0109] Controlling the camera motor to move and calculating the clarity of the selected object in real time, and taking the focusing distance that makes the selected object clearest as the first focusing distance.

[0110] In one embodiment, controlling the camera motor to move to obtain the focusing distance that makes the selected object clearest, and taking the clearest focusing distance as the first focusing distance includes:

[0111] Controlling the camera motor to move to the farthest position and then move from the farthest position to the nearest position to obtain the field of view content;

[0112] Or,

[0113] Control the camera motor to move to the nearest position, and then move from the nearest position to the farthest position to obtain the field of view content;

[0114] According to the field of view content, calculate the focusing distance that makes the selected object the clearest by the dichotomy method as the first focusing distance.

[0115] In the embodiment of the present invention, if the initial position of the camera motor is neither at the nearest position nor at the farthest position, the camera motor is moved from the initial position to the farthest position, and then from the farthest position to the nearest position, or from the initial position to the nearest position, and then from the nearest position to the farthest position. If the initial position of the camera motor is at the nearest position, the camera motor is moved from the nearest position to the farthest position. If the initial position of the camera motor is at the farthest position, the camera motor is moved from the farthest position to the nearest position.

[0116] In addition, it should be understood that generally, the image obtained from the camera is a raw image, and the raw image has no color. It is the colored image that we can see after passing through the ISP processor. Therefore, each frame of the image obtained from the camera needs to be subjected to tuning processing, including color restoration, noise reduction, LSC shadow calibration, and image exposure processing. However, for the sake of clarity, the images obtained from the camera or the images obtained by controlling the camera to take pictures described in the present invention all refer to the images that have been subjected to tuning processing.

[0117] In addition, the specific steps for calculating the focusing distance that makes the selected object the clearest based on the dichotomy method are as follows:

[0118] Control the camera motor to move from the nearest to the farthest or from the farthest to the nearest;

[0119] Calculate the clarity of the selected object when the camera moves to the farthest as the first clarity;

[0120] Calculate the clarity of the selected object when the camera moves to the nearest as the second clarity;

[0121] Calculate the clarity of the selected object when the camera moves to the middle as the third clarity;

[0122] Take the position when the camera motor moves to the farthest as the first position, the position when the camera motor moves to the nearest as the second position, and the position when the camera motor moves to the middle as the third position;

[0123] Determine the first interval where the position of the focusing distance that makes the selected object clearest is located according to the first clarity, the second clarity, and the third clarity; wherein, the first interval is between the first position and the third position, or between the third position and the second position;

[0124] Calculate the clarity of the selected object when the camera motor moves to the middle position of the interval as the fourth clarity;

[0125] Confirm the second interval where the position of the focusing distance that makes the selected object clearest is located according to the clarity of the selected object at both ends of the first interval and the fourth clarity;

[0126] And so on to obtain the focusing distance that makes the selected object clearest.

[0127] The embodiment of the present invention determines the focusing distance that makes the first target object clearest by the dichotomy method. In this way, not only can the focusing distance that makes the first target object clearest be found, but also the time and calculation amount for finding the focusing distance that makes the first target object clearest can be reduced.

[0128] In one embodiment, the controlling the camera motor to move again to obtain the focusing distance that makes the second target object clearest as the second focusing distance includes:

[0129] Control the camera motor to move again and calculate the clarity of the second target object in real time, and use the focusing distance that makes the selected object clearest as the first focusing distance.

[0130] In one embodiment, the controlling the camera motor to move again to obtain the focusing distance that makes the second target object clearest as the second focusing distance includes:

[0131] Control the camera motor to move to the farthest position and then move from the farthest position to the nearest position to obtain the field of view content;

[0132] Or,

[0133] Control the camera motor to move to the nearest position and then move from the nearest position to the farthest position to obtain the field of view content;

[0134] According to the field of view content, calculate the focusing distance that makes the second target object clearest as the second focusing distance based on the dichotomy method.

[0135] The embodiment of the present invention calculates the focusing distance that makes the second target object clearest based on the dichotomy method in the same way as the above method for calculating the focusing distance that makes the acquired object clearest based on the dichotomy method, and the embodiment of the present invention will not elaborate herein.

[0136] In one embodiment, before the step of receiving the shooting instruction, the method further includes:

[0137] Performing scene detection on the selected object to obtain the scene corresponding to the selected object;

[0138] The extracting the selected object from the first image includes:

[0139] Calling the artificial intelligence model corresponding to the scene from a preset database;

[0140] Using the artificial intelligence model to estimate the contour edge of the selected object to obtain a first contour edge;

[0141] Adjusting the first contour edge according to the color comparison of the contour edges to obtain a second contour edge;

[0142] Extracting the selected object based on the second contour edge.

[0143] In an embodiment of the present invention, the scene may be a person, food, beach, building, animal, flower, grass, car, moon, sun, etc. Each scene has its own corresponding artificial intelligence model. The corresponding artificial intelligence model is trained through the corresponding scene. Suppose the detected scene corresponding to the selected object is a person. Then, its corresponding artificial intelligence model will estimate the contour edge of the selected object by regarding the selected object as a person. Also, since the colors of the background where people are located are generally diverse, only estimating the selected object as a person by the artificial intelligence model may be inaccurate. Therefore, it is also necessary to adjust the first contour edge in combination with the color comparison of the contour edges to obtain a more accurate contour edge. In addition, to further improve the accuracy of the extracted selected object (for example, if a person is extracted, the purpose is to extract a complete person rather than an incomplete person), traditional Bayesian matting algorithms, Graph Cut, Alpha mat, etc. and some deep learning matting algorithms can be further combined for extraction.

[0144] Please refer to Figure 3 , in one embodiment, the blurring the image outside the first plane according to a preset rule to obtain a third image includes steps S41 - S45:

[0145] S41. Judging whether the user moves the slider on the blurring progress bar;

[0146] S42. If so, determining a first target blurring degree according to the position of the slider on the progress bar;

[0147] S43. Blur the image outside the first plane according to the first target blurring degree and a preset rule to obtain a third image;

[0148] S44. If not, determine the default blurring degree according to the position where the slider appears by default on the blurring progress bar;

[0149] S45. Blur the image outside the first plane according to the default blurring degree and a preset rule to obtain a third image.

[0150] In an embodiment of the present invention, a blurring progress bar is provided to enable a user to adjust the blurring degree of the image outside the first plane. The blurring degree can also be understood as the degree of blurriness of the image. It should be noted that when the blurring progress bar is shown to the user, the blurring progress bar will appear at the default position. The default position can be the optimal blurring degree considered through program calculation or a preset default position without calculation. When the user needs to adjust the blurring degree outside the first plane, move the slider on the blurring progress bar. Preferably, the further the slider moves to the right, the greater the blurring degree.

[0151] In one embodiment, the preset rule is that the further away from the center point of the first plane, the greater the blurring degree; wherein, the relationship between the blurring degree and the distance is linear or non-linear; the distance represents the distance between a point outside the first plane and the center point of the first plane;

[0152] Or the preset rule is that the blurring degree of the image outside the first plane is the same.

[0153] In an embodiment of the present invention, the preset rules are divided into three cases: First, the further away from the center point of the first plane, the greater the blurring degree, and the relationship between the blurring degree and the distance is linear; for example, the relationship between the blurring degree and the distance is: y = ax + b; where y is the blurring degree, x is the distance, and a and b are coefficients;

[0154] Second, the further away from the center point of the first plane, the greater the blurring degree, and the relationship between the blurring degree and the distance is non-linear; for example, the relationship between the blurring degree and the distance is: y = ax 2 + b; where y is the blurring degree, x is the distance, and a and b are coefficients;

[0155] Third, the blurring degree of the image outside the first plane is the same.

[0156] It should be noted that for the first case, since the blurring degree increases with the distance from the center point of the first plane, when adjusting the blurring degree of the image outside the first plane through the blurring progress bar, the blurring degree of the image changes linearly according to the progress bar. Similarly, for the second case, when adjusting the blurring degree of the image outside the first plane through the blurring progress bar, the blurring degree of the image changes non-linearly according to the progress bar. For the third case, after adjusting the blurring degree progress bar, the blurring degree of the image changes, but the blurring degree of each region of the image outside the first plane remains the same.

[0157] In one embodiment, after the step of obtaining the third image, the method further includes

[0158] When a compilation instruction for the third image is received, display a blurring progress bar;

[0159] Determine whether the user moves the slider on the blurring progress bar;

[0160] If so, determine a second target blurring degree according to the position of the slider on the blurring progress bar;

[0161] Adjust the blurring degree of the image outside the first plane in the third image according to the second target blurring degree.

[0162] In an embodiment of the present invention, after generating the third image, the user can also click the compilation function, and an electronic device, such as a mobile phone, will provide a blurring progress bar. By sliding the slider on the blurring progress bar, the blurring degree of the image outside the first plane in the third image can be adjusted.

[0163] In one embodiment, the image generation method further includes:

[0164] Obtain an image to be processed

[0165] Perform scene recognition on the image;

[0166] Optimize the image according to the recognized scene to obtain an optimized image.

[0167] In an embodiment of the present invention, specifically, the scenes include beaches, buildings, food, people, animals, flowers, etc. The method for performing scene recognition can use an AI algorithm. In an embodiment of the present invention, in the camera of a mobile phone, there is a corresponding scene optimization function. When the user clicks on this scene optimization function, the preview interface will detect the image within the preview frame in real time. If the corresponding object is detected, a corresponding identifier will be displayed to indicate that the scene recognition is successful, and relevant scene optimization will also be performed for the corresponding scene. For example, if food is recognized, the food will be processed, and the processed picture will make people look particularly appetizing.

[0168] Embodiment 2:

[0169] Please refer to Figure 4 , an embodiment of the present invention provides an image generation device, including:

[0170] The first control module 1 is configured to, in the depth-of-field image shooting mode, if a shooting instruction is received, control the camera motor to move to obtain the focusing distance that makes the selected object the clearest, and use the clearest focusing distance as the first focusing distance;

[0171] The first image acquisition module 2 is configured to acquire the image captured by the camera at the first focusing distance as the first image;

[0172] The extraction module 3 is configured to extract the selected object from the first image as the first target object

[0173] The selection module 4 is configured to select a second target object in the first image; wherein, the clarity of the second target object is less than that of the first target object;

[0174] The second control module 5 is configured to control the camera motor to move again to obtain the focusing distance that makes the second target object the clearest as the second focusing distance;

[0175] The second image acquisition module 6 is configured to acquire the image captured by the camera at the second focusing distance as the second image;

[0176] The image processing module 7 is configured to construct a first plane in the second image based on the first target object and blur the image outside the first plane according to a preset rule.

[0177] In one embodiment, multiple second target objects can be selected, that is, multiple second images can be obtained, and the depth-of-field image is obtained by using the picture stacking technology to synthesize multiple pictures (including the first image and multiple second images).

[0178] In one embodiment, the image generation device further includes:

[0179] The storage module is configured to store the first image, the second image, and the third image in a memory;

[0180] The association module is configured to associate the storage path of the third image with the storage paths of the first image and the second image.

[0181] In one embodiment, the image generation device further includes:

[0182] A depth-of-field switching module, which is used to, in the depth-of-field object switching mode, based on the object selected by the user in the third image, regenerate a fourth image by using the first image and the second image to achieve depth-of-field object switching.

[0183] In one embodiment, the depth-of-field switching module includes:

[0184] A click position acquisition unit, which is used to, in the depth-of-field object switching mode, if it detects that the user clicks on the third image, acquire the click position;

[0185] A judgment unit, which is used to judge whether the click position is on the first plane of the third image or outside the first plane of the third image;

[0186] A first image retrieval unit, which is used to, if the click position is on the first plane of the third image, retrieve the first image corresponding to the third image from the memory;

[0187] An extraction unit, which is used to extract the object corresponding to the click position in the retrieved first image as the third target object;

[0188] A second image retrieval unit, which is used to retrieve the second image corresponding to the third image from the memory;

[0189] An image processing unit, which is used to, based on the third target object, construct a second plane in the retrieved second image, and blur the image outside the second plane in the second image to obtain a fourth image;

[0190] The second image retrieval unit is further used to, if the click position is outside the first plane of the third image, retrieve the second image corresponding to the third image from the memory;

[0191] The extraction unit is further used to extract the object corresponding to the click position in the retrieved second image as the fourth target object;

[0192] The first image retrieval unit is further used to retrieve the first image corresponding to the third image from the memory;

[0193] The image processing unit is further used to, based on the fourth target object, construct a third plane in the retrieved first image, and blur the image outside the third plane in the first image to obtain a fourth image.

[0194] In one embodiment, controlling the camera motor to move to obtain the focusing distance that makes the selected object the clearest, and taking the clearest focusing distance as the first focusing distance includes:

[0195] Control the movement of the camera motor, and calculate the clarity of the selected object in real time. Take the focusing distance that makes the selected object the clearest as the first focusing distance.

[0196] In one embodiment, the controlling the movement of the camera motor to obtain the focusing distance that makes the selected object the clearest, and taking the clearest focusing distance as the first focusing distance includes:

[0197] Control the camera motor to move to the farthest position, and then move from the farthest position to the nearest position to obtain the field of view content;

[0198] Or,

[0199] Control the camera motor to move to the nearest position, and then move from the nearest position to the farthest position to obtain the field of view content;

[0200] According to the field of view content, calculate the focusing distance that makes the selected object the clearest by the dichotomy method as the first focusing distance.

[0201] In addition, the specific steps for calculating the focusing distance that makes the selected object the clearest based on the dichotomy method are as follows:

[0202] Control the camera motor to move from the nearest to the farthest or from the farthest to the nearest;

[0203] Calculate the clarity of the selected object when the camera moves to the farthest as the first clarity;

[0204] Calculate the clarity of the selected object when the camera moves to the nearest as the second clarity;

[0205] Calculate the clarity of the selected object when the camera moves to the middle as the third clarity;

[0206] Take the position when the camera motor moves to the farthest as the first position, the position when the camera motor moves to the nearest as the second position, and the position when the camera motor moves to the middle as the third position;

[0207] Judge the first interval where the position of the focusing distance that makes the selected object the clearest is located according to the first clarity, the second clarity, and the third clarity; wherein, the first interval is between the first position and the third position, or between the third position and the second position;

[0208] Calculate the clarity of the selected object when the camera motor moves to the middle position of the interval as the fourth clarity;

[0209] Based on the clarity of the selected object at the two endpoints of the first interval and the fourth clarity, confirm the second interval where the position of the focusing distance that makes the selected object clearest is located;

[0210] And so on, to obtain the focusing distance that makes the selected object clearest.

[0211] In one embodiment, the controlling the camera motor to move again to obtain the focusing distance that makes the second target object clearest as the second focusing distance includes:

[0212] Control the camera motor to move again, and calculate the clarity of the second target object in real time, and use the focusing distance that makes the selected object clearest as the first focusing distance.

[0213] In one embodiment, the controlling the camera motor to move again to obtain the focusing distance that makes the second target object clearest as the second focusing distance includes:

[0214] Control the camera motor to move to the farthest position, and then move from the farthest position to the nearest position to obtain the field of view content;

[0215] Or,

[0216] Control the camera motor to move to the nearest position, and then move from the nearest position to the farthest position to obtain the field of view content;

[0217] Based on the field of view content, calculate the focusing distance that makes the second target object clearest as the second focusing distance by using the dichotomy method.

[0218] In one embodiment, before the step of receiving the shooting instruction, it further includes:

[0219] Perform scene detection on the selected object to obtain the scene corresponding to the selected object;

[0220] The extracting the selected object from the first image includes:

[0221] Call the artificial intelligence model corresponding to the scene from a preset database;

[0222] Use the artificial intelligence model to estimate the contour edge of the selected object to obtain the first contour edge;

[0223] Adjust the first contour edge according to the color comparison of the contour edge to obtain the second contour edge;

[0224] Extract the selected object based on the second contour edge.

[0225] In one embodiment, blurring the image outside the first plane according to a preset rule to obtain a third image includes:

[0226] Determine whether the user moves the slider on the blurring progress bar;

[0227] If so, determine a first target blurring degree according to the position of the slider on the progress bar;

[0228] Blur the image outside the first plane according to the first target blurring degree and the preset rule to obtain a third image;

[0229] If not, determine a default blurring degree according to the position where the slider defaults to appear on the blurring progress bar;

[0230] Blur the image outside the first plane according to the default blurring degree and the preset rule to obtain a third image.

[0231] In one embodiment, the preset rule is that the farther away from the center point of the first plane, the greater the blurring degree; wherein, the blurring degree and the distance are in a linear or non-linear relationship; the distance represents the distance between a point outside the first plane and the center point of the first plane;

[0232] Or the preset rule is that the blurring degree of the image outside the first plane is the same.

[0233] In the embodiments of the present invention, the preset rules are divided into three cases: First, the farther away from the center point of the first plane, the greater the blurring degree, and the blurring degree and the distance are in a linear relationship; for example, the relationship between the blurring degree and the distance is: y = ax + b; where y is the blurring degree, x is the distance, and a and b are coefficients;

[0234] Second, the farther away from the center point of the first plane, the greater the blurring degree, and the blurring degree and the distance are in a non-linear relationship; for example, the relationship between the blurring degree and the distance is: y = ax 2 + b; where y is the blurring degree, x is the distance, and a and b are coefficients;

[0235] Third, the blurring degree of the image outside the first plane is the same.

[0236] It should be noted that for the first case, since the blurring degree increases as the distance from the center point of the first plane becomes farther, when adjusting the blurring degree of the image outside the first plane through the blurring progress bar, the blurring degree of the image changes linearly according to the progress bar. Similarly, for the second case, when adjusting the blurring degree of the image outside the first plane through the blurring progress bar, the blurring degree of the image changes non-linearly according to the progress bar. For the third case, after adjusting the blurring degree progress bar, the blurring degree of the image changes, but the blurring degree of each region of the image outside the first plane remains the same.

[0237] In one embodiment, after the step of obtaining the third image, it further includes

[0238] When receiving a compilation instruction for the third image, display a blurring progress bar;

[0239] Determine whether the user moves the slider on the blurring progress bar;

[0240] If so, determine the second target blurring degree according to the position of the slider on the blurring progress bar;

[0241] Adjust the blurring degree of the image outside the first plane in the third image according to the second target blurring degree.

[0242] In one embodiment, the image generation method further includes:

[0243] Obtain an image to be processed

[0244] Perform scene recognition on the image;

[0245] Optimize the image according to the recognized scene to obtain an optimized image.

[0246] In the embodiments of the present invention, specifically, the scenes include beaches, buildings, food, people, animals, flowers, etc. The method for performing scene recognition can adopt an AI algorithm. In the embodiments of the present invention, in the camera of a mobile phone, there is a corresponding scene optimization function. When the user clicks on this scene optimization function, the preview interface will detect the image within the preview frame in real time. If the corresponding object is detected, a corresponding identifier will be displayed to indicate that the scene recognition is successful, and relevant scene optimization will also be performed for the corresponding scene. For example, if food is recognized, the food will be processed, and the processed picture will make people look particularly appetizing.

[0247] It should be understood that the image generation device provided in the embodiments of the present application has the same concept as the above image generation method and the same specific implementation manner, and the embodiments of the present invention will not be elaborated too much.

[0248] Embodiment 3:

[0249] Refer toFigure 5 , embodiments of the present invention further provide a computer device, and the internal structure of the computer device may be as Figure 5 shown. The computer device includes a processor, a memory, a network interface, and a database connected through a system bus. Among them, the processor designed in the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data such as an image generation method. The network interface of the computer device is used to communicate with an external terminal through a network connection. Further, the above computer device may also be provided with an input device, a display screen, and the like. When the above computer program is executed by the processor, it implements an image generation method, including the following steps: in the depth-of-field image shooting mode, if a shooting instruction is received, control the camera motor to move to obtain the focusing distance that makes the selected object the clearest, and use the clearest focusing distance as the first focusing distance; obtain the image captured by the camera at the first focusing distance as the first image; extract the selected object from the first image as the first target object; select a second target object in the first image; wherein, the clarity of the second target object is less than that of the first target object; control the camera motor to move again to obtain the focusing distance that makes the second target object the clearest as the second focusing distance; obtain the image captured by the camera at the second focusing distance as the second image; based on the first target object, construct a first plane in the second image, and blur the image outside the first plane according to a preset rule to obtain a third image. Those skilled in the art can understand that Figure 5 the structure shown in

[0250] In an embodiment of the present invention, in the depth-of-field image shooting mode, if a shooting instruction is received, the camera motor is controlled to move to obtain the focusing distance that makes the selected object the clearest, and the clearest focusing distance is used as the first focusing distance; the image captured by the camera at the first focusing distance is obtained as the first image; the selected object is extracted from the first image as the first target object; a second target object is selected in the first image; wherein, the clarity of the second target object is less than that of the first target object; the camera motor is controlled to move again to obtain the focusing distance that makes the second target object the clearest as the second focusing distance; the image captured by the camera at the second focusing distance is obtained as the second image; based on the first target object, a first plane is constructed in the second image, and the image outside the first plane is blurred according to a preset rule. In this way, the edges of the foreground and background are clearer, and the depth-of-field effect is better. In addition, since all the cameras described above in the present invention refer to the same camera, that is, an embodiment of the present invention can generate a depth-of-field image through one camera, thus solving the technical problem that two cameras are required to generate a depth-of-field image.

[0251] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, an image generation method is implemented, including the following steps: in the depth-of-field image shooting mode, if a shooting instruction is received, the camera motor is controlled to move to obtain the focusing distance that makes the selected object the clearest, and the clearest focusing distance is used as the first focusing distance; the image captured by the camera at the first focusing distance is obtained as the first image; the selected object is extracted from the first image as the first target object; a second target object is selected in the first image; wherein, the clarity of the second target object is less than that of the first target object; the camera motor is controlled to move again to obtain the focusing distance that makes the second target object the clearest as the second focusing distance; the image captured by the camera at the second focusing distance is obtained as the second image; based on the first target object, a first plane is constructed in the second image, and the image outside the first plane is blurred according to a preset rule to obtain a third image.

[0252] In an embodiment of the present invention, in the depth-of-field image shooting mode, if a shooting instruction is received, the camera motor is controlled to move to obtain the focusing distance at which the selected object is the clearest, and the clearest focusing distance is used as the first focusing distance; an image captured by the camera at the first focusing distance is obtained as the first image; the selected object is extracted from the first image as the first target object; a second target object is selected in the first image; wherein the clarity of the second target object is less than that of the first target object; the camera motor is controlled to move again to obtain the focusing distance at which the second target object is the clearest as the second focusing distance; an image captured by the camera at the second focusing distance is obtained as the second image; based on the first target object, a first plane is constructed in the second image, and the image outside the first plane is blurred according to a preset rule. In this way, the edges of the foreground and background are clearer and the depth-of-field effect is better. In addition, since all the cameras described above in the present invention refer to the same camera, that is, an embodiment of the present invention can generate a depth-of-field image through one camera, thus solving the technical problem that two cameras are required to generate a depth-of-field image.

[0253] Those of ordinary skill in the art can understand that all or part of the processes of implementing the methods in the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, storage, database or other medium provided in the present application and used in the embodiments can include non-volatile and / or volatile memories. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0254] It should be noted that in this text, the term "including", "comprising" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, apparatus, article or method including a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent in such a process, apparatus, article or method. Without further limitation, an element defined by the statement "including one..." does not exclude the existence of additional identical elements in the process, apparatus, article or method including such an element.

[0255] The above are only the preferred embodiments of the present invention, and do not limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made by using the content of the specification and drawings of the present invention, or directly or indirectly applied in other related technical fields, shall be equally included in the patent protection scope of the present invention.

Claims

1. An image generation method, characterized in that, Including: In the depth-of-field image shooting mode, if a shooting instruction is received, control the camera motor to move to obtain the focusing distance that makes the selected object the clearest, and use the clearest focusing distance as the first focusing distance; Obtain the image captured by the camera at the first focusing distance as the first image; Extract the selected object from the first image as the first target object; Select a second target object in the first image; wherein, the clarity of the second target object is less than that of the first target object; Control the camera motor to move again to obtain the focusing distance that makes the second target object the clearest as the second focusing distance; Obtain the image captured by the camera at the second focusing distance as the second image; Based on the first target object, construct a first plane in the second image, and blur the image outside the first plane according to a preset rule to obtain a third image; The method further includes: In the depth-of-field object switching mode, based on the object selected by the user in the third image, reuse the first image and the second image to generate a fourth image to achieve depth-of-field object switching; The step of, in the depth-of-field object switching mode, based on the object selected by the user in the third image, reusing the first image and the second image to generate a fourth image to achieve depth-of-field object switching includes: In the depth-of-field object switching mode, if it is detected that the user clicks on the third image, obtain the click position; Determine whether the click position is on the first plane of the third image or outside the first plane of the third image; If the click position is on the first plane of the third image, retrieve the first image corresponding to the third image from the memory; Extract the object corresponding to the click position in the retrieved first image as the third target object; Retrieve the second image corresponding to the third image from the memory; Based on the third target object, construct a second plane in the retrieved second image, and blur the image outside the second plane in the second image to obtain a fourth image; If the click position is outside the first plane of the third image, retrieve the second image corresponding to the third image from the memory; Extract the object corresponding to the click position in the retrieved second image as the fourth target object; Retrieve the first image corresponding to the third image from the memory; Based on the fourth target object, construct a third plane in the retrieved first image, and blur the image outside the third plane in the first image to obtain a fourth image.

2. The image generation method according to claim 1, characterized in that The method further includes: Store the first image, the second image, and the third image in the memory; Associate the storage path of the third image with the storage paths of the first image and the second image.

3. The image generation method according to claim 1, characterized in that The controlling the camera motor to move to obtain the focusing distance that makes the selected object the clearest and using the clearest focusing distance as the first focusing distance includes: Control the camera motor to move to the farthest position, and then move from the farthest position to the nearest position to obtain the field of view content; Or, Control the camera motor to move to the nearest position, and then move from the nearest position to the farthest position to obtain the field of view content; According to the field of view content, calculate the focusing distance that makes the selected object the clearest based on the dichotomy method, and use it as the first focusing distance.

4. The image generation method according to claim 1, wherein Before the step of receiving the shooting instruction, it further includes: Perform scene detection on the selected object to obtain the scene corresponding to the selected object; The extracting the selected object from the first image includes: Call the artificial intelligence model corresponding to the scene from a preset database; Use the artificial intelligence model to estimate the contour edge of the selected object to obtain the first contour edge; Adjust the first contour edge according to the color comparison of the contour edges to obtain the second contour edge; Extract the selected object based on the second contour edge.

5. The image generation method according to claim 1, wherein The blurring the image outside the first plane according to a preset rule to obtain a third image includes: Determine whether the user moves the slider on the blurring progress bar; If so, determine the first target blurring degree according to the position of the slider on the progress bar; Blur the image outside the first plane according to the first target blurring degree and a preset rule to obtain a third image; If not, determine the default blurring degree according to the position where the slider appears by default on the blurring progress bar; Blur the image outside the first plane according to the default blurring degree and a preset rule to obtain a third image.

6. The image generation method according to claim 1, wherein After the step of obtaining the third image, it further includes When receiving a compilation instruction for the third image, display the blurring progress bar; Determine whether the user moves the slider on the blurring progress bar; If so, determine the second target blurring degree according to the position of the slider on the blurring progress bar; Adjust the blurring degree of the image outside the first plane in the third image according to the second target blurring degree.

7. An image generation device, characterized in that, It includes: A first control module, which is used to control the movement of the camera motor in the depth-of-field image shooting mode if a shooting instruction is received, so as to obtain the focusing distance that makes the selected object the clearest, and use the clearest focusing distance as the first focusing distance; A first image acquisition module, which is used to acquire the image taken by the camera at the first focusing distance as the first image; An extraction module, which is used to extract the selected object from the first image as the first target object A selection module, which is used to select a second target object in the first image; wherein, the clarity of the second target object is less than that of the first target object; A second control module, which is used to control the camera motor to move again to obtain the focusing distance that makes the second target object the clearest, and use it as the second focusing distance; A second image acquisition module, which is used to acquire the image taken by the camera at the second focusing distance as the second image; An image processing module, configured to construct a first plane in the second image based on the first target object, and blur the image outside the first plane according to a preset rule to obtain a third image; Wherein: In the depth-of-field object switching mode, based on the object selected by the user in the third image, the first image and the second image are reused to generate a fourth image to achieve depth-of-field object switching; The step of, in the depth-of-field object switching mode, based on the object selected by the user in the third image, reusing the first image and the second image to generate a fourth image to achieve depth-of-field object switching includes: In the depth-of-field object switching mode, if it is detected that the user clicks on the third image, obtain the click position; Determine whether the click position is on the first plane of the third image or outside the first plane of the third image; If the click position is on the first plane of the third image, retrieve the first image corresponding to the third image from the memory; Extract the object corresponding to the click position in the retrieved first image as the third target object; Retrieve the second image corresponding to the third image from the memory; Based on the third target object, construct a second plane in the retrieved second image, and blur the image outside the second plane in the second image to obtain a fourth image; If the click position is outside the first plane of the third image, retrieve the second image corresponding to the third image from the memory; Extract the object corresponding to the click position in the retrieved second image as the fourth target object; Retrieve the first image corresponding to the third image from the memory; Based on the fourth target object, construct a third plane in the retrieved first image, and blur the image outside the third plane in the first image to obtain a fourth image.

8. A computer device, comprising a memory and a processor, wherein a computer program is stored in the memory, characterized in that When the processor executes the computer program, the steps of the image generation method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Image virtualization method, mobile equipment and storage device

    CN107707809A