WO2020103604A1 - 拍照方法、装置、终端及计算机可读存储介质 - Google Patents

拍照方法、装置、终端及计算机可读存储介质

Info

Publication number
WO2020103604A1
WO2020103604A1 PCT/CN2019/110853 CN2019110853W WO2020103604A1 WO 2020103604 A1 WO2020103604 A1 WO 2020103604A1 CN 2019110853 W CN2019110853 W CN 2019110853W WO 2020103604 A1 WO2020103604 A1 WO 2020103604A1
Authority
WO
WIPO (PCT)
Prior art keywords
blurred
pixel
frame image
value
focus position
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/CN2019/110853
Other languages
English (en)
French (fr)
Inventor
张洪伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Oppo Mobile Telecommunications Corp Ltd
Original Assignee
Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong Oppo Mobile Telecommunications Corp Ltd filed Critical Guangdong Oppo Mobile Telecommunications Corp Ltd
Publication of WO2020103604A1 publication Critical patent/WO2020103604A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/60Control of cameras or camera modules
    • H04N23/67Focus control based on electronic image sensor signals
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/80Camera processing pipelines; Components thereof

Definitions

  • the present application belongs to the technical field of photographing, and particularly relates to a photographing method, device, terminal and computer-readable storage medium.
  • Image blurring refers to the focus of focusing on the theme elements in an image and blurring the non-theme elements. At present, it is usually necessary to use a large aperture SLR camera to take pictures with blurring effect. For smart terminals such as mobile phones are limited by size, cost and use environment, the lenses they match are basically of the type of small aperture and cannot pass through the lens Take photos with a blur effect. Therefore, when using a smart terminal such as a mobile phone to shoot a blurred image, it is necessary to use a depth sensor to collect depth information of each target object in the shooting scene, and then realize the image blur effect according to the depth information.
  • the depth sensor is often lower than the resolution of the photograph taken, and the depth sensor is easily affected by strong reflective objects when collecting depth information, making it impossible to use the depth information collected by the depth sensor to blur the image Get a higher quality blurred image.
  • Embodiments of the present application provide a photographing method, device, terminal, and computer-readable storage medium, which can solve the technical problem that a high-quality blurred image cannot be obtained.
  • a first aspect of an embodiment of the present application provides a photographing method, including:
  • a second aspect of an embodiment of the present application provides a photographing device, including:
  • An obtaining unit configured to obtain a first focus position and a blur value of the photographed frame image, and obtain a second focus position of the blur frame image corresponding to the first focus position and the blur value;
  • a collection unit configured to collect a photographed frame image corresponding to the first focus position and a blurred frame image corresponding to the second focus position when receiving the photographing instruction
  • the blur unit is used to synthesize the photographed frame image and the blur frame image to obtain a blur image corresponding to the blur value.
  • a third aspect of the embodiments of the present application provides a terminal, including a camera, a memory, a processor, and a computer program stored in the memory and executable on the processor.
  • the processor executes the computer program, the steps of the above method are implemented.
  • a fourth aspect of the embodiments of the present application provides a computer-readable storage medium.
  • the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the foregoing method are implemented.
  • FIG. 1 is a schematic flowchart of a first implementation of a photographing method provided by an embodiment of the present application
  • FIG. 2 is a schematic diagram of a photo preview interface provided by an embodiment of the present application.
  • step 103 of a photographing method provided by an embodiment of the present application
  • step 303 of a photographing method provided by an embodiment of the present application
  • step 303 of a photographing method provided by an embodiment of the present application
  • FIG. 6 is a schematic diagram of a second implementation process of a photographing method provided by an embodiment of the present application.
  • FIG. 7 is a schematic diagram of a positional relationship between a first focus position, a second focus position, and a third focus position provided by an embodiment of the present application;
  • FIG. 8 is a schematic flowchart of a third implementation of a photographing method provided by an embodiment of the present application.
  • FIG. 9 is a schematic diagram of a positional relationship among a first focus position, a fourth focus position, and a fifth focus position provided by an embodiment of the present application;
  • FIG. 10 is a schematic flowchart of a fourth implementation of a photographing method provided by an embodiment of the present application.
  • FIG. 11 is a schematic diagram of a positional relationship among the first focus position, the fourth focus position, the fifth focus position, the sixth focus position, and the seventh focus position provided by the embodiment of the present application;
  • FIG. 12 is a schematic structural diagram of a camera device provided by an embodiment of the present application.
  • FIG. 13 is a schematic structural diagram of a terminal provided by an embodiment of the present application.
  • the depth information of each target object in the shooting scene is usually collected by a depth sensor, and then the blurred image is blurred using a blur algorithm according to the depth information Blur the image.
  • the depth sensor is often lower than the resolution of the photograph taken, and the depth sensor is easily affected by strong reflective objects when collecting depth information, making it impossible to use the depth information collected by the depth sensor to blur the image Get a higher quality blurred image.
  • the terminal obtains the first focus position and the blur value of the photographed frame image and the second focus position of the blur frame image corresponding to the first focus position and the blur value, and
  • the terminal When receiving a photographing instruction, collect a photo frame image corresponding to the first focus position, and collect a blur frame image corresponding to the second focus position; then, the photo frame image and the blur frame
  • the images are synthesized to obtain a blurred image corresponding to the blurred value;
  • the blurred frame image captured by the camera is used to blur the photographed frame image to obtain a blurred image corresponding to the blurred value, and the Blurred images do not require the use of depth sensors to collect depth information of each target object in the shooting scene, nor do they need to use the blurring algorithm combined with the depth information to achieve the blurring effect of the image;
  • the effect of reflecting objects achieves a better image blur effect.
  • FIG. 1 shows a schematic diagram of an implementation process of a photographing method provided by an embodiment of the present application. The method is applied to a terminal, and can be executed by a photographing device configured on the terminal. , Including step 101 to step 103.
  • the terminal includes a smart phone, a tablet computer, a learning machine and other terminal devices equipped with a camera device.
  • a photographing application may be installed on the terminal device.
  • step 101 a first focus position and a blur value of a photographed frame image are obtained, and a second focus position of a blur frame image corresponding to the first focus position and the blur value is obtained.
  • the first focus position is a position where clear shooting is needed, that is, in the final blurred image, the object at the focus position should present a clear image, and the objects at other positions should present a blurred image .
  • the acquisition of the first focus position may be selected by an automatic focusing algorithm of the camera device, or may be selected by the user in the camera preview interface.
  • the blur value can be set by the user according to actual needs. For example, the blur value may be set to 2, 3, and 4, in the embodiment of the present application, the larger the blur value, the higher the blur degree.
  • the user can click on the first human face 22 in the photo preview interface 21 so that the first focus position is located on the first human face 22.
  • the acquiring the second focused position of the blurred frame image corresponding to the first focused position and the blurred value may include: looking up the first focused position, the blurred value and the second focused position three For the correspondence between the two, obtain the second focus position of the blurred frame image corresponding to the first focus position and the blur value.
  • Table 1 For example, look up the correspondence table between the first focus position, the blur value and the second focus position shown in Table 1 to determine the blur frame image corresponding to the first focus position and the blur value The second focus position. It should be noted that the first focus position and the second focus position belong to different positions.
  • the value in Table 1 can be the value calculated according to the functional relationship, or the value obtained based on practical experience.
  • step 102 when a photographing instruction is received, a photographing frame image corresponding to the first focusing position is collected, and a blurred frame image corresponding to the second focusing position is collected.
  • the motor-driven camera lens can be controlled to move to the corresponding position Collecting photo frame images and blur frame images.
  • the blur frame image is an image used to perform blur processing or clear processing on the photograph frame image.
  • the blur frame image performs the blur processing on the photograph frame image to obtain the corresponding blur image, and the blur frame image corresponds to the photograph frame When the image is processed clearly, a clear image is obtained.
  • the blurred frame image and the photographed frame image are both images generated by the camera collecting external light signals when the photographing instruction is obtained.
  • a camera is used in a continuous shooting mode to first collect a photographed frame image and then a blurred frame image to obtain the photographed frame image and the blurred frame image.
  • the camera frame image and the blur frame image can be simultaneously acquired by using multiple cameras.
  • the photo frame image and the blur frame image are collected in the continuous shooting mode, due to the time difference, the photo frame may be caused by the user's hand-held shooting or the displacement of the subject itself, resulting in the photo frame
  • the content of the image and the blurred frame image may be inconsistent. Therefore, in the embodiment of the present application, the capturing of the photo frame image corresponding to the first focus position and the capturing of the second focus position After the blurred frame image, the alignment may include aligning the photographed frame image and the blurred frame image.
  • the alignment algorithm is used to transform and cut the blurred frame image and the photographed frame image, so that the pixels in the blurred frame image and the pixels in the photographed frame image have a one-to-one correspondence.
  • the alignment algorithm may be a general alignment algorithm, for example, a forward addition algorithm and an inverse combination algorithm.
  • step 103 the photographed frame image and the blurred frame image are synthesized to obtain a blurred image corresponding to the blurred value.
  • the clear area in the photographed frame image is not the same as the clear area in the blurred frame image. That is, the clear area in the photographed frame image may correspond to the blurred area in the blurred frame image. Therefore, the blurred frame image may be used to blur the photographed frame image to obtain a blurred image, that is, the photographed frame The image and the blurred frame image are synthesized to obtain a blurred image corresponding to the blurred value.
  • the photographed frame image and the blurred frame image are synthesized to obtain a virtual corresponding to the blurred value
  • the image may include steps 301 to 303.
  • Step 301 Calculate the edge intensity of each pixel in the photographed frame image.
  • the edge intensity of each pixel refers to the weighted value of each pixel and its neighboring eight pixels. For example, the edge intensity of each pixel is obtained by calculating the Sobel operator of each pixel, or the edge intensity of each pixel is calculated by calculating the Laplace operator of each pixel.
  • Step 302 Keep the pixels whose edge intensity of the pixels in the photographed frame image is greater than or equal to the first threshold unchanged.
  • the first threshold is set according to the edge intensity of the pixel in the focus position in the photographed frame image, and is used to distinguish the pixel whose edge intensity of the pixel in the photographed frame image is greater than or equal to the first threshold as to be maintained Clear pixels, that is, pixels in the focused position in the photographed frame image, and pixels whose edge strength of the pixels in the photographed frame image is less than the first threshold are distinguished as pixels in non-focused positions, that is Pixels to be blurred (pixels to be blurred).
  • the pixel points in the photographed frame image whose edge intensity is greater than or equal to the first threshold are pixels that need to be kept clear, it is necessary to keep the edge intensity of the pixels in the photographed frame image greater than or equal to The pixels equal to the first threshold are unchanged, that is, they are not subject to blurring, and then the pixels whose edge strength of the pixels in the photographed frame image is less than the first threshold are subject to blurring.
  • Step 303 Use pixel points whose edge strengths of the pixel points in the photographed frame image are less than the first threshold as pixels to be blurred, and perform blur processing on the pixels to be blurred.
  • the process of blurring the pixels to be blurred may include: steps 401 to 403.
  • Step 401 Calculate the edge intensity of each pixel in the blurred frame image, and calculate the first difference between the edge intensity of the pixel to be blurred and the pixel at the corresponding position in the blurred frame image.
  • the edge intensity of the pixel point A to be blurred in the photographed frame image is a
  • the pixel point A and the pixel point B in the blurred frame image are pixel points at corresponding positions
  • the edge intensity of the pixel point B is b
  • Step 402 If the first difference is less than or equal to zero, then keep the pixel to be blurred unchanged.
  • the first difference since the first difference is less than or equal to zero, it means that the degree of blurring of the pixel to be blurred in the photographed frame image is greater than the degree of blurring of the pixel at the corresponding position in the blurred frame image, ie The pixel may be the pixel at the focus position in the blurred frame image. Therefore, when the first difference is less than or equal to zero, the pixel to be blurred needs to be kept unchanged.
  • Step 403 If the first difference is greater than zero, replace the pixels to be blurred with pixels at corresponding positions in the blurred frame image to obtain a blurred image corresponding to the blurred value.
  • the pixel to be blurred when the first difference is greater than zero, the pixel to be blurred is replaced with a pixel at a corresponding position in the blurred frame image to realize a blurred frame captured by a camera
  • the image blurs the photo frame image to obtain a blur image corresponding to the blur value, and the blur image does not require the use of a depth sensor to collect depth information of each target object in the shooting scene, nor does it need to use a blur algorithm Combined with the depth information, the image blur effect is realized; at the same time, it is not affected by the resolution of the depth sensor and the strong reflection object, and a better image blur effect is achieved.
  • performing the blurring processing on the pixel point to be blurred may include: steps 501 to 503.
  • Step 501 Calculate a first difference in edge strength between the pixel to be blurred and the pixel at the corresponding position in the blurred frame image.
  • step 502 if the first difference is less than or equal to zero, the pixel to be blurred remains unchanged.
  • Step 503 If the first difference is greater than zero, obtain a first synthesis ratio corresponding to the pixel to be blurred, and use the first synthesis ratio to synthesize the pixel to be blurred to obtain And replace the pixels to be blurred with the synthesized pixels to obtain a blurred image corresponding to the blurred value; wherein the first composition ratio is the blurred frame The ratio of the pixel value of the pixel corresponding to the pixel to be blurred in the image in the pixel value of the synthesized pixel.
  • the first synthesis ratio corresponding to the pixel to be blurred is obtained, and the first synthesis ratio is used to perform the pixel to be blurred Synthesis, at the same time replacing the pixels to be blurred with the pixels after synthesis to obtain a blurred image corresponding to the blurred value; instead of directly changing all the pixels when the first difference is greater than zero
  • the pixels to be blurred are replaced with pixels at corresponding positions in the blurred frame image, so that when the first difference is relatively large, the blurred pixels can be smoother and more natural, and not too obtrusive.
  • the method includes: searching for a first correspondence between the first difference value, the blurred value and the first synthesis ratio, and acquiring the first synthesis ratio corresponding to the pixel point to be blurred.
  • the first synthesis ratio corresponding to the pixel to be blurred is determined by looking up a first correspondence table between the first difference value, the blur value, and the first synthesis ratio shown in Table 2. It should be noted that the value in Table 2 may be a value calculated according to a functional relationship, or a value obtained based on practical experience.
  • an embodiment of the present application further provides a photographing method, including: step 601 To step 606.
  • a photographing method including: step 601 To step 606.
  • Step 601 Obtain a first focus position and a blur value of the photographed frame image, obtain a second focus position of the blur frame image corresponding to the first focus position and the blur value, and obtain the first focus position and the first blur position A focus position and a third focus position of the reference frame image corresponding to the blurred value; wherein the distance between the third focus position and the camera is greater than the distance between the first focus position and the camera, and , The distance between the third focusing position and the camera is smaller than the distance between the second focusing position and the camera.
  • the first focus position where the camera 71 captures the captured frame image is position 72
  • the third focus position where the camera 71 captures the reference frame image is position 73
  • the distance L is greater than the distance G between the first focus position 72 and the camera 71, and the distance between the third focus position 73 and the camera 71 is less than between the second focus position 74 and the camera 71
  • the distance J is greater than the distance G between the first focus position 72 and the camera 71, and the distance between the third focus position 73 and the camera 71 is less than between the second focus position 74 and the camera 71
  • Step 602 Collect a photo frame image corresponding to the first focusing position, a blurred frame image corresponding to the second focusing position, and a reference frame image corresponding to the third focusing position.
  • Step 603 Calculate the edge intensity of each pixel in the photographed frame image; keep the pixels whose edge intensity of the pixel in the photographed frame image is greater than or equal to the first threshold unchanged; change the pixels in the photographed frame image The pixel point whose edge intensity is less than the first threshold is used as the pixel point to be blurred.
  • the pixel points in the photographed frame image whose edge intensity is greater than or equal to the first threshold are pixels that need to be kept clear, it is necessary to keep the edge intensity of the pixels in the photographed frame image greater than or equal to The pixels equal to the first threshold are unchanged, that is, they are not subject to blurring, and then the pixels whose edge strength of the pixels in the photographed frame image is less than the first threshold are subject to blurring.
  • Step 604 Calculate a second difference between the edge intensity of the pixel to be blurred and the pixel at the corresponding position in the reference frame image.
  • Step 605 If the second difference is less than or equal to zero, then keep the pixel to be blurred unchanged.
  • Step 606 If the second difference is greater than zero, obtain a second synthesis ratio corresponding to the pixel to be blurred, and use the second synthesis ratio to synthesize the pixel to be blurred to obtain the synthesized Pixels of the image, and replace the pixels to be blurred with the synthesized pixels to obtain a blurred image corresponding to the blurred value; wherein, the second composition ratio is the blurred frame The ratio of the pixel value of the pixel corresponding to the pixel to be blurred in the image in the pixel value of the synthesized pixel.
  • the calculation The second difference between the edge intensity of the blurred pixel and the pixel at the corresponding position in the reference frame image, and the accuracy of the second composite ratio obtained from the second difference is better than using the pixel to be blurred and the virtual
  • the first difference between the edge strengths of the pixels at the corresponding position in the framed image has a higher accuracy of the first composition ratio.
  • the distance between the focus position of the blurred frame image and the focus position of the photographed frame image is greater than The distance between the focus position of the reference frame image and the focus position of the photographed frame image, therefore, the blur degree of the blur frame image is higher than that of the reference frame image.
  • the embodiment of the present application further defines the implementation described in FIG. 3. As shown in FIG. 8, the embodiment of the present application further provides a photographing method, including: steps 801 to step 808.
  • Step 801 Obtain a first focus position and a blur value of the photographed frame image, obtain a fourth focus position of the previous blur frame image corresponding to the first focus position and the blur value, and obtain A first focus position and a fifth focus position of the post-blurred frame image corresponding to the blur value, wherein the distance from the first focus position to the camera is greater than the distance from the fifth focus position to the camera, and the The distance from the first focusing position to the camera is smaller than the distance from the fourth focusing position to the camera.
  • the distance H from the first focusing position 72 to the camera 71 is greater than the distance G from the fifth focusing position 75 to the camera 71, and the distance H from the first focusing position 72 to the camera 71 Less than the distance J of the fourth focus position 74 from the camera 71.
  • Step 802 Collect a photo frame image corresponding to the first focus position, collect a front blur frame image corresponding to the fourth focus position, and collect a rear blur frame image corresponding to the fifth focus position.
  • Step 803 Calculate the edge intensity of each pixel in the photographed frame image; keep the pixels whose edge intensity of the pixel in the photographed frame image is greater than or equal to the first threshold unchanged; convert the pixels in the photographed frame image The pixel point whose edge intensity is less than the first threshold is used as the pixel point to be blurred.
  • Step 804 Calculate a third difference in edge strength between the pixel to be blurred and the pixel at the corresponding position in the previous blurred frame image; and, calculate the pixel to be blurred and the post-blurring The fourth difference value of the edge intensity of the pixel at the corresponding position in the frame image.
  • Step 805 If the third difference value and the fourth difference value are both less than or equal to zero, then keep the pixel to be blurred unchanged.
  • Step 806 If the third difference and / or the fourth difference is greater than zero, compare the magnitude of the third difference with the fourth difference.
  • Step 807 Obtain a third synthesis ratio corresponding to the pixel to be blurred with the third difference greater than the fourth difference, and use the third synthesis ratio to synthesize the pixel to be blurred, Obtaining synthesized pixels, and replacing the pixels to be blurred with the synthesized pixels to obtain a blurred image corresponding to the blurred value; wherein, the third synthesis ratio is The proportion of the pixel value of the pixel corresponding to the pixel to be blurred in the pre-blurred frame image in the pixel value of the pixel after synthesis.
  • Step 808 Acquire a fourth synthesis ratio corresponding to the pixels to be blurred with a third difference value less than or equal to the fourth difference value, and use the fourth synthesis ratio to synthesize the pixels to be blurred, Obtaining synthesized pixels, and replacing the pixels to be blurred with the synthesized pixels to obtain a blurred image corresponding to the blurred value; wherein, the fourth synthesis ratio is The proportion of the pixel value of the pixel corresponding to the pixel to be blurred in the post-blurred frame image in the pixel value of the synthesized pixel.
  • the foreground of the pre-blurred frame image is solid and the background is virtual, and the background of the post-blurred frame image is real, the foreground is virtual. Therefore, in the embodiment of the present application, by setting the first The distance between the focus position and the camera is greater than the distance between the fifth focus position and the camera, and less than the distance between the fourth focus position and the camera, that is, the front and back ends of the focus position of the frame image are captured before the blur
  • the frame image and the post-blurred frame image can make the foreground and background blur of the photographed frame image at the same time.
  • the blur frame image may be one or more front blur frame images, or one or more post blur frame images.
  • the reference frame image may also be a front reference frame image or a back reference frame image, which are used to realize a scene with only foreground blurring and a scene with only background blurring, respectively.
  • FIGS. 8 to 9 similarly, the embodiments described in FIGS. 6 to 7 may be referred to, adding a front reference frame image and a rear reference frame image, specifically, as shown in FIG. 10
  • a photographing method is further provided, including: steps 1001 to 1006.
  • Step 1001 Obtain the first focus position and blur value of the photographed frame image, obtain the fourth focus position of the previous blur frame image corresponding to the first focus position and the blur value, and obtain the first focus position Obtain the sixth focus position of the front reference frame image corresponding to the first focus position and the blur value, and obtain the sixth focus position of the front reference frame image corresponding to the first focus position and the blur value, and obtain A seventh focus position of the back-reference frame image corresponding to the first focus position and the blurred value, wherein the distance from the first focus position to the camera is greater than the distance from the fifth focus position to the camera, and The distance from the first focusing position to the camera is less than the distance from the fourth focusing position to the camera; the distance from the seventh focusing position to the camera is less than the distance from the first focusing position to the camera; the sixth The distance of the focus position from the camera is greater than the distance of the first focus position from the camera, and the distance of the sixth focus position from the camera is less than the distance of the fourth focus position from the camera.
  • the distance H from the first focusing position 72 to the camera 71 is greater than the distance G from the fifth focusing position 75 to the camera 71, and the distance H from the first focusing position 72 to the camera 71 is less than The distance J from the fourth focusing position 74 to the camera 71, the distance K from the seventh focusing position 77 to the camera 71 is greater than the distance G from the fifth focusing position 75 to the camera 71, and the seventh focusing position 77
  • the distance K from the camera 71 is less than the distance H from the first focus position 72 to the camera 71; the distance L from the sixth focus position 76 to the camera 71 is greater than the distance from the first focus position 72 to the camera 71 A distance H, and a distance L from the sixth focusing position 76 to the camera 71 is smaller than a distance J from the fourth focusing position 74 to the camera 71.
  • Step 1002 Collect a photo frame image corresponding to the first focus position, collect a front blur frame image corresponding to the fourth focus position, collect a rear blur frame image corresponding to the fifth focus position, and collect A front reference frame image corresponding to the sixth focus position, and a back reference frame image corresponding to the seventh focus position.
  • Step 1003 Calculate the edge intensity of each pixel in the photographed frame image; keep the pixels whose edge intensity of the pixel in the photographed frame image is greater than or equal to the first threshold unchanged; change the pixels in the photographed frame image The pixel point whose edge intensity is less than the first threshold is used as the pixel point to be blurred.
  • Step 1004 Calculate a fifth difference in edge strength between the pixel to be blurred and the pixel at the corresponding position in the front reference frame image; and, calculate the pixel to be blurred and the back reference frame image The sixth difference of the edge intensity of the pixel at the corresponding position in;
  • Step 1005 If the fifth difference and the sixth difference are both less than or equal to zero, then keep the pixel to be blurred unchanged;
  • Step 1006 If the fifth difference and / or the sixth difference is greater than zero, obtain a fifth synthesis corresponding to the pixel to be blurred with the fifth difference greater than the sixth difference Ratio, using the fifth synthesis ratio to synthesize the pixels to be blurred to obtain synthesized pixels, and replacing the pixels to be blurred with the synthesized pixels; wherein, the The fifth synthesis ratio is the ratio of the pixel value of the pixel corresponding to the pixel to be blurred in the pre-blurred frame image in the pixel value of the pixel after synthesis; and, obtaining the fifth A sixth synthesis ratio corresponding to the pixels to be blurred with a difference less than or equal to the sixth difference, and using the sixth synthesis ratio to synthesize the pixels to be blurred to obtain synthesized pixels And replace the pixels to be blurred with the synthesized pixels to obtain a blurred image corresponding to the blurred value; wherein the sixth synthesis ratio is in the post-blurred frame image The proportion of the pixel value of the pixel corresponding
  • the distance between the focus position of the reference frame image and the focus position of the photographed frame image is greater than the distance between the focus position of the blurred frame image and the focus position of the reference frame image , So that the composition ratio obtained according to the reference frame can be applied to the blurred frame image.
  • the distance between the focus position of the front reference frame image and the focus position of the photographed frame image is greater than the distance between the focus position of the front blur frame image and the focus position of the front reference frame image, so that the acquisition according to the front reference frame
  • the fifth composition ratio can be applied to the ratio of the pixel value of the pixel corresponding to the pixel to be blurred in the pre-blurred frame image in the pixel value of the pixel after synthesis, so that Images are smoother and more natural.
  • the blurred frame image can be used to perform clear processing on the photographed frame image in addition to the blurred processing on the photographed frame image.
  • the method further includes: Synthesize frame images to get clear images.
  • the synthesizing the photographed frame image and the blurred frame image to obtain a clear image includes: calculating the edge intensity of each pixel in the photographed frame image and the corresponding position in the blurred frame image The seventh difference of the edge intensity of the pixels of the pixel; keep the pixels of the seventh difference greater than or equal to zero in the photo frame image unchanged; replace the pixels of the seventh difference less than zero in the photo frame image with Obtaining the blurred image corresponding to the blurred value by obtaining a pixel corresponding to the blurred value in the pixel of the blurred frame image; or obtaining the clear value of the photographed frame image and obtaining the pixel with the seventh difference value less than zero
  • the seventh synthesis ratio corresponding to the point using the seventh synthesis ratio to synthesize the pixel points with the seventh difference value less than zero in the photographed frame image to obtain the synthesized pixel point, Seven pixel points with a difference value less than zero are replaced with the synthesized pixel points to obtain a clear image corresponding to the clear value; wherein the seventh synthesis
  • a blurred image corresponding to the blurred value or a sharpness corresponding to the sharpness value can be obtained Image, to achieve the effect of simulating the variable aperture of the camera.
  • FIG. 12 shows a schematic structural diagram of a photographing device 1200 provided by an embodiment of the present application, including an acquisition unit 1201, an acquisition unit 1202, and a blurring unit 1203.
  • the obtaining unit 1201 is configured to obtain a first focus position and blur value of the photographed frame image, and obtain a second focus position of the blur frame image corresponding to the first focus position and the blur value;
  • the collection unit 1202 is configured to collect a photo frame image corresponding to the first focus position and a blurred frame image corresponding to the second focus position when receiving a photo instruction;
  • the blur unit 1203 is configured to synthesize the photographed frame image and the blur frame image to obtain a blur image corresponding to the blur value.
  • the present application provides a terminal for implementing the photographing method.
  • the terminal may be a mobile terminal, and the mobile terminal may be a terminal such as a smartphone, tablet computer, personal computer (PC), or learning machine.
  • It includes: a processor 131, a memory 132, one or more input devices 133 (only one shown in FIG. 13), one or more output devices 134 (only one shown in FIG. 13), and a camera 135.
  • the processor 131, the memory 132, the input device 133, the output device 134, and the camera 135 are connected through a bus 136.
  • the camera is used to collect external light signals according to the photographing instruction to generate the photographed frame image and the blurred frame image.
  • the so-called processor 131 may be a central processing unit (Central Processing Unit, CPU), and the processor may also be other general-purpose processors, digital signal processors (Digital Signal Processor, DSP) , Application specific integrated circuit (Application Specific Integrated Circuit, ASIC), field programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc.
  • the general-purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
  • the input device 133 may include a virtual keyboard, a touch pad, a fingerprint sensor (for collecting user's fingerprint information and fingerprint direction information), a microphone, etc.
  • the output device 134 may include a display, a speaker, and the like.
  • the memory 132 may include a read-only memory and a random access memory, and provide instructions and data to the processor 131. Part or all of the memory 132 may also include non-volatile random access memory. For example, the memory 132 may also store device type information.
  • the memory 132 stores a computer program, and the computer program can run on the processor 131.
  • the computer program is a program of a photographing method.
  • the steps in the embodiment of the photographing method are implemented, for example, steps 101 to 103 shown in FIG. 1.
  • the processor 131 executes the computer program, the functions of each module / unit in the device embodiments, for example, the functions of the units 1001 to 1003 shown in FIG. 10 are realized.
  • the computer program may be divided into one or more modules / units, and the one or more modules / units are stored in the memory 132 and executed by the processor 131 to complete the present application.
  • the one or more modules / units may be a series of computer program instruction segments capable of performing specific functions, and the instruction segments are used to describe the execution process of the computer program in the photographing terminal.
  • the computer program may be divided into an acquisition unit, an acquisition unit, and a blur unit.
  • each unit uses an acquisition unit, used to acquire a first focus position and a blur value of a photographed frame image, and acquire and A first focus position and a second focus position of the blur frame image corresponding to the blur value; an acquisition unit is configured to collect a photo frame image corresponding to the first focus position when the photo instruction is received and collect A blurred frame image corresponding to the second focus position; a blurred unit, configured to synthesize the photographed frame image and the blurred frame image to obtain a blurred image corresponding to the blurred value.
  • the disclosed device / terminal and method may be implemented in other ways.
  • the device / terminal embodiments described above are only schematic.
  • the division of the modules or units is only a division of logical functions.
  • the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the integrated unit may be implemented in the form of hardware or a software functional unit.
  • the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the method of the embodiments described in this application can also be completed by instructing relevant hardware through a computer program.
  • the computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the method embodiments may be implemented.
  • the computer program includes computer program code, and the computer program code may be in the form of source code, object code, executable file, or some intermediate form.
  • the computer-readable medium may include any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, and a read-only memory (Read-Only Memory, ROM) , Random Access Memory (Random Access Memory, RAM), electrical carrier signals, telecommunications signals and software distribution media, etc.
  • ROM Read-Only Memory
  • RAM Random Access Memory
  • electrical carrier signals telecommunications signals and software distribution media, etc.
  • the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in jurisdictions. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media Does not include electrical carrier signals and telecommunications signals.

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Studio Devices (AREA)
  • Image Processing (AREA)

Abstract

本申请属于拍照技术领域,尤其涉及一种拍照方法、装置、终端及计算机可读存储介质,其中,所述方法包括:获取拍照帧图像的第一对焦位置和虚化值,以及获取与所述第一对焦位置和所述虚化值对应的虚化帧图像的第二对焦位置;在接收到拍照指令时,采集与所述第一对焦位置对应的拍照帧图像,以及采集与所述第二对焦位置对应的虚化帧图像;对所述拍照帧图像和所述虚化帧图像进行合成,得到与所述虚化值对应的虚化图像;实现了利用摄像头拍摄的虚化帧图像对拍照帧图像进行虚化,并且该虚化图像不需要利用深度传感器采集拍摄场景中各个目标对象的深度信息,更不需要利用虚化算法结合该深度信息实现图像的虚化效果。

Description

拍照方法、装置、终端及计算机可读存储介质
本申请要求于2018年11月22日提交中国专利局、申请号为201811405822.2、申请名称为“拍照方法、装置、终端及计算机可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请属于拍照技术领域,尤其涉及一种拍照方法、装置、终端及计算机可读存储介质。
背景技术
图像虚化是指在一个图像中让焦点聚集在主题元素上,并且模糊非主题元素的拍摄手段。目前,通常需要使用具备大光圈的单反相机才能拍摄出具有虚化效果的照片,对于手机等智能终端受到体积、成本和使用环境的限制,其搭配的镜头基本属于小光圈的类型,无法通过镜头拍摄出具有虚化效果的照片。因而,在利用手机等智能终端进行虚化图像的拍摄时,需要利用深度传感器采集拍摄场景中各个目标对象的深度信息,再根据深度信息实现图像的虚化效果。
然而,由于深度传感器能提供的分辨率往往比拍摄的照片的分辨率低,并且深度传感器采集深度信息时容易受强反射物体的影响,使得利用深度传感器采集的深度信息进行图像虚化时,无法得到较高质量的虚化图像。
发明内容
本申请实施例提供一种拍照方法、装置、终端及计算机可读存储介质,可以解决无法得到较高质量的虚化图像的技术问题。
本申请实施例第一方面提供一种拍照方法,包括:
获取拍照帧图像的第一对焦位置和虚化值,以及获取与所述第一对焦位置和所述虚化值对应的虚化帧图像的第二对焦位置;
在接收到拍照指令时,采集与所述第一对焦位置对应的拍照帧图像,以及采集与所述第二对焦位置对应的虚化帧图像;
对所述拍照帧图像和所述虚化帧图像进行合成,得到与所述虚化值对应的虚化图像。
本申请实施例第二方面提供一种拍照装置,包括:
获取单元,用于获取拍照帧图像的第一对焦位置和虚化值,以及获取与所述第一对焦位置和所述虚化值对应的虚化帧图像的第二对焦位置;
采集单元,用于在接收到拍照指令时,采集与所述第一对焦位置对应的拍照帧图像,以及采集与所述第二对焦位置对应的虚化帧图像;
虚化单元,用于对所述拍照帧图像和所述虚化帧图像进行合成,得到与所述虚化值对应的虚化图像。
本申请实施例第三方面提供一种终端,包括摄像头、存储器、处理器以及存储在存储器中并可在处理器上运行的计算机程序,处理器执行计算机程序时实现上述方法的步骤。
本申请实施例第四方面提供一种计算机可读存储介质,计算机可读存储介质存储有计算机程序,计算机程序被处理器执行时实现上述方法的步骤。
附图说明
为了更清楚地说明本申请实施例的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,应当理解,以下附图仅示出了本申请的某些实施例,因此不应被看作是对范围的限定,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他相关的附图。
图1是本申请实施例提供的一种拍照方法的第一实现流程示意图;
图2是本申请实施例提供的拍照预览界面示意图;
图3是本申请实施例提供的一种拍照方法的步骤103的具体实现流程示意图;
图4是本申请实施例提供的一种拍照方法的步骤303的第一具体实现流程示意图;
图5是本申请实施例提供的一种拍照方法的步骤303的第二具体实现流程示意图;
图6是本申请实施例提供的一种拍照方法的第二实现流程示意图;
图7是本申请实施例提供的第一对焦位置、第二对焦位置与第三对焦位置三者之间的位置关系示意图;
图8是本申请实施例提供的一种拍照方法的第三实现流程示意图;
图9是本申请实施例提供的第一对焦位置、第四对焦位置与第五对焦位置三者之间的位置关系示意图;
图10是本申请实施例提供的一种拍照方法的第四实现流程示意图;
图11是本申请实施例提供的第一对焦位置、第四对焦位置、第五对焦位置、第六对焦位置与第七对焦位置五者之间的位置关系示意图;
图12是本申请实施例提供的拍照装置的结构示意图;
图13是本申请实施例提供的终端的结构示意图。
具体实施方式
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。同时,在本申请的描述中,术语“第一”、“第二”等仅用于区分描述,而不能理解为指示或暗示相对重要性。
应当理解,当在本说明书和所附权利要求书中使用时,术语“包括”指示所描述特征、整体、步骤、操作、元素和/或组件的存在,但并不排除一个或多个其它特征、整体、步骤、操作、元素、组件和/或其集合的存在或添加。
还应当理解,在此本申请说明书中所使用的术语仅仅是出于描述特定实施例的目的而并不意在限制本申请。如在本申请说明书和所附权利要求书中所使用的那样,除非上下文清楚地指明其它情况,否则单数形式的“一”、“一个”及“该”意在包括复数形式。
还应当进一步理解,在本申请说明书和所附权利要求书中使用的术语“和/或”是指相关联列出的项中的一个或多个的任何组合以及所有可能组合,并且包括这些组合。
为了说明本申请所述的技术方案,下面通过具体实施例来进行说明。
目前的手机等智能终端进行虚化图像的拍摄时,通常要通过深度传感器采集拍摄场景中各个目标对象的深度信息,再根据该深度信息利用虚化算法对拍摄得到的图像进行虚化处理,得到虚化图像。
然而,由于深度传感器能提供的分辨率往往比拍摄的照片的分辨率低,并且深度传感器采集深度信息时容易受强反射物体的影响,使得利用深度传感器采集的深度信息进行图像虚化时,无法得到较高质量的虚化图像。
本申请实施例中,终端通过获取拍照帧图像的第一对焦位置和虚化值,以及获取与所述第一对焦位置和所述虚化值对应的虚化帧图像的第二对焦位置,并在接收到拍照指令时,采集与所述第一对焦位置对应的拍照帧图像,以及采集与所述第二对焦位置对应的虚化帧图像;接着对所述拍照帧图像和所述虚化帧图像进行合成,得到与所述虚化值对应的虚化图像;实现了利用摄像头拍摄的虚化帧图像对拍照帧图像进行虚化,得到与所述虚化值对应的虚化图像,并且该虚化图像不需要利用深 度传感器采集拍摄场景中各个目标对象的深度信息,更不需要利用虚化算法结合该深度信息实现图像的虚化效果;同时,也不会受深度传感器的分辨率以及强反射物体的影响,实现了较优的图像虚化效果。
如图1示出了本申请实施例提供的一种拍照方法的实现流程示意图,该方法应用于终端,可以由终端上配置的拍照装置执行,适用于需要得到较高质量的虚化图像的情形,包括步骤101至步骤103。
其中,所述终端包括智能手机、平板电脑、学习机等配置有拍照装置的终端设备。所述终端设备上可以安装有拍照应用。
步骤101中,获取拍照帧图像的第一对焦位置和虚化值,以及获取与所述第一对焦位置和所述虚化值对应的虚化帧图像的第二对焦位置。
本申请实施例中,所述第一对焦位置是需要实现清晰拍摄的位置,即,最后得到的虚化图像中,该对焦位置的对象应当呈现清晰的图像,其他位置的对象应当呈现模糊的图像。
所述第一对焦位置的获取可以通过拍照装置的自动对焦算法选定,也可以由用户在拍照预览界面中进行选定。所述虚化值可以由用户根据实际需要进行设置。例如,虚化值可以设置为2、3、4,本申请实施例中,虚化值越大,表示虚化程度越高。
例如,如图2所示,用户可以在拍照预览界面21中点击第一个人脸22,使得第一对焦位置位于第一人脸22上。
可选的,所述获取与所述第一对焦位置和所述虚化值对应的虚化帧图像的第二对焦位置,可以包括:查找第一对焦位置、虚化值与第二对焦位置三者之间的对应关系,获取与所述第一对焦位置和所述虚化值对应的虚化帧图像的第二对焦位置。
例如,查找如表一所示的第一对焦位置、虚化值与第二对焦位置三者之间的对应关系表确定与所述第一对焦位置和所述虚化值对应的虚化帧图像的第二对焦位置。需要说明的是,所述第一对焦位置与所述第二对焦位置属于不同的位置。表一中的数值可以是根据函数关系式进行计算得到的数值,或者为根据实践经验获取的数值。
表一:
第一对焦位置 虚化值 第二对焦位置
3m 2 5m
3.5m 2 6m
步骤102中,在接收到拍照指令时,采集与所述第一对焦位置对应的拍照帧图像,以及采集与所述第二对焦位置对应的虚化帧图像。
本申请实施例中,在获取了拍照帧图像的拍摄参数(第一对焦位置),以及虚化帧图像的拍摄参数(第二对焦位置)之后,即可控制马达驱动摄像头的镜头移动到相应位置进行拍照帧图像的采集以及虚化帧图像的采集。其中,虚化帧图像为用来对拍照帧图像进行虚化处理或清晰处理的图像,虚化帧图像对拍照帧图像进行虚化处理后得到相应的虚化图像,虚化帧图像对拍照帧图像进行清晰处理时,得到清晰图像。需要说明的是,所述虚化帧图像与所述拍照帧图像均为摄像头在获取到拍照指令时采集外界光信号生成的图像。
例如,利用一个摄像头通过连拍的方式,先采集拍照帧图像,再采集虚化帧图像,得到所述拍照帧图像和虚化帧图像。或者利用多个摄像头,同时采集得到所述拍照帧图像和虚化帧图像。
需要说明的是,在利用连拍的方式采集所述拍照帧图像和虚化帧图像时,由于存在时间差,可能会因为用户手持拍摄时产生的抖动或者拍摄对象本身的位移,导致所述拍照帧图像和虚化帧图像拍摄的内容会有不一致的情况,因此,在本申请实 施例中,所述采集与所述第一对焦位置对应的拍照帧图像,以及采集与所述第二对焦位置对应的虚化帧图像之后,可以包括对所述拍照帧图像和所述虚化帧图像进行对齐。
例如,利用对齐算法对虚化帧图像和拍照帧图像进行变换和剪切,使得虚化帧图像中的像素与拍照帧图像中的像素一一对应。其中,所述对齐算法可以为通用的对齐算法,例如,前向加法算法和逆组合算法。
步骤103中,对所述拍照帧图像和所述虚化帧图像进行合成,得到与所述虚化值对应的虚化图像。
本申请实施例中,由于拍照帧图像和虚化帧图像的对焦位置不相同,因此,拍照帧图像中的清晰区域与虚化帧图像中的清晰区域不相同。即,拍照帧图像中的清晰区域有可能对应虚化帧图像中的虚化区域,因此,可以利用虚化帧图像对拍照帧图像进行虚化,得到虚化图像,即,对所述拍照帧图像和所述虚化帧图像进行合成,得到与所述虚化值对应的虚化图像。
可选的,如图3所示,在本申请的一些实施方式中,所述步骤103,对所述拍照帧图像和所述虚化帧图像进行合成,得到与所述虚化值对应的虚化图像,可以包括:步骤301至步骤303。
步骤301,计算所述拍照帧图像中每个像素点的边缘强度。
所述每个像素点的边缘强度是指每个像素点与其相邻的八个像素点的加权值。例如,通过计算每个像素点的索贝尔算子(Sobel算子)得到每个像素点的边缘强度,或者通过计算每个像素点的拉普拉斯算子得到每个像素点的边缘强度。
步骤302,保持所述拍照帧图像中像素点的边缘强度大于或等于第一阈值的像素点不变。
其中,所述第一阈值是根据拍照帧图像中对焦位置的像素点的边缘强度进行设置的,用于将拍照帧图像中像素点的边缘强度大于或等于第一阈值的像素点区分为需要保持清晰的像素点,即,所述拍照帧图像中对焦位置的像素点,并将拍照帧图像中像素点的边缘强度小于所述第一阈值的像素点区分为非对焦位置的像素点,即需要进行虚化处理的像素点(待虚化像素点)。
本申请实施例中,由于拍照帧图像中像素点的边缘强度大于或等于第一阈值的像素点为需要保持清晰的像素点,因此,需要保持所述拍照帧图像中像素点的边缘强度大于或等于第一阈值的像素点不变,即,不对其进行虚化处理,接着再对拍照帧图像中像素点的边缘强度小于第一阈值的像素点进行虚化处理。
步骤303,将所述拍照帧图像中像素点的边缘强度小于所述第一阈值的像素点作为待虚化像素点,并对所述待虚化像素点进行虚化处理。
可选的,如图4所示,所述对待虚化像素点进行虚化处理可以包括:步骤401至步骤403。
步骤401,计算所述虚化帧图像中每个像素点的边缘强度,并计算所述待虚化像素点与所述虚化帧图像中对应位置的像素点的边缘强度的第一差值。
例如,拍照帧图像中的待虚化像素点A的边缘强度为a,像素点A与虚化帧图像中的像素点B为对应位置的像素点,且像素点B的边缘强度为b,则待虚化像素点A的边缘强度与虚化帧图像中对应位置的像素点B的边缘强度的第一差值为a-b。
步骤402,若所述第一差值小于或等于零,则保持所述待虚化像素点不变。
本申请实施例中,由于所述第一差值小于或等于零,表示拍照帧图像中的待虚化像素点的虚化程度大于虚化帧图像中对应位置的像素点的虚化程度,即,该像素点可能为虚化帧图像中对焦位置的像素点,因此,在所述第一差值小于或等于零,需要保持所述待虚化像素点不变。
步骤403,若所述第一差值大于零,则将所述待虚化像素点替换为所述虚化帧 图像中对应位置的像素点,得到与所述虚化值对应的虚化图像。
本申请实施例中,通过在所述第一差值大于零时,将所述待虚化像素点替换为所述虚化帧图像中对应位置的像素点,实现了利用摄像头拍摄的虚化帧图像对拍照帧图像进行虚化,得到与所述虚化值对应的虚化图像,并且该虚化图像不需要利用深度传感器采集拍摄场景中各个目标对象的深度信息,更不需要利用虚化算法结合该深度信息实现图像的虚化效果;同时,也不会受深度传感器的分辨率以及强反射物体的影响,实现了较优的图像虚化效果。
可选的,为了使得虚化图像更加的平滑自然,本申请实施例中,如图5所示,所述对待虚化像素点进行虚化处理可以包括:步骤501至步骤503。
步骤501,计算所述待虚化像素点与所述虚化帧图像中对应位置的像素点的边缘强度的第一差值。
步骤502,若所述第一差值小于或等于零,则保持所述待虚化像素点不变。
其中,所述步骤501至步骤502与所述步骤401至步骤402的实现方法相同或相应,此处不再赘述。
步骤503,若所述第一差值大于零,则获取所述待虚化像素点对应的第一合成比例,利用所述第一合成比例对所述待虚化像素点进行合成,得到合成后的像素点,并将所述待虚化像素点替换为所述合成后的像素点,得到与所述虚化值对应的虚化图像;其中,所述第一合成比例为所述虚化帧图像中与所述待虚化像素点对应的像素点的像素值在所述合成后的像素点的像素值中所占的比例。
本申请实施例中,通过在所述第一差值大于零时,获取所述待虚化像素点对应的第一合成比例,并利用所述第一合成比例对所述待虚化像素点进行合成,同时将所述待虚化像素点替换为所述合成后的像素点,得到与所述虚化值对应的虚化图像;而不是在所述第一差值大于零时,直接将所述待虚化像素点替换为所述虚化帧图像中对应位置的像素点,使得在所述第一差值比较大时,虚化后的像素点能够更加平滑自然,不会太突兀。
可选的,所述若所述第一差值大于零,则获取所述待虚化像素点对应的第一合成比例,利用所述第一合成比例对所述待虚化像素点进行合成,得到合成后的像素点,并将所述待虚化像素点替换为所述合成后的像素点,得到与所述虚化值对应的虚化图像待虚化像素点对应的第一合成比例,包括:查找第一差值、虚化值与第一合成比例三者之间的第一对应关系,获取所述待虚化像素点对应的第一合成比例。
例如,通过查找如表二所示的第一差值、虚化值与第一合成比例三者之间的第一对应关系表确定所述待虚化像素点对应的第一合成比例。需要说明的是,表二中的数值可以是根据函数关系式进行计算得到的数值,或者为根据实践经验获取的数值。
表二:
第一差值 虚化值 第一合成比例
30 2 50%
40 2 40%
在保证合成比例的精度的同时,达到更强的虚化效果,在图3描述的实施方式的基础上,如图6所示,本申请实施例中还提供一种拍照方法,包括:步骤601至步骤606。为了描述的简洁,本实施例中与图3实施例中相同或相应的部分可以参看图3实施例中的描述。
步骤601,获取拍照帧图像的第一对焦位置和虚化值,获取与所述第一对焦位置和所述虚化值对应的虚化帧图像的第二对焦位置,以及获取与所述第一对焦位置和所述虚化值对应的参照帧图像的第三对焦位置;其中,所述第三对焦位置与摄像头之间的距离大于所述第一对焦位置与所述摄像头之间的距离,并且,所述第三对 焦位置与摄像头的距离小于所述第二对焦位置与所述摄像头之间的距离。
例如,如图7所示,摄像头71拍摄拍照帧图像第一对焦位置为位置72,摄像头71拍摄参照帧图像的第三对焦位置为位置73;所述第三对焦位置73与摄像头71之间的距离L大于所述第一对焦位置72与所述摄像头71之间的距离G,且,所述第三对焦位置73与摄像头71的距离小于所述第二对焦位置74与所述摄像头71之间的距离J。
步骤602,采集与所述第一对焦位置对应的拍照帧图像,采集与所述第二对焦位置对应的虚化帧图像,以及采集与所述第三对焦位置对应的参照帧图像。
步骤603,计算所述拍照帧图像中每个像素点的边缘强度;保持所述拍照帧图像中像素点的边缘强度大于或等于第一阈值的像素点不变;将所述拍照帧图像中像素点的边缘强度小于所述第一阈值的像素点作为待虚化像素点。
本申请实施例中,由于拍照帧图像中像素点的边缘强度大于或等于第一阈值的像素点为需要保持清晰的像素点,因此,需要保持所述拍照帧图像中像素点的边缘强度大于或等于第一阈值的像素点不变,即,不对其进行虚化处理,接着再对拍照帧图像中像素点的边缘强度小于第一阈值的像素点进行虚化处理。
步骤604,计算所述待虚化像素点与所述参照帧图像中对应位置的像素点的边缘强度的第二差值。
步骤605,若所述第二差值小于或等于零,则保持所述待虚化像素点不变。
步骤606,若所述第二差值大于零,则获取所述待虚化像素点对应的第二合成比例,利用所述第二合成比例对所述待虚化像素点进行合成,得到合成后的像素点,并将所述待虚化像素点替换为所述合成后的像素点,得到与所述虚化值对应的虚化图像;其中,所述第二合成比例为所述虚化帧图像中与所述待虚化像素点对应的像素点的像素值在所述合成后的像素点的像素值中所占的比例。
本申请实施例中,由于参照帧图像的对焦位置与拍照帧图像的对焦位置之间的距离小于所述虚化帧图像的对焦位置与拍照帧图像的对焦位置之间的距离,因此,计算待虚化像素点与参照帧图像中对应位置的像素点的边缘强度的第二差值,并根据该第二差值的得到的第二合成比例的精度要比直接利用待虚化像素点与虚化帧图像中对应位置的像素点的边缘强度的第一差值得到的第一合成比例的精度要高,另外,由于虚化帧图像的对焦位置与拍照帧图像的对焦位置之间的距离大于参照帧图像的对焦位置与拍照帧图像的对焦位置之间的距离,因此,虚化帧图像的虚化程度相对于参照帧图像来说,虚化程度要更高,因此,本申请实施例中,通过在虚化帧图像与拍照帧图像之间采集一个参照帧图像,可以实现保证合成比例的精度的同时,达到更强的虚化效果。
需要说明的是,所述第二合成比例的获取方式可以参照所述第一合成比例的获取方式,此处不再赘述。
为了同时实现拍照帧图像的前景虚化和背景虚化,本申请实施例对图3描述的实施作进一步限定,如图8所示,本申请实施例中还提供一种拍照方法,包括:步骤801至步骤808。
步骤801,获取拍照帧图像的第一对焦位置和虚化值,获取与所述第一对焦位置和所述虚化值对应的前虚化帧图像的第四对焦位置,以及,获取与所述第一对焦位置和所述虚化值对应的后虚化帧图像的第五对焦位置,其中,所述第一对焦位置距离摄像头的距离大于所述第五对焦位置距离摄像头的距离,且所述第一对焦位置距离摄像头的距离小于所述第四对焦位置距离摄像头的距离。
例如,如图9所示,所述第一对焦位置72距离摄像头71的距离H大于所述第五对焦位置75距离摄像头71的距离G,且所述第一对焦位置72距离摄像头71的距离H小于所述第四对焦位置74距离摄像头71的距离J。
步骤802,采集与所述第一对焦位置对应的拍照帧图像,采集与所述第四对焦位置对应的前虚化帧图像,以及采集与所述第五对焦位置对应的后虚化帧图像。
步骤803,计算所述拍照帧图像中每个像素点的边缘强度;保持所述拍照帧图像中像素点的边缘强度大于或等于第一阈值的像素点不变;将所述拍照帧图像中像素点的边缘强度小于所述第一阈值的像素点作为待虚化像素点。
步骤804,计算所述待虚化像素点与所述前虚化帧图像中对应位置的像素点的边缘强度的第三差值;以及,计算所述待虚化像素点与所述后虚化帧图像中对应位置的像素点的边缘强度的第四差值。
步骤805,若所述第三差值和所述第四差值均小于或等于零,则保持所述待虚化像素点不变。
步骤806,若所述第三差值和/或所述第四差值大于零,则比较所述第三差值与所述第四差值的大小。
步骤807,获取所述第三差值大于所述第四差值的所述待虚化像素点对应的第三合成比例,利用所述第三合成比例对所述待虚化像素点进行合成,得到合成后的像素点,并将所述待虚化像素点替换为所述合成后的像素点,得到与所述虚化值对应的虚化图像;其中,所述第三合成比例为所述前虚化帧图像中与所述待虚化像素点对应的像素点的像素值在所述合成后的像素点的像素值中所占的比例。
步骤808,获取第三差值小于或等于所述第四差值的所述待虚化像素点对应的第四合成比例,利用所述第四合成比例对所述待虚化像素点进行合成,得到合成后的像素点,并将所述待虚化像素点替换为所述合成后的像素点,得到与所述虚化值对应的虚化图像;其中,所述第四合成比例为所述后虚化帧图像中与所述待虚化像素点对应的像素点的像素值在所述合成后的像素点的像素值中所占的比例。
由于所述前虚化帧图像的前景是实的,背景是虚的,所述后虚化帧图像的背景是实的前景是虚的,因此,本申请实施例中,通过设置所述第一对焦位置距离摄像头的距离大于所述第五对焦位置距离摄像头的距离,且小于所述第四对焦位置距离摄像头的距离,即,在拍照帧图像的对焦位置的前端和后端分别采集前虚化帧图像和后虚化帧图像,可以使得拍照帧图像同时进行前景虚化和背景虚化。
需要说明的是,在所述图1至图7描述的实施方式中,其中的虚化帧图像可以为一个或多个前虚化帧图像,也可以是一个或多个后虚化帧图像,并且其中的参照帧图像也可以为前参照帧图像或者为后参照帧图像,用于分别实现只进行前景虚化的场景和只进行背景虚化的场景。
在所述图8至图9描述的实施方式中,同样的,可以参照所述图6至图7描述的实施方式,增加前参照帧图像和后参照帧图像,具体的,如图10所示,本申请实施例中还提供一种拍照方法,包括:步骤1001至步骤1006。
步骤1001,获取拍照帧图像的第一对焦位置和虚化值,获取与所述第一对焦位置和所述虚化值对应的前虚化帧图像的第四对焦位置,获取与所述第一对焦位置和所述虚化值对应的后虚化帧图像的第五对焦位置,获取与所述第一对焦位置和所述虚化值对应的前参照帧图像的第六对焦位置,以及,获取与所述第一对焦位置和所述虚化值对应的后参照帧图像的第七对焦位置,其中,所述第一对焦位置距离摄像头的距离大于所述第五对焦位置距离摄像头的距离,且所述第一对焦位置距离摄像头的距离小于所述第四对焦位置距离摄像头的距离;所述第七对焦位置距离所述摄像头的距离小于所述第一对焦位置距离摄像头的距离;所述第六对焦位置距离所述摄像头的距离大于所述第一对焦位置距离摄像头的距离,并且,所述第六对焦位置距离所述摄像头的距离小于所述第四对焦位置距离摄像头的距离。
例如,如图11所示,第一对焦位置72距离摄像头71的距离H大于所述第五对焦位置75距离摄像头71的距离G,且所述第一对焦位置72距离摄像头71的距 离H小于所述第四对焦位置74距离摄像头71的距离J,所述第七对焦位置77距离所述摄像头71的距离K大于所述第五对焦位置75距离摄像头71的距离G,所述第七对焦位置77距离所述摄像头71的距离K小于所述第一对焦位置72距离摄像头71的距离H;所述第六对焦位置76距离所述摄像头71的距离L大于所述第一对焦位置72距离摄像头71的距离H,并且,所述第六对焦位置76距离所述摄像头71的距离L小于所述第四对焦位置74距离摄像头71的距离J。
步骤1002,采集与所述第一对焦位置对应的拍照帧图像,采集与所述第四对焦位置对应的前虚化帧图像,采集与所述第五对焦位置对应的后虚化帧图像,采集与所述第六对焦位置对应的前参照帧图像,以及采集与所述第七对焦位置对应的后参照帧图像。
步骤1003,计算所述拍照帧图像中每个像素点的边缘强度;保持所述拍照帧图像中像素点的边缘强度大于或等于第一阈值的像素点不变;将所述拍照帧图像中像素点的边缘强度小于所述第一阈值的像素点作为待虚化像素点。
步骤1004,计算所述待虚化像素点与所述前参照帧图像中对应位置的像素点的边缘强度的第五差值;以及,计算所述待虚化像素点与所述后参照帧图像中对应位置的像素点的边缘强度的第六差值;
步骤1005,若所述第五差值和所述第六差值均小于或等于零,则保持所述待虚化像素点不变;
步骤1006,若所述第五差值和/或所述第六差值大于零,则获取所述第五差值大于所述第六差值的所述待虚化像素点对应的第五合成比例,利用所述第五合成比例对所述待虚化像素点进行合成,得到合成后的像素点,并将所述待虚化像素点替换为所述合成后的像素点;其中,所述第五合成比例为所述前虚化帧图像中与所述待虚化像素点对应的像素点的像素值在所述合成后的像素点的像素值中所占的比例;以及,获取第五差值小于或等于所述第六差值的所述待虚化像素点对应的第六合成比例,利用所述第六合成比例对所述待虚化像素点进行合成,得到合成后的像素点,并将所述待虚化像素点替换为所述合成后的像素点,得到与所述虚化值对应的虚化图像;其中,所述第六合成比例为所述后虚化帧图像中与所述待虚化像素点对应的像素点的像素值在所述合成后的像素点的像素值中所占的比例。
本申请实施例中,在所述图8至图9描述的实施方式中,增加所述前参照帧和后参照帧,从而实现了更强的前景虚化效果和更强的背景虚化效果。其实现原理可以参考所述图6至图7描述的实施方式,此处不再赘述。
需要说明的是,在所述描述的实施方式中,参照帧图像的对焦位置与拍照帧图像的对焦位置之间的距离大于虚化帧图像的对焦位置与参照帧图像的对焦位置之间的距离,使得所述根据参照帧获取的合成比例能够适用于虚化帧图像。
例如,前参照帧图像的对焦位置与拍照帧图像的对焦位置之间的距离大于前虚化帧图像的对焦位置与前参照帧图像的对焦位置之间的距离,使得所述根据前参照帧获取的第五合成比例能够适用于前虚化帧图像中与所述待虚化像素点对应的像素点的像素值在所述合成后的像素点的像素值中所占的比例,使得虚化后的图像更加平滑自然。
在所述描述的实施方式中,所述虚化帧图像除了可以用来对拍照帧图像进行虚化处理之外,还可以用来对拍照帧图像进行清晰处理。
可选的,所述采集与所述第一对焦位置对应的拍照帧图像,以及采集与所述第二对焦位置对应的虚化帧图像之后,还包括:对所述拍照帧图像和所述虚化帧图像进行合成,得到清晰图像。
具体的,所述对所述拍照帧图像和所述虚化帧图像进行合成,得到清晰图像包括:计算所述拍照帧图像中每个像素点的边缘强度与所述虚化帧图像中对应位置的 像素点的边缘强度的第七差值;保持所述拍照帧图像中第七差值大于或等于零的像素点不变;将所述拍照帧图像中第七差值小于零的像素点替换为所述虚化帧图像中对应位置的像素点,得到所述虚化值对应的虚化图像;或者,获取拍照帧图像清晰值,并获取所述拍照帧图像中第七差值小于零的像素点对应的第七合成比例,利用所述第七合成比例对所述拍照帧图像中第七差值小于零的像素点进行合成,得到合成后的像素点,并将所述拍照帧图像中第七差值小于零的像素点替换为所述合成后的像素点,得到与所述清晰值对应的清晰图像;其中,所述第七合成比例为所述虚化帧图像中对应位置像素点的像素值在所述合成后的像素点的像素值中所占的比例。
基于所述描述,本申请实施例中,通过对所述拍照帧图像和所述虚化帧图像进行合成,可以得到与所述虚化值对应的虚化图像或者与所述清晰值对应的清晰图像,实现模拟摄像头可变光圈的效果。
需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本申请并不受所描述的动作顺序的限制,在本申请实施例中,某些步骤可以采用其他顺序或者同时进行。
图12示出了本申请实施例提供的一种拍照装置1200的结构示意图,包括获取单元1201、采集单元1202和虚化单元1203。
获取单元1201,用于获取拍照帧图像的第一对焦位置和虚化值,以及获取与所述第一对焦位置和所述虚化值对应的虚化帧图像的第二对焦位置;
采集单元1202,用于在接收到拍照指令时,采集与所述第一对焦位置对应的拍照帧图像,以及采集与所述第二对焦位置对应的虚化帧图像;
虚化单元1203,用于对所述拍照帧图像和所述虚化帧图像进行合成,得到与所述虚化值对应的虚化图像。
需要说明的是,为描述的方便和简洁,所述描述的拍照装置1200的具体工作过程,可以参考所述图1至图11中描述的方法的对应过程,在此不再赘述。
如图13所示,本申请提供一种用于实现所述拍照方法的终端,该终端可以为移动终端,该移动终端可以为智能手机、平板电脑、个人电脑(PC)、学习机等终端,包括:处理器131、存储器132、一个或多个输入设备133(图13中仅示出一个)、一个或多个输出设备134(图13中仅示出一个)和摄像头135。处理器131、存储器132、输入设备133、输出设备134和摄像头135通过总线136连接。该摄像头用于根据所述拍照指令采集外界光信号,生成所述拍照帧图像和虚化帧图像。
应当理解,在本申请实施例中,所称处理器131可以是中央处理单元(Central Processing Unit,CPU),该处理器还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
输入设备133可以包括虚拟键盘、触控板、指纹采传感器(用于采集用户的指纹信息和指纹的方向信息)、麦克风等,输出设备134可以包括显示器、扬声器等。
存储器132可以包括只读存储器和随机存取存储器,并向处理器131提供指令和数据。存储器132的一部分或全部还可以包括非易失性随机存取存储器。例如,存储器132还可以存储设备类型的信息。
所述存储器132存储有计算机程序,所述计算机程序可在所述处理器131上运行,例如,所述计算机程序为拍照方法的程序。所述处理器131执行所述计算机程序时实现所述拍照方法实施例中的步骤,例如图1所示的步骤101至步骤103。或者,所述处理器131执行所述计算机程序时实现所述各装置实施例中各模块/单元的 功能,例如图10所示单元1001至1003的功能。
所述计算机程序可以被分割成一个或多个模块/单元,所述一个或者多个模块/单元被存储在所述存储器132中,并由所述处理器131执行,以完成本申请。所述一个或多个模块/单元可以是能够完成特定功能的一系列计算机程序指令段,该指令段用于描述所述计算机程序在所述进行拍照的终端中的执行过程。例如,所述计算机程序可以被分割成获取单元、采集单元和虚化单元,各单元具体功能如下:获取单元,用于获取拍照帧图像的第一对焦位置和虚化值,以及获取与所述第一对焦位置和所述虚化值对应的虚化帧图像的第二对焦位置;采集单元,用于在接收到拍照指令时,采集与所述第一对焦位置对应的拍照帧图像,以及采集与所述第二对焦位置对应的虚化帧图像;虚化单元,用于对所述拍照帧图像和所述虚化帧图像进行合成,得到与所述虚化值对应的虚化图像。
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以所述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将所述功能分配由不同的功能单元、模块完成,即将所述装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。实施例中的各功能单元、模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中,所述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。另外,各功能单元、模块的具体名称也只是为了便于相互区分,并不用于限制本申请的保护范围。所述系统中单元、模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
在所述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述或记载的部分,可以参见其它实施例的相关描述。
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
在本申请所提供的实施例中,应该理解到,所揭露的装置/终端和方法,可以通过其它的方式实现。例如,以上所描述的装置/终端实施例仅仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通讯连接可以是通过一些接口,装置或单元的间接耦合或通讯连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。所述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
所述集成的模块/单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实现所述实施例方法中的全部或部分流程,也可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一计算机可读存储介质中,该计算机程序在被处理器执行时,可实现所述各个方法实施例的步骤。其中,所述计算机程序包括计 算机程序代码,所述计算机程序代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。所述计算机可读介质可以包括:能够携带所述计算机程序代码的任何实体或装置、记录介质、U盘、移动硬盘、磁碟、光盘、计算机存储器、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、电载波信号、电信信号以及软件分发介质等。需要说明的是,所述计算机可读介质包含的内容可以根据司法管辖区内立法和专利实践的要求进行适当的增减,例如在某些司法管辖区,根据立法和专利实践,计算机可读介质不包括电载波信号和电信信号。
以上所述实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。

Claims (20)

  1. 一种拍照方法,其特征在于,包括:
    获取拍照帧图像的第一对焦位置和虚化值,以及获取与所述第一对焦位置和所述虚化值对应的虚化帧图像的第二对焦位置;
    在接收到拍照指令时,采集与所述第一对焦位置对应的拍照帧图像,以及采集与所述第二对焦位置对应的虚化帧图像;
    对所述拍照帧图像和所述虚化帧图像进行合成,得到与所述虚化值对应的虚化图像。
  2. 如权利要求1所述的拍照方法,其特征在于,所述获取与所述第一对焦位置和所述虚化值对应的虚化帧图像的第二对焦位置,包括:
    查找第一对焦位置、虚化值与第二对焦位置三者之间的对应关系,获取与所述第一对焦位置和所述虚化值对应的虚化帧图像的第二对焦位置。
  3. 如权利要求1或2所述的拍照方法,其特征在于,所述对所述拍照帧图像和所述虚化帧图像进行合成,得到与所述虚化值对应的虚化图像,包括:
    计算所述拍照帧图像中每个像素点的边缘强度;
    保持所述拍照帧图像中像素点的边缘强度大于或等于第一阈值的像素点不变;
    将所述拍照帧图像中像素点的边缘强度小于所述第一阈值的像素点作为待虚化像素点,并对所述待虚化像素点进行虚化处理。
  4. 如权利要求3所述的拍照方法,其特征在于,所述对所述待虚化像素点进行虚化处理,包括:
    计算所述待虚化像素点与所述虚化帧图像中对应位置的像素点的边缘强度的第一差值;
    若所述第一差值小于或等于零,则保持所述待虚化像素点不变;
    若所述第一差值大于零,则将所述待虚化像素点替换为所述虚化帧图像中对应位置的像素点,得到与所述虚化值对应的虚化图像;
    或者,
    若所述第一差值大于零,则获取所述待虚化像素点对应的第一合成比例,利用所述第一合成比例对所述待虚化像素点进行合成,得到合成后的像素点,并将所述待虚化像素点替换为所述合成后的像素点,得到与所述虚化值对应的虚化图像;其中,所述第一合成比例为所述虚化帧图像中与所述待虚化像素点对应的像素点的像素值在所述合成后的像素点的像素值中所占的比例。
  5. 如权利要求4所述的拍照方法,其特征在于,所述获取所述待虚化像素点对应的第一合成比例,包括:
    查找第一差值、虚化值与第一合成比例三者之间的第一对应关系,获取所述待虚化像素点对应的第一合成比例。
  6. 如权利要求3所述的拍照方法,其特征在于,所述获取与所述第一对焦位置和所述虚化值对应的虚化帧图像的第二对焦位置,还包括:
    获取与所述第一对焦位置和所述虚化值对应的参照帧图像的第三对焦位置;其中,所述第三对焦位置与摄像头之间的距离大于所述第一对焦位置与所述摄像头之间的距离,并且,所述第三对焦位置与摄像头的距离小于所述第二对焦位置与所述摄像头之间的距离;
    相应的,所述采集与所述第一对焦位置对应的拍照帧图像,以及采集与所述第二对焦位置对应的虚化帧图像,还包括:
    采集与所述第三对焦位置对应的参照帧图像;
    所述对所述待虚化像素点进行虚化处理,包括:
    计算所述待虚化像素点与所述参照帧图像中对应位置的像素点的边缘强度的第二差值;
    若所述第二差值小于或等于零,则保持所述待虚化像素点不变;
    若所述第二差值大于零,则获取所述待虚化像素点对应的第二合成比例,利用所述第二合成比例对所述待虚化像素点进行合成,得到合成后的像素点,并将所述待虚化像素点替换为所述合成后的像素点,得到与所述虚化值对应的虚化图像;其中,所述第二合成比例为所述虚化帧图像中与所述待虚化像素点对应的像素点的像素值在所述合成后的像素点的像素值中所占的比例。
  7. 如权利要求3所述的拍照方法,其特征在于,所述获取与所述第一对焦位置和所述虚化值对应的虚化帧图像的第二对焦位置,包括:
    获取与所述第一对焦位置和所述虚化值对应的前虚化帧图像的第四对焦位置,以及,获取与所述第一对焦位置和所述虚化值对应的后虚化帧图像的第五对焦位置;其中,所述第一对焦位置距离摄像头的距离大于所述第五对焦位置距离摄像头的距离,且所述第一对焦位置距离摄像头的距离小于所述第四对焦位置距离摄像头的距离;
    相应的,所述采集与所述第二对焦位置对应的虚化帧图像,包括:
    采集与所述第四对焦位置对应的前虚化帧图像,以及采集与所述第五对焦位置 对应的后虚化帧图像;
    所述对所述待虚化像素点进行虚化处理,包括:
    计算所述待虚化像素点与所述前虚化帧图像中对应位置的像素点的边缘强度的第三差值;以及,计算所述待虚化像素点与所述后虚化帧图像中对应位置的像素点的边缘强度的第四差值;
    若所述第三差值和所述第四差值均小于或等于零,则保持所述待虚化像素点不变;
    若所述第三差值和/或所述第四差值大于零,则比较所述第三差值与所述第四差值的大小;
    获取所述第三差值大于所述第四差值的所述待虚化像素点对应的第三合成比例,利用所述第三合成比例对所述待虚化像素点进行合成,得到合成后的像素点,并将所述待虚化像素点替换为所述合成后的像素点,得到与所述虚化值对应的虚化图像;其中,所述第三合成比例为所述前虚化帧图像中与所述待虚化像素点对应的像素点的像素值在所述合成后的像素点的像素值中所占的比例;
    获取第三差值小于或等于所述第四差值的所述待虚化像素点对应的第四合成比例,利用所述第四合成比例对所述待虚化像素点进行合成,得到合成后的像素点,并将所述待虚化像素点替换为所述合成后的像素点,得到与所述虚化值对应的虚化图像;其中,所述第四合成比例为所述后虚化帧图像中与所述待虚化像素点对应的像素点的像素值在所述合成后的像素点的像素值中所占的比例。
  8. 如权利要求7所述拍照方法,其特征在于,所述获取与所述第一对焦位置和所述虚化值对应的前虚化帧图像的第四对焦位置,以及,获取与所述第一对焦位置和所述虚化值对应的后虚化帧图像的第五对焦位置,还包括:
    获取与所述第一对焦位置和所述虚化值对应的前参照帧图像的第六对焦位置,以及,获取与所述第一对焦位置和所述虚化值对应的后参照帧图像的第七对焦位置;其中,所述第一对焦位置距离摄像头的距离大于所述第五对焦位置距离摄像头的距离,且所述第一对焦位置距离摄像头的距离小于所述第四对焦位置距离摄像头的距离;所述第七对焦位置距离所述摄像头的距离小于所述第一对焦位置距离摄像头的距离;所述第六对焦位置距离所述摄像头的距离大于所述第一对焦位置距离摄像头的距离,并且,所述第六对焦位置距离所述摄像头的距离小于所述第四对焦位置距离摄像头的距离;
    相应的,采集与所述第四对焦位置对应的前虚化帧图像,以及采集与所述第五 对焦位置对应的后虚化帧图像,还包括:
    采集与所述第六对焦位置对应的前参照帧图像,以及采集与所述第七对焦位置对应的后参照帧图像;
    所述对所述待虚化像素点进行虚化处理,包括:
    计算所述待虚化像素点与所述前参照帧图像中对应位置的像素点的边缘强度的第五差值;以及,计算所述待虚化像素点与所述后参照帧图像中对应位置的像素点的边缘强度的第六差值;
    若所述第五差值和所述第六差值均小于或等于零,则保持所述待虚化像素点不变;
    若所述第五差值和/或所述第六差值大于零,则比较所述第五差值与所述第六差值的大小;并获取所述第五差值大于所述第六差值的所述待虚化像素点对应的第五合成比例,利用所述第五合成比例对所述待虚化像素点进行合成,得到合成后的像素点,并将所述待虚化像素点替换为所述合成后的像素点;其中,所述第五合成比例为所述前虚化帧图像中与所述待虚化像素点对应的像素点的像素值在所述合成后的像素点的像素值中所占的比例;以及,
    获取第五差值小于或等于所述第六差值的所述待虚化像素点对应的第六合成比例,利用所述第六合成比例对所述待虚化像素点进行合成,得到合成后的像素点,并将所述待虚化像素点替换为所述合成后的像素点,得到与所述虚化值对应的虚化图像;其中,所述第六合成比例为所述后虚化帧图像中与所述待虚化像素点对应的像素点的像素值在所述合成后的像素点的像素值中所占的比例。
  9. 如权利要求1-2任一项所述拍照方法,其特征在于,所述采集与所述第一对焦位置对应的拍照帧图像,以及采集与所述第二对焦位置对应的虚化帧图像之后,包括:
    对所述拍照帧图像和所述虚化帧图像进行对齐。
  10. 如权利要求1所述拍照方法,其特征在于,所述采集与所述第一对焦位置对应的拍照帧图像,以及采集与所述第二对焦位置对应的虚化帧图像之后,还包括:
    对所述拍照帧图像和所述虚化帧图像进行合成,得到清晰图像。
  11. 如权利要求10所述拍照方法,其特征在于,所述对所述拍照帧图像和所述虚化帧图像进行合成,得到与所述清晰值对应的清晰图像,包括:
    计算所述拍照帧图像中每个像素点的边缘强度与所述虚化帧图像中对应位置的像素点的边缘强度的第七差值;
    保持所述拍照帧图像中第七差值大于或等于零的像素点不变;
    将所述拍照帧图像中第七差值小于零的像素点替换为所述虚化帧图像中对应位置的像素点,得到所述虚化值对应的虚化图像;或者,
    获取拍照帧图像清晰值,并获取所述拍照帧图像中第七差值小于零的像素点对应的第七合成比例,利用所述第七合成比例对所述拍照帧图像中第七差值小于零的像素点进行合成,得到合成后的像素点,并将所述拍照帧图像中第七差值小于零的像素点替换为所述合成后的像素点,得到与所述清晰值对应的清晰图像;其中,所述第七合成比例为所述虚化帧图像中对应位置像素点的像素值在所述合成后的像素点的像素值中所占的比例。
  12. 一种拍照装置,其特征在于,包括:
    获取单元,用于获取拍照帧图像的第一对焦位置和虚化值,以及获取与所述第一对焦位置和所述虚化值对应的虚化帧图像的第二对焦位置;
    采集单元,用于在接收到拍照指令时,采集与所述第一对焦位置对应的拍照帧图像,以及采集与所述第二对焦位置对应的虚化帧图像;
    虚化单元,用于对所述拍照帧图像和所述虚化帧图像进行合成,得到与所述虚化值对应的虚化图像。
  13. 一种终端,包括摄像头、存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述计算机程序时实现如下步骤:
    获取拍照帧图像的第一对焦位置和虚化值,以及获取与所述第一对焦位置和所述虚化值对应的虚化帧图像的第二对焦位置;
    在接收到拍照指令时,采集与所述第一对焦位置对应的拍照帧图像,以及采集与所述第二对焦位置对应的虚化帧图像;
    对所述拍照帧图像和所述虚化帧图像进行合成,得到与所述虚化值对应的虚化图像。
  14. 如权利要求13所述的一种终端,其特征在于,所述处理器执行所述计算机程序时还实现以下步骤:
    查找第一对焦位置、虚化值与第二对焦位置三者之间的对应关系,获取与所述第一对焦位置和所述虚化值对应的虚化帧图像的第二对焦位置。
  15. 如权利要求13或14所述的一种终端,其特征在于,所述处理器执行所述计算机程序时还实现以下步骤:
    计算所述拍照帧图像中每个像素点的边缘强度;
    保持所述拍照帧图像中像素点的边缘强度大于或等于第一阈值的像素点不变;
    将所述拍照帧图像中像素点的边缘强度小于所述第一阈值的像素点作为待虚化像素点,并对所述待虚化像素点进行虚化处理。
  16. 如权利要求15所述的一种终端,其特征在于,所述处理器执行所述计算机程序时还实现以下步骤:
    计算所述待虚化像素点与所述虚化帧图像中对应位置的像素点的边缘强度的第一差值;
    若所述第一差值小于或等于零,则保持所述待虚化像素点不变;
    若所述第一差值大于零,则将所述待虚化像素点替换为所述虚化帧图像中对应位置的像素点,得到与所述虚化值对应的虚化图像;
    或者,
    若所述第一差值大于零,则获取所述待虚化像素点对应的第一合成比例,利用所述第一合成比例对所述待虚化像素点进行合成,得到合成后的像素点,并将所述待虚化像素点替换为所述合成后的像素点,得到与所述虚化值对应的虚化图像;其中,所述第一合成比例为所述虚化帧图像中与所述待虚化像素点对应的像素点的像素值在所述合成后的像素点的像素值中所占的比例。
  17. 如权利要求16所述的一种终端,其特征在于,所述处理器执行所述计算机程序时还实现以下步骤:
    查找第一差值、虚化值与第一合成比例三者之间的第一对应关系,获取所述待虚化像素点对应的第一合成比例。
  18. 如权利要求15所述的一种终端,其特征在于,所述处理器执行所述计算机程序时还实现以下步骤:
    获取与所述第一对焦位置和所述虚化值对应的参照帧图像的第三对焦位置;其中,所述第三对焦位置与摄像头之间的距离大于所述第一对焦位置与所述摄像头之间的距离,并且,所述第三对焦位置与摄像头的距离小于所述第二对焦位置与所述摄像头之间的距离;
    采集与所述第一对焦位置对应的拍照帧图像,采集与所述第二对焦位置对应的虚化帧图像,以及采集与所述第三对焦位置对应的参照帧图像;
    计算所述待虚化像素点与所述参照帧图像中对应位置的像素点的边缘强度的第二差值;
    若所述第二差值小于或等于零,则保持所述待虚化像素点不变;
    若所述第二差值大于零,则获取所述待虚化像素点对应的第二合成比例,利用所述第二合成比例对所述待虚化像素点进行合成,得到合成后的像素点,并将所述待虚化像素点替换为所述合成后的像素点,得到与所述虚化值对应的虚化图像;其中,所述第二合成比例为所述虚化帧图像中与所述待虚化像素点对应的像素点的像素值在所述合成后的像素点的像素值中所占的比例。
  19. 如权利要求15所述的一种终端,其特征在于,所述处理器执行所述计算机程序时还实现以下步骤:
    获取与所述第一对焦位置和所述虚化值对应的前虚化帧图像的第四对焦位置,以及,获取与所述第一对焦位置和所述虚化值对应的后虚化帧图像的第五对焦位置;其中,所述第一对焦位置距离摄像头的距离大于所述第五对焦位置距离摄像头的距离,且所述第一对焦位置距离摄像头的距离小于所述第四对焦位置距离摄像头的距离;
    采集与所述第四对焦位置对应的前虚化帧图像,以及采集与所述第五对焦位置对应的后虚化帧图像;
    计算所述待虚化像素点与所述前虚化帧图像中对应位置的像素点的边缘强度的第三差值;以及,计算所述待虚化像素点与所述后虚化帧图像中对应位置的像素点的边缘强度的第四差值;
    若所述第三差值和所述第四差值均小于或等于零,则保持所述待虚化像素点不变;
    若所述第三差值和/或所述第四差值大于零,则比较所述第三差值与所述第四差值的大小;
    获取所述第三差值大于所述第四差值的所述待虚化像素点对应的第三合成比例,利用所述第三合成比例对所述待虚化像素点进行合成,得到合成后的像素点,并将所述待虚化像素点替换为所述合成后的像素点,得到与所述虚化值对应的虚化图像;其中,所述第三合成比例为所述前虚化帧图像中与所述待虚化像素点对应的像素点的像素值在所述合成后的像素点的像素值中所占的比例;
    获取第三差值小于或等于所述第四差值的所述待虚化像素点对应的第四合成比例,利用所述第四合成比例对所述待虚化像素点进行合成,得到合成后的像素点,并将所述待虚化像素点替换为所述合成后的像素点,得到与所述虚化值对应的虚化图像;其中,所述第四合成比例为所述后虚化帧图像中与所述待虚化像素点对应的 像素点的像素值在所述合成后的像素点的像素值中所占的比例。
  20. 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如权利要求1至11任意一项所述方法的步骤。
PCT/CN2019/110853 2018-11-22 2019-10-12 拍照方法、装置、终端及计算机可读存储介质 Ceased WO2020103604A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201811405822.2A CN109151329A (zh) 2018-11-22 2018-11-22 拍照方法、装置、终端及计算机可读存储介质
CN201811405822.2 2018-11-22

Publications (1)

Publication Number Publication Date
WO2020103604A1 true WO2020103604A1 (zh) 2020-05-28

Family

ID=64806189

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/110853 Ceased WO2020103604A1 (zh) 2018-11-22 2019-10-12 拍照方法、装置、终端及计算机可读存储介质

Country Status (2)

Country Link
CN (1) CN109151329A (zh)
WO (1) WO2020103604A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112085686A (zh) * 2020-08-21 2020-12-15 北京迈格威科技有限公司 图像处理方法、装置、电子设备及计算机可读存储介质
CN117173004A (zh) * 2022-05-26 2023-12-05 Oppo广东移动通信有限公司 图像处理方法、终端、芯片及存储介质

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109151329A (zh) * 2018-11-22 2019-01-04 Oppo广东移动通信有限公司 拍照方法、装置、终端及计算机可读存储介质
CN110505406A (zh) * 2019-08-26 2019-11-26 宇龙计算机通信科技(深圳)有限公司 背景虚化方法、装置、存储介质及终端
CN111246092B (zh) * 2020-01-16 2021-07-20 Oppo广东移动通信有限公司 图像处理方法、装置、存储介质及电子设备
CN111246093B (zh) * 2020-01-16 2021-07-20 Oppo广东移动通信有限公司 图像处理方法、装置、存储介质及电子设备
WO2021142711A1 (zh) * 2020-01-16 2021-07-22 Oppo广东移动通信有限公司 图像处理方法、装置、存储介质及电子设备
CN111212231B (zh) * 2020-01-16 2021-06-15 Oppo广东移动通信有限公司 图像处理方法、装置、存储介质及电子设备
CN112351204A (zh) * 2020-10-27 2021-02-09 歌尔智能科技有限公司 一种拍照方法、装置、移动终端及计算机可读存储介质
CN112954212B (zh) * 2021-02-08 2022-08-30 维沃移动通信有限公司 视频生成方法、装置及设备
CN113888435A (zh) * 2021-10-11 2022-01-04 维沃移动通信有限公司 图像处理方法、装置、电子设备和可读存储介质
CN115633261B (zh) * 2022-09-30 2026-01-02 Oppo广东移动通信有限公司 拍摄方法、拍摄装置、电子设备和计算机可读存储介质
CN118784991B (zh) * 2024-09-06 2025-04-15 荣耀终端股份有限公司 一种图像处理方法及相关装置

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130329120A1 (en) * 2012-06-11 2013-12-12 Canon Kabushiki Kaisha Image processing apparatus, image processing method, image pickup apparatus, method of controlling image pickup apparatus, and non-transitory computer-readable storage medium
CN104333700A (zh) * 2014-11-28 2015-02-04 广东欧珀移动通信有限公司 一种图像虚化方法和图像虚化装置
CN104660900A (zh) * 2013-10-30 2015-05-27 株式会社摩如富 图像处理装置及图像处理方法
CN104680478A (zh) * 2015-02-15 2015-06-03 青岛海信移动通信技术股份有限公司 一种目标图像数据的选取方法和装置
CN106941590A (zh) * 2017-05-19 2017-07-11 深圳天珑无线科技有限公司 一种图像处理方法及装置
CN106952222A (zh) * 2017-03-17 2017-07-14 成都通甲优博科技有限责任公司 一种交互式图像虚化方法及装置
CN107592466A (zh) * 2017-10-13 2018-01-16 维沃移动通信有限公司 一种拍照方法及移动终端
CN108230234A (zh) * 2017-05-19 2018-06-29 深圳市商汤科技有限公司 图像虚化处理方法、装置、存储介质及电子设备
CN109151329A (zh) * 2018-11-22 2019-01-04 Oppo广东移动通信有限公司 拍照方法、装置、终端及计算机可读存储介质

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101599872B1 (ko) * 2009-02-25 2016-03-04 삼성전자주식회사 디지털 영상 처리 장치, 그 제어방법 및 이를 실행시키기 위한 프로그램을 저장한 기록매체
CN102625038A (zh) * 2012-02-10 2012-08-01 明基电通有限公司 影像撷取装置及影像处理方法
CN105187722B (zh) * 2015-09-15 2018-12-21 努比亚技术有限公司 景深调节方法、装置及终端
CN105227847B (zh) * 2015-10-30 2018-10-12 上海斐讯数据通信技术有限公司 一种手机的相机拍照方法和系统
CN106454118A (zh) * 2016-11-18 2017-02-22 上海传英信息技术有限公司 照片虚化方法和移动终端
CN108769545A (zh) * 2018-06-12 2018-11-06 Oppo(重庆)智能科技有限公司 一种图像处理方法、图像处理装置及移动终端

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130329120A1 (en) * 2012-06-11 2013-12-12 Canon Kabushiki Kaisha Image processing apparatus, image processing method, image pickup apparatus, method of controlling image pickup apparatus, and non-transitory computer-readable storage medium
CN104660900A (zh) * 2013-10-30 2015-05-27 株式会社摩如富 图像处理装置及图像处理方法
CN104333700A (zh) * 2014-11-28 2015-02-04 广东欧珀移动通信有限公司 一种图像虚化方法和图像虚化装置
CN104680478A (zh) * 2015-02-15 2015-06-03 青岛海信移动通信技术股份有限公司 一种目标图像数据的选取方法和装置
CN106952222A (zh) * 2017-03-17 2017-07-14 成都通甲优博科技有限责任公司 一种交互式图像虚化方法及装置
CN106941590A (zh) * 2017-05-19 2017-07-11 深圳天珑无线科技有限公司 一种图像处理方法及装置
CN108230234A (zh) * 2017-05-19 2018-06-29 深圳市商汤科技有限公司 图像虚化处理方法、装置、存储介质及电子设备
CN107592466A (zh) * 2017-10-13 2018-01-16 维沃移动通信有限公司 一种拍照方法及移动终端
CN109151329A (zh) * 2018-11-22 2019-01-04 Oppo广东移动通信有限公司 拍照方法、装置、终端及计算机可读存储介质

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112085686A (zh) * 2020-08-21 2020-12-15 北京迈格威科技有限公司 图像处理方法、装置、电子设备及计算机可读存储介质
CN117173004A (zh) * 2022-05-26 2023-12-05 Oppo广东移动通信有限公司 图像处理方法、终端、芯片及存储介质

Also Published As

Publication number Publication date
CN109151329A (zh) 2019-01-04

Similar Documents

Publication Publication Date Title
WO2020103604A1 (zh) 拍照方法、装置、终端及计算机可读存储介质
JP7003238B2 (ja) 画像処理方法、装置、及び、デバイス
CN110473185B (zh) 图像处理方法和装置、电子设备、计算机可读存储介质
EP3480784B1 (en) Image processing method, and device
CN109906599B (zh) 一种终端的拍照方法和终端
CN105339841B (zh) 双镜头设备的拍照方法及双镜头设备
CN110324532B (zh) 一种图像虚化方法、装置、存储介质及电子设备
TWI538512B (zh) 調整對焦位置的方法及電子裝置
CN109474780B (zh) 一种用于图像处理的方法和装置
CN110650288B (zh) 对焦控制方法和装置、电子设备、计算机可读存储介质
CN110493527A (zh) 主体对焦方法、装置、电子设备和存储介质
JP2017505004A (ja) 画像生成方法及びデュアルレンズ装置
CN109040596B (zh) 一种调整摄像头的方法、移动终端及存储介质
CN104780315A (zh) 摄像装置拍摄的方法和系统
CN109005367B (zh) 一种高动态范围图像的生成方法、移动终端及存储介质
JP6319972B2 (ja) 画像処理装置、撮像装置、画像処理方法、およびプログラム
CN108632512A (zh) 图像处理方法、装置、电子设备及计算机可读存储介质
CN105049695A (zh) 一种视频录制方法及装置
CN108776800B (zh) 一种图像处理方法、移动终端及计算机可读存储介质
CN110349163A (zh) 图像处理方法和装置、电子设备、计算机可读存储介质
CN110084765A (zh) 一种图像处理方法、图像处理装置及终端设备
CN110335216A (zh) 图像处理方法、图像处理装置、终端设备及可读存储介质
CN111263063A (zh) 拍摄图像的方法、装置及设备
CN112019734A (zh) 图像采集方法、装置、电子设备和计算机可读存储介质
CN110881103B (zh) 对焦控制方法和装置、电子设备、计算机可读存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19887523

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19887523

Country of ref document: EP

Kind code of ref document: A1