Search

US-12626426-B2 - Image generation method and apparatus, electronic device, and readable storage medium

US12626426B2US 12626426 B2US12626426 B2US 12626426B2US-12626426-B2

Abstract

An image generation method and apparatus, an electronic device, and a readable storage medium. In the image generation method, a first image is acquired, and a target feature of the first image is acquired according to depth information and image content information of the first image, so that a corresponding target feature can be acquired according to image information, thereby facilitating generation of diversified images; and a second image is generated according to the target feature, where the target feature includes color information, and if the depth information and the image content information indicate that the first image includes a subject, the target feature further includes contour information of the subject; or if the depth information and the image content information indicate that the first image does not include a subject, the target feature further includes material information.

Inventors

  • Wenbin Ji
  • Hongli Wang

Assignees

  • VIVO MOBILE COMMUNICATION CO., LTD.

Dates

Publication Date
20260512
Application Date
20231229
Priority Date
20210630

Claims (14)

  1. 1 . An image generation method, performed by one or more processors of an electronic device, comprising: acquiring a first image, wherein the first image comprises depth information and image content information; acquiring a target feature of the first image according to the depth information and the image content information of the first image; and generating a second image according to the target feature, wherein the target feature comprises color information, and in a case that the depth information and the image content information indicate that the first image comprises a subject, the target feature further comprises contour information of the subject; or in a case that the depth information and the image content information indicate that the first image does not comprise a subject, the target feature further comprises material information; wherein the acquiring a target feature of the first image according to the depth information and the image content information of the first image comprises: determining N pieces of color information corresponding to N pixel regions in the first image; and obtaining M pieces of color information according to the N pieces of color information, wherein the M pieces of color information do not comprise same color information or preset color information, both N and M are positive integers, and N>M.
  2. 2 . The method according to claim 1 , wherein after the obtaining M pieces of color information according to the N pieces of color information, the method further comprises: classifying the M pieces of color information according to chroma values of the M pieces of color information to obtain P categories, and acquiring one color in the P categories, to obtain P pieces of color information, wherein P is a positive integer and M≥P.
  3. 3 . The method according to claim 1 , wherein the acquiring a target feature of the first image according to the depth information and the image content information of the first image comprises: in a case that the first image comprises at least two types of contour information, determining a contour ratio of each piece of contour information, and using Q pieces of contour information of which the contour ratio is greater than or equal to a preset first ratio threshold as the target feature, wherein the contour ratio of the contour information is a quantity ratio of the contour information in the first image, and Q is a positive integer; or in a case that the first image comprises at least two types of material information, determining a material ratio of each piece of material information, and using R pieces of material information of which the material ratio is greater than or equal to a preset second ratio threshold as the target feature, wherein the material ratio of the material information is an area ratio of the material information in the first image, and R is a positive integer.
  4. 4 . The method according to claim 3 , wherein the generating a second image according to the target feature comprises: in a case that the depth information and the image content information indicate that the first image comprises a subject, determining a position of each of the Q pieces of contour information, filling the positions of the Q pieces of contour information with P pieces of the color information, and generating the second image; or in a case that the depth information and the image content information indicate that the first image does not comprise a subject, determining a position of each of the R pieces of material information, filling the positions of the R pieces of material information with P pieces of the color information, and generating the second image.
  5. 5 . A chip, comprising a processor, a non-volatile storage medium and a communication interface, wherein the communication interface is coupled to the processor, and the processor is configured to run a program or instructions stored in the non-volatile storage medium, to implement steps of the image generation method according to claim 1 .
  6. 6 . A computer program product, wherein the program product is stored in a non-volatile storage medium, and the program product is executed by at least one processor to implement the image generation method according to claim 1 .
  7. 7 . An electronic device, comprising a processor, a memory, and a program or instructions stored in the memory and runnable on the processor, wherein the memory is a non-volatile memory and the program or instructions stored therein, when executed by the processor, causes the electronic device to perform: acquiring a first image, wherein the first image comprises depth information and image content information; acquiring a target feature of the first image according to the depth information and the image content information of the first image; and generating a second image according to the target feature, wherein the target feature comprises color information, and in a case that the depth information and the image content information indicate that the first image comprises a subject, the target feature further comprises contour information of the subject; or in a case that the depth information and the image content information indicate that the first image does not comprise a subject, the target feature further comprises material information; wherein the acquiring a target feature of the first image according to the depth information and the image content information of the first image comprises: determining N pieces of color information corresponding to N pixel regions in the first image; and obtaining M pieces of color information according to the N pieces of color information, wherein the M pieces of color information do not comprise same color information or preset color information, both N and M are positive integers, and N>M.
  8. 8 . The electronic device according to claim 7 , wherein after the obtaining M pieces of color information according to the N pieces of color information, the program or the instruction, when executed by the processor, causes the electronic device to further perform: classifying the M pieces of color information according to chroma values of the M pieces of color information to obtain P categories, and acquiring one color in the P categories, to obtain P pieces of color information, wherein P is a positive integer and M≥P.
  9. 9 . The electronic device according to claim 7 , wherein when acquiring a target feature of the first image according to the depth information and the image content information of the first image, the program or the instruction, when executed by the processor, causes the electronic device to perform: in a case that the first image comprises at least two types of contour information, determining a contour ratio of each piece of contour information, and using Q pieces of contour information of which the contour ratio is greater than or equal to a preset first ratio threshold as the target feature, wherein the contour ratio of the contour information is a quantity ratio of the contour information in the first image, and Q is a positive integer; or in a case that the first image comprises at least two types of material information, determining a material ratio of each piece of material information, and using R pieces of material information of which the material ratio is greater than or equal to a preset second ratio threshold as the target feature, wherein the material ratio of the material information is an area ratio of the material information in the first image, and R is a positive integer.
  10. 10 . The electronic device according to claim 9 , wherein when generating a second image according to the target feature, the program or the instruction, when executed by the processor, causes the electronic device to perform: in a case that the depth information and the image content information indicate that the first image comprises a subject, determining a position of each of the Q pieces of contour information, filling the positions of the Q pieces of contour information with P pieces of the color information, and generating the second image; or in a case that the depth information and the image content information indicate that the first image does not comprise a subject, determining a position of each of the R pieces of material information, filling the positions of the R pieces of material information with P pieces of the color information, and generating the second image.
  11. 11 . A non-transitory readable storage medium, storing a program or instructions, wherein the program or instructions, when executed by a processor, causes the processor to perform: acquiring a first image, wherein the first image comprises depth information and image content information; acquiring a target feature of the first image according to the depth information and the image content information of the first image; and generating a second image according to the target feature, wherein the target feature comprises color information, and in a case that the depth information and the image content information indicate that the first image comprises a subject, the target feature further comprises contour information of the subject; or in a case that the depth information and the image content information indicate that the first image does not comprise a subject, the target feature further comprises material information; wherein when acquiring a target feature of the first image according to the depth information and the image content information of the first image, the program or the instruction, when executed by the processor, causes the processor to perform: determining N pieces of color information corresponding to N pixel regions in the first image; and obtaining M pieces of color information according to the N pieces of color information, wherein the M pieces of color information do not comprise same color information or preset color information, both N and M are positive integers, and N≥M.
  12. 12 . The non-transitory readable storage medium according to claim 11 , wherein after the obtaining M pieces of color information according to the N pieces of color information, the program or the instruction, when executed by the processor, causes the processor to further perform: classifying the M pieces of color information according to chroma values of the M pieces of color information to obtain P categories, and acquiring one color in the P categories, to obtain P pieces of color information, wherein P is a positive integer and M≥P.
  13. 13 . The non-transitory readable storage medium according to claim 11 , wherein when acquiring a target feature of the first image according to the depth information and the image content information of the first image, the program or the instruction, when executed by the processor, causes the processor to perform: in a case that the first image comprises at least two types of contour information, determining a contour ratio of each piece of contour information, and using Q pieces of contour information of which the contour ratio is greater than or equal to a preset first ratio threshold as the target feature, wherein the contour ratio of the contour information is a quantity ratio of the contour information in the first image, and Q is a positive integer; or in a case that the first image comprises at least two types of material information, determining a material ratio of each piece of material information, and using R pieces of material information of which the material ratio is greater than or equal to a preset second ratio threshold as the target feature, wherein the material ratio of the material information is an area ratio of the material information in the first image, and R is a positive integer.
  14. 14 . The non-transitory readable storage medium according to claim 13 , wherein when generating a second image according to the target feature, the program or the instruction, when executed by the processor, causes the processor to perform: in a case that the depth information and the image content information indicate that the first image comprises a subject, determining a position of each of the Q pieces of contour information, filling the positions of the Q pieces of contour information with P pieces of the color information, and generating the second image; or in a case that the depth information and the image content information indicate that the first image does not comprise a subject, determining a position of each of the R pieces of material information, filling the positions of the R pieces of material information with P pieces of the color information, and generating the second image.

Description

CROSS-REFERENCE TO RELATED APPLICATIONS This application is a continuation of PCT International Application No. PCT/CN2022/101464 filed on Jun. 27, 2022, which claims priority to Chinese Patent Application No. 202110736284.0 filed on Jun. 30, 2021, which are incorporated herein by reference in their entireties. TECHNICAL FIELD This application relates to the field of image processing technologies, and specifically, to an image generation method and apparatus, an electronic device, and a readable storage medium. BACKGROUND With the development of science and technology and the improvement of people's living standards, the development of electronic devices, such as smartphones, smart tablets, and smart watches, is accelerating, and functions that can be implemented by the electronic devices are increasing. For example, image processing functions also become increasingly diverse. Currently, in the process of users using electronic devices such as smartphones, smart tablets, and smart watches, users can process images of the electronic devices according to their requirements, for example, edit the images, or select and set the images in a personalized manner. During implementation of this application, the inventor found at least the following problems in the prior art: in the process of image processing, richer image resources cannot be provided according to image information. SUMMARY According to a first aspect, an embodiment of this application provides an image generation method, the method including: acquiring a first image, where the first image includes depth information and image content information;acquiring a target feature of the first image according to the depth information and the image content information of the first image; andgenerating a second image according to the target feature, where the target feature includes color information, andin a case that the depth information and the image content information indicate that the first image includes a subject, the target feature further includes contour information of the subject; or in a case that the depth information and the image content information indicate that the first image does not include a subject, the target feature further includes material information. According to second aspect, an embodiment of this application provides an image generation apparatus, the apparatus including: an acquisition module, configured to: acquire a first image, where the first image includes depth information and image content information; and acquire a target feature of the first image according to the depth information and the image content information of the first image; anda generation module, configured to generate a second image according to the target feature, where the target feature includes color information, andin a case that the depth information and the image content information indicate that the first image includes a subject, the target feature further includes contour information of the subject; orin a case that the depth information and the image content information indicate that the first image does not include a subject, the target feature further includes material information. According to a third aspect, an embodiment of this application provides an electronic device. The electronic device includes a processor, a memory, and a program or instructions stored in the memory and runnable on the processor, the program or instructions, when executed by the processor, implementing steps of the image generation method according to the first aspect. According to a fourth aspect, an embodiment of this application provides a readable storage medium. The readable storage medium stores a program or instructions, the program or instructions, when executed by a processor, implementing steps of the image generation method according to the first aspect. According to a fifth aspect, an embodiment of this application provides a chip. The chip includes a processor and a communication interface, where the communication interface is coupled to the processor, and the processor is configured to run a program or instructions, to implement the image generation method according to the first aspect. According to a sixth aspect, an embodiment of this application provides a computer program product. The computer program product is stored in a non-volatile storage medium, and executed by at least one processor to implement the image generation method according to the first aspect. According to a seventh aspect, an embodiment of this application provides an electronic device, configured to perform the image generation method according to the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS One or more embodiments are exemplarily described with reference to the corresponding figures in the accompanying drawings, and the exemplary descriptions are not to be construed as limiting the embodiments. Elements in the accompanying drawings that have same reference numerals are r