Image generation method, device, server, and storage medium

By integrating the image processing process in the server and using the target color to fill the target style bottom plate, the problem of low manual processing efficiency is solved, and efficient color addition of the image bottom plate is achieved.

CN115115741BActive Publication Date: 2025-08-22东莞市步步高教育软件有限公司
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210314161.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-28
Publication Date
2025-08-22
Estimated Expiration
2042-03-28

AI Technical Summary

Technical Problem

In the prior art, the image edge expansion or addition of base color requires manual processing, which is inefficient and cannot process multiple pictures at the same time.

Method used

Integrate the image processing process into the server, and obtain the target color in the area to be extracted from the server as the fill color of the target style bottom plate to generate the target picture.

Benefits of technology

It improves the processing efficiency of adding base color to the picture and realizes the automated operation of batch processing of multiple pictures.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115115741B_ABST
    Figure CN115115741B_ABST
Patent Text Reader

Abstract

The present application discloses a method, device, server and storage medium for generating an image, and belongs to the field of image processing technology. The method is applied to a server, and the method includes: obtaining an image to be processed and a target style base; determining an area to be extracted in the image to be processed according to area division parameters and the image to be processed; obtaining a target color in the area to be extracted; filling the color of the target style base with the target color; generating a target image according to the image to be processed and the target style base, wherein the target image uses the target style base as the background of the image to be processed. The present application sets the filling selection of the target style base in the server, and the server can independently select the target color in the area to be extracted and fill the target style base, merge the image to be processed with the filled target style base, and generate an image with the base color added, thereby improving the processing efficiency of adding the base color to the image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to an image generation method, device, server, and storage medium. Background Art

[0002] With the rapid development of science and technology, there are more and more scenarios in which terminal devices are used in daily life. For example, people use terminal devices to shoot the external environment, obtain corresponding environmental pictures, and then process these environmental pictures to achieve satisfactory results.

[0003] To expand the edges of captured images or add a base color, it is often necessary to install an image editing application (Application, App) on the terminal device, open the image in the App, and then perform editing to expand the edges of the image or add a base color. This process not only requires a lot of manual processing, but also requires processing multiple images one by one, resulting in low efficiency in adding a base color to the image. Summary of the Invention

[0004] The embodiments of the present application provide an image generation method, device, server and storage medium, which can integrate the image processing process into the server, and the server obtains the target color in the area to be extracted of the image as the filling color of the target style background, thereby improving the processing efficiency of adding the background color to the image.

[0005] In one aspect, an embodiment of the present application provides a method for generating an image, which is applied to a server and includes:

[0006] Get the image to be processed and the target style base;

[0007] Determining a region to be extracted in the image to be processed according to the region division parameter and the image to be processed;

[0008] Acquire a target color in the area to be extracted, where the target color is a color in the area to be extracted that meets a preset condition;

[0009] Fill the target style base with the target color;

[0010] A target image is generated according to the image to be processed and the target pattern base, wherein the target pattern base serves as a background of the image to be processed.

[0011] Optionally, determining the area to be extracted in the image to be processed according to the area division parameter and the image to be processed includes:

[0012] Dividing the image to be processed into at least two regions according to the region division parameter;

[0013] The area containing the target object in the at least two areas is used as the area to be extracted.

[0014] Optionally, before obtaining the target color in the area to be extracted, the method further includes:

[0015] Obtaining a target ratio, where the target ratio is the ratio between the number of pixels occupied by the target object and the number of pixels contained in the area to be extracted;

[0016] The preset condition is obtained according to the target ratio.

[0017] Optionally, obtaining the preset condition according to the target ratio includes:

[0018] When the target ratio is within the first range, obtaining a first preset condition, where the first preset condition is the color with the largest number of pixels occupied by each of the colors in the area to be extracted;

[0019] When the target ratio is within the second range, a second preset condition is obtained, where the second preset condition is the color with the largest number of pixels occupied by various colors contained in the other pixels in the area to be extracted, except for the pixels occupied by the target object.

[0020] Optionally, before obtaining the target color in the area to be extracted, the method further includes:

[0021] Convert each pixel point in the area to be extracted into a hexagonal pyramid model space;

[0022] The acquiring of the target color in the area to be extracted comprises:

[0023] The target color in the area to be extracted is obtained in the hexagonal pyramid model space.

[0024] Optionally, obtaining the image to be processed and the target style base includes:

[0025] Receive a to-be-processed image and an image processing request sent by a terminal device, wherein the image processing request includes style customization parameters and display screen parameters of the terminal device;

[0026] Acquire the style customization parameters and the display screen parameters of the terminal device according to the image processing request;

[0027] The target style template is obtained according to the style customization parameters and the display screen parameters of the terminal device.

[0028] Optionally, before determining the area to be extracted in the image to be processed according to the area division parameter and the image to be processed, the method further includes:

[0029] Identifying the image to be processed and determining the scene type of the image to be processed;

[0030] According to the scene type, area division parameters are obtained.

[0031] In another aspect, an embodiment of the present application provides a picture generation device, which is applied to a server and includes:

[0032] The first acquisition module is used to obtain the image to be processed and the target style base;

[0033] A first determining module, configured to determine a region to be extracted in the image to be processed according to a region division parameter and the image to be processed;

[0034] A second acquisition module is used to acquire a target color in the area to be extracted, where the target color is a color in the area to be extracted that meets a preset condition;

[0035] A color filling module, used to fill the color of the target style base with the target color;

[0036] The image generation module is used to generate a target image based on the image to be processed and the target style base, wherein the target image uses the target style base as the background of the image to be processed.

[0037] On the other hand, an embodiment of the present application provides a server, which includes a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor implements the image generation method described in one aspect above.

[0038] In another aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the image generation method as described in the above-mentioned other aspect and its optional manner.

[0039] On the other hand, an embodiment of the present application provides a computer program product, which, when executed on a computer, enables the computer to execute the image generation method as described in one aspect above.

[0040] On the other hand, an embodiment of the present application provides an application publishing platform, which is used to publish a computer program product, wherein when the computer program product runs on a computer, the computer executes the image generation method described in one aspect above.

[0041] The technical solutions provided by the embodiments of the present application may have at least the following beneficial effects:

[0042] This application obtains the image to be processed and the target style base through the server; determines the area to be extracted in the image to be processed based on the area division parameters and the image to be processed; obtains the target color in the area to be extracted, and the target color is the color that meets the preset conditions in the area to be extracted; fills the color of the target style base with the target color; generates a target image based on the image to be processed and the target style base, and uses the target style base as the background of the image to be processed in the target image. This application sets the filling selection of the target style base in the server, and the server can independently select the target color in the area to be extracted and fill the target style base, merge the image to be processed with the filled target style base, and generate a picture with the base color added, thereby improving the processing efficiency of adding the base color to the image. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0044] Figure 1 This is a flowchart of a method for generating an image provided by an exemplary embodiment of the present application;

[0045] Figure 2 1 is a schematic structural diagram of a target pattern master plate involved in an exemplary embodiment of the present application;

[0046] Figure 3 This is a flowchart of a method for generating an image provided by an exemplary embodiment of the present application;

[0047] Figure 4 This is a schematic diagram of a style parameter editing interface involved in an exemplary embodiment of the present application;

[0048] Figure 5 is a schematic diagram of a picture to be processed involved in an exemplary embodiment of the present application;

[0049] Figure 6 This is a schematic diagram of dividing a picture to be processed involved in an exemplary embodiment of the present application;

[0050] Figure 7 is a schematic structural diagram of a target image involved in an exemplary embodiment of the present application;

[0051] Figure 8 This is a flowchart of a method for generating an image provided by an exemplary embodiment of the present application;

[0052] Figure 9 This is a structural block diagram of a picture generating device provided by an exemplary embodiment of the present application;

[0053] Figure 10 It is a structural diagram of a server provided by an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0054] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.

[0055] In this document, "plurality" refers to two or more. "And / or" describes a relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can mean: A exists alone, A and B exist simultaneously, or B exists alone. The character " / " generally indicates an "or" relationship between the associated objects.

[0056] It should be noted that the terms "first," "second," "third," and "fourth" in the specification and claims of this application are used to distinguish different objects rather than to describe a specific order. The terms "including" and "having," as well as any variations thereof, in the embodiments of this application are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units that are not explicitly listed or are inherent to these processes, methods, products, or apparatuses.

[0057] The solution provided by this application can be used in application scenarios where it is necessary to add a base color to the captured pictures after taking pictures with a terminal device with a shooting function used in people's daily lives. For ease of understanding, some of the terms and application architectures involved in the embodiments of this application are briefly introduced below.

[0058] HSV (Hue, Saturation, Value) is a color space created by AR Smith in 1978 based on the intuitive characteristics of color, also known as the Hexcone Model.

[0059] With the continuous advancement of technology, terminal devices are used more and more frequently in daily life. People can use these terminal devices to take pictures of the external environment. After obtaining the photos, they can process them through the App with picture editing function installed on the terminal device to expand the edges of the photos or fill the background color.

[0060] Optionally, the terminal device is a terminal installed with an image processing app. For example, the terminal device may be a mobile phone, tablet computer, notebook computer, e-book reader, smart glasses, smart watch, laptop computer, desktop computer, smart robot, smart bracelet, tutoring device, etc.

[0061] Alternatively, the user can activate the capture function on the terminal device to capture the external environment, obtain the corresponding environmental image, and then activate the image processing app to process the desired image. For example, if the user needs to fill a background color on an image, they can load the image into the image processing app and use the capture tool in the app to extract the pixel value of a certain pixel in the image. Then, fill the background color to be filled according to the captured pixel value.

[0062] With the aforementioned technical solution, when manually capturing images through an app with image processing capabilities, the pixel value of a single, precise pixel point is often obtained. This not only fails to reflect the other background colors of the environment image that the user needs to process, but also results in a poor fit between the filled base color and the environment image. Furthermore, each manual process can only process a single image, and the base color cannot be filled in every captured image in a timely manner. This process also suffers from the problem of low efficiency in adding the base color to the image.

[0063] In order to improve the processing efficiency of adding background color to images, this application proposes a solution that can integrate the process into the server, extract the target color from the area to be extracted through the server, fill the target style background with the target color, combine the photo to be processed with the target style background, and generate the image with the background color added.

[0064] Please refer to Figure 1 , which shows a method flow chart of a method for generating an image provided by an exemplary embodiment of the present application. The method can be applied to a server and executed by the server. Figure 1As shown, the image generation method includes the following steps.

[0065] Step 101: Obtain the image to be processed and the target style base.

[0066] In this application, the server can be at least one of a single server, multiple servers, a cloud computing platform, and a virtualization center. The server is used to provide background services for applications that support virtual environments.

[0067] Optionally, a communication network connection can be established between the server and the terminal device, and the image to be processed sent by the terminal is received through the communication network connection, wherein the communication network connection can use standard communication technology and / or protocol. The network is usually the Internet, but it can also be any network, including but not limited to a local area network (LAN), a metropolitan area network (MAN), a wide area network (WAN), a mobile, wired or wireless network, a private network or any combination of a virtual private network). In some embodiments, technologies and / or formats including Hyper Text Mark-up Language (HTML), Extensible Markup Language (XML), etc. are used to represent data exchanged through the network. In addition, conventional encryption technologies such as Secure Socket Layer (SSL), Transport Layer Security (TLS), Virtual Private Network (VPN), Internet Protocol Security (IPsec), etc. can also be used to encrypt all or some links. In other embodiments, customized and / or dedicated data communication technologies may be used to replace or supplement the above-mentioned data communication technologies.

[0068] Optional, please refer to Figure 2 , which shows a schematic structural diagram of a target pattern base plate involved in an exemplary embodiment of the present application. Figure 2 As shown, it includes the target style base 201. Similar to Figure 2 The target style base can be created by the developer and pre-set in the server, or generated by the server according to a pre-set template, or sent through the above terminal device. This application does not limit the method of obtaining the image to be processed and the target style base.

[0069] Step 102: Determine the region to be extracted in the image to be processed according to the region division parameters and the image to be processed.

[0070] The region division parameters may be pre-set by the developer in the server, obtained by the server from the terminal device, or generated by the server based on the image to be processed. The server may divide the image to be processed according to the region division parameters to obtain regions of the image to be processed, and determine the region to be extracted from each region of the image to be processed.

[0071] Optionally, the region to be extracted can be any area in the image to be processed that can serve as the background. For example, each divided region contains its own label. The server selects the region with the "background" label as the region to be extracted from the image to be processed, and selects the color to be filled in the target style base from the obtained region to be extracted.

[0072] Step 103 , obtaining a target color in the area to be extracted, where the target color is a color in the area to be extracted that meets a preset condition.

[0073] Optionally, the server can filter the colors within the area to be extracted using a preset condition and select a target seat color from the colors within the area to be extracted. The preset condition can be pre-set by the developer on the server. Optionally, the preset condition is related to the ratio between the number of pixels occupied by the target object within the area to be extracted and the number of pixels within the area to be extracted.

[0074] Step 104: Fill the target pattern base with the target color.

[0075] Optionally, after obtaining the target color, the server fills the obtained target style base, filling the color of the target style base with the target color.

[0076] Step 105 : generating a target image based on the image to be processed and the target pattern base, wherein the target pattern base is used as the background of the image to be processed.

[0077] Optionally, based on the target style base, the server uses the target style base as the background of the image to be processed, and fuses the image to be processed with the target style base to generate the target image. For example, the server uses the target style base as the bottom layer of the target image, adds the image to be processed to the target image, and combines the two to generate the final target image.

[0078] In summary, the present application obtains the image to be processed and the target style base through the server; determines the area to be extracted in the image to be processed according to the area division parameters and the image to be processed; obtains the target color in the area to be extracted, and the target color is the color that meets the preset conditions in the area to be extracted; fills the color of the target style base with the target color; generates a target image according to the image to be processed and the target style base, and uses the target style base as the background of the image to be processed in the target image. The present application sets the filling selection of the target style base in the server, and the server can independently select the target color in the area to be extracted and fill the target style base, merge the image to be processed with the filled target style base, and generate a picture with the base color added, thereby improving the processing efficiency of adding the base color to the image.

[0079] In one possible implementation, the server can receive the unprocessed images sent by the terminal device through a communication connection with the terminal device. Taking the processing of the unprocessed images as an example, the present application can realize the simultaneous addition of target style backgrounds to multiple unprocessed images sent by the terminal device through the server, thereby realizing batch processing of images and improving the processing efficiency of adding background colors to images.

[0080] Please refer to Figure 3 , which shows a method flow chart of a method for generating an image provided by an exemplary embodiment of the present application. The method can be applied to a server and executed by the server. Figure 3 As shown, the image generation method includes the following steps.

[0081] Step 301: Receive a picture to be processed and a picture processing request sent by a terminal device, where the picture processing request includes style customization parameters and display screen parameters of the terminal device.

[0082] Optionally, in this application, the server and the terminal device are connected through the above-mentioned communication network. After the user uses the terminal device to take a picture, the terminal device sends the taken picture to the server, and the picture received by the server is the picture to be processed.

[0083] The terminal device can also send an image processing request, which includes style customization parameters and the terminal device's display parameters. In one possible implementation, the terminal device can package the image processing request and the captured image into a single data packet and send it to the server, or send them separately, so that the server receives both the image to be processed and the image processing request.

[0084] Optionally, the style customization parameters can be edited by the user by opening the style customization interface in the terminal device. For example, the style customization parameters may include any one or more of the following: style base shape parameters, style base scale parameters, style base position parameters, style base side length parameters, etc. Among them, the style base shape parameters are used to indicate the shape of the target style base selected by the user, the style base scale parameters are used to indicate the ratio between the size of the target style base selected by the user and the size of the image to be processed, the style base position parameters are used to indicate the position of the image to be processed on the target style base, and the style base side length parameters are used to indicate the side length of the target style base.

[0085] For example, please refer to Figure 4 , which shows a schematic diagram of an interface for editing style parameters involved in an exemplary embodiment of the present application. Figure 4 As shown, the editing interface 400 includes style base shape parameters 401, style base scale parameters 402, style base position parameters 403, a send control 404, and a cancel control 405. In the editing interface 400 displayed on the terminal device, the user can edit the style base shape parameters 401, style base scale parameters 402, and style base position parameters 403, respectively, and click the send control 404 to send an image processing request containing each custom style parameter to the server. Accordingly, the server can receive the image processing request.

[0086] Optionally, the display screen parameters of the terminal device can be obtained by the terminal device and then added to the image processing request. For example, if the display screen parameters of the terminal device are 2.8 inches, the display screen parameters included in the image processing request sent by the terminal device are 2.8 inches.

[0087] Step 302: Obtain style customization parameters and display screen parameters of the terminal device according to the image processing request.

[0088] Correspondingly, after receiving the image processing request, the server parses the image processing request to obtain the style customization parameters and display screen parameters of the terminal device contained in the image processing request.

[0089] Step 303: Obtain the target style template according to the style customization parameters and the display screen parameters of the terminal device.

[0090] Optionally, the server obtains a target style base that is identical to the style customization parameters and conforms to the display screen parameters based on the style customization parameters and the display screen parameters of the terminal device. The server can generate a corresponding target style base according to the style customization parameters, and scale the generated target style base according to the display screen parameters so that the target style base can be displayed normally on the display screen. For example, in the above Figure 4 In the style customization parameters set by the user, the style base shape parameter is a rectangle, the style base ratio parameter is 2:1, and the style base position parameter is the center position. Then, the target style base obtained by the server is a rectangle, and the size of the target style base is twice the size of the image to be processed. When adding the image to be processed to the target style base to generate the target image, the image to be processed is added to the center position of the target style base.

[0091] In one possible implementation, the server may also obtain a target style base corresponding to the size of the image to be processed based on the size of the image to be processed. For example, a default style base is pre-set in the server. For example, the shape of the default style base is a rectangle. For each image to be processed, the server may enlarge the default style base by twice the size of the image to be processed, and obtain a target style base that is twice the size of the image to be processed. That is, steps 301 to 303 may also be changed to two steps: obtaining the image to be processed, and obtaining the target style base according to the size of the image to be processed. This method does not require the user to perform the above-mentioned parameter editing process and parse the image processing request to obtain the style customization parameters and the display screen parameters of the terminal device. The server may autonomously generate the target style base based on the size of the image to be processed, thereby reducing the steps of obtaining the target style base and improving the efficiency of generating the target style base.

[0092] Step 304 : determining the region to be extracted in the image to be processed according to the region division parameters and the image to be processed.

[0093] Optionally, a region division parameter is used to divide the image to be processed. The server can divide the image to be processed based on the region division parameter to obtain different regions in the image to be processed. In one possible implementation, the server divides the image to be processed into at least two regions based on the region division parameter; and the region containing the target object in the at least two regions is used as the region to be extracted. Similar to the description in step 102 above, the region division parameter can be pre-set in the server by the developer, sent by the receiving terminal device, or determined based on the image to be processed.

[0094] For example, the region division parameters pre-set by the developer in the server are as follows: reduce the image by B pixels in the direction perpendicular to the length of each side of the image to be processed. For example, please refer to Figure 5 , which shows a schematic diagram of a picture to be processed involved in an exemplary embodiment of the present application. Figure 5As shown, the image to be processed 501 is included, and the image to be processed 501 includes a first side length 501a, a second side length 501b, a third side length 501c, a fourth side length 501d, a first area 502 after division, and a second area 503 after division. After the server receives the image to be processed, it shrinks each side length of the image to be processed inward by B pixels perpendicular to the image to be processed to obtain the second area 503.

[0095] Optionally, the terminal device may also send region division parameters to the server. The server then divides the image to be processed based on the region division parameters sent by the terminal device to obtain different regions of the image to be processed. For example, the region division parameters sent by the terminal device may be as follows: a first boundary pixel set and a second boundary pixel set. After receiving the region division parameters, the server obtains a first boundary in the image to be processed based on the first boundary pixel set and a second boundary in the image to be processed based on the second boundary pixel set, thereby dividing the image to be processed into different regions.

[0096] Optionally, the server can also obtain corresponding region division parameters based on the recognition results of the image to be processed. For example, the server can identify the acquired image to be processed, determine the scene type of the image to be processed, and obtain the region division parameters based on the scene type. Optionally, the server includes an image recognition model, which can be pre-trained by the developer. By inputting the image to be processed into the image recognition model, the image recognition model can identify the scene type of the image to be processed and then obtain the corresponding region division parameters.

[0097] Optionally, the scene type may include restaurant scene, bedroom scene, home scene, travel scene, seaside scene, mountain scene, etc. For example, the server performs scene recognition on the image to be processed and determines that the scene type of the image to be processed is a seaside scene. The server divides the image to be processed into various areas based on the seaside scene and obtains the area division parameters after the division. For example, please refer to Figure 6 , which shows a schematic diagram of dividing a picture to be processed involved in an exemplary embodiment of the present application. Figure 6 As shown, it includes a picture to be processed 601, a first divided area 602, a second divided area 603, and a third divided area 604. The scene type of the picture to be processed is a seaside scene. The server divides the picture to be processed according to the division method of the seaside scene, and obtains the boundary pixels of the three divided areas as area division parameters.

[0098] Optionally, after the server divides the image to be processed according to the area division parameters and obtains at least two areas in the image to be processed, it can identify each area, obtain the objects contained in each area, and select the area containing the target object as the area to be extracted. The target object can be a person or an object in the image to be processed. Optionally, the information of the target object can also be sent to the server by the terminal device. For example, if the image to be processed contains objects such as a person, a table, or a television, the user can enter the object information "person" in the object input interface displayed by the terminal device and send it to the server, so that the server knows that the target object of the image to be processed is the person in the image to be processed, and the area containing the person is used as the area to be extracted. If the user enters the object information "table" in the object input interface displayed by the terminal device and sends it to the server, so that the server knows that the target object of the image to be processed is the table in the image to be processed, the area containing the table is used as the area to be extracted.

[0099] Step 305 , obtaining a target color in the area to be extracted, where the target color is a color in the area to be extracted that meets a preset condition.

[0100] Optionally, after determining the area to be extracted, the server may filter various colors contained in the area to be extracted and use the color that meets the preset conditions as the target color.

[0101] In one possible implementation, the server may obtain a target ratio, which is the ratio of the number of pixels occupied by the target object to the number of pixels contained in the area to be extracted; and obtain a preset condition based on the target ratio. When the target ratio is within a first range, the server obtains the first preset condition, which is the color with the largest number of pixels occupied by each color in the area to be extracted. When the target ratio is within a second range, the server obtains the second preset condition, which is the color with the largest number of pixels occupied by each color contained in pixels other than the target object in the area to be extracted.

[0102] Specifically, the server can count the number of pixels occupied by the target object within the extraction area to obtain the target pixel count, then count all pixels within the extraction area to obtain the total number of pixels within the extraction area, and then calculate the ratio between the two to obtain the target ratio. For example, if the target object occupies 1000 pixels and the extraction area contains 3000 pixels, the target ratio obtained by the server is 1 / 3.

[0103] Optionally, the range of the target ratio corresponds to the preset condition. Please refer to Table 1, which shows a table of correspondence between the range of the target ratio and the preset condition involved in an exemplary embodiment of the present application.

[0104] Target ratio range Preconditions First range First precondition Second range Second prerequisite

[0105] Table 1

[0106] As shown in Table 1, when the target ratio obtained by the server is within a first range, the server may obtain a first preset condition, and when the target ratio is within a second range, the server may obtain a second preset condition.

[0107] For example, the first range is 0-0.5, and the second range is 0.5-1. If the target ratio obtained by the server is 1 / 3, it means that the target ratio is within the first range. The preset condition obtained by the server is the color with the largest number of pixels occupied by each color in the area to be extracted. In this case, the server can obtain the color with the largest number of pixels in the area to be extracted. For example, if the area to be extracted contains color 1, color 2, color 3, and color 4, respectively, and color 4 occupies the largest number of pixels, then the target color obtained by the server is color 4. If the target ratio obtained by the server is 2 / 3, it means that the target ratio is within the second range. The preset condition obtained by the server is the color with the largest number of pixels occupied by each color in the area to be extracted, excluding the pixels occupied by the target object. In this case, the server can obtain the color with the largest number of pixels in the area to be extracted, excluding the pixels occupied by the target object. For example, if the area to be extracted contains color 1, color 2, and color 3, respectively, and color 2 occupies the largest number of pixels, then the target color obtained by the server is color 2.

[0108] In one possible implementation, the server may first convert each pixel point in the area to be extracted into a hexagonal pyramid model space; and obtain the target color in the area to be extracted in the hexagonal pyramid model space. That is, the server may convert the area to be extracted of the image to be processed into the HSV (Hue, Saturation, Value) color space, and obtain the histogram distribution of the three channels H, S, and V in the area to be extracted in the HSV space. If the preset condition obtained by the server is the first condition, then the value with the highest frequency is obtained, and the value with the highest frequency in the three channels (H) is obtained. max , S max , V max), then convert the color values ​​in the HSV space to the conventional RGB (Red, Green, Blue) color space to obtain a hexadecimal color code, thereby obtaining the corresponding target color. If the preset condition obtained by the server is the second condition, then obtain the most frequently appearing values ​​in the data except for the data of the target object containing various colors in the HSV channels, obtain the values ​​with the highest frequency in the three channels, and then convert the color values ​​in the HSV space to the conventional RGB color space.

[0109] Step 306: Fill the target style base with the target color.

[0110] Optionally, the server fills the color of the target style base with the target color obtained above.

[0111] Step 307 : Generate a target image based on the image to be processed and the target pattern base, wherein the target image uses the target pattern base as the background of the image to be processed.

[0112] The server fuses the image to be processed with the target style base, using the filled target style base as the background of the image to be processed. The server can set the target style base as the bottom layer and add the image to be processed to the bottom layer to complete the image fusion. In one possible implementation method described above, if the style customization parameters included in the image processing request include a style base position parameter, in this step, the image to be processed can be added to the corresponding position according to the style base position parameter to obtain the target image.

[0113] Please refer to Figure 7 , which shows a schematic diagram of the structure of a target image involved in an exemplary embodiment of the present application. Figure 7 As shown, target image 700 includes image to be processed 701 and target style base 702. Optionally, when the style base position parameter is set to center, the server sets the image to be processed at the center of the target style base. When the style base position parameter is set to center and rotated 30 degrees, the server rotates the image to be processed 30 degrees and sets it at the center of the target style base.

[0114] In summary, the present application obtains the image to be processed and the target style base through the server; determines the area to be extracted in the image to be processed according to the area division parameters and the image to be processed; obtains the target color in the area to be extracted, and the target color is the color that meets the preset conditions in the area to be extracted; fills the color of the target style base with the target color; generates a target image according to the image to be processed and the target style base, and uses the target style base as the background of the image to be processed in the target image. The present application sets the filling selection of the target style base in the server, and the server can independently select the target color in the area to be extracted and fill the target style base, merge the image to be processed with the filled target style base, and generate a picture with the base color added, thereby improving the processing efficiency of adding the base color to the image.

[0115] In addition, in this application, by obtaining the target ratio, the corresponding screening conditions are obtained, so that the obtained target color and the image to be processed are more in line with actual applications, the transition is smoother, and the filling effect of the target style base is improved.

[0116] The above embodiment is described below by taking the interaction between a terminal device and a server as an example, where the terminal device can send at least two pictures to be processed, the server receives at least two pictures to be processed, and batch processes multiple pictures to be processed.

[0117] Please refer to Figure 8 , which shows a method flow chart of a method for generating an image provided by an exemplary embodiment of the present application. The method can be applied to a server and executed by the server. Figure 8 As shown, the image generation method includes the following steps.

[0118] Step 801: The terminal device captures at least two pictures to be processed and sends them to the server.

[0119] Step 802: The server obtains each picture to be processed.

[0120] Optionally, this step may refer to the method of obtaining the image to be processed in the above step 301, which will not be repeated here.

[0121] Step 803 : Divide the image to be processed according to the default region division parameters to obtain regions to be extracted.

[0122] The default region division parameters can be pre-set in the server, and the server can divide each image to be processed according to the parameters to obtain the region to be extracted. For example, if the images to be processed are all rectangular, the two longer sides of the rectangle are reduced by a pixels, and the two shorter sides of the rectangle are reduced by b pixels, and the inner region is obtained as the region to be extracted.

[0123] Step 804: convert the area to be extracted into the HSV space.

[0124] Step 805: Count the values ​​with the highest frequency in different channels.

[0125] Step 806: Obtain the RGB color according to the value with the highest frequency.

[0126] The obtained RGB color is the target color mentioned in the above embodiment.

[0127] Step 807: Fill the target style base and obtain the target image in combination with the image to be processed.

[0128] Optionally, the method of obtaining the target image in this step may refer to the content of step 307 in the above embodiment, which will not be repeated here.

[0129] Step 808: The server returns the target image corresponding to each to-be-processed image to the terminal device.

[0130] That is, the server may generate a target image for each image to be processed, and send the target image back to the terminal device.

[0131] To sum up, this application encapsulates the background filling process and deploys it to the server. The server opens certain ports to request external services to respond to the needs of adding background color to the image. This can greatly facilitate the application, achieve automatic batch processing, and reduce manual interference.

[0132] The following are device embodiments of the present application, which can be used to implement the method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.

[0133] Please refer to Figure 9 , which shows a structural block diagram of an image generation device provided by an exemplary embodiment of the present application. The image generation device 900 can be applied to a server. The image generation device 900 includes:

[0134] The first acquisition module 901 is used to obtain the image to be processed and the target pattern base;

[0135] A first determining module 902 is configured to determine a region to be extracted in the image to be processed based on the region division parameter and the image to be processed;

[0136] The second acquisition module 903 is used to acquire a target color in the area to be extracted, where the target color is a color in the area to be extracted that meets a preset condition;

[0137] A color filling module 904 is used to fill the color of the target pattern base with the target color;

[0138] The image generation module 905 is configured to generate a target image based on the image to be processed and the target pattern base, wherein the target image uses the target pattern base as the background of the image to be processed.

[0139] In summary, the present application obtains the image to be processed and the target style base through the server; determines the area to be extracted in the image to be processed according to the area division parameters and the image to be processed; obtains the target color in the area to be extracted, and the target color is the color that meets the preset conditions in the area to be extracted; fills the color of the target style base with the target color; generates a target image according to the image to be processed and the target style base, and uses the target style base as the background of the image to be processed in the target image. The present application sets the filling selection of the target style base in the server, and the server can independently select the target color in the area to be extracted and fill the target style base, merge the image to be processed with the filled target style base, and generate a picture with the base color added, thereby improving the processing efficiency of adding the base color to the image.

[0140] Optionally, the first determining module 902 includes: a first dividing unit and a first acquiring unit;

[0141] The first division unit is configured to divide the image to be processed into at least two regions according to the region division parameter;

[0142] The first acquiring unit is configured to use the region containing the target object among the at least two regions as the region to be extracted.

[0143] Optionally, the device further includes:

[0144] A third acquisition module is configured to acquire a target ratio before acquiring the target color in the area to be extracted, where the target ratio is the ratio between the number of pixels occupied by the target object and the number of pixels contained in the area to be extracted;

[0145] A fourth acquisition module is configured to acquire the preset condition according to the target ratio.

[0146] Optionally, the fourth acquisition module includes: a first acquisition unit and a second acquisition unit;

[0147] The first acquisition unit is configured to acquire a first preset condition when the target ratio is within a first range, wherein the first preset condition is the color with the largest number of pixels occupied by each of the colors in the area to be extracted;

[0148] The second acquisition unit is used to obtain a second preset condition when the target ratio is within a second range. The second preset condition is the color with the largest number of pixels occupied by various colors contained in other pixel points in the area to be extracted, except for the pixel points occupied by the target object.

[0149] Optionally, the device further includes:

[0150] A space conversion module, configured to convert each pixel point in the area to be extracted into a hexagonal pyramid model space before obtaining the target color in the area to be extracted;

[0151] The second acquisition module 903 is further configured to acquire the target color in the area to be extracted in the hexagonal pyramid model space.

[0152] Optionally, the first acquisition module 901 includes: a first receiving unit, a third acquisition unit and a fourth acquisition unit;

[0153] The first receiving unit is configured to receive a to-be-processed image and an image processing request sent by a terminal device, wherein the image processing request includes style customization parameters and display screen parameters of the terminal device;

[0154] The third acquiring unit is configured to acquire the style customization parameters and the display screen parameters of the terminal device according to the image processing request;

[0155] The fourth acquiring unit is configured to acquire the target style template according to the style customization parameters and the display screen parameters of the terminal device.

[0156] Optionally, the device further includes:

[0157] a scene determination module, configured to identify the image to be processed and determine the scene type of the image to be processed before determining the area to be extracted in the image to be processed based on the area division parameters and the image to be processed;

[0158] The parameter acquisition module is used to obtain area division parameters according to the scene type.

[0159] Figure 10 This is a schematic diagram of the structure of a server provided by an exemplary embodiment of the present application. Figure 10As shown, server 1000 includes a central processing unit (CPU) 1001, a system memory 1004 including a random access memory (RAM) 1002 and a read-only memory (ROM) 1003, and a system bus 1005 connecting system memory 1004 and CPU 1001. Server 1000 also includes a basic input / output system (I / O system) 1006 for facilitating information transmission between various components within the computer, and a mass storage device 1007 for storing an operating system 1012, application programs 1013, and other program modules 1014.

[0160] The basic input / output system 1006 includes a display 1006 for displaying information and an input device 1009 such as a mouse and keyboard for user input. The display 1006 and the input device 1009 are both connected to the central processing unit 1001 via an input / output controller 1010 connected to the system bus 1005. The basic input / output system 1006 may also include an input / output controller 1010 for receiving and processing input from a variety of other devices such as a keyboard, mouse, or electronic stylus. Similarly, the input / output controller 1010 also provides output to a display screen, printer, or other types of output devices.

[0161] The mass storage device 1007 is connected to the central processing unit 1001 via a mass storage controller (not shown) connected to the system bus 1005. The mass storage device 1007 and its associated computer-readable medium provide non-volatile storage for the server 1000. In other words, the mass storage device 1007 may include a computer-readable medium (not shown) such as a hard disk or a CD-ROM (Compact Disc Read-Only Memory) drive.

[0162] The computer-readable medium may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented by any method or technology for storing information such as computer-readable instructions, data structures, program modules or other data. Computer storage media include RAM, ROM, EPROM (Erasable Programmable Read Only Memory), EEPROM (Electrically Erasable Programmable Read-Only Memory), flash memory or other solid-state storage technologies, CD-ROM, DVD (Digital Video Disc) or other optical storage, tape cassettes, magnetic tape, disk storage or other magnetic storage devices. Of course, those skilled in the art will appreciate that the computer storage media are not limited to the above-mentioned ones. The above-mentioned system memory 1004 and mass storage device 1007 can be collectively referred to as memory.

[0163] The server 1000 can be connected to the Internet or other network devices through a network interface unit 1011 connected to the system bus 1005 .

[0164] The memory also includes one or more programs, which are stored in the memory. The central processing unit 1001 implements all or part of the steps performed by the server in the methods provided in the above embodiments of the present application by executing the one or more programs. Optionally, the structure of the terminal device can also refer to the structure of the server 1000, which will not be repeated here.

[0165] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware, or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.

[0166] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, a computer, a server, or a data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website, a computer, a server, or a data center. The computer-readable storage medium can be any available medium that a computer can store or a data storage device such as a server or a data center that includes one or more available media integrations. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a high-density digital video disc (DVD)), or a semiconductor medium (e.g., a solid-state drive (SSD)). An embodiment of the present application further discloses a computer-readable storage medium storing a computer program, wherein the computer program implements the method in the above method embodiment when executed by a processor.

[0167] The embodiments of the present application further disclose a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to enable a computer to execute the method in the above method embodiments.

[0168] An embodiment of the present application further discloses an application publishing platform, wherein the application publishing platform is used to publish a computer program product, wherein when the computer program product runs on a computer, the computer executes the method in the above method embodiment.

[0169] In addition, the functional units in the embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0170] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-accessible memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a memory and includes several requests for a server (which can be a personal computer, server or network device, etc., specifically a processor in the server) to execute some or all of the steps of the above-mentioned methods of the various embodiments of the present application.

[0171] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program. The program can be stored in a computer-readable storage medium, and the storage medium includes a read-only memory (ROM), a random access memory (RAM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium capable of carrying or storing data.

[0172] The above is an example introduction to an image generation method, device, server and storage medium disclosed in the embodiments of the present application. Individual examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, based on the ideas of the present application, there will be changes in the implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A method for generating an image, characterized in that: The method is applied to a server and includes: Get the image to be processed and the target style base; Determine, according to the region division parameter and the image to be processed, an area to be extracted in the image to be processed, wherein the area to be extracted is an area containing a target object; Obtaining a target ratio, where the target ratio is the ratio between the number of pixels occupied by the target object and the number of pixels contained in the area to be extracted; According to the target ratio, obtaining a preset condition; Acquire a target color in the area to be extracted, where the target color is a color in the area to be extracted that meets the preset conditions; Fill the target style base with the target color; generating a target image according to the image to be processed and the target pattern base, wherein the target image uses the target pattern base as the background of the image to be processed; Wherein, obtaining the preset condition according to the target ratio includes: When the target ratio is within the first range, obtaining a first preset condition, where the first preset condition is the color with the largest number of pixels occupied by each of the colors in the area to be extracted; When the target ratio is within the second range, a second preset condition is obtained, where the second preset condition is that, in the area to be extracted, except for the pixels occupied by the target object, the various colors contained in the other pixels each have the largest number of pixel points, and the first range is smaller than the second range.

2. The method according to claim 1, characterized in that The step of determining the area to be extracted in the image to be processed according to the area division parameter and the image to be processed includes: Dividing the image to be processed into at least two regions according to the region division parameter; The area containing the target object in the at least two areas is used as the area to be extracted.

3. The method according to any one of claims 1 to 2, characterized in that: Before obtaining the target color in the area to be extracted, the method further includes: Convert each pixel point in the area to be extracted into a hexagonal pyramid model space; The acquiring of the target color in the area to be extracted comprises: The target color in the area to be extracted is obtained in the hexagonal pyramid model space.

4. The method according to any one of claims 1 to 2, characterized in that: The step of obtaining the image to be processed and the target style base includes: Receive a to-be-processed image and an image processing request sent by a terminal device, wherein the image processing request includes style customization parameters and display screen parameters of the terminal device; Acquire the style customization parameters and the display screen parameters of the terminal device according to the image processing request; The target style template is obtained according to the style customization parameters and the display screen parameters of the terminal device.

5. The method according to any one of claims 1 to 2, characterized in that: Before determining the area to be extracted in the image to be processed according to the area division parameters and the image to be processed, the method further includes: Identifying the image to be processed and determining the scene type of the image to be processed; According to the scene type, area division parameters are obtained.

6. A picture generating device, characterized in that: The device is applied to a server, and includes: The first acquisition module is used to obtain the image to be processed and the target style base; A first determining module is configured to determine a region to be extracted in the image to be processed according to the region division parameter and the image to be processed, wherein the region to be extracted is a region containing a target object; A third acquisition module is used to acquire a target ratio, where the target ratio is the ratio between the number of pixels occupied by the target object and the number of pixels contained in the area to be extracted; A fourth acquisition module, configured to acquire a preset condition according to the target ratio; The fourth acquisition module is further configured to acquire a first preset condition when the target ratio is within a first range, wherein the first preset condition is the color with the largest number of pixels occupied by each of the colors in the area to be extracted; The fourth acquisition module is further configured to acquire a second preset condition when the target ratio is within a second range, wherein the second preset condition is that the color of each of the various colors included in the pixels in the area to be extracted, excluding the pixels occupied by the target object, has the largest number of pixels, and the first range is smaller than the second range; A second acquisition module is used to acquire a target color in the area to be extracted, where the target color is a color in the area to be extracted that meets the preset conditions; A color filling module, used to fill the color of the target style base with the target color; The image generation module is used to generate a target image based on the image to be processed and the target style base, wherein the target image uses the target style base as the background of the image to be processed.

7. A server, characterized in that: The server includes a memory and a processor, wherein a computer program is stored in the memory. When the computer program is executed by the processor, the processor implements the image generation method according to any one of claims 1 to 5.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the image generation method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Vehicle color identification method based on defogging processing and weight blocking

    CN104715239A

  • Color setting method, device, apparatus, and computer-readable storage medium

    CN109410295A

  • Image processing method and device and electronic equipment

    CN110599571A