CN114092604A - Image generation method, device, equipment and storage medium - Google Patents

Image generation method, device, equipment and storage medium Download PDF

Info

Publication number
CN114092604A
CN114092604A CN202111320443.5A CN202111320443A CN114092604A CN 114092604 A CN114092604 A CN 114092604A CN 202111320443 A CN202111320443 A CN 202111320443A CN 114092604 A CN114092604 A CN 114092604A
Authority
CN
China
Prior art keywords
image
color
gradient
text
characters
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.)
Pending
Application number
CN202111320443.5A
Other languages
Chinese (zh)
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.)
Beijing Xiaomi Mobile Software Co Ltd
Beijing Xiaomi Pinecone Electronic Co Ltd
Original Assignee
Beijing Xiaomi Mobile Software Co Ltd
Beijing Xiaomi Pinecone Electronic Co 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 Beijing Xiaomi Mobile Software Co Ltd, Beijing Xiaomi Pinecone Electronic Co Ltd filed Critical Beijing Xiaomi Mobile Software Co Ltd
Priority to CN202111320443.5A priority Critical patent/CN114092604A/en
Publication of CN114092604A publication Critical patent/CN114092604A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/60Editing figures and text; Combining figures or text
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/001Texturing; Colouring; Generation of texture or colour

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Image Processing (AREA)
  • Facsimile Image Signal Circuits (AREA)
  • Color Image Communication Systems (AREA)

Abstract

The present disclosure relates to an image generation method, apparatus, device, and storage medium, the method comprising: generating an original gradient color image in response to receiving an instruction to generate gradient color text in a target image; responding to the detection that characters are written in the original gradient color image, adjusting the color value of the characters to be a preset color, and obtaining a gradient color image containing the characters with the preset color; obtaining a gradient color text image of the preset color background according to the original gradient color image and the gradient color image containing the characters with the preset color; and generating a target image with the gradient color characters based on the gradient color character image of the preset color background and the target image. The method and the device can ensure that the gradient color characters are not influenced by the background color in the target image, thereby improving the generation quality of the gradient color characters and being suitable for various pure-color or gradient-color images.

Description

Image generation method, device, equipment and storage medium
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to an image generation method, an image generation apparatus, an image generation device, and a storage medium.
Background
With the rapid development of computer technology and internet technology, the marketing mode based on advertisement has become the mainstream mode of contacting the user with the commodity. In the related art, in order to improve the diversified visual effects of the advertisement interface, it is generally necessary to write gradient text in the advertisement image. From the aesthetic point of view, the gradually-changed characters are more colorful than the pure-color characters, and the advertisement image with the gradually-changed characters can meet the aesthetic requirements of the current consumer groups which pay more and more attention to quality and content. Therefore, how to provide an image generation scheme with high quality, easy multiplexing, and wide application range and having characters with gradient colors has become one of the technical problems to be solved at present.
Disclosure of Invention
To overcome the problems in the related art, embodiments of the present disclosure provide an image generation method, an apparatus, a device, and a storage medium, so as to solve the defects in the related art.
According to a first aspect of embodiments of the present disclosure, there is provided an image generation method, the method including:
generating an original gradient color image in response to receiving an instruction to generate gradient color text in a target image;
responding to the detection that characters are written in the original gradient color image, adjusting the color value of the characters to be a preset color, and obtaining a gradient color image containing the characters with the preset color;
obtaining a gradient color text image of the preset color background according to the original gradient color image and the gradient color image containing the characters with the preset color;
and generating a target image with the gradient color characters based on the gradient color character image of the preset color background and the target image.
In some embodiments, the generating the original gradient color image comprises:
generating a blank image with the same size as the target image;
generating an original gradient color image in the blank image.
In some embodiments, the generating an original gradient color image in the blank image comprises:
calling a set gradient image generating function in the blank image to generate a gradient color image to be adjusted;
and adjusting the tone of the to-be-adjusted gradient color image to obtain the original gradient color image.
In some embodiments, the gradient-color text image of the preset-color background comprises a black-background gradient-color text image;
obtaining a gradient color text digital image of the preset color background according to the original gradient color image and the gradient color image containing the characters with the preset color, wherein the gradient color text digital image comprises:
obtaining the difference value of the original gradient color image and the gradient color image containing the characters with the preset color to obtain a difference value image with the characters with the gradient color;
and adjusting the color value of the background except the gradient color characters in the difference image to be 0 to obtain a black background gradient color character image.
In some embodiments, the obtaining the difference between the original gradient color image and the gradient color image containing the text of the preset color comprises:
and acquiring a difference value between the image matrix of the original gradient color image and the image matrix of the gradient color image containing the characters with the preset color.
In some embodiments, the original gradient color image is an RGB image;
the obtaining of the difference value between the image matrix of the original gradient color image and the image matrix of the gradient color image containing the characters with the preset color comprises:
and acquiring the difference value between the RGB three-channel pixel value in the image matrix of the original gradient color image and the RGB three-channel pixel value in the image matrix of the gradient color image containing the characters with the preset color.
In some embodiments, the gradient-color text image of the preset-color background comprises a black-background gradient-color text image;
generating a target image with the gradient-color characters based on the gradient-color character image with the preset color background and the target image, wherein the generating comprises the following steps:
acquiring a target image of the text portion to be scratched out based on the pixel position of the gradient color text in the black background gradient color text image and the target image;
and superposing the target image of the character scratching part and the black background gradient-color character image to obtain the target image with the gradient-color characters.
In some embodiments, the acquiring a target image for text portion matting based on the pixel position of the gradient-color text in the black background gradient-color text digital image and the target image comprises:
acquiring the pixel position of the gradient color characters in the black background gradient color character image;
and adjusting the pixel value corresponding to the pixel position in the target image to zero to obtain a target image with the character portion removed.
In some embodiments, the target image is an advertisement design image to be inserted with gradient color words, and the content of the gradient color words is preset advertisement file content.
According to a second aspect of embodiments of the present disclosure, there is provided an image generation apparatus, the apparatus comprising:
the original image generation module is used for responding to a received instruction of generating the gradient color characters in the target image and generating an original gradient color image;
the first image acquisition module is used for responding to the detection that characters are written in the original gradient color image, adjusting the color value of the characters to be a preset color, and obtaining a gradient color image containing the characters with the preset color;
the second image acquisition module is used for obtaining a gradient-color text image of the preset color background according to the original gradient color image and the gradient color image containing the characters with the preset color;
and the third image acquisition module is used for generating a target image with the gradient color characters based on the gradient color character image of the preset color background and the target image.
In some embodiments, the raw image generation module comprises:
a blank image generating unit for generating a blank image having the same size as the target image;
an original image generation unit for generating an original gradation color image in the blank image.
In some embodiments, the raw image generation unit is further configured to:
calling a set gradient image generating function in the blank image to generate a gradient color image to be adjusted;
and adjusting the tone of the to-be-adjusted gradient color image to obtain the original gradient color image.
In some embodiments, the gradient-color text image of the preset-color background comprises a black-background gradient-color text image;
the second image acquisition module includes:
a difference image obtaining unit, configured to obtain a difference value between the original gradient color image and a gradient color image containing the characters with the preset color, so as to obtain a difference image with the characters with the gradient color;
and the black scene image acquisition unit is used for adjusting the color value of the background except the gradient color characters in the difference image to be 0 to obtain a black background gradient color character image.
In some embodiments, the difference image acquisition unit is further configured to:
and acquiring a difference value between the image matrix of the original gradient color image and the image matrix of the gradient color image containing the characters with the preset color.
In some embodiments, the original gradient color image is an RGB image;
the difference image acquisition unit is further configured to:
and acquiring the difference value between the RGB three-channel pixel value in the image matrix of the original gradient color image and the RGB three-channel pixel value in the image matrix of the gradient color image containing the characters with the preset color.
In some embodiments, the gradient-color text image of the preset-color background comprises a black-background gradient-color text image;
the third image acquisition module includes:
a matting image obtaining unit, configured to obtain a target image of a matting character portion based on a pixel position of the gradient-color character in the black background gradient-color character image and the target image;
and the image acquisition unit is used for superposing the target image of the character scratching part and the black background gradient-color character image to obtain the target image with the gradient-color characters.
In some embodiments, the matte image acquisition unit is further configured to:
acquiring the pixel position of the gradient color characters in the black background gradient color character image;
and adjusting the pixel value corresponding to the pixel position in the target image to zero to obtain a target image with the character portion removed.
In some embodiments, the target image is an advertisement design image to be inserted with gradient color words, and the content of the gradient color words is preset advertisement file content.
According to a third aspect of embodiments of the present disclosure, there is provided an electronic apparatus, the apparatus comprising:
a processor and a memory for storing a computer program;
wherein the processor is configured to, when executing the computer program, implement:
generating an original gradient color image in response to receiving an instruction to generate gradient color text in a target image;
responding to the detection that characters are written in the original gradient color image, adjusting the color value of the characters to be a preset color, and obtaining a gradient color image containing the characters with the preset color;
obtaining a gradient color text image of the preset color background according to the original gradient color image and the gradient color image containing the characters with the preset color;
and generating a target image with the gradient color characters based on the gradient color character image of the preset color background and the target image.
According to a fourth aspect of embodiments of the present disclosure, there is provided a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements:
generating an original gradient color image in response to receiving an instruction to generate gradient color text in a target image;
responding to the detection that characters are written in the original gradient color image, adjusting the color value of the characters to be a preset color, and obtaining a gradient color image containing the characters with the preset color;
obtaining a gradient color text image of the preset color background according to the original gradient color image and the gradient color image containing the characters with the preset color;
and generating a target image with the gradient color characters based on the gradient color character image of the preset color background and the target image.
The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects:
the method generates an original gradient color image in response to receiving an instruction of generating gradient color characters in a target image, adjusts the color values of the characters to preset colors in response to detecting that the characters are written in the original gradient color image, obtains the gradient color image containing the characters with the preset colors, obtains the gradient color character image with the preset color background according to the original gradient color image and the gradient color image containing the characters with the preset colors, and generates the target image with the gradient color characters based on the gradient color character image with the preset color background and the target image, so that the gradient color characters can be ensured not to be influenced by the background color in the target image, the generation quality of the gradient color characters is improved, the scheme for generating the characters is easy to multiplex, and the method can be applied to various pure-color or gradient-color images, the application range is wide.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure.
FIG. 1A is a flow chart illustrating an image generation method according to an exemplary embodiment of the present disclosure;
FIG. 1B is a schematic diagram of an original gradient color image shown in accordance with an exemplary embodiment;
FIG. 1C is a schematic illustration of a black-word gradient color image shown in accordance with an exemplary embodiment;
FIG. 1D is a schematic diagram of a black background gradient color textual digital image shown in accordance with an exemplary embodiment;
FIG. 2 is a flow diagram illustrating the generation of an original gradient color image according to an exemplary embodiment of the present disclosure;
FIG. 3 is a flow diagram illustrating the generation of an original gradient color image in the blank image according to an exemplary embodiment of the present disclosure;
FIG. 4 is a flow chart illustrating obtaining a gradient-color text image of the preset-color background from the original gradient-color image and a gradient-color image containing text of the preset color according to an exemplary embodiment of the present disclosure;
FIG. 5 is a flowchart illustrating a generation of a target image with gradient-color text based on a gradient-color text digital image of the preset-color background and the target image according to an exemplary embodiment of the present disclosure;
FIG. 6 is a flowchart illustrating the acquisition of a target image for text portion matting according to an exemplary embodiment of the present disclosure;
FIG. 7 is a block diagram illustrating an image generation apparatus according to an exemplary embodiment of the present disclosure;
FIG. 8 is a block diagram illustrating yet another image generation apparatus according to an exemplary embodiment of the present disclosure;
fig. 9 is a block diagram illustrating an electronic device according to an exemplary embodiment of the present disclosure.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
Nowadays, with the rapid development of computer technology and internet technology, marketing mode based on advertisement has become the mainstream mode of contacting with users. In the related art, in order to improve the diversified visual effects of the advertisement interface, it is usually necessary to write gradually-changed characters in the advertisement image so as to satisfy the aesthetic requirements of consumers who increasingly pay attention to quality and content nowadays. The current solution usually uses a design image as a background and inserts gradient text into it. However, the implementation process of this solution is cumbersome, and the color of the inserted text is easily affected by the background color of the image, which cannot meet the personalized aesthetic of the public and the requirement of the advertisement platform for advertisement batch. In view of the above, the embodiments of the present disclosure provide an image generation method, an apparatus, a device and a storage medium, which are used to solve the above-mentioned drawbacks in the related art.
FIG. 1A is a flow diagram illustrating an image generation method according to an exemplary embodiment; FIG. 1B is a schematic diagram of an original gradient color image shown in accordance with an exemplary embodiment; FIG. 1C is a schematic illustration of a black-word gradient color image shown in accordance with an exemplary embodiment; FIG. 1D is a schematic diagram of a black background gradient color textual digital image shown in accordance with an exemplary embodiment;
the method of the embodiment can be applied to electronic devices with image processing functions (such as terminal devices such as smart phones, tablet computers and desktop computers, or a server cluster formed by one or more servers, where the server may be a local server or a cloud server).
As shown in fig. 1A, the method comprises the following steps S101-S103:
in step S101, in response to receiving an instruction to generate a gradation character in a target image, an original gradation color image is generated.
For example, when a user needs to generate a gradient-color text in a target image, an instruction to generate the gradient-color text in the target image may be triggered in the electronic device, and the electronic device may generate an original gradient-color image in response to receiving the instruction, as shown in fig. 1B. As can be seen from fig. 1B, the color of the image is gradually changed from top to bottom.
Illustratively, the color of the original gradient color image may be the same as the color of the final desired generated gradient color text.
In another embodiment, the original gradient color image can be generated in the following manner as shown in fig. 2, and will not be described in detail.
It can be understood that, in an application scenario of advertisement design, the target image may be an advertisement design image into which gradient text is to be inserted, and the content of the gradient text may be preset advertisement file content, which is not limited in this embodiment.
In step S102, in response to detecting that characters are written in the original gradient color image, adjusting color values of the characters to preset colors, so as to obtain a gradient color image containing the characters in the preset colors.
In this embodiment, after the original gradient color image is generated, in response to detecting that the text is written in the original gradient color image, the color value of the text is adjusted to a preset color, so as to obtain the gradient color image containing the text with the preset color.
For example, the electronic device may continue to detect text written by the user in the original gradient color image after generating the original gradient color image in response to receiving an instruction to generate gradient color text in the target image. The content of the text can be the content of the gradient-color text which is expected to be generated in the target image by the user. Furthermore, when the electronic device detects the written text in the original gradient color image, the color of the text can be adjusted to a preset color (e.g., black, etc.) to obtain a gradient color image containing the text in the preset color, as shown in fig. 1C. As can be seen from fig. 1C, in the gradient color image containing the text with the preset color, the color of the text is the preset color, and the color of the background outside the text is still the above gradient color. The color adjustment method of the text may include adjusting a pixel value of a position where a pixel of the text is located.
In step S103, a gradient-color text-image of the background with the preset color is obtained according to the original gradient-color image and the gradient-color image containing the text with the preset color.
In this embodiment, after the color value of the text is adjusted to the preset color in response to detecting that the text is written in the original gradient color image, and the gradient color text image including the text with the preset color is obtained, the gradient color text image with the preset color background can be obtained according to the original gradient color image and the gradient color image including the text with the preset color.
It should be noted that, in the gradient-color text-image with the background of the preset color, the color of the text portion is the same gradient as that of the original gradient-color image, and the background color outside the text is the preset color.
For example, after obtaining the gradient color image of the text containing the preset color, a gradient color text digital image of the background containing the preset color can be obtained based on a difference value between the original gradient color image and the gradient color image of the text containing the preset color, as shown in fig. 1D. It is worth mentioning that the difference of two images may refer to the difference between the pixel matrices of the two images.
In another embodiment, the manner of obtaining the gradient-color text digital image of the background with the preset color according to the original gradient-color image and the gradient-color image containing the text with the preset color can also be referred to the embodiment shown in fig. 4 described below, and will not be described in detail herein.
In step S104, a target image with the gradient-color text is generated based on the gradient-color text digital image of the preset color background and the target image.
In this embodiment, after obtaining the text image with the gradient color of the background with the preset color according to the original gradient color image and the gradient color image containing the text with the preset color, the target image with the text with the gradient color may be generated based on the text image with the gradient color of the background with the preset color and the target image.
The target image with the gradient color characters is the same as the original target image except the gradient color characters.
In another embodiment, the above manner of generating the target image with the gradient-color text based on the gradient-color text digital image of the preset-color background and the target image can be seen in the following embodiment shown in fig. 5, and will not be described in detail herein.
As can be seen from the above description, in the method of this embodiment, an original gradient color image is generated in response to receiving a command for generating gradient color characters in a target image, and in response to detecting that characters are written in the original gradient color image, color values of the characters are adjusted to preset colors, so as to obtain a gradient color image containing the characters with the preset colors, and then according to the original gradient color image and the gradient color image containing the characters with the preset colors, a gradient color character image with a background of the preset colors is obtained, and further, based on the gradient color character image with the background of the preset colors and the target image, a target image with the gradient color characters is generated, so as to ensure that the gradient color characters are not affected by the background color in the target image, thereby improving generation quality of the gradient color characters, and the scheme for generating the characters is easy to reuse, and can be applied to various pure color or gradient color images, and has wide application range.
FIG. 2 is a flow chart showing how an original gradient color image is generated according to an exemplary embodiment of the present disclosure; the present embodiment exemplifies how to generate an original gradation color image on the basis of the above-described embodiments. As shown in fig. 2, the generation of the original gradient color image described in the above step S101 may include the following steps S201 to S202:
in step S201, a blank image having the same size as the target image is generated.
In this embodiment, after receiving an instruction to generate gradient-color characters in a target image, a blank image having the same size as the target image may be generated.
For example, when the blank image needs to be generated, the size of the target image may be obtained, and then the corresponding blank image may be generated based on the size.
In step S202, an original gradation color image is generated in the blank image.
In this embodiment, after a blank image having the same size as the target image is generated, an original gradation color image may be generated in the blank image.
For example, after a blank image having the same size as the target image is generated, an original gradient color image may be generated on the blank image based on a set software library.
It should be noted that the set software library may be set based on actual business needs, for example, the set software library is set as an OpenCV software library, and the present embodiment does not limit this.
In another embodiment, the above manner of generating the original gradient color image in the blank image can also be referred to the embodiment shown in fig. 3, which will not be described in detail.
As can be seen from the above description, in the embodiment, by generating a blank image having the same size as the target image and generating an original gradient color image in the blank image, an original gradient color image having the same size as the target image can be generated, and a foundation can be laid for subsequently detecting writing of characters in the original gradient color image and obtaining of a black character gradient color image.
FIG. 3 is a flow chart showing how an original gradient color image is generated in the blank image according to an exemplary embodiment of the present disclosure; the present embodiment exemplifies how to generate an original gradient color image in the blank image on the basis of the above-described embodiments. As shown in fig. 3, the generating of the original gradient color image in the blank image in the above step S202 may include the following steps S301 to S302:
in step S301, a set gradation map generation function is called in the blank image to generate a gradation color image to be adjusted.
In this embodiment, after a blank image having the same size as the target image is generated, a set gradient image generating function may be called in the blank image to generate a gradient color image to be adjusted.
For example, after generating a blank image with the same size as the target image, a gradient image generation function in the OpenCV software library may be called to generate a to-be-tuned gradient color image in the blank image.
The to-be-adjusted gradient color image can be an initial gradient color image generated by calling a gradient image generation function in an OpenCV software library, and the to-be-adjusted gradient color image can be subjected to subsequent color adjustment to obtain an original gradient color image.
In step S302, the tone of the to-be-tuned gradient color image is tuned to obtain the original gradient color image.
In this embodiment, after the preset gradient image generating function is called in the blank image to generate the to-be-adjusted gradient color image, the tone of the to-be-adjusted gradient color image may be adjusted to obtain the original gradient color image.
For example, after the above-mentioned to-be-adjusted gradient color image is generated, the gradient color of the to-be-adjusted gradient color image can be adjusted based on actual requirements, so that the original gradient color image can be obtained. It can be seen that the tone of the gradation of the original gradation color image generated in the present embodiment is controllable, and thus the tone of the original gradation color image currently generated can be adjusted based on the tone of the gradation color text that needs to be generated.
As can be seen from the above description, in this embodiment, a to-be-adjusted gradient color image is generated by calling a set gradient image generation function in the blank image, and the tone of the to-be-adjusted gradient color image is adjusted to obtain the original gradient color image, so that the original gradient color image can be generated based on the pre-generated blank image having the same size as the target image, and further, writing of characters in the original gradient color image and obtaining of a black character gradient color image can be realized through subsequent detection.
FIG. 4 is a flow chart illustrating obtaining a gradient-color text image of the preset-color background from the original gradient-color image and a gradient-color image containing text of the preset color according to an exemplary embodiment of the present disclosure; based on the above embodiments, the present embodiment exemplifies how to obtain a gradient-color text digital image of the background with the preset color according to the original gradient-color image and the gradient-color image containing the text with the preset color.
In this embodiment, the gradient-color text image with the preset color background includes a black background gradient-color text image. On this basis, as shown in fig. 4, the obtaining of the gradient-color text digital image of the background with the preset color according to the original gradient-color image and the gradient-color image containing the text with the preset color in step S103 may include the following steps S401 to S402:
in step S401, a difference value between the original gradient color image and the gradient color image containing the characters with the preset color is obtained, so as to obtain a difference value image with the characters with the gradient color.
In this embodiment, after obtaining a gradient color image of the text with the preset color, such as a black-character gradient color image (i.e., a gradient color image of the text with the preset color being black), a difference between the original gradient color image and the gradient color image of the text with the preset color may be obtained, so as to obtain a difference image of the text with the gradient color. Illustratively, a difference between an image matrix of the original gradient color image and an image matrix of a gradient color image containing the text of the preset color may be obtained.
Taking the original gradient color image as an RGB image as an example, the step S401 may include:
and acquiring the difference value between the RGB three-channel pixel value in the image matrix of the original gradient color image and the RGB three-channel pixel value in the image matrix of the gradient color image containing the characters with the preset color.
In step S402, the color value of the background in the difference image except for the gradient-color text is adjusted to 0, so as to obtain a black background gradient-color text-digital image.
In this embodiment, after obtaining a difference between the original gradient color image and the gradient color image containing the text with the preset color to obtain a difference image with the text with the gradient color, the color value of the background in the difference image except for the text with the gradient color may be adjusted to 0 to obtain a black background gradient color text digital image.
For example, after obtaining a difference image with gradient color characters based on the difference between the original gradient color image and the black character gradient color image, the background color of the difference image except for the gradient color characters may be set to black (e.g., the pixel value of the pixel position of the background is adjusted to 0), so as to obtain a black background gradient color character image. In the text and image with the black background and the gradient color, the color of the text part is the gradient color, and the color of the background outside the text is black. It can be understood that each RGB color image is composed of three-channel grid pixels of red, green and blue, and the RGB value of the black pixel is [0, 0, 0], so that the three-channel pixel value of the black character gradient color image is subtracted from the three-channel pixel value of the original gradient color image, the gradient color of the character part of the latter can be reserved, and on this basis, if the pixel value of the background except the gradient color characters is set to 0, the above-mentioned black background gradient color character image can be obtained.
As can be seen from the above description, in this embodiment, a difference image with gradient color characters is obtained by obtaining a difference value between the original gradient color image and a gradient color image containing the characters with the preset color, and then a color value of a background in the difference image except for the gradient color characters is adjusted to be 0, so as to obtain a black background gradient color character image, and further, a target image with the gradient color characters can be generated based on the subsequent gradient color character image with the preset color background and the target image, so that the generation quality of the gradient color characters can be improved, and the method is suitable for various pure color or gradient color images.
FIG. 5 is a flowchart illustrating a generation of a target image with gradient-color text based on a gradient-color text digital image of the preset-color background and the target image according to an exemplary embodiment of the present disclosure; the present embodiment is exemplified by how to generate the target image with the gradient-color text based on the gradient-color text digital image of the preset-color background and the target image on the basis of the above-mentioned embodiments. In this embodiment, the gradient-color text image with the preset color background may include a black background gradient-color text image.
On this basis, as shown in fig. 5, the generating of the target image with the gradient-color text based on the gradient-color text digital image with the preset-color background and the target image in the above step S104 may include the following steps S501-S502:
in step S501, an object image with text portions scratched out is obtained based on the pixel positions of the gradient-color text in the black background gradient-color text image and the object image.
In this embodiment, after the gradient-color text image of the preset color background is obtained, the target image of the text portion to be scratched out may be obtained based on the pixel position of the gradient-color text in the black background gradient-color text image and the target image.
For example, after obtaining the gradient-color text image of the preset color background, the pixel position of the gradient-color text in the black background gradient-color text image may be determined, and then the pixels of the text portion in the target image are deducted based on the pixel position to obtain the target image with the text portion removed.
In another embodiment, the above manner of acquiring the target image for text portion matting can be referred to the following embodiment shown in fig. 6, and will not be described in detail first.
In step S502, the target image of the text portion with the cut-out text portion is superimposed with the black background gradient-color text image, so as to obtain a target image with the gradient-color text.
In this embodiment, after the target image of the text portion is obtained based on the pixel position of the gradient-color text in the black background gradient-color text image and the target image, the target image of the text portion can be superimposed with the black background gradient-color text image to obtain the target image with the gradient-color text.
For example, the image matrix of the target image with the text portion removed can be added to the image matrix of the black background gradient-color text image to obtain the image matrix of the target image with the text with the gradient color, so as to obtain the target image with the text with the gradient color.
As can be seen from the above description, in this embodiment, the target image with the text portion scratched out is obtained based on the pixel position of the gradient-color text in the black background gradient-color text image and the target image, and the target image with the text portion scratched out is superimposed on the black background gradient-color text image, so as to obtain the target image with the gradient-color text, which can ensure that the gradient-color text is not affected by the background color in the target image, thereby improving the generation quality of the gradient-color text, and the scheme for generating the text can be multiplexed and can be applied to various pure-color or gradient-color images.
FIG. 6 is a flowchart illustrating the acquisition of a target image for text portion matting according to an exemplary embodiment of the present disclosure; the present embodiment is exemplified by how to acquire an object image for cutting out text portions on the basis of the above-described embodiments.
As shown in fig. 6, the above-mentioned obtaining an object image for matting out text portions based on the pixel positions of the gradient-color text in the black background gradient-color text digital image and the object image may include the following steps S601-S602:
in step S601, the pixel position of the gradient-color text in the black background gradient-color text digital image is obtained.
In this embodiment, after the gradient-color text image of the preset color background is obtained, the pixel positions of the gradient-color texts in the black-background gradient-color text image can be obtained.
For example, after obtaining the gradient-color text image of the preset color background, the pixel position of the gradient-color text can be obtained from the gradient-color text image of the black background based on the pixel value of the gradient-color text. It can be understood that, in practical applications, other preset manners may be selected based on needs to obtain the pixel positions of the gradient color texts in the black background gradient color text image, and the obtained result is also applicable to the subsequent steps in this embodiment.
In step S602, a pixel value corresponding to the pixel position in the target image is adjusted to zero, so as to obtain a target image with text portions being cut out.
In this embodiment, after the pixel position of the gradient-color text in the black background gradient-color text digital image is obtained, the pixel value corresponding to the pixel position in the target image may be adjusted to zero, so as to obtain a target image with text portions removed.
For example, after the pixel position of the gradient-color text in the black background gradient-color text image is obtained, the pixel value corresponding to the pixel position in the target image may be adjusted to zero (that is, the pixel at the pixel position in the target image is set to black, which is equivalent to the pixel at the pixel position being scratched out), and thus the target image with the text portion scratched out may be obtained.
As can be seen from the above description, in this embodiment, by obtaining the pixel position of the gradient-color text in the black background gradient-color text image, and adjusting the pixel value corresponding to the pixel position in the target image to zero, a target image of the text portion to be scratched out is obtained, so that the target image of the text portion to be scratched out can be obtained based on the pixel position of the gradient-color text in the black background gradient-color text image and the target image, and then the target image of the text portion to be scratched out can be subsequently superimposed on the black background gradient-color text image to obtain the target image with the gradient-color text, so that the gradient-color text can be ensured not to be affected by the background color in the target image, thereby improving the generation quality of the gradient-color text, and being applicable to various pure-color or gradient-color images.
FIG. 7 is a block diagram illustrating an image generation apparatus according to an exemplary embodiment; the device of the embodiment can be applied to electronic equipment with an image processing function (such as terminal equipment such as a smart phone, a tablet computer and a desktop computer; or a server cluster formed by one or more servers).
As shown in fig. 7, the apparatus includes: an original image generation module 110, a first image acquisition module 120, a second image acquisition module 130, and a third image acquisition module 140, wherein:
an original image generation module 110, configured to generate an original gradient color image in response to receiving an instruction to generate gradient color text in a target image;
the first image obtaining module 120 is configured to, in response to detecting that a character is written in the original gradient color image, adjust a color value of the character to a preset color, and obtain a gradient color image containing the character with the preset color;
a second image obtaining module 130, configured to obtain a gradient-color text image of the preset-color background according to the original gradient color image and the gradient color image containing the text with the preset color;
and a third image obtaining module 140, configured to generate a target image with the gradient-color text based on the gradient-color text image with the preset color background and the target image.
As can be seen from the above description, the apparatus of this embodiment generates an original gradient color image by responding to a received instruction for generating gradient color text in a target image, and adjusts a color value of the text to a preset color in response to detecting that the text is written in the original gradient color image, so as to obtain a gradient color image containing the text with the preset color, and then obtains a gradient color text digital image with a background of the preset color according to the original gradient color image and the gradient color image containing the text with the preset color, and further generates the target image with the gradient color text based on the gradient color text digital image with the background of the preset color and the target image, so as to ensure that the gradient color text is not affected by the background color in the target image, thereby improving the generation quality of the gradient color text, and the scheme for generating the text is easy to reuse, and can be applied to various pure color or gradient color images, and has wide application range.
FIG. 8 is a block diagram illustrating an image generation apparatus according to yet another exemplary embodiment; the device of the embodiment can be applied to electronic equipment with an image processing function (such as terminal equipment such as a smart phone, a tablet computer and a desktop computer; or a server cluster formed by one or more servers). The original image generation module 210, the first image obtaining module 220, the second image obtaining module 230, and the third image obtaining module 240 have the same functions as the original image generation module 110, the first image obtaining module 120, the second image obtaining module 130, and the third image obtaining module 140 in the embodiment shown in fig. 7, and are not repeated herein. As shown in fig. 8, the original image generation module 210 may include:
a blank image generation unit 211 for generating a blank image having the same size as the target image;
an original image generating unit 212 for generating an original gradient color image in the blank image.
In some embodiments, the raw image generation unit 212 may be further configured to:
calling a set gradient image generating function in the blank image to generate a gradient color image to be adjusted;
and adjusting the tone of the to-be-adjusted gradient color image to obtain the original gradient color image.
In some embodiments, the gradient-color text image of the preset-color background may comprise a black background gradient-color text image;
the second image acquisition module 230 may include:
a difference image obtaining unit 231, configured to obtain a difference value between the original gradient color image and a gradient color image containing the text with the preset color, so as to obtain a difference image with gradient color text;
and a black image obtaining unit 232, configured to adjust the color value of the background in the difference image, except for the gradient-color text, to be 0, so as to obtain a black background gradient-color text digital image.
In some embodiments, the difference image obtaining unit 231 is further configured to:
and acquiring a difference value between the image matrix of the original gradient color image and the image matrix of the gradient color image containing the characters with the preset color.
In some embodiments, the original gradient color image may be an RGB image;
the difference image acquisition unit 231 may be further configured to:
and acquiring the difference value between the RGB three-channel pixel value in the image matrix of the original gradient color image and the RGB three-channel pixel value in the image matrix of the gradient color image containing the characters with the preset color.
In some embodiments, the gradient-color text image of the preset-color background may comprise a black background gradient-color text image;
the third image obtaining module 240 may include:
a matting image obtaining unit 241, configured to obtain a target image of a matting text portion based on a pixel position of the gradient-color text in the black background gradient-color text image and the target image;
and a digital image acquiring unit 242, configured to superimpose the target image of the text portion with the scratched-out text portion and the black background gradient-color text image, so as to obtain a target image with the gradient-color text.
In some embodiments, the matte image acquisition unit 241 may also be used to:
acquiring the pixel position of the gradient color characters in the black background gradient color character image;
and adjusting the pixel value corresponding to the pixel position in the target image to zero to obtain a target image with the character portion removed.
In some embodiments, the target image may be an advertisement design image into which gradient text is to be inserted, and the content of the gradient text may be the content of a preset advertisement scheme.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
FIG. 9 is a block diagram illustrating an electronic device in accordance with an example embodiment. For example, the device 900 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, an exercise device, a personal digital assistant, and so forth.
Referring to fig. 9, device 900 may include one or more of the following components: processing component 902, memory 904, power component 906, multimedia component 908, audio component 910, input/output (I/O) interface 912, sensor component 914, and communication component 916.
The processing component 902 generally controls the overall operation of the device 900, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. Processing component 902 may include one or more processors 920 to execute instructions to perform all or a portion of the steps of the methods described above. Further, processing component 902 can include one or more modules that facilitate interaction between processing component 902 and other components. For example, the processing component 902 can include a multimedia module to facilitate interaction between the multimedia component 908 and the processing component 902.
The memory 904 is configured to store various types of data to support operation at the device 900. Examples of such data include instructions for any application or method operating on device 900, contact data, phonebook data, messages, tiles, videos, etc. The memory 904 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
The power component 906 provides power to the various components of the device 900. The power components 906 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 900.
The multimedia components 908 include a screen that provides an output interface between the device 900 and a user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 908 includes a front facing camera and/or a rear facing camera. The front-facing camera and/or the rear-facing camera may receive external multimedia data when the device 900 is in an operating mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 910 is configured to output and/or input audio signals. For example, audio component 910 includes a Microphone (MIC) configured to receive external audio signals when device 900 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may further be stored in the memory 904 or transmitted via the communication component 916. In some embodiments, audio component 910 also includes a speaker for outputting audio signals.
I/O interface 912 provides an interface between processing component 902 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor component 914 includes one or more sensors for providing status assessment of various aspects of the device 900. For example, the sensor component 914 may detect an open/closed state of the device 900, the relative positioning of components, such as a display and keypad of the device 900, the sensor component 914 may also detect a change in the position of the device 900 or a component of the device 900, the presence or absence of user contact with the device 900, orientation or acceleration/deceleration of the device 900, and a change in the temperature of the device 900. The sensor assembly 914 may also include a proximity sensor configured to detect the presence of a nearby object in the absence of any physical contact. The sensor assembly 914 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 914 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 916 is configured to facilitate communications between the device 900 and other devices in a wired or wireless manner. The device 900 may access a wireless network based on a communication standard, such as WiFi, 2G or 3G, 4G or 5G, or a combination thereof. In an exemplary embodiment, the communication component 916 receives a broadcast signal or broadcast associated information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 916 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the device 900 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer readable storage medium comprising instructions, such as the memory 904 comprising instructions, executable by the processor 920 of the device 900 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (12)

1. An image generation method, characterized in that the method comprises:
generating an original gradient color image in response to receiving an instruction to generate gradient color text in a target image;
responding to the detection that characters are written in the original gradient color image, adjusting the color value of the characters to be a preset color, and obtaining a gradient color image containing the characters with the preset color;
obtaining a gradient color text image of the preset color background according to the original gradient color image and the gradient color image containing the characters with the preset color;
and generating a target image with the gradient color characters based on the gradient color character image of the preset color background and the target image.
2. The method of claim 1, wherein the generating an original gradient color image comprises:
generating a blank image with the same size as the target image;
generating an original gradient color image in the blank image.
3. The method of claim 2, wherein generating an original gradient color image in the blank image comprises:
calling a set gradient image generating function in the blank image to generate a gradient color image to be adjusted;
and adjusting the tone of the to-be-adjusted gradient color image to obtain the original gradient color image.
4. The method of claim 1, wherein the gradient-color text image of the pre-set color background comprises a black background gradient-color text image;
obtaining a gradient color text digital image of the preset color background according to the original gradient color image and the gradient color image containing the characters with the preset color, wherein the gradient color text digital image comprises:
obtaining the difference value of the original gradient color image and the gradient color image containing the characters with the preset color to obtain a difference value image with the characters with the gradient color;
and adjusting the color value of the background except the gradient color characters in the difference image to be 0 to obtain a black background gradient color character image.
5. The method of claim 4, wherein obtaining a difference between the original gradient color image and a gradient color image containing text of the preset color comprises:
and acquiring a difference value between the image matrix of the original gradient color image and the image matrix of the gradient color image containing the characters with the preset color.
6. The method of claim 5, wherein the original gradient color image is an RGB image;
the obtaining of the difference value between the image matrix of the original gradient color image and the image matrix of the gradient color image containing the characters with the preset color comprises:
and acquiring the difference value between the RGB three-channel pixel value in the image matrix of the original gradient color image and the RGB three-channel pixel value in the image matrix of the gradient color image containing the characters with the preset color.
7. The method of claim 1, wherein the gradient-color text image of the pre-set color background comprises a black background gradient-color text image;
generating a target image with the gradient-color characters based on the gradient-color character image with the preset color background and the target image, wherein the generating comprises the following steps:
acquiring a target image of the text portion to be scratched out based on the pixel position of the gradient color text in the black background gradient color text image and the target image;
and superposing the target image of the character scratching part and the black background gradient-color character image to obtain the target image with the gradient-color characters.
8. The method of claim 7, wherein the obtaining of the target image for text portion matting based on the pixel position of the gradient-color text in the black background gradient-color text digital image and the target image comprises:
acquiring the pixel position of the gradient color characters in the black background gradient color character image;
and adjusting the pixel value corresponding to the pixel position in the target image to zero to obtain a target image with the character portion removed.
9. The method of claim 1, wherein the target image is an advertisement design image to be inserted with gradient color text, and the content of the gradient color text is a preset advertisement file content.
10. An image generation apparatus, characterized in that the apparatus comprises:
the original image generation module is used for responding to a received instruction of generating the gradient color characters in the target image and generating an original gradient color image;
the first image acquisition module is used for responding to the detection that characters are written in the original gradient color image, adjusting the color value of the characters to be a preset color, and obtaining a gradient color image containing the characters with the preset color;
the second image acquisition module is used for obtaining a gradient-color text image of the preset color background according to the original gradient color image and the gradient color image containing the characters with the preset color;
and the third image acquisition module is used for generating a target image with the gradient color characters based on the gradient color character image of the preset color background and the target image.
11. An electronic device, characterized in that the device comprises:
a processor and a memory for storing a computer program;
wherein the processor is configured to, when executing the computer program, implement:
generating an original gradient color image in response to receiving an instruction to generate gradient color text in a target image;
responding to the detection that characters are written in the original gradient color image, adjusting the color value of the characters to be a preset color, and obtaining a gradient color image containing the characters with the preset color;
obtaining a gradient color text image of the preset color background according to the original gradient color image and the gradient color image containing the characters with the preset color;
and generating a target image with the gradient color characters based on the gradient color character image of the preset color background and the target image.
12. A computer-readable storage medium on which a computer program is stored, the program, when executed by a processor, implementing:
generating an original gradient color image in response to receiving an instruction to generate gradient color text in a target image;
responding to the detection that characters are written in the original gradient color image, adjusting the color value of the characters to be a preset color, and obtaining a gradient color image containing the characters with the preset color;
obtaining a gradient color text image of the preset color background according to the original gradient color image and the gradient color image containing the characters with the preset color;
and generating a target image with the gradient color characters based on the gradient color character image of the preset color background and the target image.
CN202111320443.5A 2021-11-09 2021-11-09 Image generation method, device, equipment and storage medium Pending CN114092604A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111320443.5A CN114092604A (en) 2021-11-09 2021-11-09 Image generation method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111320443.5A CN114092604A (en) 2021-11-09 2021-11-09 Image generation method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114092604A true CN114092604A (en) 2022-02-25

Family

ID=80299669

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111320443.5A Pending CN114092604A (en) 2021-11-09 2021-11-09 Image generation method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114092604A (en)

Similar Documents

Publication Publication Date Title
JP6363299B2 (en) Color gamut mode switching method and apparatus
EP3236665A1 (en) Method and apparatus for performing live broadcast of a game
CN106657780B (en) Image preview method and device
CN110231901B (en) Application interface display method and device
CN111078170B (en) Display control method, display control device, and computer-readable storage medium
JP2016530554A (en) Image switching method, apparatus, program, and recording medium
CN111462701A (en) Backlight brightness adjusting method and device
CN105677352B (en) Method and device for setting application icon color
CN112331158B (en) Terminal display adjusting method, device, equipment and storage medium
CN110876014B (en) Image processing method and device, electronic device and storage medium
CN107730443B (en) Image processing method and device and user equipment
CN107222576B (en) Photo album synchronization method and device
CN112905135A (en) Screen brightness processing method, electronic device and storage medium
CN106296775B (en) Icon generation method and device
CN107832112B (en) Wallpaper setting method and device
CN111612875A (en) Dynamic image generation method and device, electronic equipment and storage medium
CN111182362A (en) Video control processing method and device
CN114092604A (en) Image generation method, device, equipment and storage medium
CN106371714B (en) Information display method and device
CN110874829B (en) Image processing method and device, electronic device and storage medium
CN107682623B (en) Photographing method and device
CN114418865A (en) Image processing method, device, equipment and storage medium
CN111538447A (en) Information display method, device, equipment and storage medium
CN111261035B (en) Screen display method and device
CN114666439B (en) Method, device and medium for adjusting dark color mode display state

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination