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

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

Info

Publication number
CN112116681B
CN112116681B CN201910533812.5A CN201910533812A CN112116681B CN 112116681 B CN112116681 B CN 112116681B CN 201910533812 A CN201910533812 A CN 201910533812A CN 112116681 B CN112116681 B CN 112116681B
Authority
CN
China
Prior art keywords
layout
information
image
elements
size
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.)
Active
Application number
CN201910533812.5A
Other languages
Chinese (zh)
Other versions
CN112116681A (en
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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201910533812.5A priority Critical patent/CN112116681B/en
Publication of CN112116681A publication Critical patent/CN112116681A/en
Application granted granted Critical
Publication of CN112116681B publication Critical patent/CN112116681B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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

Abstract

The invention provides an image generation method, an image generation device, computer equipment and a storage medium, and belongs to the technical field of computers. The method comprises the following steps: dividing at least two elements included in a first image to be adjusted into at least two element groups, wherein each element group comprises at least one element of the same type; acquiring at least two layout information of the first image based on the element layout definition information and at least two element groups of the first image according to the target image size; acquiring target layout information from at least two pieces of layout information; a second image is generated based on the target layout information and the at least two element groups. The layout of the elements in the at least two element groups is limited according to the at least two layout information, the layout is not limited by the size stored in a layout library and the number of layout schemes, and one layout is flexibly selected from the at least two layouts combined by the element arrangements in the at least two element groups, so that the layout mode of the elements in the generated image is flexible.

Description

Image generation method, device, computer equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to an image generating method, an image generating device, a computer device, and a storage medium.
Background
With the rapid development of internet technology, advertising of internet products has also appeared in more and more forms of presentation. For example, by banner advertisements on web pages or within an APP (Application), etc. The advertisement can be a static image or a dynamic image spliced by multiple frames of images, and the images comprise various elements such as picture elements, text elements, background elements and the like. Taking a picture advertisement as an example, when the picture advertisement is presented on different interfaces, a designer needs to design pictures with different sizes and element layouts.
In order to reduce the workload of the designer, a layout library is generally provided, and the layout library contains layout schemes of images with various sizes. When advertisement images with various sizes are needed, a layout scheme with the nearest size and element position is selected according to the layout schemes stored in the layout library, and the existing advertisement images are adjusted to obtain advertisement images with different sizes.
The technical scheme has the problems that the advertisement image can only be adjusted to the existing layout scheme under the existing size by the limitation of the size stored in the layout library and the number of the layout schemes, and the layout of the image obtained after adjustment is relatively fixed.
Disclosure of Invention
The embodiment of the invention provides an image generation method, an image generation device, computer equipment and a storage medium, which are used for solving the problem that the advertisement image can only be adjusted to the existing layout scheme under the existing size due to the limitation of the size stored in a layout library and the number of the layout schemes when the image is generated at present, and the layout of the image obtained after adjustment is relatively fixed. The technical scheme is as follows:
in one aspect, there is provided an image generation method, the method including:
dividing at least two elements included in a first image to be adjusted into at least two element groups, wherein each element group comprises at least one element of the same type;
acquiring at least two pieces of layout information of the first image based on the element layout definition information of the first image and the at least two element groups according to a target image size, wherein the element layout definition information is used for defining a position relation between any type of elements;
acquiring target layout information from the at least two pieces of layout information;
a second image is generated based on the target layout information and the at least two element groups.
In one aspect, there is provided an image generating apparatus, the method including:
The dividing module is used for dividing at least two elements included in the first image to be adjusted into at least two element groups, wherein each element group comprises at least one element of the same type;
a first obtaining module, configured to obtain at least two pieces of layout information of the first image based on element layout definition information of the first image and the at least two element groups according to a target image size, where the element layout definition information is used to define a positional relationship between any type of elements;
the first obtaining module is further configured to obtain target layout information from the at least two layout information;
and a generation module for generating a second image based on the target layout information and the at least two element groups.
In one aspect, a computer device is provided that includes a processor and a memory having stored therein program code that is loaded and executed by the processor to perform operations performed in an image generation method in an embodiment of the present invention.
In one aspect, a storage medium is provided, in which a program code for executing the image generating method in the embodiment of the present invention is stored.
The technical scheme provided by the embodiment of the invention has the beneficial effects that:
according to the technical scheme provided by the embodiment of the invention, the same type of elements in at least two elements included in a first image to be adjusted are divided into the same element groups, the target image size of the image to be generated is based on element layout limiting information for limiting the position relation between the elements and the at least two element groups, at least two layout information is obtained, target layout information is obtained from the at least two layout information, the target layout information is layout information meeting design requirements, and a second image is generated based on the target layout information and the at least two element groups and is an image meeting the design requirements. At least two elements in the first image are divided into at least two element groups according to element types, the layout of the elements in the at least two element groups is limited according to at least two layout information, the layout is not limited by the size stored in a layout library and the number of layout schemes, one layout is flexibly selected from a plurality of element layouts formed by arranging and combining the elements in the at least two element groups, and therefore the layout mode of the elements in the generated image is flexible.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a block diagram of an image generation system 100 according to an embodiment of the present invention;
FIG. 2 is a flowchart of an image generation method according to an embodiment of the present invention;
FIG. 3 is a schematic layout view of at least two elements in a first image according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a layout of at least two elements within a blank canvas according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of a layout of elements in an element group according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of a layout of elements in another element group according to an embodiment of the present invention;
FIG. 7 is a schematic diagram of a layout of elements in another element group according to an embodiment of the present invention;
FIG. 8 is a schematic layout view of at least two elements in a first image according to another embodiment of the present invention;
FIG. 9 is a schematic diagram of a layout of at least two elements within another blank canvas provided by an embodiment of the present invention;
FIG. 10 is a schematic diagram of a layout of at least two elements within another blank canvas provided by an embodiment of the present invention;
FIG. 11 is a schematic diagram of a layout of at least two elements within another blank canvas provided by an embodiment of the present invention;
FIG. 12 is a schematic diagram of a layout of at least two elements within another blank canvas provided by an embodiment of the present invention;
fig. 13 is a block diagram of an image generating apparatus provided by an embodiment of the present invention;
fig. 14 is a schematic structural diagram of a computer device according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present invention more apparent, the embodiments of the present invention will be described in further detail with reference to the accompanying drawings.
The embodiment of the invention mainly relates to an image making scene, taking making advertisement pictures as an example, in order to enable the advertisement pictures to adapt to screens with different sizes, the advertisement pictures with various sizes need to be designed, so that the advertisement pictures suitable for the screens can be displayed on the screens with different sizes, and the layout of contents in the advertisement pictures with different sizes is different. For example, the content in the advertisement picture displayed on the screen of the tablet computer is in a horizontal layout, and the content in the advertisement picture displayed on the screen of the mobile phone is in a vertical layout.
The advertisement picture can comprise a plurality of elements, such as a text element, a picture element, a background element and the like, and a designer can set a plurality of layers when designing the advertisement picture, wherein each layer corresponds to one element. For example, a certain advertisement picture has four layers corresponding to four elements: background pictures, trademark pictures, product pictures, and advertising. When the advertisement pictures with different sizes are designed, various elements required in the advertisement pictures are placed on blank canvas with different sizes according to design rules, so that the theme displayed by the advertisement pictures is outstanding, and the effect of attracting users is achieved.
Fig. 1 is a block diagram of an image generation system 100 according to an embodiment of the present invention. The image generation system 100 includes: a computer device 101 and an image generation platform 102.
The computer device 101 is connected to the image generation platform 102 via a wireless network or a wired network. The computer device 101 may be at least one of a smart phone, a game console, a desktop computer, a tablet computer, an electronic book reader, an MP3 player, an MP4 player, and a laptop portable computer. The computer device 101 installs and runs an application program supporting image generation. The application may be an image processing class application or the like.
The image generation platform 102 includes at least one of a server, a plurality of servers, a cloud computing platform, and a virtualization center. The image generation platform 102 is used to provide background services for applications that support image generation. Optionally, the image generation platform 102 undertakes primary image generation work and the computer device 101 undertakes secondary image generation work; alternatively, the image generation platform 102 takes on secondary image generation work and the computer device 101 takes on primary image generation work; alternatively, the image generation platform 102 or the computer device 101, respectively, may solely undertake image generation work.
Optionally, the image generation platform 102 includes: an access server, an image generation server and a database. The access server is used to provide access services for the computer device 101. The image generation server is used for providing background services related to image generation. The image generation server may be one or more. When the image generating servers are plural, there are at least two image generating servers for providing different services, and/or there are at least two image generating servers for providing the same service, such as providing the same service in a load balancing manner, which is not limited in the embodiment of the present invention.
Alternatively, the computer device 101 may also refer to one of a plurality of terminals, or may refer to one of a plurality of servers, and this embodiment is merely illustrated by the computer device 101.
Those skilled in the art will appreciate that the number of computer devices 101 described above may be greater or lesser. For example, the computer device 101 may be only one, or the computer device 101 may be several tens or hundreds, or more, in which case the image generating system may further include other computer devices 101. The number and type of the computer devices 101 are not limited in the embodiment of the present invention.
Fig. 2 is a flowchart of an image generating method according to an embodiment of the present invention, referring to fig. 2, including the following steps:
201. the computer device obtains a first image to be adjusted, the first image including at least two elements, and a target image size.
In an embodiment of the present invention, the target image size is a size determined according to the current image generation requirements.
For example, the first image has a size 1920×1080, the size is suitable for a computer screen, the current image generation requirement is to adjust the first image to a size suitable for a mobile phone screen, and the target image size is 900×1600 according to the image generation requirement.
In the embodiment of the present invention, at least two elements included in the first image may be elements of the same element type, or may be elements of different element types, where the element types of the elements may be divided into a picture element, a text element, a background element, and the like.
For example, the first image includes an element a, an element B, an element C, an element D, an element E, and an element F, the element types of the element a and the element B are text elements, the element types of the element C, the element D, and the element E are picture elements, and the element type of the element F is a background element.
In an alternative implementation, the first image to be adjusted may be a design drawing source file, where the design drawing source file may include information about layers of multiple layers, and dimensions and sizes of elements included in each layer. The layer information included in the design drawing source file may be information added for each layer in the first image when the first image is designed, where the layer information is used to indicate an element corresponding to each layer and an element group identifier corresponding to the layer. The element group identifier is used for indicating an element group to which an element corresponding to each layer belongs, and the element group identifier may be a number of the element group or a name of the element group, for example, a picture group, a text group, a background group, and the like. The computer device may read and parse layer information of a plurality of layers included in the first image through a plug-in or an application.
For example, layer information of layer a, layer b, layer c, layer d, layer e, and layer f is included in the first image. According to the layer information, the layer a corresponds to the element A, and the corresponding element group is marked as a text group; layer B corresponds to element B, and the corresponding element group is identified as a text group; the layer C corresponds to the element C, and the corresponding element group is identified as a picture group; the layer D corresponds to the element D, and the corresponding element group is identified as a picture group; layer E corresponds to element E, and the corresponding element group is identified as a picture group; layer F corresponds to element F, and the corresponding element group is identified as the background group.
In an alternative implementation, the computer device may also extract, through an image recognition technique, element type information of at least two elements included in the first image, and information such as a size and a size of each element.
For example, the computer device extracts, through an image recognition technology, that the first image includes an element a, an element B, an element C, an element D, an element E, and an element F, where the element types of the element a and the element B are text elements, the element types of the element C, the element D, and the element E are picture elements, the element type of the element F is a background element, and the sizes and dimensions of the respective elements.
202. The computer device divides at least two elements included in the first image into at least two element groups, each element group including at least one element of the same type.
The computer device may divide the elements belonging to the same type into one element group, each element group corresponding to one element type, according to element types of at least two elements included in the first image. This element group may also be referred to as a virtual element group.
For example, in the first image, the element types of the element a and the element B are text elements, and the computer device divides the element a and the element B into text groups; the element types of the element C, the element D and the element E are picture elements, the computer equipment divides the element C, the element D and the element E into picture groups, the element type of the element F is a background element, and the computer equipment divides the element F into background groups.
In an alternative implementation, the element types of the at least two elements may be determined based on the layer information, and the step of dividing the at least two element groups by the computer device may be: the computer device may divide elements corresponding to layers having the same element group identifier in the first image into the same element group according to layer information of the plurality of layers in the first image.
For example, the first image in step 201 includes layer information of layer a, layer b, layer c, layer d, layer e, and layer f. According to the layer information, the computer equipment divides an element A corresponding to a layer a and an element B corresponding to a layer B into text groups, divides an element C corresponding to a layer C, an element D corresponding to a layer D and an element E corresponding to a layer E into picture groups, and divides an element F corresponding to a layer F into background groups.
203. The computer device acquires at least two pieces of layout information of the first image based on the element layout definition information of the first image and the at least two element groups, the element layout definition information indicating a positional relationship between any type of elements, according to the target image size.
The computer device may acquire at least two layout information by means of machine learning or the like in a manner of solving an optimal solution using the target image size, the element layout definition information, and the at least two element groups as constraint conditions or target functions.
Wherein the element layout definition information may be a positional relationship between elements set for the first image when the first image is designed. The at least two layout information may be obtained by obtaining a global optimal solution or may be obtained by obtaining a local optimal solution. The at least two layout information are different from each other, and any one of the layout information may include position information between at least two element groups, position and size information between each element in at least two element groups, and the like.
For example, taking element layout limitation information as an example of a positional relationship set for elements in the first image, a canvas where the first image is located may be used as a rectangular coordinate system, the canvas has a width of W pixels and a length of H pixels, and the coordinate value of the upper left corner position of the canvas is x=0 and y=0. The width of the element a is w pixel points, the height is h pixel points, and the coordinate value of the upper left corner of the element a is x=x and y=y. If the element a is limited not to exceed the canvas range, the layout limiting information of the element a is: x > =0, y > =0, x+w < =w, y+h < =h.
In an alternative implementation, the element layout definition information may be generic element layout definition information that applies not only to the first image but also to other images. The general element layout defining information may include at least one of a position, a size, a color, an overlapping, and a proportion, and the element layout defining information may further include a tolerance term, a random term, a quantization term of other dimensions, and other design rules set for the element, which is not particularly limited in the present invention.
In an alternative implementation manner, the general element layout definition information may be stored in a layout definition information base, and the computer device obtains element layout definition information corresponding to element types of at least two elements included in the first image from the layout definition information base according to the element types of the at least two elements. The layout definition information base stores a plurality of design rules set for elements, which are design rules applicable to elements in any image. For example, the adjacent elements with similar colors can not be overlapped by more than 10% of the total area of any element, the proportion of the picture elements to the whole canvas can not be more than 60%, etc.
In an alternative implementation, the element layout defining information of the first image may be a combination of common element layout defining information and element layout defining information set for the first image. The computer device may acquire first element layout definition information corresponding to element types of at least two elements included in the first image from the common element layout definition information, then remove element layout definition information having a conflict with element layout definition information in the element layout definition information set for the first image from the first element layout definition information, combine the remaining first element layout definition information with the element layout definition information set for the first image to obtain second element layout definition information, and use the second layout definition information as the element layout definition information of the first image. By combining the two element layout limiting information, the obtained at least two layout information can meet the general design rule and the design rule of at least two elements included in the first image, so that the process of generating the image is smoother, and the design style of the generated image is not changed greatly.
204. The computer device determines one layout information from the at least two layout information as target layout information.
The computer device may filter the at least two layout information according to a filter rule to determine the target layout information. The screening rule may be the size of the mutual shielding area between the elements, whether the edge elements are aligned, whether the same-tone elements are adjacent, and the like. Through setting the screening rule, the layout information which does not meet the design rule of the design drawing or does not meet the requirement can be removed, so that the target layout information meeting the requirement is obtained.
In the embodiment of the invention, the screening rule is taken as an example to describe the size of the mutual shielding area between elements. Accordingly, the steps may be: the computer equipment determines the area of mutual shielding between the elements in each piece of layout information according to at least two pieces of layout information, and takes the layout information as target layout information when the area of mutual shielding between the elements in any piece of layout information is minimum. By selecting the layout information with the smallest shielding area as the target layout information, the shielding among the elements in the finally generated image can be minimized, so that the elements can normally display the content without mutual influence.
In an alternative implementation manner, the computer device may determine, according to at least two layout information, an area of mutual occlusion between the elements in each layout information, for any layout information, the computer device determines an occlusion area of at least two elements that are randomly occluded with each other, obtains an occlusion proportion of the occlusion area to an element with a minimum area in the at least two elements, removes the layout information when the occlusion proportion between any elements in the layout information is greater than a preset proportion, and selects one layout information from the rest layout information as the target layout information. Through setting up the proportion of predetermineeing, can be with the area that shelters from each other not big between the element, but the less element of area shelters from or shelter from the screening of the overall arrangement information of most completely to each element can normally show the content.
For example, the preset ratio is 10%, the total area of the elements in the layout information M blocked from each other is 20 square centimeters, and the total area of the elements in the layout information N blocked from each other is 40 square centimeters. The element P in the layout information M shields the element Q mostly, the shielding area is 15 square centimeters, and the shielding proportion is 90%. Ten pairs of elements in the layout information N are mutually shielded, and the maximum value of shielding proportion in the ten pairs of elements is 10%. Therefore, although the total area of the layout information N in which the elements are blocked from each other is large, the layout information N is regarded as the target layout information.
It should be noted that, the filtering rule may be set according to actual needs, or multiple filtering may be performed on at least two layout information by using multiple filtering rules until the target layout information meeting the needs is obtained. For example, screening the shielding area, screening the distance between the elements, and finally screening the distance between the elements and the edge of the canvas.
205. The computer device obtains a blank canvas.
The computer device may obtain a blank canvas satisfying the target image size from existing blank canvases, or may call a canvas creation program to create a blank canvas satisfying the target image size, thereby obtaining the blank canvas.
206. The computer device adjusts at least one of a position and a size of each element in the at least two element groups according to the target layout information.
The computer device may divide the blank canvas into at least two regions, each region corresponding to an element group, for placing elements in the element group, according to the target layout information. For any element group, the computer device may adjust at least one of a position and a size of each element in the element group on the blank canvas according to a size and a shape of an area corresponding to the element group.
For example, referring to fig. 3 and 4, fig. 3 is a layout of elements in two element groups in a first image before adjustment, and fig. 4 is a layout of elements in two element groups in a blank canvas after adjustment. The size and position of each element in the two element groups are changed to adapt to the size and shape of the corresponding region of the element groups.
In an alternative implementation, the computer device may also adjust, for each element group, the size of each element within the element group and the relative position between the elements based on the element layout definition information. After adjustment based on the element layout limiting information, the elements in the element group are distributed uniformly, and the size ratio is proper.
For example, taking the case that the element layout limitation information indicates that the text elements need to be aligned in the center, as shown in fig. 5 to 7, fig. 5 is a layout of each text element in a certain text group in a first image before adjustment, and all text elements are horizontally aligned in the center, and since the area corresponding to the text group is narrowed, after the computer device adjusts according to the target layout information, fig. 6 is obtained, and in order to ensure that each text element in the text group is still aligned in the center, the computer device adjusts each text element in the text group again, so as to obtain fig. 7, and fig. 7 is a layout of each text element after the text group is adjusted based on the element layout limitation information.
In another alternative implementation, for each element group, the computer device may further obtain a first positional relationship of elements in the element group in the first image, keep the first positional relationship unchanged, and adjust a size of each element in the element group according to a size of the element group. The first position relation of the element in the first image is kept unchanged, so that the element positioned at the edge of the image is unchanged from the position of the edge of the image when the size of the element is changed, such as the name of a product at the upper right corner of the advertisement picture, and the element is more prominent.
For example, referring to fig. 8 to 10, fig. 8 shows a layout of each text element in a text group in a first image before adjustment, a distance between an upper left corner of an element a and an upper left corner of a canvas in an X-axis direction is M pixels, a distance between the element a and the canvas in a Y-axis direction is N pixels, and fig. 9 shows a layout of an element a in the text group after adjustment by a computer device according to target layout information. In order to ensure that the distance between the upper left corner of the element A and the upper left corner of the canvas in the X-axis direction is still M pixels, the distance between the element A and the upper left corner of the canvas in the Y-axis direction is still N pixels, the computer equipment adjusts the position of the element A in the text group to obtain the graph 10.
In another alternative implementation, the computer device may also determine a second positional relationship between elements within different element groups based on the element layout definition information, and adjust a position of at least one element on the blank canvas based on the second positional relationship. By adjusting the positional relationship of the elements within the different element groups based on the second positional relationship, the collocation of the different types of elements can be made more coordinated.
For example, taking the case where the element layout definition information indicates that the text element is to be aligned with the picture element as an example, as shown in fig. 11 and 12, fig. 11 is a layout of the element a, the element B, and the element D of the text group after the computer device adjusts according to the target layout information. The computer device determines that the second positional relationship of the element a, the element B, and the element D is aligned as the center according to the element layout definition information, and the computer device adjusts the element a, the element B, and the element D according to the second positional relationship, resulting in fig. 12.
207. And the computer equipment draws at least two adjusted element groups on the blank canvas according to the adjusted element positions and sizes to obtain a second image.
After the computer device adjusts the elements in the at least two element groups according to step 206, the adjusted at least two element groups are drawn on the blank canvas according to the adjusted element positions and sizes, so as to obtain the second image. The size of the second image is the target image size, when the images with multiple sizes are needed, the computer equipment can repeat the steps to sequentially generate the images with different sizes, and the computer equipment can also perform the steps in parallel by multiple threads to generate the images with different sizes.
It should be noted that, the blank canvas may also be a blank canvas with an infinite size or a size far greater than the target image size, and after the computer device draws the adjusted at least two element groups on the blank canvas, the canvas including the at least two element groups may be cut from the blank canvas according to the target image size to obtain the second image.
It should be further noted that, the foregoing steps 205 to 207 are one implementation of generating the second image by the computer device based on the target layout information and the at least two element groups, and in some embodiments, the computer device may further directly draw the elements in the at least two element groups on the blank canvas according to the target layout information to generate the second image.
According to the technical scheme provided by the embodiment of the invention, the same type of elements in at least two elements included in a first image to be adjusted are divided into the same element groups, the target image size of the image to be generated is based on element layout limiting information for limiting the position relation between the elements and the at least two element groups, at least two layout information is obtained, target layout information is obtained from the at least two layout information, the target layout information is layout information meeting design requirements, and a second image is generated based on the target layout information and the at least two element groups and is an image meeting the design requirements. At least two elements in the first image are divided into at least two element groups according to element types, the layout of the elements in the at least two element groups is limited according to at least two layout information, the layout is not limited by the size stored in a layout library and the number of layout schemes, one layout is flexibly selected from a plurality of element layouts formed by arranging and combining the elements in the at least two element groups, and therefore the layout mode of the elements in the generated image is flexible.
Fig. 13 is a block diagram of an image generating apparatus according to an embodiment of the present invention, see fig. 13, including: a dividing module 1301, a first obtaining module 1302, and a generating module 1303.
A dividing module 1301, configured to divide at least two elements included in the first image to be adjusted into at least two element groups, where each element group includes at least one element of the same type;
a first obtaining module 1302, configured to obtain at least two layout information of the first image based on the element layout definition information and at least two element groups of the first image according to the target image size, where the element layout definition information is used to define a positional relationship between any type of elements;
the first obtaining module 1302 is further configured to obtain target layout information from at least two layout information;
the generating module 1303 is configured to generate a second image based on the target layout information and at least two element groups.
In a possible implementation manner, the first obtaining module 1302 is further configured to determine, according to at least two layout information, an area of each element in each layout information that is blocked by each other; when the area of the mutual shielding between the elements in any one of the layout information is minimum, the layout information is taken as the target layout information.
In another possible implementation, the generating module 1303 is further configured to obtain a blank canvas; according to the target layout information, at least one of the position and the size of each element in at least two element groups is adjusted; and drawing elements of at least two element groups on the blank canvas according to the adjusted element positions and sizes to obtain a second image.
In another possible implementation, the apparatus further includes:
and the first adjusting module is used for adjusting the size of each element in the element group and the relative position among the elements based on the element layout limiting information for each element group.
In another possible implementation, the apparatus further includes:
the second acquisition module is used for acquiring a first position relation of elements in the element groups in the first image for each element group;
and the second adjusting module is used for keeping the first position relation unchanged and adjusting the size of each element in the element group according to the size of the element group.
In another possible implementation, the apparatus further includes:
a determining module, configured to determine a second positional relationship between elements in different element groups according to the element layout defining information;
and the third adjusting module is used for adjusting the position of at least one element on the blank canvas according to the second position relation.
According to the technical scheme provided by the embodiment of the invention, the same type of elements in at least two elements included in a first image to be adjusted are divided into the same element groups, the target image size of the image to be generated is based on element layout limiting information for limiting the position relation between the elements and the at least two element groups, at least two layout information is obtained, target layout information is obtained from the at least two layout information, the target layout information is layout information meeting design requirements, and a second image is generated based on the target layout information and the at least two element groups and is an image meeting the design requirements. At least two elements in the first image are divided into at least two element groups according to element types, the layout of the elements in the at least two element groups is limited according to at least two layout information, the layout is not limited by the size stored in a layout library and the number of layout schemes, one layout is flexibly selected from a plurality of element layouts formed by arranging and combining the elements in the at least two element groups, and therefore the layout mode of the elements in the generated image is flexible.
Fig. 14 shows a block diagram of a computer device 1400 provided in accordance with an exemplary embodiment of the present invention. The computer device 1400 may be: a smart phone, a tablet computer, an MP3 player (Moving Picture Experts Group Audio Layer III, motion picture expert compression standard audio plane 3), an MP4 (Moving Picture Experts Group Audio Layer IV, motion picture expert compression standard audio plane 4) player, a notebook computer, or a desktop computer. The computer device 1400 may also be referred to as a user device, portable terminal, laptop terminal, desktop terminal, and the like.
In general, the computer device 1400 includes: a processor 1401 and a memory 1402.
Processor 1401 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and the like. The processor 1401 may be implemented in at least one hardware form of DSP (Digital Signal Processing ), FPGA (Field-Programmable Gate Array, field programmable gate array), PLA (Programmable Logic Array ). The processor 1401 may also include a main processor, which is a processor for processing data in an awake state, also called a CPU (Central Processing Unit ), and a coprocessor; a coprocessor is a low-power processor for processing data in a standby state. In some embodiments, the processor 1401 may be integrated with a GPU (Graphics Processing Unit, image processor) for rendering and rendering of content required to be displayed by the display screen. In some embodiments, the processor 1401 may also include an AI (Artificial Intelligence ) processor for processing computing operations related to machine learning.
Memory 1402 may include one or more computer-readable storage media, which may be non-transitory. Memory 1402 may also include high-speed random access memory, as well as non-volatile memory, such as one or more magnetic disk storage devices, flash memory storage devices. In some embodiments, a non-transitory computer readable storage medium in memory 1402 is used to store at least one instruction for execution by processor 1401 to implement an image generation method provided by an embodiment of a method in the present invention.
In some embodiments, the computer device 1400 may also optionally include: a peripheral interface 1403 and at least one peripheral. The processor 1401, memory 1402, and peripheral interface 1403 may be connected by a bus or signal lines. The individual peripheral devices may be connected to the peripheral device interface 1403 via buses, signal lines or a circuit board. Specifically, the peripheral device includes: at least one of a radio frequency circuit 1404, a display screen 1405, a camera 1406, an audio circuit 1407, and a power supply 1409.
Peripheral interface 1403 may be used to connect at least one Input/Output (I/O) related peripheral to processor 1401 and memory 1402. In some embodiments, processor 1401, memory 1402, and peripheral interface 1403 are integrated on the same chip or circuit board; in some other embodiments, either or both of processor 1401, memory 1402, and peripheral interface 1403 may be implemented on separate chips or circuit boards, which is not limited in this embodiment.
The Radio Frequency circuit 1404 is configured to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuit 1404 communicates with a communication network and other communication devices via electromagnetic signals. The radio frequency circuit 1404 converts an electrical signal into an electromagnetic signal for transmission, or converts a received electromagnetic signal into an electrical signal. Optionally, the radio frequency circuit 1404 includes: antenna systems, RF transceivers, one or more amplifiers, tuners, oscillators, digital signal processors, codec chipsets, subscriber identity module cards, and so forth. The radio frequency circuit 1404 may communicate with other terminals via at least one wireless communication protocol. The wireless communication protocol includes, but is not limited to: metropolitan area networks, various generations of mobile communication networks (2G, 3G, 4G, and 5G), wireless local area networks, and/or WiFi (Wireless Fidelity ) networks. In some embodiments, the radio frequency circuit 1404 may also include NFC (Near Field Communication, short-range wireless communication) related circuits, which the present invention is not limited to.
The display screen 1405 is used to display UI (User Interface). The UI may include graphics, text, icons, video, and any combination thereof. When the display screen 1405 is a touch display screen, the display screen 1405 also has the ability to collect touch signals at or above the surface of the display screen 1405. The touch signal may be input to the processor 1401 as a control signal for processing. At this time, the display 1405 may also be used to provide virtual buttons and/or a virtual keyboard, also referred to as soft buttons and/or a soft keyboard. In some embodiments, the display 1405 may be one, providing a front panel of the computer device 1400; in other embodiments, the display 1405 may be at least two, disposed on different surfaces of the computer device 1400 or in a folded configuration; in some embodiments, the display 1405 may be a flexible display disposed on a curved surface or a folded surface of the computer device 1400. Even more, the display 1405 may be arranged in a non-rectangular irregular pattern, i.e. a shaped screen. The display 1405 may be made of LCD (Liquid Crystal Display ), OLED (Organic Light-Emitting Diode) or other materials.
The camera component 1406 is used to capture images or video. Optionally, camera assembly 1406 includes a front camera and a rear camera. Typically, the front camera is disposed on the front panel of the terminal and the rear camera is disposed on the rear surface of the terminal. In some embodiments, the at least two rear cameras are any one of a main camera, a depth camera, a wide-angle camera and a tele camera, so as to realize that the main camera and the depth camera are fused to realize a background blurring function, and the main camera and the wide-angle camera are fused to realize a panoramic shooting and Virtual Reality (VR) shooting function or other fusion shooting functions. In some embodiments, camera assembly 1406 may also include a flash. The flash lamp can be a single-color temperature flash lamp or a double-color temperature flash lamp. The dual-color temperature flash lamp refers to a combination of a warm light flash lamp and a cold light flash lamp, and can be used for light compensation under different color temperatures.
The audio circuitry 1407 may include a microphone and a speaker. The microphone is used for collecting sound waves of users and the environment, converting the sound waves into electric signals, and inputting the electric signals to the processor 1401 for processing, or inputting the electric signals to the radio frequency circuit 1404 for voice communication. For purposes of stereo acquisition or noise reduction, the microphone may be multiple, each disposed at a different location of the computer device 1400. The microphone may also be an array microphone or an omni-directional pickup microphone. The speaker is used to convert electrical signals from the processor 1401 or the radio frequency circuit 1404 into sound waves. The speaker may be a conventional thin film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, not only the electric signal can be converted into a sound wave audible to humans, but also the electric signal can be converted into a sound wave inaudible to humans for ranging and other purposes. In some embodiments, audio circuitry 1407 may also include a headphone jack.
The power supply 1409 is used to power the various components in the computer device 1400. The power supply 1409 may be an alternating current, a direct current, a disposable battery, or a rechargeable battery. When the power supply 1409 includes a rechargeable battery, the rechargeable battery may support wired or wireless charging. The rechargeable battery may also be used to support fast charge technology.
In some embodiments, computer device 1400 also includes one or more sensors 1410. The one or more sensors 1410 include, but are not limited to: acceleration sensor 1411, gyro sensor 1412, pressure sensor 1413, optical sensor 1415, and proximity sensor 1416.
The acceleration sensor 1411 may detect the magnitudes of accelerations on three coordinate axes of a coordinate system established with the computer device 1400. For example, the acceleration sensor 1411 may be used to detect components of gravitational acceleration in three coordinate axes. The processor 1401 may control the display screen 1405 to display a user interface in a landscape view or a portrait view according to the gravitational acceleration signal acquired by the acceleration sensor 1411. The acceleration sensor 1411 may also be used for the acquisition of motion data of a game or a user.
The gyro sensor 1412 may detect the body direction and the rotation angle of the computer apparatus 1400, and the gyro sensor 1412 may collect the 3D motion of the user to the computer apparatus 1400 in cooperation with the acceleration sensor 1411. The processor 1401 may implement the following functions based on the data collected by the gyro sensor 1412: motion sensing (e.g., changing UI according to a tilting operation by a user), image stabilization at shooting, game control, and inertial navigation.
The pressure sensor 1413 may be disposed on a side frame of the computer device 1400 and/or on an underside of the display screen 1405. When the pressure sensor 1413 is disposed at a side frame of the computer device 1400, a user's grip signal to the computer device 1400 may be detected, and the processor 1401 performs a left-right hand recognition or a quick operation according to the grip signal collected by the pressure sensor 1413. When the pressure sensor 1413 is disposed at the lower layer of the display screen 1405, the processor 1401 realizes control of the operability control on the UI interface according to the pressure operation of the user on the display screen 1405. The operability controls include at least one of a button control, a scroll bar control, an icon control, and a menu control.
The optical sensor 1415 is used to collect the ambient light intensity. In one embodiment, processor 1401 may control the display brightness of display screen 1405 based on the intensity of ambient light collected by optical sensor 1415. Specifically, when the intensity of the ambient light is high, the display luminance of the display screen 1405 is turned high; when the ambient light intensity is low, the display luminance of the display screen 1405 is turned down. In another embodiment, the processor 1401 may also dynamically adjust the shooting parameters of the camera assembly 1406 based on the ambient light intensity collected by the optical sensor 1415.
A proximity sensor 1416, also known as a distance sensor, is typically provided on the front panel of the computer device 1400. The proximity sensor 1416 is used to capture the distance between the user and the front of the computer device 1400. In one embodiment, when the proximity sensor 1416 detects a gradual decrease in the distance between the user and the front of the computer device 1400, the processor 1401 controls the display 1405 to switch from the on-screen state to the off-screen state; when the proximity sensor 1416 detects that the distance between the user and the front of the computer device 1400 gradually increases, the display 1405 is controlled by the processor 1401 to switch from the off-screen state to the on-screen state.
Those skilled in the art will appreciate that the architecture shown in fig. 14 is not limiting as to the computer device 1400, and may include more or fewer components than shown, or may combine certain components, or employ a different arrangement of components.
The embodiment of the invention also provides a storage medium applied to a computer device, wherein the storage medium stores a program code for executing the image generating method of the above embodiment.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program for instructing relevant hardware, where the program may be stored in a storage medium, and the storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The foregoing description of the preferred embodiments of the invention is not intended to limit the invention to the precise form disclosed, and any such modifications, equivalents, and alternatives falling within the spirit and scope of the invention are intended to be included within the scope of the invention.

Claims (14)

1. An image generation method, the method comprising:
acquiring a first image to be adjusted, wherein the first image is a design drawing source file, the design drawing source file comprises drawing layer information of a plurality of drawing layers and the sizes of elements included in each drawing layer, the drawing layer information is used for indicating elements corresponding to each drawing layer and corresponding element group identifiers, and the element group identifiers are used for indicating element groups to which the elements corresponding to each drawing layer belong;
dividing elements corresponding to layers with the same element group identification in the first image into the same element group according to layer information of a plurality of layers in the first image to obtain at least two element groups, wherein each element group comprises at least one element with the same type;
acquiring first element layout limiting information from common element layout limiting information, wherein the first element layout limiting information corresponds to element types of at least two elements included in the first image, the common element layout limiting information comprises at least one of position, size, color, overlapping and proportion, and the common element layout limiting information also comprises design rules set by at least one of tolerance items, random items and quantization items of other dimensions as elements;
Removing element layout definition information having a conflict with element layout definition information set for the first image from among the first element layout definition information;
combining the remaining first element layout limiting information with the element layout limiting information set for the first image to obtain second element layout limiting information;
acquiring at least two layout information of the first image based on the second element layout definition information and the at least two element groups according to a target image size;
acquiring target layout information from the at least two pieces of layout information;
a second image is generated based on the target layout information and the at least two element groups.
2. The method of claim 1, wherein the obtaining target layout information from the at least two layout information comprises:
determining the area of the mutual shielding between the elements in each layout information according to the at least two layout information;
and when the area of the mutual shielding between the elements in any piece of layout information is minimum, taking the layout information as target layout information.
3. The method of claim 1, wherein the generating a second image based on the target layout information and the at least two element groups comprises:
Acquiring a blank canvas;
according to the target layout information, at least one of the position and the size of each element in the at least two element groups is adjusted;
and drawing the elements of the at least two element groups on the blank canvas according to the adjusted element positions and sizes to obtain a second image.
4. The method of claim 3, wherein after adjusting at least one of the position and the size of each element in the at least two element groups according to the target layout information, the method further comprises:
for each element group, adjusting the size of each element and the relative position between elements in the element group based on the element layout definition information.
5. The method of claim 3, wherein after adjusting at least one of the position and the size of each element in the at least two element groups according to the target layout information, the method further comprises:
for each element group, acquiring a first position relation of elements in the element group in the first image;
and keeping the first position relation unchanged, and adjusting the size of each element in the element group according to the size of the element group.
6. The method according to any one of claims 3 to 5, wherein after adjusting at least one of the positions and sizes of the respective elements in the at least two element groups according to the target layout information, the method further comprises:
determining a second positional relationship between elements in different element groups according to the element layout limiting information;
and adjusting the position of at least one element on the blank canvas according to the second position relation.
7. An image generation apparatus, the apparatus comprising:
the dividing module is used for acquiring a first image to be adjusted, wherein the first image is a design drawing source file, the design drawing source file comprises drawing layer information of a plurality of drawing layers, the size and the size of elements included in each drawing layer, the drawing layer information is used for indicating elements corresponding to each drawing layer and corresponding element group identifiers, and the element group identifiers are used for indicating element groups to which the elements corresponding to each drawing layer belong; dividing elements corresponding to layers with the same element group identification in the first image into the same element group according to layer information of a plurality of layers in the first image to obtain at least two element groups, wherein each element group comprises at least one element with the same type;
A first obtaining module, configured to obtain first element layout limitation information from common element layout limitation information, where the first element layout limitation information corresponds to element types of at least two elements included in the first image, the common element layout limitation information includes at least one of a position, a size, a color, an overlap, and a proportion, and the common element layout limitation information further includes a design rule set by at least one of a tolerance term, a random term, and a quantization term of other dimensions as an element; removing element layout definition information having a conflict with element layout definition information set for the first image from among the first element layout definition information; combining the remaining first element layout limiting information with the element layout limiting information set for the first image to obtain second element layout limiting information; acquiring at least two layout information of the first image based on the second element layout definition information and the at least two element groups according to a target image size, wherein the element layout definition information is used for defining a position relation between any type of elements;
the first obtaining module is further configured to obtain target layout information from the at least two layout information;
And a generation module for generating a second image based on the target layout information and the at least two element groups.
8. The apparatus of claim 7, wherein the first obtaining module is further configured to determine, according to the at least two layout information, an area of each of the layout information that is blocked by each of the elements; and when the area of the mutual shielding between the elements in any piece of layout information is minimum, taking the layout information as target layout information.
9. The apparatus of claim 7, wherein the generating module is further configured to obtain a blank canvas; according to the target layout information, at least one of the position and the size of each element in the at least two element groups is adjusted; and drawing the elements of the at least two element groups on the blank canvas according to the adjusted element positions and sizes to obtain a second image.
10. The apparatus of claim 9, wherein the apparatus further comprises:
and the first adjusting module is used for adjusting the size of each element in the element group and the relative position among the elements based on the element layout limiting information for each element group.
11. The apparatus of claim 9, wherein the apparatus further comprises:
a second obtaining module, configured to obtain, for each element group, a first positional relationship of elements in the element group in the first image;
and the second adjusting module is used for keeping the first position relation unchanged and adjusting the size of each element in the element group according to the size of the element group.
12. The apparatus according to any one of claims 9 to 11, further comprising:
a determining module, configured to determine a second positional relationship between elements in different element groups according to the element layout defining information;
and the third adjusting module is used for adjusting the position of at least one element on the blank canvas according to the second position relation.
13. A computer device comprising a processor and a memory for storing program code that is loaded and executed by the processor to implement the operations performed in the image generation method of any of claims 1 to 6.
14. A storage medium having stored therein a program code for executing the image generation method of any one of claims 1 to 6.
CN201910533812.5A 2019-06-19 2019-06-19 Image generation method, device, computer equipment and storage medium Active CN112116681B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910533812.5A CN112116681B (en) 2019-06-19 2019-06-19 Image generation method, device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910533812.5A CN112116681B (en) 2019-06-19 2019-06-19 Image generation method, device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN112116681A CN112116681A (en) 2020-12-22
CN112116681B true CN112116681B (en) 2023-07-25

Family

ID=73795553

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910533812.5A Active CN112116681B (en) 2019-06-19 2019-06-19 Image generation method, device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112116681B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112783392A (en) * 2021-01-29 2021-05-11 展讯通信(上海)有限公司 Information screen display method and device
CN113642059A (en) * 2021-08-10 2021-11-12 稿定(厦门)科技有限公司 Size expanding method and device for planar design
CN116679924A (en) * 2022-02-22 2023-09-01 华为技术有限公司 Processing method of user interface of application program and related equipment

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9317175B1 (en) * 2013-09-24 2016-04-19 Amazon Technologies, Inc. Integration of an independent three-dimensional rendering engine
CN109271075A (en) * 2018-09-06 2019-01-25 天津字节跳动科技有限公司 Page elements autoplacement method and device

Family Cites Families (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070255616A1 (en) * 2006-04-27 2007-11-01 Microsoft Corporation Techniques for authoring ads for dynamic layout environments
US8862986B2 (en) * 2007-10-01 2014-10-14 Hewlett-Packard Development Company, L.P. Arranging graphic objects on a page with relative position based control
JP5830055B2 (en) * 2013-05-31 2015-12-09 京セラドキュメントソリューションズ株式会社 Image processing apparatus and image processing system
US10127327B2 (en) * 2014-05-21 2018-11-13 Adobe Systems Incorporated Cloud-based image processing web service
CN105550980B (en) * 2014-10-29 2018-11-27 阿里巴巴集团控股有限公司 A kind of Picture Generation Method and relevant apparatus
US10002451B2 (en) * 2015-01-15 2018-06-19 Qualcomm Incorporated Text-based image resizing
US20190026929A1 (en) * 2017-07-19 2019-01-24 Microsoft Technology Licensing, Llc Organizing images automatically into image grid layout
US20190156537A1 (en) * 2017-11-21 2019-05-23 Logojoy Inc. Method of digital design generation
CN109271604B (en) * 2018-09-27 2023-05-23 三六零科技集团有限公司 Advertisement layout method and device and computer equipment
CN109857388B (en) * 2019-01-10 2021-06-15 北京城市网邻信息技术有限公司 Code generation method, device, server and computer readable medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9317175B1 (en) * 2013-09-24 2016-04-19 Amazon Technologies, Inc. Integration of an independent three-dimensional rendering engine
CN109271075A (en) * 2018-09-06 2019-01-25 天津字节跳动科技有限公司 Page elements autoplacement method and device

Also Published As

Publication number Publication date
CN112116681A (en) 2020-12-22

Similar Documents

Publication Publication Date Title
CN110427110B (en) Live broadcast method and device and live broadcast server
CN112116681B (en) Image generation method, device, computer equipment and storage medium
CN109948581B (en) Image-text rendering method, device, equipment and readable storage medium
CN110321126B (en) Method and device for generating page code
WO2022134632A1 (en) Work processing method and apparatus
CN112230908B (en) Method and device for aligning components, electronic equipment and storage medium
CN110928464A (en) User interface display method, device, equipment and medium
CN111694478A (en) Content display method, device, terminal and storage medium
CN111539795A (en) Image processing method, image processing device, electronic equipment and computer readable storage medium
CN111353946B (en) Image restoration method, device, equipment and storage medium
CN112825040A (en) User interface display method, device, equipment and storage medium
CN112750190B (en) Three-dimensional thermodynamic diagram generation method, device, equipment and storage medium
CN110992268B (en) Background setting method, device, terminal and storage medium
CN112717393B (en) Virtual object display method, device, equipment and storage medium in virtual scene
CN112612405B (en) Window display method, device, equipment and computer readable storage medium
CN113240784B (en) Image processing method, device, terminal and storage medium
CN110335224B (en) Image processing method, image processing device, computer equipment and storage medium
CN113535039A (en) Method and device for updating page, electronic equipment and computer readable storage medium
CN112231619A (en) Conversion method, conversion device, electronic equipment and storage medium
CN113608649B (en) Method, device, equipment and readable storage medium for displaying sliding list
CN113205582B (en) Method, device, equipment and medium for generating and using baking paste chart
CN115379274B (en) Picture-based interaction method and device, electronic equipment and storage medium
CN110201392B (en) User interface generation method, device and terminal
CN113763486B (en) Dominant hue extraction method, device, electronic equipment and storage medium
CN112230828B (en) Component layout method and device and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40035337

Country of ref document: HK

SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant