Method and apparatus for synthesizing images
By receiving attribute information input by users, obtaining and migrating style packages, and generating picture combination knowledge scripts, it solves the problem of low efficiency and high cost of picture design in e-commerce page decoration, realizes the rapid generation of rich and beautiful pictures, and reduces learning costs. Sample set requirements.
Patent Information
- Application Number
- CN202110218004.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-26
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2041-02-26
AI Technical Summary
In the existing technology, when decorating e-commerce pages, manually designing pictures is time-consuming and labor-intensive, and the efficiency is low. Moreover, it is difficult to accurately control the position and semantic relationship of pictures synthesized by machine learning, which requires a large number of sample picture training sets and is costly.
By receiving the synthetic image attribute information input by the user, the matching skeleton is obtained, the style package is searched and migrated, the composition knowledge script is generated, composition, material loading, color matching and composition are performed, and the recursive migration relationship and pre-established functions are used to perform image elements Position, size and color processing to achieve rapid image generation.
It realizes the rapid generation of rich and beautiful pictures that meet user needs, reduces the learning sample set, improves efficiency and cost-effectiveness, and can handle complex compositions and multiple theme styles.
Smart Images

Figure CN113822957B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to the field of computer technology, and more particularly to a method and device for synthesizing images. Background Art
[0002] In the process of e-commerce page decoration, a large number of graphic web design pictures are needed, and for different users, pages of interest to users need to be generated in real time according to user preferences to achieve the ability to have thousands of faces for thousands of people. If the design of the pictures is completely dependent on manual design, it will be time-consuming and labor-intensive, costly, and inefficient, and cannot meet the needs of real-time picture merging. Through machine merging, a large number of beautiful pictures with rich content that meet the user's theme, size, and text requirements can be generated with one click, providing users with a variety of choices, with almost zero cost, high efficiency, and rapid satisfaction of users' various needs.
[0003] The existing technology can synthesize pictures through manually edited scripts, but the efficiency is low. Each script is only for the synthesis of pictures with content in a specific format and scene, and it is difficult to be compatible with different scenes.
[0004] Existing technologies can synthesize images through machine learning and deep learning, but cannot accurately control the position, size, etc. of the image primitives (short for image elements) in the image. At the same time, they cannot understand the semantic relationship between the image primitives in the image, and require a large number of sample image training sets, which is costly. Summary of the invention
[0005] Embodiments of the present disclosure provide a method and apparatus for synthesizing images.
[0006] In a first aspect, an embodiment of the present disclosure provides a method for synthesizing images, comprising: receiving attribute information of a synthesized image input by a user; obtaining a skeleton matching the attribute information; searching for a style package under the skeleton, and then migrating the style package according to a recursive migration relationship to generate a combined image knowledge script; composing an image according to the position and size information of the picture elements of the synthesized image specified in the combined image knowledge script; loading the content of the picture elements of the synthesized image according to the material specified in the combined image knowledge script; coloring the picture elements of the synthesized image according to the color specified in the combined image knowledge script; and combining the image according to the layers specified in the combined image knowledge script.
[0007] In some embodiments, the attribute information includes a subject, a title, a product image, and an image size of the product image.
[0008] In some embodiments, the style package includes a composition package, a scene package, a color package, and a layer package.
[0009] In some embodiments, the migrating the style package according to the recursive migration relationship to generate a combined picture knowledge script includes: migrating the theme of the style package according to the theme to generate a combined picture knowledge script for specifying the material; determining the title type of the style package according to the title, and migrating the style of the title according to the title type to generate a combined picture knowledge script for modifying the title; migrating the composition package of the style package according to the product image and the image size of the product image to generate a combined picture knowledge script for modifying the skeleton.
[0010] In some embodiments, migrating the style package according to the recursive migration relationship to generate a combined graph knowledge script includes: obtaining a migrator, wherein the directory of the migrator is divided into five layers of directories: skeleton, style, title, theme, and mode, and all packages in the directory support incremental migration; searching for the migration path of each package node in each layer of the directory; obtaining the package node migration path from the upper layer to the lower layer through generalization of a predetermined tree structure reasoning; establishing a package manager according to the package node migration path, and generating a combined graph knowledge script for using the package manager.
[0011] In some embodiments, the migrating the style package according to the recursive migration relationship to generate a combined image knowledge script includes: inputting the aspect ratio of the picture elements of the composite image into a pre-established regression function to obtain the positions of the picture elements of the composite image, and generating a combined image knowledge script for specifying the positions of the picture elements; inputting the aspect ratio of the picture elements of the composite image into a pre-established size adaptive adjustment function to obtain the size information of the picture elements of the composite image, and generating a combined image knowledge script for specifying the size information of the picture elements.
[0012] In some embodiments, the method further includes: performing pixel interpolation on picture elements of the composite image according to a pre-established deformation function, and generating a composite image knowledge script for specifying the position and pixel value of the inserted pixel.
[0013] In some embodiments, color matching is performed on the picture elements of the composite image, including: obtaining at least one configured color value and the proportion of each color according to the composite image knowledge script; inputting the at least one color value and the proportion of each color into a pre-trained machine color matching function to predict the next color value to be matched.
[0014] In some embodiments, the method further includes: establishing an edge probability field for the text of the title; calculating the contrast of the background image as the edge probability field changes, and generating a combined image knowledge script for specifying the contrast.
[0015] In a second aspect, an embodiment of the present disclosure provides a device for synthesizing images, comprising: a receiving unit, configured to receive attribute information of a synthesized image input by a user; a matching unit, configured to obtain a skeleton matching the attribute information; a migration unit, configured to search for a style package under the skeleton, and then migrate the style package according to a recursive migration relationship to generate a combined image knowledge script; a composition unit, configured to compose according to the position and size information of the picture elements of the synthesized image specified in the combined image knowledge script; a material selection unit, configured to load the content of the picture elements of the synthesized image with the specified material; a color matching unit, configured to match the colors of the picture elements of the synthesized image; and a combining unit, configured to combine the images according to the hierarchical relationship of the picture elements of the synthesized image.
[0016] In some embodiments, the attribute information includes a subject, a title, a product image, and an image size of the product image.
[0017] In some embodiments, the style package includes a composition package, a scene package, a color package, and a layer package.
[0018] In some embodiments, the migration unit is further configured to: migrate the theme of the style package according to the theme, and generate a combined picture knowledge script for specifying the material; determine the title type of the style package according to the title, and migrate the style of the title according to the title type, and generate a combined picture knowledge script for modifying the title; migrate the composition package of the style package according to the product picture and the picture size of the product picture, and generate a combined picture knowledge script for modifying the skeleton.
[0019] In some embodiments, the migration unit is further configured to: obtain a migrator, wherein the directory of the migrator is divided into five levels of directories: skeleton, style, title, theme, and mode, and all packages in the directory support incremental migration; search for a migration path for each package node in each level of the directory; obtain the package node migration path from the upper level to the lower level through generalization of a predetermined tree structure reasoning; establish a package manager based on the package node migration path, and generate a composite graph knowledge script for using the package manager.
[0020] In some embodiments, the migration unit is further configured to: input the aspect ratio of the picture elements of the composite image into a pre-established regression function to obtain the position of the picture elements of the composite image, and generate a combined image knowledge script for specifying the position of the picture elements; input the aspect ratio of the picture elements of the composite image into a pre-established size adaptive adjustment function to obtain the size information of the picture elements of the composite image, and generate a combined image knowledge script for specifying the size information of the picture elements.
[0021] In some embodiments, the migration unit is further configured to: perform pixel interpolation on the picture elements of the composite image according to a pre-established deformation function, and generate a composite image knowledge script for specifying the position and pixel value of the inserted pixel.
[0022] In some embodiments, the migration unit is further configured to: obtain at least one configured color value and the proportion of each color; input the at least one color value and the proportion of each color into a pre-trained machine color matching function, predict the next color value to be matched, and generate a composite image knowledge script for specifying the color of image elements.
[0023] In some embodiments, the migration unit is further configured to: establish an edge probability field for the text of the title; calculate the contrast of the background image as the edge probability field changes, and generate a combined image knowledge script for specifying the contrast.
[0024] In a third aspect, an embodiment of the present disclosure provides an electronic device for synthesizing images, comprising: one or more processors; a storage device on which one or more programs are stored, and when the one or more programs are executed by the one or more processors, the one or more processors implement a method as described in any one of the first aspects.
[0025] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable medium having a computer program stored thereon, wherein when the program is executed by a processor, the method as described in any one of the first aspects is implemented.
[0026] The method and device for synthesizing images provided by the embodiments of the present disclosure can realize compositions of any complexity by continuous recursion from the simplest composite image structure, migrate knowledge layer by layer, incrementally assign knowledge to scripts, nest and reuse knowledge to the maximum extent, generalize the logic of knowledge into symbols, perform parameter optimization learning under a certain logical framework through symbolic system reasoning, greatly reduce the sample set for learning, and make the framework compatible with both knowledge empowerment and learning and training capabilities, and ultimately generalize and synthesize a large number of pictures with rich content and beautiful styles. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Other features, objects and advantages of the present disclosure will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:
[0028] Figure 1 is an exemplary system architecture diagram in which an embodiment of the present disclosure may be applied;
[0029] Figure 2 is a flow chart of one embodiment of a method for synthesizing images according to the present disclosure;
[0030] Figures 3a-3s is a schematic diagram of a style pack migration process of a method for synthesizing an image according to the present disclosure;
[0031] Figure 4a-4h is a schematic diagram of a picture element size adjustment process of a method for synthesizing images according to the present disclosure;
[0032] Figure 5a-5d is a schematic diagram of a picture color matching process of a method for synthesizing an image according to the present disclosure;
[0033] Figure 6 is a structural schematic diagram of an embodiment of a device for synthesizing images according to the present disclosure;
[0034] Figure 7 It is a structural diagram of a computer system of an electronic device suitable for implementing an embodiment of the present disclosure. DETAILED DESCRIPTION
[0035] The present disclosure is further described in detail below in conjunction with the accompanying drawings and embodiments. It is understood that the specific embodiments described herein are only used to explain the relevant invention, rather than to limit the invention. It is also necessary to explain that, for ease of description, only the parts related to the relevant invention are shown in the accompanying drawings.
[0036] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present disclosure may be combined with each other. The present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0037] Figure 1 An exemplary system architecture 100 is shown to which embodiments of the method for synthesizing an image or the apparatus for synthesizing an image of the present disclosure may be applied.
[0038] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0039] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as image synthesis applications, web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0040] Terminal devices 101, 102, 103 can be hardware or software. When terminal devices 101, 102, 103 are hardware, they can be various electronic devices with display screens and supporting image browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III, Moving Picture Experts Group Audio Layer 3), MP4 (Moving Picture Experts Group Audio Layer IV, Moving Picture Experts Group Audio Layer 4) players, laptop computers and desktop computers, etc. When terminal devices 101, 102, 103 are software, they can be installed in the electronic devices listed above. It can be implemented as multiple software or software modules (for example, to provide distributed services), or it can be implemented as a single software or software module. No specific limitation is made here.
[0041] The server 105 may be a server that provides various services, such as a background image synthesis server that provides support for images displayed on the terminal devices 101, 102, and 103. The background image synthesis server may analyze and process the received image synthesis request (which may include attribute information of the synthesized image, such as the theme, title, product image, and image size of the product image), and feed back the processing result (such as the synthesized image) to the terminal device.
[0042] It should be noted that the server can be hardware or software. When the server is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or it can be implemented as a single server. When the server is software, it can be implemented as multiple software or software modules (for example, multiple software or software modules used to provide distributed services), or it can be implemented as a single software or software module. No specific limitation is made here. The server can also be a server of a distributed system, or a server combined with a blockchain. The server can also be a cloud server, or an intelligent cloud computing server or intelligent cloud host with artificial intelligence technology.
[0043] It should be noted that the method for synthesizing images provided in the embodiments of the present disclosure is generally executed by the server 105 , and accordingly, the device for synthesizing images is generally disposed in the server 105 .
[0044] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0045] Continue to refer Figure 2, shows a process 200 of an embodiment of a method for synthesizing an image according to the present disclosure. The method for synthesizing an image comprises the following steps:
[0046] Step 201: receiving attribute information of a composite image input by a user.
[0047] In this embodiment, the execution subject of the method for synthesizing an image (eg Figure 1 The server shown in the figure can receive attribute information of the composite image input by the user from the terminal using which the user composites the image through a wired connection or a wireless connection. The attribute information may include a subject and a title. The attribute information may also include a product (SKU) image and the image size of the product image. There may be multiple titles, and the titles may be multi-level titles.
[0048] Step 202: Obtain a skeleton that matches the attribute information.
[0049] In this embodiment, the concept of skeleton is proposed. All elements in the picture are based on the skeleton. The skeleton determines the main structure of the picture. Other elements adjust their positions and sizes around the skeleton. The simplest skeleton structure is as follows: Figure 3a As shown, it consists of a background and a line of text. The matching skeleton can be found according to the content of the subject and the number of titles. For example, if the user enters the subject "cosmetics" and two titles of the same level, the skeleton with a level 2 title and the subject "cosmetics" can be found.
[0050] Step 203, searching for the style package under the skeleton, and then migrating the style package according to the recursive migration relationship to generate a combined graph knowledge script.
[0051] In this embodiment, the parameters of the skeleton may be determined by a style package, which may include a composition package, a scene package, a color package, and a layer package.
[0052] The synthesis of a picture consists of four major functions: composition, scene, color matching, and layer. Composition is responsible for the size and position of elements. Scene construction is responsible for the content of picture elements and assembles elements that conform to the style of the theme content. Color matching is to match the colors of all elements so that the synthesized picture effect has harmonious and consistent colors and is beautiful. Layers are responsible for the hierarchical relationship of all elements. You can directly use layer packages with the same type of theme and the same type and number of titles to write the synthesis knowledge script.
[0053] The knowledge of composition package is as follows Figure 3b As shown, the class is defined Figure 3a The initial values of the spring parameters are defined as parameter variables ParamVar. These parameter values can be learned and regressed according to the parameters in the sample set to further optimize the parameters.
[0054] The knowledge configuration of the scene package is as follows Figure 3c As shown, class 2, class 3, and class 4 in the scene package are migrated from class 1. The material type of the background is specified in class 1. Class 2 and class 3 modify the background of class 1, and class 4 modifies the title of class 1.
[0055] The scene package materials are obtained from the material manager. The structure of the material manager is as follows: Figure 3d As shown, the materials are classified and managed from large to small, so that the granularity of the searched materials can be large or small, which can ensure the richness of the combined image effect and improve the matching degree of the user input conditions.
[0056] The configuration of the color pack is as follows Figure 3e As shown, class 1 defines the hue variable of the background, and then converts the background into the hue of the background. The color of title one is the contrast color of the background. In class 2, the color of title one is changed to white. turnHue(hue) converts the background into the hue of hue. contrast contrasts the color of title one with the background color. p1 is an adjustment parameter in the comparison process, and p2 is also an adjustment parameter.
[0057] Migrate the style package according to the recursive migration relationship and generate a composite picture knowledge script, including: migrate the theme of the style package according to the theme to generate a composite picture knowledge script for specifying the material; determine the title type of the style package according to the title, and migrate the style of the title according to the title type to generate a composite picture knowledge script for modifying the title; migrate the composition package of the style package according to the product image and the image size of the product image to generate a composite picture knowledge script for modifying the skeleton. Knowledge can be understood as some generalizable key, value configuration files, and scripts are actions that execute these configurations, that is, actual actions. In some cases, you only need to modify the script instead of the code.
[0058] After realizing the functions of composition, scene, color matching, and layer, you need to realize pictures with multiple themes. First, use the above packages to combine a general style package, and then create multiple theme packages such as cosmetics, clothing, etc. through migration. Figure 3f As shown. The migration process is to retain the same content, modify different content, and add missing content. The whole process is recursive from simple to complex, with incremental modifications to maximize the reuse of existing knowledge. However, there is no deletion operation in the entire migration process, and all operations are incremental additions. Generate a combined picture knowledge script for specifying materials. The key of the combined picture knowledge script here is the theme, and the value is configured according to the material manager of the scene package that matches the theme. Materials corresponding to different themes can be machine-learned based on existing design specifications. Therefore, the material can be determined based on the theme entered by the user and written into the combined picture knowledge script.
[0059] The above realizes the ability to combine pictures of all themes of the simplest skeleton, and then adds multi-line titles on this basis, such as Figure 3g As shown, add sub-skeletons of Title 2 and Title 3. Title 2 adds f and h based on the previous parameters, and Title 3 adds parameters i and j based on Title 2. Generate a combined picture knowledge script for modifying the title. The key of the combined picture knowledge script here is the title, and the value is set according to the composition package that matches the title.
[0060] Therefore, we incrementally migrate the first package of title, add f and h as the second package of title, and add i and j as the third package of title. The parameter configuration process is as follows: Figure 3h shown.
[0061] After determining the title type, the next step is to migrate the style, including the extension of the title style and the extension of the modifying elements, such as adding corner elements, side elements, and multiple styles of corner and side element combinations. Figure 3i As shown, first expand the title style, then expand the decorative elements, and the last step is to increase the migration of floating elements.
[0062] After the skeleton is extended with elements and styles, the migration and extension of the skeleton structure is further realized, such as Figure 3j As shown, you need to generate a structure with horizontal and vertical versions of product (SKU) pictures. You can choose one of them, depending on the aspect ratio of the picture. Generate a combined picture knowledge script for modifying the skeleton. The key of the combined picture knowledge script here is the skeleton, and the value is set according to the composition package that matches the title, the scene package that matches the theme, and the color package.
[0063] right Figure 3j The structure shown in the figure is expanded by adding the following parameters to the package: Figure 3k shown.
[0064] Migration is equivalent to a process of dimensionality increase. In the nth layer, all packages have their own inheritance relationship. When recursively pushing to the n+1th layer, all or part of the packages in the Nth layer will be copied, modified and added. Figure 3l shown.
[0065] During the dimension upgrade process, some node packages of the lower layer will be copied, so the lower layer nodes are logically grouped and only the logical groups that meet the conditions are migrated. Figure 3m As shown, styles 1, 2, and 3 are partial migrations of the basic style.
[0066] Similarly, the migration of skeletons is the migration of high-dimensional tensor packages, and skeleton n+1 is the partial modification, copying, and addition of skeleton n, such as Figure 3nAs shown in the figure, all packages in skeleton n, which are divided into three dimensions, title style, content style, and theme type, are migrated to skeleton n+1. Only a small amount of modification is needed to complete the style package with rich content of the entire skeleton. Both title style and content style have basic styles, and some floating elements are added to the basic styles, or a rich style category with multiple decorative elements is added.
[0067] The migrator can be used to migrate style packages. The generated composite picture knowledge script specifies the skeleton, style, title, theme, and mode. This information determines the position and size information, material, color, and layer of the image elements. The entire migrator directory is divided into five levels: skeleton, style, title, theme, and mode. All packages in the directory can be migrated incrementally. Assume that the mutual migration relationship between packages in each level of the directory is as follows: Figure 3o shown.
[0068] The next step is to search the migration path for each package node in each directory layer. Assume that the path relationship of each package node is as follows: Figure 3p As shown, all paths are equivalent to a node.
[0069] The last step is to generalize the migration paths of all package nodes from the upper layer to the lower layer through the predetermined tree structure reasoning, such as Figure 3q As shown, Figure 3p The equivalent nodes in the layer can be connected arbitrarily between layers. If the logical group is specified, the connection of the lower layer node packets is performed according to the logical group. Figure 3q The dotted lines in the figure represent the connections of invalid logic groups. This generalization method is used to achieve dimensionality increase of the packet migration path.
[0070] After using the above incremental migration process, multiple levels of package knowledge will be generated. In order to quickly obtain the style package results that meet the user input conditions during the merging process, it is necessary to establish a manager for these packages and directly retrieve the corresponding style packages based on the merging conditions. The entire catalog retrieval process is as follows: Figure 3r After retrieving the corresponding package, register it with the package manager as follows Figure 3r shown. Figure 3q The dotted line in the middle does not require registration. Generate a combined graph knowledge script for using the package manager so that the style package can be directly searched and used after registration.
[0071] The styles of some graphics elements are often reused, so these graphics element styles are defined as components (which can be called in the combined graphics knowledge script) to facilitate nested calls during the combined graphics process, such as Figure 3s As shown, the title package is migrated, and the composition, color, and scene all use style 1 components. The keyword call is used to call the component, and the corresponding composition and color parameters need to be passed in for the component.
[0072] In some optional implementations of the present embodiment, the style package is migrated according to the recursive migration relationship to generate a combined image knowledge script, including: inputting the aspect ratio of the picture elements of the composite image into a pre-established regression function to obtain the positions of the picture elements of the composite image, and generating a combined image knowledge script for specifying the positions of the picture elements; inputting the aspect ratio of the picture elements of the composite image into a pre-established size adaptive adjustment function to obtain the size information of the picture elements of the composite image, and generating a combined image knowledge script for specifying the size information of the picture elements.
[0073] The specific process is as follows: To realize a combined image of any size, it is necessary to determine the size of each element for any aspect ratio. This application establishes a continuous regression function for the size and aspect ratio of each element. According to the given parameter set points, the regression curve is learned to calculate the size of each element of any input size. The skeleton parameter vector with sku picture in the previous section is shown in the following formula.
[0074] P=[a, b, c, d, e, f, h, e, f, k, aa, bb, cc, dd, ee]
[0075] Use quadratic function as regression function
[0076] y=ax 2 +bx+c
[0077] Any component in the P vector is used as y, and the aspect ratio of the image input is used as x.
[0078] c=y-ax 2 -bx
[0079] Substitute all points (x, y) in the learning sample set into the above formula. Using the three-dimensional cube voting method, select the first n cubes with the most votes to obtain the parameters of multiple regression curves. The voting three-dimensional grid is as follows Figure 4a shown.
[0080] After obtaining the n grids with the largest voting grid weights, multiple n regression curves can be obtained. Figure 4b shown.
[0081] If the length of the title text input is too long, the maximum width ratio of the text needs to be limited. Therefore, this value is also regressed with the aspect ratio. For example Figure 4c shown.
[0082] After regression, all the previous parameter values are obtained by calculating the aspect ratio based on the product image size input by the user, and then all the values are normalized in the y direction or the x direction. For example, the normalization of a in the y direction is as follows.
[0083]
[0084] The data set required by the above model is obtained by the following three methods. The first is to obtain it by manual configuration, which is directly added to the composition script based on the designer's experience. The second is to match the skeleton from a large number of annotated design templates and then obtain the corresponding parameter data set. The third method is to generate a PSD image after the combination and save it after the designer modifies it. The regression model is learned through these three types of data. The processes of the three methods are as follows: Figure 4d shown.
[0085] The corner elements of the image are adaptively adjusted according to the skeleton size. The position of the corner elements in the image is as follows: Figure 4e shown.
[0086] The adaptive adjustment process of corner elements and titles is as follows Figure 4f As shown in the figure, all the primitives are firstly processed into grids and discretized, and then the original image of the corner primitive in the upper left corner is continuously enlarged and then discretized into grids, and enlarged according to the increased discrete grid values. Each time a discrete grid is added, the primitive will be enlarged. Figure 4f It can be seen that after four enlargements, it overlaps with the first-level title, after three enlargements, it is adjacent to the first-level title, and after two enlargements, it is one grid away from it. Therefore, the optimal size of the corner element is two enlargements.
[0087] Similarly, the edge primitives are intelligently adjusted to the optimal size using the same method. The adjusted size information and position are written into the combined image knowledge script.
[0088] In some optional implementations of this embodiment, the migrating the style package according to the recursive migration relationship to generate a composite image knowledge script includes: performing pixel interpolation on the image elements of the composite image according to a pre-established deformation function to generate a composite image knowledge script for specifying the position and pixel value of the inserted pixel. The specific process is as follows:
[0089] In the process of merging images, some primitives need to change their original size to match some foreground primitives, but the resizing of the primitives will cause the texture structure of the primitives to change. Therefore, this application calculates the gradient change of the primitives in the x or y direction, and then uses the gradient value to perform non-uniform interpolation processing on the image, such as Figure 4g As shown in the left figure, after calculating the gradient based on the column pixels, a column of pixels is interpolated between the x(n-1) and x(n) column pixels in the x direction, and two columns of pixels are interpolated between x(n) and x(n+1).
[0090] First, the gradient change function representation in the x direction is calculated.
[0091] Among them, GC(x) refers to the gradient change of the column elements and F(x, y) is the pixel grayscale value of x and y.
[0092] The gradient function is exponentially reversed to increase the weights of columns with small gradient changes and reduce the weights of columns with large changes.
[0093] GC(x)'=e -w·GC(x)
[0094] This formula is an inverse change mapping curve with no specific meaning, and the weight w is adjusted based on experience.
[0095] The Gaussian kernel function is accumulated on the above function to obtain W(x) to make it stable.
[0096]
[0097]
[0098] Among them, f(x; μ, σ) is the Gaussian kernel function, and W(x) is the accumulation of the inverse transformation of the gradient using the Gaussian kernel function.
[0099] The size relationship of the enlarged element is as follows Figure 4h As shown, when interpolating between column pixels, the source size is first enlarged to the same height as the target size, and then the difference between the source size and the target size is obtained by subtracting the width difference ΔW. Similarly, when interpolating between row pixels, the source size is first enlarged to the same width as the target size, and then the difference between the source size and the target size is obtained by subtracting the height difference ΔH.
[0100] The width increment is apportioned according to the weight function to obtain the number of pixel columns that should be inserted between each column of pixels.
[0101] Among them, W(xi) represents the slowness of the gradient change of the i-th column. w(xi) is normalized and then multiplied by ΔW to obtain the insertion pixel width of the i-th column.
[0102] ΔW is the width that needs to be increased
[0103] Interpolate between two columns of pixels using the following formula.
[0104]
[0105] p(x i ) is the pixel value of the i-th column, in x i With x i+1 Insert between Column pixel value,
[0106] p(j) is the jth column of inserted pixels,
[0107] Similarly, ΔH can be used instead of ΔW when interpolating between row pixels. In the above formula, the inserted row pixel value is calculated in the y direction. The position and pixel value of the specified inserted pixel are written into the combined image knowledge script.
[0108] In some optional implementations of this embodiment, the migration of the style package according to the recursive migration relationship to generate a combined picture knowledge script includes: obtaining at least one configured color value and the proportion of each color; inputting the at least one color value and the proportion of each color into a pre-trained machine color matching function, predicting the next color value to be matched, and generating a combined picture knowledge script for specifying the color of the picture element. The specific process is as follows:
[0109] The machine color matching function can be used to predict the next color value to be matched after the matched color value and its proportion are given, such as Figure 5a As shown, all color components and their corresponding area ratio weights are extracted from the preferred picture, their colors are sorted from large to small according to the ratio weights, and then the corresponding training set is constructed.
[0110] The training set is constructed as follows: Figure 5a As shown, the proportion weights and color values of all the previous colors of each color component are concatenated and then concatenated with the weight of the predicted color as the input vector. If it does not reach 9 dimensions, fill it with 0. Perform the above operation on each color component. 4 sets of training data can be obtained for every 5 components. After obtaining the training data of all pictures, the following network is trained to obtain the corresponding color output value, which is written into the combined picture knowledge script. In this way, during the combined picture process, the color components and proportion weights of the determined area and the area weight of the area to be matched are input, and the color of the area to be matched is output. The training network model is as follows: Figure 5b shown.
[0111] In some optional implementations of this embodiment, the migration of the style package according to the recursive migration relationship to generate a combined picture knowledge script includes: establishing an edge probability field for the text of the title; calculating the contrast of the background image as the edge probability field changes, and generating a combined picture knowledge script for specifying the contrast. The specific process is as follows:
[0112] The text needs to be very eye-catching in the picture. The contrast of the background picture needs to be reduced near the text area to increase the clarity of the text foreground picture. However, this contrast changes gradually with the distance from the text edge. Therefore, an edge probability field is established for the text to allow the contrast of the background picture to change with the field. This field can also be used to achieve special effects such as highlights and shadows. The probability field effect established for the title text is as follows: Figure 5c shown.
[0113] like Figure 5dAs shown in the left figure, the process of establishing the field is actually to find the nearest k adjacent text edge points (neighboring points) for each pixel (target point) in the image, and then perform kernel function superposition on these k nearest edge points. In order to improve the search efficiency of k adjacent points, a quadtree (spherical tree) is established to manage all edge points, as shown in Figure 5d As shown in the right figure, during the search process, the relationship between the maximum and minimum distances from the area to the current point is determined based on the relationship with the center point in the management area, and most of the search nodes are filtered out to improve the search efficiency.
[0114] The distance relationship between the target point and all points in the area is as follows.
[0115] d>d c -R, d<d c +R
[0116] The kernel function is weighted for the edge points, and the kernel function is as follows.
[0117]
[0118] The final probability field is obtained by accumulating the kernel function.
[0119] G(x, y, xi, yi) is the field strength at each edge point
[0120]
[0121] The probability field is continuous, so we first generate a Gaussian kernel function for k edge points, and then accumulate the fields of k points to get the field strength of the target point. F(X, Y) is the field strength of the target point.
[0122] Calculate the contrast of the background image as it changes with the edge probability field, and write the contrast into the combined image knowledge script. This can achieve text highlights and shadows, or weaken the text background to make the text more eye-catching.
[0123] Step 204, composing the image according to the position and size information of the image elements of the composite image specified in the composite image knowledge script.
[0124] In this embodiment, the position and size information of the picture elements of the composite image are specified in the composite image knowledge script. The size of the picture element is adjusted according to the size information, and then placed at the specified position to complete the composition.
[0125] Step 205, obtaining materials that meet the theme and loading the content of the picture elements of the composite image according to the composite image knowledge script.
[0126] In this embodiment, the graph knowledge script can be Figure 3dGet the material that matches the theme from the material manager shown. For example, according to the theme of cosmetics, select geometry from layer 1 in the material manager, select lines from layer 2, and then select element 2. Run the combined image knowledge script to load the attribute information of element 2 into the element.
[0127] Step 206, color matching of the picture elements of the composite image is performed according to the colors specified in the composite image knowledge script.
[0128] In this embodiment, the color of each primitive is specified in the combined image knowledge script, and each primitive is filled with the specified color.
[0129] Step 207, combining the images according to the layers specified in the combining knowledge script.
[0130] In this example, the configuration of key and val is implemented. The layers are as follows, with three titles on the background.
[0131] Background: Title 1
[0132] Background: Title 2
[0133] Background: Multi-word background
[0134] Multi-word bottom: Title three.
[0135] According to the layer specified in the combined image knowledge script, different graphics elements after being placed and color matched are combined to obtain a composite image.
[0136] The migration reasoning process of image synthesis is realized, which maximizes the use of existing knowledge, incrementally assigns knowledge to scripts, establishes a large number of functional functions, describes the deterministic logic in the field of image design, and minimizes the training sample set.
[0137] (1) A complete abstract framework design for graph merging is realized
[0138] (2) The functions of scene construction, composition, and color matching are realized.
[0139] (3) The recursive principle from simple to complex is implemented in the process of combining graphs.
[0140] (4) The multi-curve regression learning method is used to realize the multi-size requirement merging function.
[0141] (5) The ability to adaptively adjust the size of corner elements is realized.
[0142] (6) The non-uniform interpolation of primitive deformation is realized.
[0143] (7) Implemented the function of machine learning color matching.
[0144] (8) A mathematical modeling method for text edge field was implemented.
[0145] Further references Figure 6 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a device for synthesizing images, and the device embodiment is Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0146] like Figure 6 As shown, the apparatus 600 for synthesizing images of this embodiment includes: a receiving unit 601, configured to receive attribute information of a synthesized image input by a user; a matching unit 602, configured to obtain a skeleton matching the attribute information; a migration unit 603, configured to search for a style package under the skeleton, and then migrate the style package according to a recursive migration relationship to generate a combined image knowledge script; a composition unit 604, configured to compose according to the position and size information of the picture elements of the synthesized image specified in the combined image knowledge script; a material selection unit 605, configured to load the content of the picture elements of the synthesized image with the specified material; a color matching unit 606, configured to match the colors of the picture elements of the synthesized image; and a combined image unit 607, configured to combine the pictures according to the hierarchical relationship of the picture elements of the synthesized image.
[0147] In some embodiments, the attribute information includes a subject, a title, a product image, and an image size of the product image.
[0148] In some embodiments, the style package includes a composition package, a scene package, a color package, and a layer package.
[0149] In some embodiments, the migration unit 603 is further configured to: migrate the theme of the style package according to the theme, and generate a combined picture knowledge script for specifying the material; determine the title type of the style package according to the title, and migrate the style of the title according to the title type, and generate a combined picture knowledge script for modifying the title; migrate the composition package of the style package according to the product picture and the picture size of the product picture, and generate a combined picture knowledge script for modifying the skeleton.
[0150] In some embodiments, the migration unit 603 is further configured to: obtain a migrator, wherein the directory of the migrator is divided into five layers of directories: skeleton, style, title, theme, and mode, and all packages in the directory support incremental migration; search for a migration path for each package node in each layer of the directory; obtain the package node migration path from the upper layer to the lower layer through a predetermined tree structure reasoning generalization; establish a package manager according to the package node migration path, and generate a composite graph knowledge script for using the package manager.
[0151] In some embodiments, the migration unit 603 is further configured to: input the aspect ratio of the picture elements of the composite image into a pre-established regression function to obtain the position of the picture elements of the composite image, and generate a combined image knowledge script for specifying the position of the picture elements; input the aspect ratio of the picture elements of the composite image into a pre-established size adaptive adjustment function to obtain the size information of the picture elements of the composite image, and generate a combined image knowledge script for specifying the size information of the picture elements.
[0152] In some embodiments, the migration unit 603 is further configured to: perform pixel interpolation on the picture elements of the composite image according to a pre-established deformation function, and generate a composite image knowledge script for specifying the position and pixel value of the inserted pixel.
[0153] In some embodiments, the migration unit 603 is further configured to: obtain at least one configured color value and the proportion of each color; input the at least one color value and the proportion of each color into a pre-trained machine color matching function, predict the next color value to be matched, and generate a combined image knowledge script for specifying the color of image elements.
[0154] In some embodiments, the migration unit 603 is further configured to: establish an edge probability field for the text of the title; calculate the contrast of the background image as the edge probability field changes, and generate a combined image knowledge script for specifying the contrast.
[0155] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device and a readable storage medium.
[0156] Figure 7 A schematic block diagram of an example electronic device 700 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0157] like Figure 7As shown, the device 700 includes a computing unit 701, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 702 or a computer program loaded from a storage unit 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the device 700 can also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0158] A number of components in the device 700 are connected to the I / O interface 705, including: an input unit 706, such as a keyboard, a mouse, etc.; an output unit 707, such as various types of displays, speakers, etc.; a storage unit 708, such as a disk, an optical disk, etc.; and a communication unit 709, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 709 allows the device 700 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0159] The computing unit 701 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 701 performs the various methods and processes described above, such as methods for synthesizing images. For example, in some embodiments, the method for synthesizing images may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 708. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 700 via the ROM 702 and / or the communication unit 709. When the computer program is loaded into the RAM 703 and executed by the computing unit 701, one or more steps of the method described above for synthesizing images may be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to execute the method for synthesizing images in any other appropriate manner (e.g., by means of firmware).
[0160] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0161] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0162] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0163] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0164] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0165] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the respective computers and having a client-server relationship with each other. The server may be a server of a distributed system, or a server combined with a blockchain. The server may also be a cloud server, or an intelligent cloud computing server or intelligent cloud host with artificial intelligence technology. The server may be a server of a distributed system, or a server combined with a blockchain. The server may also be a cloud server, or an intelligent cloud computing server or intelligent cloud host with artificial intelligence technology.
[0166] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0167] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A method for synthesizing an image, comprising: Receiving attribute information of a composite image input by a user; Obtaining a skeleton matching the attribute information, wherein all elements in the image are based on the skeleton, the skeleton determines the main structure of the image, and other elements are adjusted in position and size around the skeleton; Searching for the style package under the skeleton, and then migrating the style package according to the recursive migration relationship to generate a combined graph knowledge script; Composing the image according to the position and size information of the image elements of the composite image specified in the composite image knowledge script; Loading the content of the picture element of the composite image according to the material specified in the composite image knowledge script; Matching the colors of the picture elements of the composite image according to the colors specified in the composite image knowledge script; The images are combined according to the layers specified in the image combination knowledge script.
2. The method according to claim 1, wherein: The attribute information includes a subject, a title, a product image, and an image size of the product image.
3. The method according to claim 2, wherein: The style package includes a composition package, a scene package, a color package, and a layer package.
4. The method according to claim 3, wherein: The step of migrating the style package according to the recursive migration relationship to generate a combined graph knowledge script includes: Migrating the theme of the style package according to the theme to generate a combined picture knowledge script for specifying the material; Determine the title type of the style package according to the title, migrate the style of the title according to the title type, and generate a combined image knowledge script for modifying the title; The composition package of the style package is migrated according to the product image and the image size of the product image, and a composite image knowledge script for modifying the skeleton is generated.
5. The method according to claim 3, wherein: The step of migrating the style package according to the recursive migration relationship to generate a combined graph knowledge script includes: Get the migrator, where the directory of the migrator is divided into five levels of directories: skeleton, style, title, theme, and mode. All packages in the directory support incremental migration. Search the migration path for each package node in each directory layer; The migration path of the package nodes from the upper layer to the lower layer is obtained through the predetermined tree structure reasoning and generalization; A package manager is established according to the package node migration path, and a graph knowledge script for using the package manager is generated.
6. The method according to claim 1, wherein: The step of migrating the style package according to the recursive migration relationship to generate a combined graph knowledge script includes: Inputting the aspect ratio of the picture element of the composite image into a pre-established regression function to obtain the position of the picture element of the composite image, and generating a composite image knowledge script for specifying the position of the picture element; The aspect ratio of the picture element of the composite image is input into a pre-established size adaptive adjustment function to obtain the size information of the picture element of the composite image, and generate a composite image knowledge script for specifying the size information of the picture element.
7. The method according to claim 6, wherein: The step of migrating the style package according to the recursive migration relationship to generate a combined graph knowledge script includes: Pixel interpolation is performed on the picture elements of the composite image according to a pre-established deformation function to generate a composite image knowledge script for specifying the position and pixel value of the inserted pixel.
8. The method according to claim 1, wherein: The step of migrating the style package according to the recursive migration relationship to generate a combined graph knowledge script includes: Get at least one configured color value and the weight of each color; The at least one color value and the weight of each color are input into a pre-trained machine color matching function, the next color value to be matched is predicted, and a combined picture knowledge script for specifying the color of the picture element is generated.
9. The method according to claim 1, wherein: The step of migrating the style package according to the recursive migration relationship to generate a combined graph knowledge script includes: Establish marginal probability field for the text of title; The contrast of the background image as it changes with the edge probability field is calculated, and a composite image knowledge script for specifying the contrast is generated.
10. A device for synthesizing an image, comprising: A receiving unit, configured to receive attribute information of a composite image input by a user; A matching unit is configured to obtain a skeleton that matches the attribute information, wherein all elements in the image are based on the skeleton, the skeleton determines the main structure of the image, and other elements are adjusted in position and size around the skeleton; A migration unit is configured to search for a style package under the skeleton, and then migrate the style package according to a recursive migration relationship to generate a combined graph knowledge script; A composition unit, configured to compose an image according to the position and size information of the picture elements of the composite image specified in the composite image knowledge script; A material selection unit, configured to load the content of the picture element of the composite image according to the material specified in the composite image knowledge script; A color matching unit, configured to match the colors of the picture elements of the composite image according to the colors specified in the composite image knowledge script; The image merging unit is configured to merge images according to the layers specified in the image merging knowledge script.
11. An electronic device for synthesizing an image, comprising: one or more processors; a storage device having one or more programs stored thereon, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 9.
12. A computer readable medium having a computer program stored thereon, wherein: When the program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Image synthesis device, image synthesis method, and image synthesis program
CN109076137A
Image style migration method and device, electronic device and storage medium
CN109859096A
