WO2020253766A1 - 图片生成方法、装置、电子设备及存储介质 - Google Patents

图片生成方法、装置、电子设备及存储介质 Download PDF

Info

Publication number
WO2020253766A1
WO2020253766A1 PCT/CN2020/096762 CN2020096762W WO2020253766A1 WO 2020253766 A1 WO2020253766 A1 WO 2020253766A1 CN 2020096762 W CN2020096762 W CN 2020096762W WO 2020253766 A1 WO2020253766 A1 WO 2020253766A1
Authority
WO
WIPO (PCT)
Prior art keywords
copy
picture
added
edited
rectangle
Prior art date
Application number
PCT/CN2020/096762
Other languages
English (en)
French (fr)
Inventor
黄晨婕
Original Assignee
北京字节跳动网络技术有限公司
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 北京字节跳动网络技术有限公司 filed Critical 北京字节跳动网络技术有限公司
Publication of WO2020253766A1 publication Critical patent/WO2020253766A1/zh

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

Definitions

  • the present disclosure relates to the field of data processing technology, for example, to a picture generation method, device, electronic device, and storage medium.
  • the display pictures such as posters are usually generated by adding text information to the pictures related to the event or the displayed content.
  • the present disclosure provides a picture generation method, device, electronic equipment, and storage medium to improve the efficiency of copywriting in pictures.
  • the embodiment of the present disclosure provides a method for generating a picture, including:
  • the copy information includes the copy to be added
  • the copywriting to be added is added to the target area to generate a picture to be displayed.
  • the embodiment of the present disclosure also provides a picture generating device, including:
  • the picture acquisition module is configured to acquire pictures to be edited and copy information; wherein, the copy information includes copy to be added;
  • the saliency map forming module is configured to perform saliency detection on the picture to be edited, obtain the feature value of each pixel in the picture to be edited, and form a saliency map corresponding to the picture to be edited according to the obtained feature value ;
  • the target area determining module is configured to determine the target area for adding the copy to be added to the picture to be edited based on the feature value in the saliency map and the determined coverage area of the copy to be added in the saliency map ;
  • the copywriting adding module is configured to add the copywriting to be added to the target area to generate a picture to be displayed.
  • the embodiments of the present disclosure also provide an electronic device, including:
  • One or more processors are One or more processors;
  • Memory set to store one or more programs
  • the one or more processors When the one or more programs are executed by the one or more processors, the one or more processors implement the image generation method provided in the embodiment of the present disclosure.
  • the embodiment of the present disclosure also provides a computer-readable storage medium on which a computer program is stored.
  • the program is executed by a processor, the method for generating a picture as provided in the embodiment of the present disclosure is implemented.
  • FIG. 1 is a flow chart of a method for generating a picture provided by Embodiment 1 of the present disclosure
  • FIG. 2 is a flowchart of a method for generating a picture according to Embodiment 2 of the present disclosure
  • FIG. 3 is a flowchart of a method for generating a picture according to Embodiment 3 of the present disclosure
  • FIG. 4 is a structural diagram of a picture generating device provided by Embodiment 4 of the present disclosure.
  • FIG. 5 is a structural diagram of an electronic device provided by Embodiment 5 of the present disclosure.
  • each embodiment provides optional features and examples at the same time. Multiple features recorded in the embodiments can be combined to form multiple alternative solutions. Each numbered embodiment should not be combined Only regarded as a technical solution.
  • Fig. 1 is a flowchart of a picture generation method provided in the first embodiment of the present disclosure.
  • the embodiment of the present disclosure is applicable to the process of adding copywriting to a picture to generate a new picture.
  • the method is executed by a picture generation device, which uses software And/or hardware implementation, and configured in an electronic device with certain data processing capabilities.
  • a picture generation method as shown in Fig. 1 includes:
  • the picture to be edited is a picture that needs to be added with copywriting, for example, it may be a poster material picture.
  • the copy information includes the text information to be added to the copy, and the text information includes the number of words and the content of the words.
  • the copywriting information may also include other text attribute information, such as at least one of font size, font type, and font color, as needed.
  • S120 Perform saliency detection on the picture to be edited to obtain a feature value of each pixel in the picture to be edited, and form a saliency map corresponding to the picture to be edited according to the obtained feature value.
  • the saliency detection algorithm can be used to analyze the saliency characteristics of the picture to be edited to obtain the feature value of each pixel, and form a saliency map corresponding to the picture to be edited to show the uniqueness of each pixel in the picture to be edited Sex.
  • the saliency detection algorithm may be at least one of an AC algorithm, a Histogram Contrast (HC) algorithm, a Luminance Contrast (LC) algorithm, and a Frequency-Tuned (FT) algorithm.
  • the range of the feature value is between [0, 255], the smaller the saliency value, the more important the content of the corresponding pixel in the picture to be edited, such as the key person in the poster and other important information; the greater the saliency value, Indicates that the content of the corresponding pixel in the picture to be edited is less important, such as the picture background.
  • S130 Determine a target area for adding the copy to be added to the picture to be edited according to the feature value in the saliency map and the determined coverage area of the copy to be added in the saliency map.
  • the at least one copy rectangle corresponding to the copy to be added can be determined according to the copy information; according to multiple feature values corresponding to the coverage area of the copy rectangle in the saliency map, determine Place the target area of the copy rectangle; where the content covered by the target area in the picture to be edited corresponds to the feature value in the saliency map as large as possible, so that the area covered by the target area only includes non-important information, such as the picture background. And avoid the important content in the picture to be edited from being overwritten.
  • determining at least one copywriting rectangle corresponding to the copywriting to be added according to the copywriting information may be acquiring information such as font size, number of copy lines, and line spacing in the copywriting information, and determining the corresponding copywriting to be added according to the obtained information At least one copywriting rectangle.
  • At least one copy rectangle corresponding to the copy to be added is determined according to the copy information, or word segmentation is performed on the copy to be added, and the number of candidate text lines of the copy to be added is determined according to the word segmentation result; according to the candidate text
  • the number of lines determine at least one copy rectangle.
  • determining the at least one copy rectangle according to the number of candidate text lines may be based on the number of candidate text lines, determining the aspect ratio of each copy rectangle in the at least one copy rectangle; according to the preset font height, different aspect ratios The corresponding copy rectangles are adjusted to increase the number of the copy rectangles.
  • the font size can be at least one font size value added by the user to the copywriting information according to user requirements; it can also be determined according to the picture to be edited and the copy to be added.
  • the font size is determined according to the picture to be edited and the copy to be added, which can be to determine the area of the picture to be edited; according to the number of texts contained in the copy to be added, the amount of copy to be added in different font sizes is calculated
  • the area occupied by the text; the ratio of the area occupied by the filtered text to the area of the picture to be edited meets the value of the font size when the ratio is set, so as to adjust the copy rectangle according to the filtered font size.
  • the set proportion can be determined by a technician according to needs or experience values. For example, x is used to represent the ratio of the area occupied by the text to the area of the picture to be edited, and the set proportion can be 15% ⁇ x ⁇ 30%.
  • adding the copy to be added in the text box may be performed in the text box according to the font size, font type, font color and other information contained in the copy information.
  • the embodiment of the present disclosure obtains the picture to be edited and the copywriting information including the copywriting to be added; detects the saliency of the picture to be edited to obtain the characteristic value of each pixel in the picture to be edited, and forms the picture to be edited according to the obtained characteristic value.
  • Corresponding saliency map according to the feature value of the saliency map and the coverage area of the saliency map to be added, determine the target area for adding the copy to be added to the picture to be edited; add the copy to be added to the target area, and the target area has been generated. Show pictures.
  • the above technical solution introduces the saliency map corresponding to the picture to be edited, and combines the coverage area of the text to be added in the saliency map to realize the automatic determination of the target area when copywriting is added to the picture to be edited, and then proceed in the determined target area
  • the addition of copywriting improves the efficiency of copywriting in pictures and reduces the generation time of displaying pictures.
  • FIG. 2 is a flowchart of a method for generating a picture according to Embodiment 2 of the present disclosure. This embodiment is improved on the basis of the optional solutions in the foregoing embodiment.
  • the operation "determine the target area for adding the copy to be added in the picture to be edited based on the feature value in the saliency map and the determined coverage area of the copy to be added in the saliency map” is refined into "According to the copywriting information, determine at least one copywriting rectangle corresponding to the copywriting to be added; sequentially traverse different areas of the saliency map, and according to the multiple feature values in the saliency map covered by the at least one copywriting rectangle , Determine the coverage scores of the at least one copy rectangle in different areas; determine the coverage area of the saliency map for the copy to be added according to the coverage scores of the at least one copy rectangle in different coverage areas; according to the determined
  • the text to be added is in the coverage area of the saliency map, and the target area for adding the text to be added to the picture to be edited is determined to improve the target area determination mechanism.
  • a picture generation method as shown in Fig. 2 includes:
  • S220 Perform saliency detection on the picture to be edited to obtain a feature value of each pixel in the picture to be edited, and form a saliency map corresponding to the picture to be edited according to the obtained feature value.
  • At least one copy rectangle corresponding to the copy to be added is determined by permutation and combination; the copy rectangle is adjusted according to the font size to increase the number of copy rectangles.
  • the font size can be at least one default font size, and can also be carried in the copy information, and the font size can also be determined according to the picture to be edited and the copy to be added. Among them, the method for determining the font size according to the picture to be edited and the copy to be added is consistent with the foregoing, and will not be repeated here.
  • S240 Traverse different regions of the saliency map in sequence, and determine the coverage scores of the at least one copy rectangle in different regions according to the multiple feature values in the saliency map covered by the at least one copy rectangle.
  • the coverage score determined by the multiple feature values of the saliency map covered by the copy rectangle is used as a reference factor for important information in the saliency map covered by the copy rectangle.
  • the coverage scores of the copy rectangles in different regions are determined according to the characteristic values of the determined regions, which may be based on the weighted sum, product, or sum of squares of multiple characteristic values corresponding to the determined regions; The sum, product, or sum of squares corresponding to the area is used as the coverage score of the copy rectangle in the corresponding area.
  • the copy rectangle For each copy rectangle, different areas of the saliency map are traversed in sequence, and the copy rectangle may be moved over the saliency map according to a preset traversal path. For example, you can move the copy rectangle on the saliency map in the order from left to right and top to bottom with one pixel as the step length.
  • S250 Determine, according to the coverage scores of the at least one copywriting rectangle in different regions, that the copy to be added is in the coverage area of the saliency map; and determine whether the copy to be added is in the coverage area of the saliency map. Add the target area of the copy to be added to the picture to be edited.
  • the coverage score is calculated based on the feature values corresponding to the area covered by the copy rectangle in the image to be edited through weighted sum, product, or square sum. The larger the coverage score, the less important information covered by the copy rectangle. Therefore, according to the coverage scores of different copy rectangles in different areas, the coverage area with the largest coverage score is selected as the target area.
  • the embodiment of the present disclosure refines the operation of determining the target area into determining at least one copy rectangle corresponding to the copy to be added according to the copy information; for each copy rectangle, sequentially traverse different areas of the saliency map, and according to the saliency covered by the copy rectangle
  • the multiple feature values in the figure determine the coverage scores of the copy rectangles in different areas; according to the coverage scores of at least one copy rectangle in different areas, determine the target area for adding the copy to be added to the picture to be edited.
  • the above technical solution is adopted to quantify the important information corresponding to the area covered by the copy rectangle by introducing the coverage score, thereby realizing the determination of the target area, and improving the determination mechanism of the target area.
  • the quantified coverage score is used to determine the target area, which makes the determined target area more accurate, thereby reducing the amount of important information covered by adding copy to the picture to be edited.
  • the target area determined according to the coverage score may be more inclined to use the target area determined by the copy rectangle with a smaller font.
  • other parameters can be introduced to suppress the influence of font size on the coverage score.
  • the following step may be added: determining that each copywriting rectangle is in the saliency map The number of background pixels covered by different areas of, and the background pixels are pixels with feature values greater than a set threshold.
  • the setting threshold can be set by a technician according to needs or experience values, for example, it can be 200.
  • the method further includes: for each copy rectangle, according to The number of background pixels covered by each area of the copy rectangle in the saliency map is updated, and the coverage score of the copy rectangle in the area is updated.
  • updating the coverage score of the copy rectangle in the area may be obtained by obtaining the copy rectangle in each area.
  • the current coverage score of the region; the number of background pixels covered in the region and the current coverage score are multiplied to obtain the coverage score of the copy rectangle in the region.
  • updating the coverage score of the copy rectangle in the area may be obtained by obtaining the copy rectangle in each area.
  • the current coverage score of the area; the weighted sum of the number of background pixels covered in the area and the current coverage score is used to obtain the coverage score of the copy rectangle in the area.
  • the weights set for the current coverage score and the number of background pixels corresponding to each copy rectangle in the area can be the same or different, and can be set by a technician according to needs or experience values.
  • the weight of the current coverage score is set to be greater than the weight of the number of background pixels.
  • the embodiment of the present disclosure adds a step for determining the number of background pixels, and updates the coverage score of each area according to the number of background pixels, which effectively suppresses the influence of font size on the coverage score and avoids the determined target area The occurrence of a situation that is too small improves the practicality of the determined target area.
  • FIG. 3 is a flowchart of a method for generating a picture provided in Embodiment 3 of the present disclosure. This embodiment is improved on the basis of the optional solutions in the foregoing embodiment.
  • the text attributes include font type and/or font Color” to realize the automatic determination of the text attributes to be added to the copy, and then to improve the determination mechanism of the text attributes.
  • a picture generation method as shown in Figure 3 includes:
  • S320 Perform saliency detection on the picture to be edited to obtain a feature value of each pixel in the picture to be edited, and form a saliency map corresponding to the picture to be edited according to the obtained feature value.
  • S330 Determine a target area for adding the copy to be added to the picture to be edited according to the feature value in the saliency map and the determined coverage area of the copy to be added in the saliency map.
  • the text attributes include font type and/or font color.
  • the font category of the copy to be added is determined, which may be: input the picture to be edited as input data into a pre-trained font category model; output and input data The corresponding font category.
  • the pre-trained font category model may take a large number of pictures to be edited and font categories corresponding to the pictures to be edited as training samples, and train a known model to obtain the first font category model.
  • the known model may be a neural network model.
  • the input data when using the first font category model is the picture to be edited.
  • determining the font color of the copywriting to be added according to the picture to be edited may be: determining the picture background color of the picture to be edited according to the picture to be edited; The font color corresponding to the background color of the picture.
  • determining the picture background color of the picture to be edited according to the picture to be edited may be by using a K-means clustering algorithm to classify the pixels in the picture to be edited, and selecting candidate color categories according to set rules.
  • the background color of the picture is determined according to the pixel values of multiple pixels in the candidate color category.
  • the selection of K value can be set by technicians according to needs or empirical values, or it can be determined according to a large number of limited experiments.
  • the setting rule may be determined according to the number of pixels contained in the category. For example, it may be to select the color category with the largest or second largest number of pixels as the candidate color category.
  • the determination of the background color of the picture based on the pixel values of multiple pixels in the candidate color category may be to select the pixel value of one of the pixel points in the candidate color category as the picture background color; or The pixel values of the included multiple pixels are weighted and summed, and the result is used as the background color of the picture.
  • searching and acquiring the font color corresponding to the background color of the picture may be using the background color of the picture as the font color, or searching and acquiring the font color corresponding to the background color of the picture in a preset font color comparison table.
  • the text attribute of the text to be added according to the picture to be edited wherein, the text attribute includes font type and/or font color to achieve The font category and/or font color to be added to the copy are automatically determined, and the mechanism for determining text attributes is improved.
  • the determined target area is located in an area that contains non-important information, such as the background area of a picture.
  • non-important information such as the background area of a picture.
  • the color of the target area does not match the determined background color of the picture (for example, the same, similar or poor visual effect), it will be serious Reduce the quality of generated images to be displayed.
  • the following steps may be added: determining the background color of the text box corresponding to the target area; Finding and acquiring the font color corresponding to the background color of the picture includes: combining the background color of the picture and the background color of the text box to find the font color corresponding to the combined background color; or, according to the background color of the picture The color and the background color of the text box are searched to obtain the corresponding font color.
  • determining the background color of the text box corresponding to the target area may be by using the K-means clustering algorithm to classify pixels in the target area of the picture to be edited, and selecting the candidate color category according to the set rules;
  • the pixel values of multiple pixels in the category determine the background color of the text box.
  • the selection of K value can be set by technicians according to needs or empirical values, or it can be determined according to a large number of limited experiments.
  • the setting rule can be determined according to the number of pixels contained in the category, for example, the color category with the largest or the second largest number of pixels can be selected as the candidate color category.
  • combining the background color of the picture and the background color of the text box may be a weighted summation of the pixel values corresponding to the determined picture background color and the pixel values corresponding to the text box background color to obtain the combined The pixel value corresponding to the background color.
  • searching and acquiring the corresponding font color according to the background color of the picture and the background color of the text box may be searching and acquiring the corresponding font color in a preset font color comparison table. Font color.
  • the embodiment of the present disclosure introduces the background color of the text box when determining the font color, so that the determined font color can better adapt to the picture to be edited, thereby improving the quality of the generated picture to be displayed, and improving the user's viewing of the picture to be displayed Visual experience.
  • FIG. 4 is a structural diagram of a picture generating device provided in the fourth embodiment of the present disclosure.
  • the embodiment of the present disclosure is suitable for the process of adding copy to the picture to generate a new picture.
  • the device is implemented by software and/or hardware and configured In electronic equipment with certain data processing capabilities.
  • a picture generation device as shown in FIG. 4 includes: a picture acquisition module 410, a saliency map formation module 420, a target area determination module 430, and a copywriting module 440.
  • the picture acquisition module 410 is configured to acquire pictures to be edited and copy information; wherein, the copy information includes the copy to be added.
  • the saliency map forming module 420 is configured to perform saliency detection on the picture to be edited, obtain the feature value of each pixel in the picture to be edited, and form a saliency corresponding to the picture to be edited according to the obtained feature value.
  • the target area determining module 430 is configured to determine a target for adding the copy to be added to the picture to be edited based on the feature value in the saliency map and the determined coverage area of the copy to be added in the saliency map area.
  • the copywriting adding module 440 is configured to add the copywriting to be added to the target area to generate a picture to be displayed.
  • the embodiment of the present disclosure obtains the picture to be edited and the copywriting information including the copywriting to be added by the picture obtaining module; the saliency detection of the picture to be edited is performed by the saliency map forming module to obtain the feature value of each pixel in the picture to be edited, and according to the obtained The eigenvalues of to form a saliency map corresponding to the picture to be edited; the target area determination module determines the target of adding the copywriting to the picture to be edited according to the saliency map feature values and the determined copywriting in the coverage area of the saliency map Area; add the copy to be added to the target area through the copy add module, and the picture to be displayed has been generated.
  • the above technical solution introduces the saliency map corresponding to the picture to be edited, and combines the coverage area of the text to be added in the saliency map to realize the automatic determination of the target area when copywriting is added to the picture to be edited, and then proceed in the determined target area
  • the addition of copywriting improves the efficiency of copywriting in pictures and reduces the generation time of displaying pictures.
  • the target area determination module 430 includes:
  • the copy rectangle determining unit is set to determine at least one copy rectangle corresponding to the copy to be added according to the copy information; the coverage score determination unit is set to sequentially traverse different regions of the saliency map and based on the at least one copy
  • the multiple feature values in the saliency map covered by the rectangles are used to determine the coverage scores of the at least one copy rectangle in different areas;
  • the target area determining unit is configured to determine the coverage scores of the at least one copy rectangle in different areas
  • the copy to be added is in the coverage area of the saliency map; according to the determined coverage area of the copy to be added in the saliency map, a target area for adding the copy to be added to the picture to be edited is determined.
  • the target area determination module 430 also includes:
  • a quantity statistics unit configured to determine the number of background pixels covered by each copy rectangle in different areas of the saliency map after determining at least one copy rectangle corresponding to the copy to be added according to the copy information; wherein The background pixel is a pixel with a feature value greater than a set threshold; the coverage score update unit is configured to: after determining the coverage score of the at least one copy rectangle in the area, after determining the coverage score of the at least one copy rectangle Coverage scores of different areas, determine the copy to be added before the coverage area of the saliency map, for each copy rectangle, according to the number of background pixels covered by the copy rectangle in each area of the saliency map To update the coverage score of the copy rectangle in the area.
  • the coverage score determination unit is set to:
  • the coverage score update unit is set to:
  • the determination unit of the copy rectangle is set to:
  • the copy rectangle determination unit is set to determine at least one copy rectangle according to the number of candidate text lines in the following manner:
  • the aspect ratio of each copy rectangle in at least one copy rectangle is determined; according to the preset font height, the copy rectangles corresponding to different aspect ratios are adjusted.
  • the device also includes a text attribute determination module, which is set to:
  • the text attributes include font type and/or font color.
  • the text attribute determination module including a font color determination unit, is configured to: determine the picture background color of the picture to be edited according to the picture to be edited and/or the salient picture of the picture to be edited; find and obtain the picture background The font color corresponding to the color.
  • the font color determining unit is further configured to determine the background color of the text box corresponding to the target area before searching and acquiring the font color corresponding to the background color of the picture.
  • the above-mentioned picture generation device can execute the picture generation method provided by any embodiment of the present disclosure, and has the corresponding functional modules and effects for executing the picture generation method.
  • FIG. 5 shows a schematic structural diagram of an electronic device 500 suitable for implementing embodiments of the present disclosure.
  • the terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile phones, notebook computers, digital broadcast receivers, personal digital assistants (Personal Digital Assistant, PDA), tablet computers (PAD), portable multimedia players (Portable Media Player). , PMP), mobile terminals such as in-vehicle terminals (for example, in-vehicle navigation terminals) and fixed terminals such as digital televisions (Television, TV), desktop computers, etc.
  • PDA Personal Digital Assistant
  • PAD tablet computers
  • PMP portable multimedia players
  • PMP portable multimedia players
  • PMP mobile terminals
  • in-vehicle terminals for example, in-vehicle navigation terminals
  • fixed terminals such as digital televisions (Television, TV), desktop computers, etc.
  • the electronic device shown in FIG. 5 is only an example, and should not bring any limitation to the function and scope of use of the embodiments of the present disclosure
  • the electronic device 500 may include a processing device (such as a central processing unit, a graphics processor, etc.) 501, which may be based on a program stored in a read-only memory (Read-Only Memory, ROM) 502 or from a storage device 505 loads the program in random access memory (Random Access Memory RAM) 503 to execute various appropriate actions and processes.
  • ROM Read-Only Memory
  • RAM Random Access Memory RAM
  • various programs and data required for the operation of the electronic device 500 are also stored.
  • the processing device 501, the ROM 502, and the RAM 503 are connected to each other through a bus 504.
  • An input/output (Input/Output, I/O) interface 505 is also connected to the bus 504.
  • the following devices can be connected to the I/O interface 505: including input devices 506 such as touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; including, for example, a liquid crystal display (LCD) Output devices 507 such as speakers, vibrators, etc.; storage devices 505 including, for example, magnetic tapes, hard disks, etc.;
  • the communication device 509 may allow the electronic device 500 to perform wireless or wired communication with other devices to exchange data.
  • FIG. 5 shows an electronic device 500 with various devices, it is not required to implement or have all the devices shown. It may alternatively be implemented or provided with more or fewer devices.
  • the process described above with reference to the flowchart may be implemented as a computer software program.
  • the embodiments of the present disclosure include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart.
  • the computer program may be downloaded and installed from the network through the communication device 509, or installed from the storage device 505, or installed from the ROM 502.
  • the processing device 501 the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
  • the aforementioned computer-readable medium in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the two.
  • the computer-readable storage medium may be, for example, but not limited to, an electric, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any combination of the above.
  • Examples of computer-readable storage media may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only Memory (Erasable Programmable Read-Only Memory, EPROM or flash memory), optical fiber, portable compact disk read-only memory (Compact Disc Read-Only Memory, CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above .
  • a computer-readable storage medium may be any tangible medium that contains or stores a program, and the program may be used by or in combination with an instruction execution system, apparatus, or device.
  • a computer-readable signal medium may include a data signal propagated in a baseband or as a part of a carrier wave, and a computer-readable program code is carried therein. This propagated data signal can take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing.
  • the computer-readable signal medium may also be any computer-readable medium other than the computer-readable storage medium.
  • the computer-readable signal medium may send, propagate or transmit the program for use by or in combination with the instruction execution system, apparatus, or device .
  • the program code contained on the computer-readable medium can be transmitted by any suitable medium, including but not limited to: wire, optical cable, radio frequency (RF), etc., or any suitable combination of the above.
  • the above-mentioned computer-readable medium may be included in the above-mentioned electronic device; or it may exist alone without being assembled into the electronic device.
  • the above-mentioned computer-readable medium carries one or more programs, and when the above-mentioned one or more programs are executed by the electronic device, the electronic device: obtains the picture to be edited and the copy information; wherein, the copy information includes the copy text to be added
  • the saliency detection of the picture to be edited is performed to obtain the feature value of each pixel in the picture to be edited, and a saliency map corresponding to the picture to be edited is formed according to the obtained feature value; according to the saliency map
  • the feature value in and the determined text to be added in the coverage area of the saliency map determine the target area for adding the text to be added in the picture to be edited; add the text to be added to the target Area to generate images to be displayed.
  • the computer program code used to perform the operations of the present disclosure may be written in one or more programming languages or a combination thereof.
  • the above-mentioned programming languages include object-oriented programming languages—such as Java, Smalltalk, C++, and also conventional Procedural programming language-such as "C" language or similar programming language.
  • the program code can be executed entirely on the user's computer, partly on the user's computer, executed as an independent software package, partly on the user's computer and partly executed on a remote computer, or entirely executed on the remote computer or server.
  • the remote computer can be connected to the user's computer through any kind of network-including Local Area Network (LAN) or Wide Area Network (WAN)-or it can be connected to an external computer (for example, use an Internet service provider to connect via the Internet).
  • LAN Local Area Network
  • WAN Wide Area Network
  • each block in the flowchart or block diagram can represent a module, program segment, or part of code, and the module, program segment, or part of code contains one or more for realizing the specified logical function Executable instructions.
  • the functions marked in the block may also occur in a different order from the order marked in the drawings. For example, two blocks shown in succession can actually be executed substantially in parallel, or they can sometimes be executed in the reverse order, depending on the functions involved.
  • each block in the block diagram and/or flowchart, and the combination of the blocks in the block diagram and/or flowchart can be implemented by a dedicated hardware-based system that performs the specified functions or operations Or it can be realized by a combination of dedicated hardware and computer instructions.
  • the units involved in the embodiments described in the present disclosure may be implemented in a software manner, or may be implemented in a hardware manner.
  • the name of the unit in one case does not constitute a limitation on the unit itself.
  • the picture acquisition module can also be described as "a module for acquiring pictures and copy information to be edited".

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Processing Or Creating Images (AREA)

Abstract

本文公开了一种图片生成方法、装置、电子设备及存储介质。该图片生成方法包括:获取待编辑图片和文案信息;其中,文案信息包括待添加文案;对待编辑图片进行显著性检测,得到待编辑图片中每个像素点的特征值,并根据得到的特征值形成与待编辑图片对应的显著图;根据显著图中的特征值和确定的待添加文案在所述显著图的覆盖区域,确定在待编辑图片中添加待添加文案的目标区域;将待添加文案添加至目标区域,以生成待展示图片。

Description

图片生成方法、装置、电子设备及存储介质
本申请要求在2019年06月19日提交中国专利局、申请号为201910533231.1的中国专利申请的优先权,该申请的全部内容通过引用结合在本申请中。
技术领域
本公开涉及数据处理技术领域,例如涉及一种图片生成方法、装置、电子设备及存储介质。
背景技术
在进行活动宣传或内容展示时,通常采用在活动或所展示内容相关的图片中添加文字信息的方式生成海报等展示图片。
相关技术在生成展示图片的过程中,通常由用户提供图片和文字信息,并通过人工手段在图片上添加相应的文字。并且,在图片中所添加的文字的位置等信息,也通常由操作用户人为选择,使得图片文案排版过程效率较低。
发明内容
本公开提供一种图片生成方法、装置、电子设备及存储介质,以提高图片中的文案排版效率。
本公开实施例提供了一种图片生成方法,包括:
获取待编辑图片和文案信息;其中,所述文案信息包括待添加文案;
对所述待编辑图片进行显著性检测,得到所述待编辑图片中每个像素点的特征值,并根据得到的特征值形成与所述待编辑图片对应的显著图;
根据所述显著图中的特征值和确定的所述待添加文案在所述显著图的覆盖区域,确定在所述待编辑图片中添加所述待添加文案的目标区域;
将所述待添加文案添加至所述目标区域,以生成待展示图片。
本公开实施例还提供了一种图片生成装置,包括:
图片获取模块,设置为获取待编辑图片和文案信息;其中,所述文案信息包括待添加文案;
显著图形成模块,设置为对所述待编辑图片进行显著性检测,得到所述待编辑图片中每个像素点的特征值,并根据得到的特征值形成与所述待编辑图片对应的显著图;
目标区域确定模块,设置为根据所述显著图中的特征值和确定的所述待添加文案在所述显著图的覆盖区域,确定在所述待编辑图片中添加所述待添加文案的目标区域;
文案添加模块,设置为将所述待添加文案添加至所述目标区域,以生成待展示图片。
本公开实施例还提供了一种电子设备,包括:
一个或多个处理器;
存储器,设置为存储一个或多个程序;
当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如本公开实施例提供的一种图片生成方法。
本公开实施例还提供了一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现如本公开实施例提供的一种图片生成方法。
附图说明
图1是本公开实施例一提供的一种图片生成方法的流程图;
图2是本公开实施例二提供的一种图片生成方法的流程图;
图3是本公开实施例三提供的一种图片生成方法的流程图;
图4是本公开实施例四提供的一种图片生成装置的结构图;
图5是本公开实施例五提供的一种电子设备的结构图。
具体实施方式
下面结合附图和实施例对本公开进行说明。此处所描述的具体实施例仅仅用于解释本公开,而非对本公开的限定。为了便于描述,附图中仅示出了与本公开相关的部分而非全部结构。
下述多个实施例中,每个实施例中同时提供了可选特征和示例,实施例中记载的多个特征可进行组合,形成多个可选方案,不应将每个编号的实施例仅视为一个技术方案。
实施例一
图1是本公开实施例一提供的一种图片生成方法的流程图,本公开实施例适用于在图片中添加文案以生成新的图片的过程,该方法由图片生成装置执行,该装置通过软件和/或硬件实现,并配置于具备一定数据处理能力的电子设备中。
如图1所示的一种图片生成方法,包括:
S110、获取待编辑图片和文案信息;其中,所述文案信息包括待添加文案。
待编辑图片为需要添加文案的图片,例如可以是海报素材图。文案信息包括待添加文案的文字信息,文字信息包括文字数量和文字内容。文案信息还可以根据需要包括其他文字属性信息,例如字体大小、字体类别以及字体颜色等中的至少一个。
S120、对所述待编辑图片进行显著性检测,得到所述待编辑图片中每个像素点的特征值,并根据得到的特征值形成与所述待编辑图片对应的显著图。
示例性地,可以采用显著性检测算法对待编辑图片进行显著性特征分析,得到每个像素点的特征值,并形成与待编辑图片对应的显著图,以显示待编辑图片中每个像素的独特性。其中,显著性检测算法可以是AC算法、直方图对比度(Histogram Contrast,HC)算法、亮度对比度(Luminance Contrast,LC)算法以及频率调谐(Frequency-Tuned,FT)算法等中的至少一种。其中,特征值的范围在[0,255]之间,显著值越小,表明在待编辑图片中相应像素点的内容越重要,例如是海报中的关键人物等重要信息;显著值越大,表明在待编辑图片中相应像素点的内容越不重要,例如图片背景。
S130、根据所述显著图中的特征值和确定的所述待添加文案在所述显著图的覆盖区域,确定在所述待编辑图片中添加所述待添加文案的目标区域。
在该步骤中,可以根据文案信息确定所述待添加文案对应的至少一个文案矩形,也即文本框对应的矩形区域;根据文案矩形在显著图中的覆盖区域所对应的多个特征值,确定放置文案矩形的目标区域;其中,在待编辑图片中的目标区域所覆盖的内容对应在显著图中的特征值尽可能大,以使目标区域所覆盖区域仅包括非重要信息,例如图片背景,而避免待编辑图片中的重要内容被覆盖。
可选的,根据文案信息确定所述待添加文案对应的至少一个文案矩形,可以是获取文案信息中的字体大小、文案行数以及行间距等信息,并根据获取到的信息确定待添加文案对应的至少一个文案矩形。
可选的,根据文案信息确定所述待添加文案对应的至少一个文案矩形,还可以是对所述待添加文案进行分词,根据分词结果确定所述待添加文案的候选文本行数;根据候选文本行数,确定至少一个文案矩形。通过对待添加文案进行分词,并将同一词汇在同一文本行中放置,确定待添加文案的候选文本行数,从而实现了对待编辑图片进行文案添加时的换行功能。通常情况下,在制作海报或商品详情页时,候选文本行数一般为一行或两行。
示例性地,根据候选文本行数,确定至少一个文案矩形,可以是根据候选文本行数,确定至少一个文案矩形中每个文案矩形的长宽比;根据预设字体高度,对不同长宽比对应的文案矩形进行调整,以增加所述文案矩形的数量。
根据候选文本行数,以及待添加文案中的文字数量,确定每行文本包含的文字数量,并根据最大文字数量确定文案矩形的长宽比;根据不同字体大小对应的预设字体高度,对不同长宽比对应的文案矩形进行调整,并根据每次调整后生成的文案矩形作为新的文案矩形,进行目标区域的确定。其中,字体大小可以是用户根据用户需求添加至文案信息中的至少一个字体大小数值;还可以根据待编辑图片和待添加文案加以确定。
在本公开一个可选实施方式中,根据待编辑图片和待添加文案确定字体大小,可以是确定待编辑图片的面积;根据待添加文案中包含的文字数量,计算不同字体大小时待添加文案的文字占用面积;筛选文字占用面积与待编辑图片面积的比值满足设定占比时的字体大小的数值,以根据筛选后的字体大小进行文案矩形的调整。其中,设定占比可以由技术人员根据需要或经验值进行确定,例如用x表示文字占用面积与待编辑图片面积的比值,设定占比可以是15%<x<30%。
S140、将所述待添加文案添加至所述目标区域,以生成待展示图片。
在待添加文案的目标区域设置与目标区域相同大小的文本框,并在文本框中添加待添加文案,以生成待展示图片。相应的,还可以对生成的待展示图片加以展示。
示例性地,在文本框中添加待添加文案,可以是根据文案信息所包含的字体大小、字体类型以及字体颜色等信息,在文本框中进行待添加文案的添加操作。
本公开实施例通过获取待编辑图片以及包括待添加文案的文案信息;对待编辑图片进行显著性检测,得到待编辑图片中每个像素点的特征值,并根据得到的特征值形成与待编辑图片对应的显著图;根据显著图中特征值和确定的待添加文案在显著图的覆盖区域,确定在待编辑图片中添加待添加文案的目标区域;将待添加文案添加至目标区域,已生成待展示图片。上述技术方案通过引入待编辑图片对应的显著图,并结合待添加文字在显著图中的覆盖区域,实现待编辑图片中进行文案添加时的目标区域的自动确定,进而在确定的目标区域中进行文案添加,提高了在图片中进行文案排版的效率,减少了展示图片的生成时间。
实施例二
图2是本公开实施例二提供的一种图片生成方法的流程图,本实施例以上述实施例中可选方案为基础进行了改进。
将操作“根据所述显著图中的特征值和确定的所述待添加文案在所述显著图的覆盖区域,确定在所述待编辑图片中添加所述待添加文案的目标区域”细化为“根据所述文案信息,确定所述待添加文案对应的至少一个文案矩形;依次遍历所述显著图的不同区域,并根据所述至少一个文案矩形覆盖的所述显著图中的多个特征值,确定所述至少一个文案矩形在不同区域的覆盖得分;根据所述至少一个文案矩形在不同覆盖区域的覆盖得分,确定所述待添加文案在所述显著图的覆盖区域;根据确定的所述待添加文案在所述显著图的覆盖区域,确定在所述待编辑图片中添加所述待添加文案的目标区域”,以完善目标区域的确定机制。
如图2所示的一种图片生成方法,包括:
S210、获取待编辑图片和文案信息;其中,所述文案信息包括待添加文案。
S220、对所述待编辑图片进行显著性检测,得到所述待编辑图片中每个像素点的特征值,并根据得到的特征值形成与所述待编辑图片对应的显著图。
S230、根据所述文案信息,确定所述待添加文案对应的至少一个文案矩形。
根据待添加文案的文字数量,通过排列组合的方式确定待添加文案对应的至少一个文案矩形;根据字体大小调整文案矩形,以更加文案矩形的数量。
字体大小可以是默认的至少一个字体大小,还可以携带在文案信息中,还可以根据待编辑图片和待添加文案确定字体大小。其中,根据待编辑图片和待添加文案确定字体大小的确定方式与前文相一致,在此不再赘述。
S240、依次遍历所述显著图的不同区域,并根据所述至少一个文案矩形覆盖的所述显著图中的多个特征值,确定所述至少一个文案矩形在不同区域的覆盖得分。
由于特征值越小,表明待编辑图片中对应像素点包含的重要信息越多;特征值越大,表明待编辑图片中对应像素点的内容包含的重要信息越少。所以,将文案矩形覆盖的显著图的多个特征值所确定的覆盖得分,作为文案矩形覆盖的显著图中的重要信息的参照因子。
在该步骤中,针对每个文案矩形,依次遍历显著图的不同区域,并确定文案矩形覆盖的显著图中的多个特征值;根据确定的区域对应的多个特征值,确定文案矩形在不同区域的覆盖得分。示例性地,根据确定的区域的特征值,确定文案矩形在不同区域的覆盖得分,可以是根据确定的区域对应的多个特征值的加权和、乘积、或者平方和等;将文案矩形在不同区域对应的和值、乘积、 或者平方和等,作为文案矩形在相应区域的覆盖得分。
针对每个文案矩形,依次遍历显著图的不同区域,可以是按照预先设定的遍历路径,将文案矩形在显著图上覆盖移动。例如可以按照从左到右,从上到下的顺序,以一个像素点为步长在显著图上移动文案矩形。
S250、根据所述至少一个文案矩形在不同区域的覆盖得分,确定确定所述待添加文案在所述显著图的覆盖区域;根据确定的所述待添加文案在所述显著图的覆盖区域,确定在所述待编辑图片中添加所述待添加文案的目标区域。
由于特征值越小,表明待编辑图片中对应像素点包含的重要信息越多;特征值越大,表明待编辑图片中对应像素点的内容包含的重要信息越少。而覆盖得分根据文案矩形在待编辑图片中所覆盖区域对应的特征值经过加权和、乘积、或者平方和等方式进行运算得到,那么覆盖得分越大,表明文案矩形覆盖的重要信息越少。因此,根据不同文案矩形在不同区域的覆盖得分,选择覆盖得分最大的覆盖区域作为目标区域。
S260、将所述待添加文案添加至所述目标区域,以生成待展示图片。
本公开实施例通过将目标区域的确定操作细化为根据文案信息,确定待添加文案对应的至少一个文案矩形;针对每个文案矩形,依次遍历显著图的不同区域,并根据文案矩形覆盖的显著图中的多个特征值,确定文案矩形在不同区域的覆盖得分;根据至少一个文案矩形在不同区域的覆盖得分,确定待编辑图片中添加待添加文案的目标区域。采用上述技术方案通过引入覆盖得分对文案矩形所覆盖区域对应的重要信息进行量化,进而实现目标区域的确定,完善了目标区域的确定机制。同时,通过量化后的覆盖得分进行目标区域的确定,使所确定的目标区域更加准确,进而减少了在待编辑图片中添加文案后所覆盖的重要信息的信息量。
由于文案矩形经过字体大小进行调整后,在根据覆盖得分所确定的目标区域可能更倾向于使用字体较小的文案矩形所确定的目标区域。为了避免上述情况的发生,在确定覆盖得分时,还可以引入其他参数抑制字体大小对覆盖得分的影响。
在本公开实施例的一个可选实施方式中,在根据所述文案信息,确定所述待添加文案对应的至少一个文案矩形之后,还可以追加以下步骤:确定每个文案矩形在所述显著图的不同区域所覆盖的背景像素点的数量;所述背景像素点为特征值大于设定阈值的像素点。
设定阈值可以由技术人员根据需要或经验值进行设定,例如可以是200。
在确定所述文案矩形在不同区域的覆盖得分之后,在根据至少一个文案矩 形在不同区域的覆盖得分,确定添加待添加文案在显著图的覆盖区域之前,还包括:针对每个文案矩形,根据所述文案矩形在所述显著图中每个区域所覆盖的背景像素点的数量,更新所述文案矩形在所述区域的覆盖得分。
示例性地,根据所述文案矩形在所述显著图中每个区域所覆盖的背景像素点的数量,更新所述文案矩形在所述区域的覆盖得分,可以是获取所述文案矩形在每个区域的当前覆盖得分;将在所述区域所覆盖的背景像素点的数量以及所述当前覆盖得分相乘,得到所述文案矩形在所述区域的覆盖得分。
示例性地,根据所述文案矩形在所述显著图中每个区域所覆盖的背景像素点的数量,更新所述文案矩形在所述区域的覆盖得分,可以是获取所述文案矩形在每个区域的当前覆盖得分;对在所述区域所覆盖的背景像素点的数量以及所述当前覆盖得分加权求和,得到所述文案矩形在所述区域的覆盖得分。其中,对每个文案矩形在区域对应的当前覆盖得分和背景像素点的数量两者所设置的权重可以相同也可以不同,可以由技术人员根据需要或经验值进行设定。
为了提高所确定的目标区域的实用性,设置当前覆盖得分的权重大于背景像素点的数量的权重。
本公开实施例通过追加背景像素点的数量的确定步骤,并根据背景像素点的数量对每个区域的覆盖得分进行更新,有效抑制了字体大小对覆盖得分的影响,避免了所确定的目标区域过小的情况的发生,提高了所确定的目标区域的实用性。
实施例三
图3是本公开实施例三提供的一种图片生成方法的流程图,本实施例以上述实施例中可选方案为基础进行了改进。
在操作“将所述待添加文案添加至所述目标区域”之前,追加“根据所述待编辑图片,确定所述待添加文案的文字属性;其中,所述文字属性包括字体类别和/或字体颜色”,以实现对待添加文案的文字属性的自动确定,进而完善文字属性的确定机制。
如图3所示的一种图片生成方法,包括:
S310、获取待编辑图片和文案信息;其中,所述文案信息包括待添加文案。
S320、对所述待编辑图片进行显著性检测,得到所述待编辑图片中每个像素点的特征值,并根据得到的特征值形成与所述待编辑图片对应的显著图。
S330、根据所述显著图中的特征值和确定的所述待添加文案在所述显著图的覆盖区域,确定在所述待编辑图片中添加所述待添加文案的目标区域。
S340、根据所述待编辑图片,确定所述待添加文案的文字属性。
所述文字属性包括字体类别和/或字体颜色。
在本公开一个可选实施方式中,根据待编辑图片,确定所述待添加文案的字体类别,可以是;将待编辑图片作为输入数据输入至预先训练好的字体类别模型中;输出与输入数据对应的字体类别。
示例性地,预先训练好的字体类别模型可以是以大量的待编辑图片以及待编辑图片对应的字体类别为训练样本,训练已知模型得到第一字体类别模型。已知模型可以是神经网络模型。使用第一字体类别模型时的输入数据为待编辑图片。
在本公开一个可选实施方式中,根据所述待编辑图片,确定所述待添加文案的字体颜色,可以是:根据所述待编辑图片,确定所述待编辑图片的图片背景颜色;查找获取与所述图片背景颜色相对应的字体颜色。
示例性地,根据所述待编辑图片,确定所述待编辑图片的图片背景颜色,可以是采用K均值聚类算法对待编辑图片中的像素点进行分类,并按照设定规则选择候选颜色类别,并根据候选颜色类别中的多个像素点的像素值进行图片背景颜色的确定。其中,K值的选取可以由技术人员根据需要或经验值进行设定,也可以根据大量有限次试验加以确定。
示例性地,设定规则可以根据该类别包含的像素点数量确定,例如可以是选择包含像素点数量最多、或次多的颜色类别作为候选颜色类别。
示例性地,根据候选颜色类别中的多个像素点的像素值进行图片背景颜色的确定,可以是选择候选颜色类别中的其中一个像素点的像素值作为图片背景颜色;或者对候选颜色类别中所包含的多个像素点的像素值加权求和,并将得到的结果作为图片背景颜色。
示例性地,查找获取与所述图片背景颜色相对应的字体颜色,可以是将图片背景颜色作为字体颜色,或者在预先设定的字体颜色对照表中查找获取与图片背景颜色对应的字体颜色。
S350、将所述待添加文案添加至所述目标区域,以生成待展示图片。
本公开实施例通过在将待添加文案添加至目标区域之前,添加根据所述待编辑图片,确定所述待添加文案的文字属性;其中,所述文字属性包括字体类别和/或字体颜色,实现了对待添加文案的字体类别和/或字体颜色的自动确定,进而完善了文字属性的确定机制。
通常情况下确定的目标区域位于包含非重要信息的区域,例如图片的背景 区域,当目标区域的颜色与确定的图片背景颜色不匹配(例如相同、相似或视觉效果不佳)时,将会严重降低生成的待展示图片的质量。
为了克服上述问题,在本公开另一可选实施方式中,在查找获取与所述图片背景颜色相对应的字体颜色之前,还可以追加以下步骤:确定所述目标区域对应的文本框背景颜色;查找获取与所述图片背景颜色相对应的字体颜色,包括:将所述图片背景颜色和所述文本框背景颜色组合,查找与组合后的背景颜色对应的字体颜色;或者,根据所述图片背景颜色和所述文本框背景颜色,查找获取对应的字体颜色。
示例性地,确定所述目标区域对应的文本框背景颜色,可以是采用K均值聚类算法对待编辑图片的目标区域中的像素点进行分类,并按照设定规则选择候选颜色类别;根据候选颜色类别中的多个像素点的像素值进行文本框背景颜色的确定。其中,K值的选取可以由技术人员根据需要或经验值进行设定,也可以根据大量有限次试验加以确定。其中,设定规则可以根据该类别包含的像素点数量确定,例如可以是选择包含像素点数量最多、或次多的颜色类别作为候选颜色类别。
示例性地,将所述图片背景颜色和所述文本框背景颜色组合,可以是将确定的图片背景颜色对应的像素值以及将文本框背景颜色对应的像素值进行加权求和,得到组合后的背景颜色对应的像素值。
示例性地,根据所述图片背景颜色和所述文本框背景颜色,查找获取对应的字体颜色,可以是在预先设定的字体颜色对照表中查找获取与图片背景颜色以及文本框背景颜色所对应的字体颜色。
本公开实施例通过在确定字体颜色时引入文本框背景颜色,使得所确定的字体颜色能够更好的适配待编辑图片,进而提高所生成待展示图片的质量,提升用户观看待展示图片时的视觉体验。
实施例四
图4是本公开实施例四提供的一种图片生成装置的结构图,本公开实施例适用于在图片中添加文案以生成新的图片的过程,该装置通过软件和/或硬件实现,并配置于具备一定数据处理能力的电子设备中。
如图4所示的一种图片生成装置,包括:图片获取模块410,显著图形成模块420,目标区域确定模块430以及文案添加模块440。
图片获取模块410,设置为获取待编辑图片和文案信息;其中,所述文案信息包括待添加文案。
显著图形成模块420,设置为对所述待编辑图片进行显著性检测,得到所述 待编辑图片中每个像素点的特征值,并根据得到的特征值形成与所述待编辑图片对应的显著图。
目标区域确定模块430,设置为根据所述显著图中的特征值和确定的所述待添加文案在所述显著图的覆盖区域,确定在所述待编辑图片中添加所述待添加文案的目标区域。
文案添加模块440,设置为将所述待添加文案添加至所述目标区域,以生成待展示图片。
本公开实施例通过图片获取模块获取待编辑图片以及包括待添加文案的文案信息;通过显著图形成模块对待编辑图片进行显著性检测,得到待编辑图片中每个像素点的特征值,并根据得到的特征值形成与待编辑图片对应的显著图;通过目标区域确定模块根据显著图中的特征值和确定的待添加文案在显著图的覆盖区域,确定在待编辑图片中添加待添加文案的目标区域;通过文案添加模块将待添加文案添加至目标区域,已生成待展示图片。上述技术方案通过引入待编辑图片对应的显著图,并结合待添加文字在显著图中的覆盖区域,实现待编辑图片中进行文案添加时的目标区域的自动确定,进而在确定的目标区域中进行文案添加,提高了在图片中进行文案排版的效率,减少了展示图片的生成时间。
目标区域确定模块430,包括:
文案矩形确定单元,设置为根据所述文案信息,确定所述待添加文案对应的至少一个文案矩形;覆盖得分确定单元,设置为依次遍历所述显著图的不同区域,并根据所述至少一个文案矩形覆盖的所述显著图中的多个特征值,确定所述至少一个文案矩形在不同区域的覆盖得分;目标区域确定单元,设置为根据所述至少一个文案矩形在不同区域的覆盖得分,确定所述待添加文案在所述显著图的覆盖区域;根据确定的所述待添加文案在所述显著图的覆盖区域,确定在所述待编辑图片中添加所述待添加文案的目标区域。
目标区域确定模块430,还包括:
数量统计单元,设置为在根据所述文案信息,确定所述待添加文案对应的至少一个文案矩形之后,确定每个文案矩形在所述显著图的不同区域所覆盖的背景像素点的数量;其中,所述背景像素点为特征值大于设定阈值的像素点;覆盖得分更新单元,设置为在确定所述至少一个文案矩形在所述区域的覆盖得分之后,在根据所述至少一个文案矩形在不同区域的覆盖得分,确定所述待添加文案在所述显著图的覆盖区域之前,针对每个文案矩形,根据所述文案矩形在所述显著图中每个区域所覆盖的背景像素点的数量,更新所述文案矩形在所 述区域的覆盖得分。
覆盖得分确定单元,是设置为:
依次遍历所述显著图的不同区域,并确定每个文案矩形覆盖的所述显著图中的多个特征值的和值;将所述文案矩形在每个区域对应的和值,作为所述文案矩形在相应覆盖区域的覆盖得分。
覆盖得分更新单元,是设置为:
获取所述文案矩形在每个区域的当前覆盖得分;对在所述区域所覆盖的背景像素点的数量以及所述当前覆盖得分加权求和,得到所述文案矩形在所述区域的覆盖得分。
文案矩形确定单元,是设置为:
对所述待添加文案进行分词,根据分词结果确定所述待添加文案的候选文本行数;根据所述候选文本行数,确定至少一个文案矩形。
文案矩形确定单元,是设置为通过如下方式根据所述候选文本行数,确定至少一个文案矩形时:
根据所述候选文本行数,确定至少一个文案矩形中每个文案矩形的长宽比;根据预设字体高度,对不同长宽比对应的文案矩形进行调整。
该装置还包括文字属性确定模块,设置为:
在将所述待添加文案添加至所述目标区域之前,根据所述待编辑图片,确定所述待添加文案的文字属性;其中,所述文字属性包括字体类别和/或字体颜色。
文字属性确定模块,包括字体颜色确定单元,设置为:根据所述待编辑图片和/或所述待编辑图片的显著图,确定所述待编辑图片的图片背景颜色;查找获取与所述图片背景颜色相对应的字体颜色。
字体颜色确定单元,还设置为:在查找获取与所述图片背景颜色相对应的字体颜色之前,确定所述目标区域对应的文本框背景颜色。
字体颜色确定单元,是设置为通过如下方式查找获取与所述图片背景颜色相对应的字体颜色:
将所述图片背景颜色和所述文本框背景颜色组合,查找与组合后的背景颜色对应的字体颜色;或者,根据所述图片背景颜色和所述文本框背景颜色,查找获取对应的字体颜色。
上述图片生成装置可执行本公开任意实施例所提供的图片生成方法,具备 执行图片生成方法相应的功能模块和效果。
实施例五
下面参考图5,图5示出了适于用来实现本公开实施例的电子设备500的结构示意图。本公开实施例中的终端设备可以包括但不限于诸如移动电话、笔记本电脑、数字广播接收器、个人数字助理(Personal Digital Assistant,PDA)、平板电脑(PAD)、便携式多媒体播放器(Portable Media Player,PMP)、车载终端(例如车载导航终端)等等的移动终端以及诸如数字电视机(Television,TV)、台式计算机等等的固定终端。图5示出的电子设备仅仅是一个示例,不应对本公开实施例的功能和使用范围带来任何限制。
如图5所示,电子设备500可以包括处理装置(例如中央处理器、图形处理器等)501,其可以根据存储在只读存储器(Read-Only Memory,ROM)502中的程序或者从存储装置505加载到随机访问存储器(Random Access Memory RAM)503中的程序而执行多种适当的动作和处理。在RAM 503中,还存储有电子设备500操作所需的多种程序和数据。处理装置501、ROM 502以及RAM 503通过总线504彼此相连。输入/输出(Input/Output,I/O)接口505也连接至总线504。
通常,以下装置可以连接至I/O接口505:包括例如触摸屏、触摸板、键盘、鼠标、摄像头、麦克风、加速度计、陀螺仪等的输入装置506;包括例如液晶显示器(Liquid Crystal Display,LCD)、扬声器、振动器等的输出装置507;包括例如磁带、硬盘等的存储装置505;以及通信装置509。通信装置509可以允许电子设备500与其他设备进行无线或有线通信以交换数据。虽然图5示出了具有多种装置的电子设备500,并不要求实施或具备所有示出的装置。可以替代地实施或具备更多或更少的装置。
根据本公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本公开的实施例包括一种计算机程序产品,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信装置509从网络上被下载和安装,或者从存储装置505被安装,或者从ROM 502被安装。在该计算机程序被处理装置501执行时,执行本公开实施例的方法中限定的上述功能。
本公开上述的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只 读存储器(ROM)、可擦式可编程只读存储器(Erasable Programmable Read-Only Memory,EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(Compact Disc Read-Only Memory,CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。
在本公开中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本公开中,计算机可读信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读信号介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:电线、光缆、射频(Radio Frequency,RF)等等,或者上述的任意合适的组合。
上述计算机可读介质可以是上述电子设备中所包含的;也可以是单独存在,而未装配入该电子设备中。
上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被该电子设备执行时,使得该电子设备:获取待编辑图片和文案信息;其中,所述文案信息包括待添加文案;对所述待编辑图片进行显著性检测,得到所述待编辑图片中每个像素点的特征值,并根据得到的特征值形成与所述待编辑图片对应的显著图;根据所述显著图中的特征值和确定的所述待添加文案在所述显著图的覆盖区域,确定在所述待编辑图片中添加所述待添加文案的目标区域;将所述待添加文案添加至所述目标区域,以生成待展示图片。
可以以一种或多种程序设计语言或其组合来编写用于执行本公开的操作的计算机程序代码,上述程序设计语言包括面向对象的程序设计语言—诸如Java、Smalltalk、C++,还包括常规的过程式程序设计语言—诸如“C”语言或类似的程序设计语言。程序代码可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络——包括局域网(Local Area Network,LAN)或广域网(Wide Area Network,WAN)—连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。
附图中的流程图和框图,图示了按照本公开多种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图 中的每个方框可以代表一个模块、程序段、或代码的一部分,该模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。
描述于本公开实施例中所涉及到的单元可以通过软件的方式实现,也可以通过硬件的方式来实现。其中,单元的名称在一种情况下并不构成对该单元本身的限定,例如,图片获取模块还可以被描述为“获取待编辑图片和文案信息的模块”。

Claims (13)

  1. 一种图片生成方法,包括:
    获取待编辑图片和文案信息;其中,所述文案信息包括待添加文案;
    对所述待编辑图片进行显著性检测,得到所述待编辑图片中每个像素点的特征值,并根据得到的特征值形成与所述待编辑图片对应的显著图;
    根据所述显著图中的特征值和确定的所述待添加文案在所述显著图的覆盖区域,确定在所述待编辑图片中添加所述待添加文案的目标区域;
    将所述待添加文案添加至所述目标区域,以生成待展示图片。
  2. 根据权利要求1所述的方法,所述根据所述显著图中的特征值和确定的所述待添加文案在所述显著图的覆盖区域,确定在所述待编辑图片中添加所述待添加文案的目标区域,包括:
    根据所述文案信息,确定所述待添加文案对应的至少一个文案矩形;
    依次遍历所述显著图的不同区域,并根据所述至少一个文案矩形覆盖的所述显著图中的多个特征值,确定所述至少一个文案矩形在不同区域的覆盖得分;
    根据所述至少一个文案矩形在不同区域的覆盖得分,确定所述待添加文案在所述显著图的覆盖区域;
    根据确定的所述待添加文案在所述显著图的覆盖区域,确定在所述待编辑图片中添加所述待添加文案的目标区域。
  3. 根据权利要求2所述的方法,在根据所述文案信息,确定所述待添加文案对应的至少一个文案矩形之后,还包括:
    确定每个文案矩形在所述显著图的不同区域所覆盖的背景像素点的数量;其中,所述背景像素点为特征值大于设定阈值的像素点;
    在所述确定所述至少一个文案矩形在不同区域的覆盖得分之后,在所述根据所述至少一个文案矩形在不同区域的覆盖得分,确定所述待添加文案在所述显著图的覆盖区域之前,还包括:
    针对每个文案矩形,根据所述文案矩形在所述显著图中每个区域所覆盖的背景像素点的数量,更新所述文案矩形在所述区域的覆盖得分。
  4. 根据权利要求2所述的方法,其中,所述依次遍历所述显著图的不同区域,并根据所述至少一个文案矩形覆盖的所述显著图中的多个特征值,确定所述至少一个文案矩形在不同区域的覆盖得分,包括:
    依次遍历所述显著图的不同区域,并确定每个文案矩形覆盖的所述显著图中的多个特征值的和值;
    将所述文案矩形在每个区域对应的和值,作为所述文案矩形在相应区域的覆盖得分。
  5. 根据权利要求3所述的方法,其中,所述根据所述文案矩形在所述显著图中每个区域所覆盖的背景像素点的数量,更新所述文案矩形在所述区域的覆盖得分,包括:
    获取所述文案矩形在每个区域的当前覆盖得分;
    对在所述区域所覆盖的背景像素点的数量以及所述当前覆盖得分加权求和,得到所述文案矩形在所述区域的覆盖得分。
  6. 根据权利要求2所述的方法,其中,所述根据所述文案信息,确定所述待添加文案对应的至少一个文案矩形,包括:
    对所述待添加文案进行分词,根据分词结果确定所述待添加文案的候选文本行数;
    根据所述候选文本行数,确定所述至少一个文案矩形。
  7. 根据权利要求6所述的方法,其中,所述根据所述候选文本行数,确定所述至少一个文案矩形,包括:
    根据所述候选文本行数,确定所述至少一个文案矩形中每个文案矩形的长宽比;
    根据预设字体高度,对不同长宽比对应的文案矩形进行调整。
  8. 根据权利要求1-7任一项所述的方法,在所述将所述待添加文案添加至所述目标区域之前,还包括:
    根据所述待编辑图片,确定所述待添加文案的文字属性;
    其中,所述文字属性包括字体类别和字体颜色中的至少之一。
  9. 根据权利要求8所述的方法,其中,所述根据所述待编辑图片,确定所述待添加文案的文字属性,包括:
    根据所述待编辑图片,确定所述待编辑图片的图片背景颜色;
    查找获取与所述图片背景颜色相对应的字体颜色。
  10. 根据权利要求9所述的方法,在所述查找获取与所述图片背景颜色相对应的字体颜色之前,还包括:
    确定所述目标区域对应的文本框背景颜色;
    所述查找获取与所述图片背景颜色相对应的字体颜色,包括:
    将所述图片背景颜色和所述文本框背景颜色组合,查找与组合后的背景颜色对应的字体颜色;或者,
    根据所述图片背景颜色和所述文本框背景颜色,查找获取对应的字体颜色。
  11. 一种图片生成装置,包括:
    图片获取模块,设置为获取待编辑图片和文案信息;其中,所述文案信息包括待添加文案;
    显著图形成模块,设置为对所述待编辑图片进行显著性检测,得到所述待编辑图片中每个像素点的特征值,并根据得到的特征值形成与所述待编辑图片对应的显著图;
    目标区域确定模块,设置为根据所述显著图中的特征值和确定的所述待添加文案在所述显著图的覆盖区域,确定在所述待编辑图片中添加所述待添加文案的目标区域;
    文案添加模块,设置为将所述待添加文案添加至所述目标区域,以生成待展示图片。
  12. 一种电子设备,包括:
    至少一个处理器;
    存储器,设置为存储至少一个程序;
    当所述至少一个程序被所述至少一个处理器执行,使得所述至少一个处理器实现如权利要求1-10中任一项所述的图片生成方法。
  13. 一种计算机可读存储介质,存储有计算机程序,其中,所述程序被处理器执行时实现如权利要求1-10中任一项所述的图片生成方法。
PCT/CN2020/096762 2019-06-19 2020-06-18 图片生成方法、装置、电子设备及存储介质 WO2020253766A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910533231.1 2019-06-19
CN201910533231.1A CN110264545A (zh) 2019-06-19 2019-06-19 图片生成方法、装置、电子设备及存储介质

Publications (1)

Publication Number Publication Date
WO2020253766A1 true WO2020253766A1 (zh) 2020-12-24

Family

ID=67919483

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/096762 WO2020253766A1 (zh) 2019-06-19 2020-06-18 图片生成方法、装置、电子设备及存储介质

Country Status (2)

Country Link
CN (1) CN110264545A (zh)
WO (1) WO2020253766A1 (zh)

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110264545A (zh) * 2019-06-19 2019-09-20 北京字节跳动网络技术有限公司 图片生成方法、装置、电子设备及存储介质
CN111768471A (zh) * 2019-09-29 2020-10-13 北京京东尚科信息技术有限公司 在图片中编辑文字的方法和装置
CN110889267A (zh) * 2019-11-29 2020-03-17 北京金山安全软件有限公司 一种图片中的字符编辑方法、装置、电子设备及存储介质
CN111580909B (zh) * 2020-05-08 2023-05-05 广州市百果园信息技术有限公司 图片生成方法、装置、设备和存储介质
CN111581926B (zh) * 2020-05-15 2023-09-01 抖音视界有限公司 文案生成方法、装置、设备和计算机可读存储介质
CN114003319B (zh) 2020-07-28 2024-04-23 华为技术有限公司 一种灭屏显示的方法和电子设备
CN112862926B (zh) * 2021-01-29 2023-08-01 成都环宇知了科技有限公司 一种基于Swoole框架的智能图片合成方法及系统
CN113537487B (zh) * 2021-06-25 2023-08-04 北京百度网讯科技有限公司 模型训练的方法、生成图片的方法及其装置
CN113744365B (zh) * 2021-07-19 2024-04-26 稿定(厦门)科技有限公司 基于显著性感知的文案智能布局方法、系统、储存介质
CN113989404B (zh) * 2021-11-05 2024-06-25 北京字节跳动网络技术有限公司 图片处理方法、装置、设备、存储介质和程序产品
CN114529635B (zh) * 2022-02-15 2024-08-20 腾讯科技(深圳)有限公司 一种图像生成方法、装置、存储介质及设备

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105320391A (zh) * 2014-07-31 2016-02-10 宇龙计算机通信科技(深圳)有限公司 一种调整待机界面显示效果的方法及终端
US9298980B1 (en) * 2013-03-07 2016-03-29 Amazon Technologies, Inc. Image preprocessing for character recognition
CN106973324A (zh) * 2017-03-28 2017-07-21 深圳市茁壮网络股份有限公司 一种海报生成方法及装置
CN107103635A (zh) * 2017-03-20 2017-08-29 中国科学院自动化研究所 图像排版配色方法
CN107517303A (zh) * 2016-06-17 2017-12-26 中兴通讯股份有限公司 壁纸处理方法及装置
CN108960247A (zh) * 2017-05-22 2018-12-07 阿里巴巴集团控股有限公司 图像显著性检测方法、装置以及电子设备
CN110264545A (zh) * 2019-06-19 2019-09-20 北京字节跳动网络技术有限公司 图片生成方法、装置、电子设备及存储介质

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106775747B (zh) * 2016-12-28 2020-03-24 Tcl集团股份有限公司 一种颜色配置的方法和装置
CN109522908B (zh) * 2018-11-16 2023-04-14 辽宁工程技术大学 基于区域标签融合的图像显著性检测方法
CN109543701A (zh) * 2018-11-30 2019-03-29 长沙理工大学 视觉显著性区域检测方法及装置

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9298980B1 (en) * 2013-03-07 2016-03-29 Amazon Technologies, Inc. Image preprocessing for character recognition
CN105320391A (zh) * 2014-07-31 2016-02-10 宇龙计算机通信科技(深圳)有限公司 一种调整待机界面显示效果的方法及终端
CN107517303A (zh) * 2016-06-17 2017-12-26 中兴通讯股份有限公司 壁纸处理方法及装置
CN107103635A (zh) * 2017-03-20 2017-08-29 中国科学院自动化研究所 图像排版配色方法
CN106973324A (zh) * 2017-03-28 2017-07-21 深圳市茁壮网络股份有限公司 一种海报生成方法及装置
CN108960247A (zh) * 2017-05-22 2018-12-07 阿里巴巴集团控股有限公司 图像显著性检测方法、装置以及电子设备
CN110264545A (zh) * 2019-06-19 2019-09-20 北京字节跳动网络技术有限公司 图片生成方法、装置、电子设备及存储介质

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
YIPING MENG, TANG FAN , DONG WEIMING ,HUANG FEIYUE ,ZHANG XIAOPENG: "Automatic layout and color matching of photo watermark", JOURNAL OF IMAGE AND GRAPHICS, vol. 22, no. 3, 16 March 2017 (2017-03-16), pages 405 - 414, XP055767033, ISSN: 1006-8961, DOI: 10.11834/jig.20170315 *

Also Published As

Publication number Publication date
CN110264545A (zh) 2019-09-20

Similar Documents

Publication Publication Date Title
WO2020253766A1 (zh) 图片生成方法、装置、电子设备及存储介质
CN109618222B (zh) 一种拼接视频生成方法、装置、终端设备及存储介质
CN109783178B (zh) 一种界面组件的颜色调整方法、装置、设备和介质
CN109168026B (zh) 即时视频显示方法、装置、终端设备及存储介质
WO2021052085A1 (zh) 视频推荐方法、装置、电子设备及计算机可读介质
WO2020056903A1 (zh) 用于生成信息的方法和装置
WO2020248900A1 (zh) 全景视频的处理方法、装置及存储介质
WO2020228406A1 (zh) 图像风格化生成方法、装置及电子设备
US12093592B2 (en) Picture displaying method and apparatus, and electronic device
CN109474850B (zh) 运动像素视频特效添加方法、装置、终端设备及存储介质
US11924520B2 (en) Subtitle border-crossing processing method and apparatus, and electronic device
WO2020007113A1 (zh) 用于加载图像的方法和装置
CN110796664B (zh) 图像处理方法、装置、电子设备及计算机可读存储介质
WO2023104102A1 (zh) 一种直播评论展示方法、装置、设备、程序产品及介质
JP2022505118A (ja) 画像処理方法、装置、ハードウェア装置
CN109600559B (zh) 一种视频特效添加方法、装置、终端设备及存储介质
CN110070499A (zh) 图像处理方法、装置和计算机可读存储介质
CN112785669B (zh) 一种虚拟形象合成方法、装置、设备及存储介质
WO2023138441A1 (zh) 视频生成方法、装置、设备及存储介质
CN111107381A (zh) 直播间弹幕显示方法、存储介质、设备及系统
WO2024193511A1 (zh) 互动方法、装置、电子设备、计算机可读介质
WO2024179508A1 (zh) 一种虚拟礼物生成方法、装置、设备及介质
WO2023078281A1 (zh) 图片处理方法、装置、设备、存储介质和程序产品
CN114399645A (zh) 多模态数据扩充方法、系统、介质、计算机设备及终端
CN113905177A (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: 20826007

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: 20826007

Country of ref document: EP

Kind code of ref document: A1

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 28.03.2022)

122 Ep: pct application non-entry in european phase

Ref document number: 20826007

Country of ref document: EP

Kind code of ref document: A1