Image processing method, apparatus, storage medium, device, and computer program product
By acquiring image feature representation data and target color swatches from a color swatch library, image colors are processed automatically, solving the problem of time-consuming and labor-intensive manual color replacement in existing technologies and improving image design effects.
Patent Information
- Application Number
- CN202210506589.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-10
- Publication Date
- 2026-02-13
- Estimated Expiration
- 2042-05-10
AI Technical Summary
In existing technologies, image color changing requires manual operation, which is time-consuming, labor-intensive, and lacks standardization and regularization, resulting in poor image quality.
By acquiring the feature representation data of the image, including key color values and target color value ranges, the target color swatch is automatically determined from the color swatch library, and the target color swatch is used to perform color replacement processing on the layer elements in the image.
It automates image color changing, improving the quality of image design.
Smart Images

Figure CN115115725B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, in particular to an image processing method, an image processing device, a computer readable storage medium, a computer device and a computer program product. BACKGROUND
[0002] In the prior art, if color changing is required for electronic banners, interactive design interfaces and the like, people need to change the color of each layer element manually, even if a semi-automatic method is used, people need to mark each layer in advance and determine the color relationship between layers, and then the machine changes the color according to the marking information. These methods are time-consuming and laborious, and the color matching is not standardized and regularized, resulting in poor image effect. SUMMARY
[0003] The embodiments of the present application provide an image processing method, device, storage medium, equipment and computer program product, which can automatically change the color of an image and improve the design effect of the image.
[0004] In one aspect, the embodiments of the present application provide an image processing method, which comprises:
[0005] obtaining a to-be-processed image, wherein the to-be-processed image comprises one or more layer elements;
[0006] determining feature representation data of the to-be-processed image based on the one or more layer elements, wherein the feature representation data comprises one or both of N key color values and a target color value interval, and N is a positive integer;
[0007] determining a target color palette from a plurality of color palettes included in a color palette library based on the feature representation data;
[0008] performing color replacement processing on each layer element in the to-be-processed image by using the target color palette, to obtain a target image.
[0009] In one aspect, the embodiments of the present application provide an image processing device, which comprises:
[0010] an obtaining unit, configured to obtain a to-be-processed image, wherein the to-be-processed image comprises one or more layer elements;
[0011] a processing unit, configured to determine feature representation data of the to-be-processed image based on the one or more layer elements, wherein the feature representation data comprises one or both of N key color values and a target color value interval, and N is a positive integer;
[0012] The processing unit is further configured to determine a target color palette from a plurality of color palettes included in a color palette library based on the feature representation data.
[0013] The processing unit is further configured to perform color replacement processing on each layer element in the image to be processed by using the target color palette, to obtain a target image.
[0014] In an aspect, the embodiments of the present application provide a computer device, which comprises a processor, a communication interface and a memory, the processor, the communication interface and the memory are connected with each other, wherein the memory stores a computer program, and the processor is configured to invoke the computer program to execute the image processing method according to any possible implementation manner.
[0015] In an aspect, the embodiments of the present application provide a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the image processing method according to any possible implementation manner.
[0016] Correspondingly, the embodiments of the present application further provide a computer program product, the computer program product comprises a computer program or computer instructions, and the computer program or computer instructions are executed by a processor to implement the steps of the image processing method provided by the embodiments of the present application.
[0017] Correspondingly, the embodiments of the present application further provide a computer program, the computer program comprises computer instructions, the computer instructions are stored in a computer readable storage medium, a processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer device executes the image processing method provided by the embodiments of the present application.
[0018] In the embodiments of the present application, an image to be processed can be acquired, the image to be processed comprises one or more layer elements, feature representation data of the image to be processed is determined based on the one or more layer elements, the feature representation data comprises one or both of N key color values and a target color value interval, N is a positive integer, a target color palette is determined from a plurality of color palettes included in a color palette library based on the feature representation data, and each layer element in the image to be processed is subjected to color replacement processing by using the target color palette, to obtain a target image. Through the method of the present application, image color changing can be automatically performed, and the design effect of the image is improved. BRIEF DESCRIPTION OF DRAWINGS
[0019] In order to more clearly illustrate the technical methods of the embodiments of the present application, the drawings required in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0020] Figure 1A system architecture schematic diagram of an image processing system provided by an embodiment of the present application is provided.
[0021] Figure 2 A flowchart of an image processing method provided by an embodiment of the present application is provided Figure 1 ;
[0022] Figure 3 A flowchart of an image processing method provided by an embodiment of the present application is provided Figure 2 ;
[0023] Figure 4 A flowchart of an image processing method provided by an embodiment of the present application is provided Figure 3 ;
[0024] Figure 5 A training schematic diagram of an emotion classification model provided by an embodiment of the present application is provided.
[0025] Figure 6 A training schematic diagram of an expression recognition model provided by an embodiment of the present application is provided.
[0026] Figure 7 An output schematic diagram of an expression recognition model provided by an embodiment of the present application is provided.
[0027] Figure 8 A schematic diagram of a color and emotion wheel provided by an embodiment of the present application is provided.
[0028] Figure 9 A schematic diagram of a spatial distance involved in a cosine similarity algorithm provided by an embodiment of the present application is provided.
[0029] Figure 10 An example schematic diagram of a color palette provided by an embodiment of the present application is provided.
[0030] Figure 11 A flowchart of an image processing method provided by an embodiment of the present application is provided Figure 4 ;
[0031] Figure 12 A structural schematic diagram of an image processing device provided by an embodiment of the present application is provided.
[0032] Figure 13 A structural schematic diagram of a computer device provided by an embodiment of the present application is provided. DETAILED DESCRIPTION
[0033] The technical methods in the embodiments of the present application will be clearly and completely described below with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative efforts fall within the scope of the present application.
[0034] The present application provides an image processing method, which can automatically change the color of an image, improve the design effect of the image, and can be applied to various fields or scenarios such as cloud technology, artificial intelligence, blockchain, Internet of Vehicles, intelligent transportation, smart home, etc. In an embodiment, the image processing method can be implemented based on machine learning technology in artificial intelligence technology. Machine Learning (ML) is a multi-disciplinary subject involving probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory, etc. It is a subject that studies how computers simulate or implement human learning behavior to acquire new knowledge or skills, reorganize existing knowledge structure to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental approach to making computers intelligent, and its applications are widespread in various fields of artificial intelligence. Machine learning and deep learning usually include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and rule-based learning.
[0035] In a feasible embodiment, the image processing method can also be implemented based on cloud technology. Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. applied based on the cloud computing business model, which can form a resource pool for on-demand use and flexible convenience. Cloud computing technology will become an important support. The background service of a technical network system requires a large amount of computing and storage resources, such as video websites, picture websites, and more portals. With the high development and application of the Internet industry, every item in the future may have its own identification mark and needs to be transmitted to the background system for logical processing. Different levels of data will be processed separately, and various industry data will need strong system support, which can only be realized through cloud computing. The image processing method provided in the embodiments of the present application can specifically involve one or more of cloud storage, cloud database, and big data in cloud technology. For example, data required for executing the image processing method (such as images to be processed, etc.) is obtained from the cloud database.
[0036] Please refer to Figure 1 , Figure 1 The system architecture diagram of an image processing system provided in the embodiments of the present application is shown in FIG. 1. Figure 1The system architecture shown can be used to implement the image processing method proposed in the embodiments of the present application. As shown in the figure Figure 1 The network architecture shown includes a server 10 and a plurality of terminal devices 11 (three are shown as an example in the figure).
[0037] The server 10 can be a standalone physical server, a server cluster or a distributed system composed of a plurality of physical servers, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and basic cloud computing services such as big data and artificial intelligence platforms. The terminal device 11 can be a smartphone, a tablet computer, a notebook computer, a desktop computer, a smart voice interaction device, a smart home appliance, a vehicle-mounted terminal, etc., but is not limited thereto. Figure 1 The terminal device 11 and the server 10 are connected through a network, as shown.
[0038] Figure 1 The system architecture shown can implement the image processing method provided by the embodiments of the present application. Taking the server 10 or the terminal device 11 as an example, the implementation process of the method includes: the server 10 or the terminal device 11 obtains a to-be-processed image, the to-be-processed image includes one or more layer elements, further determines feature representation data of the to-be-processed image based on the one or more layer elements, the feature representation data includes one or both of N key color values and a target color value interval, N is a positive integer, further determines a target color palette from a plurality of color palettes included in a color palette library based on the feature representation data, and performs color replacement processing on each layer element in the to-be-processed image using the target color palette to obtain a target image; using the method of the present application, the image color can be automatically replaced, and the design effect of the image can be improved.
[0039] In an embodiment, the image processing method can be jointly executed by the server 10 and the terminal device 11. Specifically, the server 10 receives the to-be-processed image sent by the terminal device 11, performs color replacement processing using the image processing method of the present application to obtain a target image, and returns the target image to the terminal device 11.
[0040] It can be understood that the system architecture diagram described in the embodiments of the present application is used to more clearly illustrate the technical solutions of the embodiments of the present application, and does not constitute a limitation on the technical solutions provided by the embodiments of the present application. Those skilled in the art can know that the technical solutions provided by the embodiments of the present application are also applicable to similar technical problems as the system architecture evolves and new business scenarios appear.
[0041] The specific implementation of the image processing method is described in detail below.
[0042] Please refer to Figure 2 , Figure 2 A flowchart of an image processing method provided in an embodiment of the present application Figure 1 The method can be applied to the server 10 and / or the terminal device 11 in the image processing system described above, and the method includes but is not limited to the following steps:
[0043] S201, obtaining a to-be-processed image, the to-be-processed image including one or more layer elements.
[0044] In an embodiment of the present application, the to-be-processed image can be an image source file obtained by using Photoshop (PS) and Sketch and other graphic design software. The to-be-processed image can be used to make an electronic banner in a website page and an application, and an interactive design interface of an application, etc. The to-be-processed image includes one or more layer elements, which can include text, images, tables, plug-ins, etc.
[0045] S202, determining feature representation data of the to-be-processed image based on the one or more layer elements, the feature representation data including one or both of N key color values and a target color value interval, the N being a positive integer.
[0046] The N key color values are used to describe the color matching relationship between the layer elements in the to-be-processed image, and are obtained by color analysis on the original color values of the layer elements in the to-be-processed image. The original color value of each layer element in the to-be-processed image refers to the color value corresponding to the color included in each layer element in the to-be-processed image, which includes one or more of the three attributes of hue (H), lightness (L) and chroma (C). Hue, saturation and lightness are three attributes of color. Hue is the primary feature of color and the most accurate standard to distinguish different colors. Saturation refers to the degree of color brightness, and lightness refers to the degree of color brightness. It should be noted that the key color value can also include one or more of hue, saturation and lightness. The key color value obtained by color analysis on the hue corresponding to the color of each layer element in the to-be-processed image is hue. The same applies to saturation and lightness.
[0047] Color is related to people's emotion and feeling, for example, red represents passion, self-confidence and energy, orange represents cheerfulness, health and kindness, the application can determine the target emotion that the target image corresponding to the to-be-processed image needs to provide, and take the numerical interval of the color representing the target emotion on the color spectrum as the target color value interval. For example, when the target image is expected to provide the emotion of passion and self-confidence to people, the color representing passion and self-confidence can be determined as red, and the numerical interval of red on the 36-color spectrum is (0, 10), so the target color value interval is (0, 10).
[0048] wherein the color spectrum refers to a circularly arranged color spectrum, colors are arranged in the order of spectrum appearing in nature, each color is a numerical interval in the color spectrum, and each color in the color spectrum can be represented by 0 to 255. The 36-color spectrum means that there are 36 colors in the color spectrum.
[0049] In the embodiment of the application, the feature representation data of the to-be-processed image can include one or both of the N key color values and the target color value interval. In an embodiment, if the feature representation data of the to-be-processed image includes the N key color values, the N key color values are determined based on the representative color values of each of the one or more layer elements. If the feature representation data of the to-be-processed image includes the target color value interval, the target color value interval is determined based on the state indication data corresponding to the one or more layer elements. If the feature representation data of the to-be-processed image includes the N key color values and the target color value interval, the N key color values are determined based on the representative color values of each of the one or more layer elements, and the target color value interval is determined based on the state indication data corresponding to the one or more layer elements.
[0050] S203, determining a target color palette from a plurality of color palettes included in a color palette library based on the feature representation data.
[0051] The color palette library includes a plurality of color palettes, each color palette includes at least N colors, but only N colors in the color palette are needed in actual use of the color palette, therefore, the application is described by taking each color palette including N colors as an example. In addition, it should be noted that each color corresponds to three attributes: color value, saturation and brightness, therefore, each color palette also includes N color values, that is, each color palette includes N hues, N saturations and N brightnesses.
[0052] In an embodiment, the target color palette can be determined from a plurality of color palettes included in the color palette library based on the N key color values, including: obtaining a fitting degree value corresponding to each color palette in the plurality of color palettes. For example, the N key color values are hue A1, hue A2, and hue A3, respectively, and the color palette A in the color palette library includes three colors corresponding to hue B1, hue B2, and hue B3, respectively, then the fitting degree value corresponding to the color palette A can be obtained as: ||hue A1-hue A2|-|hue B1-hue B2||+||hue A1-hue A3|-|hue B1-hue B3||+||hue A2-hue A3|-|hue B2-hue B3||. After obtaining the fitting degree value corresponding to each color palette in the plurality of color palettes, the color palette corresponding to the smallest fitting degree value in the plurality of color palettes can be taken as the target color palette, or the color palette corresponding to the fitting degree value greater than a preset degree value (which can be artificially set) can be taken as the target color palette. This is because the smaller the fitting degree value, the closer the color matching relationship between the N target color values included in the target color palette to the color matching relationship between the N key color values, and the N key color values describe the color matching relationship between the elements of each layer in the image to be processed, so the N target color values included in the target color palette also describe similar or identical color matching relationships.
[0053] In an implementation, the acquiring the fitting degree value corresponding to each of the plurality of color palettes comprises: when the key color value comprises one or more of hue, lightness and saturation, a first fitting degree value can be determined by using the hue comprised in the N key color values and the hue corresponding to the N colors comprised in each color palette; a second fitting degree value can be determined by using the saturation comprised in the N key color values and the saturation corresponding to the N colors comprised in each color palette; a third fitting degree value can be determined by using the lightness comprised in the N key color values and the lightness corresponding to the N colors comprised in each color palette; and the fitting degree value corresponding to each color palette can be determined by using one or more of the first fitting degree value, the second fitting degree value and the third fitting degree value. For example, the hue comprised in the N key color values is hue A1, hue A2 and hue A3, the saturation comprised in the N key color values is saturation A1, saturation A2 and lightness A2, and the lightness comprised in the N key color values is lightness A1, lightness A2 and lightness A2. The hue, saturation and lightness corresponding to the 3 colors comprised in the color palette A in the color palette library are hue B1, hue B2, hue B3, saturation B1, saturation B2, saturation B3 and lightness B1, lightness B2, lightness B3 respectively. Then the first fitting degree value is ||hue A1-hue A2|-hue B1-hue B2||+||hue A1-hue A3|-hue B1-hue B3||+||hue A2-hue A3|-hue B2-hue B3||, the second fitting degree value is ||saturation A1-saturation A2|-saturation B1-saturation B2||+||saturation A1-saturation A3|-saturation B1-saturation B3||+||saturation A2-saturation A3|-saturation B2-saturation B3||, the third fitting degree value is ||lightness A1-lightness A2|-lightness B1-lightness B2||+||lightness A1-lightness A3|-lightness B1-lightness B3||+||lightness A2-lightness A3|-lightness B2-lightness B3||, and the fitting degree value corresponding to the color palette A is obtained according to (weighting coefficient 1 x the first fitting degree value + weighting coefficient 2 x the second fitting degree value + weighting coefficient 3 x the third fitting degree value) / 3. When the key color value does not comprise hue, the weighting coefficient 1 is 0; when the key color value does not comprise saturation, the weighting coefficient 2 is 0; and when the key color value does not comprise lightness, the weighting coefficient 3 is 0. In addition, when the key color value comprises hue, saturation and lightness, since hue is the primary feature of color, the weighting coefficient 1 can be set to be relatively large, and the weighting coefficient 2 and the weighting coefficient 3 can be set to be relatively small.
[0054] In another embodiment, the target color palette can be determined from the plurality of color palettes included in the color palette library based on the target color value interval. For example, if there is at least one color in the N colors included in the color palette A that is in the target color value interval (0, 10), the color palette A can be taken as the target color palette.
[0055] In an implementable embodiment, the target color palette can also be determined from the plurality of color palettes included in the color palette library based on the target color value interval and the N key color values. For example, one or more candidate color palettes can be determined from the plurality of color palettes included in the color palette library, at least one candidate color in the N candidate colors included in each candidate color palette is in the target color value interval or in the numerical interval on the color wheel, a fitting degree value corresponding to each candidate color palette is further calculated, and the candidate color palette corresponding to the minimum fitting degree value in the one or more candidate color palettes is taken as the target color palette.
[0056] S204, color replacement processing is performed on each layer element in the to-be-processed image by using the target color palette, and a target image is obtained.
[0057] The color replacement processing refers to replacing the original color value of each layer element in the to-be-processed image with the target color value in the target color palette. It should be noted that color includes three inherent properties: hue, saturation, and lightness. In the color replacement processing, the hue corresponding to the color in the target color palette (i.e., the target color value) is used to replace the hue corresponding to the color of each layer element in the to-be-processed image (i.e., the original color value), and the lightness and saturation are the same. In an implementation manner, the color replacement processing can be to replace one or more of the lightness, hue, and saturation corresponding to the color of each layer element in the to-be-processed image. Since the hue is the main color feature of color, only the hue can be replaced in the color replacement processing, and the original lightness and saturation are retained.
[0058] In the embodiments of the present application, a to-be-processed image including one or more layer elements can be obtained, feature representation data of the to-be-processed image is determined based on the one or more layer elements, the feature representation data includes one or both of N key color values and a target color value interval, N is a positive integer, a target color palette is determined from a plurality of color palettes included in a color palette library based on the feature representation data, color replacement processing is performed on each layer element in the to-be-processed image by using the target color palette, and a target image is obtained. Through the method of the present application, image color changing can be automatically performed, and the design effect of the image is improved.
[0059] Please refer to Figure 3 , Figure 3 A flowchart of an image processing method provided in the embodiments of the present application Figure 2The method can be applied to the server 10 and / or the terminal device 11 in the image processing system described above, and the method includes but is not limited to the following steps:
[0060] S301, obtaining a to-be-processed image, the to-be-processed image including one or more layer elements.
[0061] In an implementation, the to-be-processed image can be stored in a server or a terminal device, and the server or the terminal device can obtain the to-be-processed image locally. Alternatively, the terminal device can send the to-be-processed image to the server after obtaining the to-be-processed image locally. Alternatively, the terminal device can receive the to-be-processed image input by a user through the terminal device and send the input to-be-processed image to the server.
[0062] The one or more layer elements included in the to-be-processed image can be obtained by parsing a source file of the to-be-processed image, and the parsing can be implemented by a parsing plug-in or a parsing program. For example, the source file of the to-be-processed image can be a PS file, and the layer information can be obtained by parsing the PS file, the layer information including a plurality of layer elements in an image corresponding to the PS file, and the size, position, etc. of each layer element.
[0063] In an implementation, the length and width of the to-be-processed image can be compressed, for example, to 100x100 pixels, to reduce the amount of calculation.
[0064] S302, determining N key color values based on the representative color values of each layer element in the one or more layer elements, N being a positive integer.
[0065] Processing mode 1:
[0066] In an embodiment, referring to Figure 4 determining the N key color values based on the representative color values of each layer element in the one or more layer elements includes the following steps:
[0067] S3021, obtaining the representative color values of each layer element in the one or more layer elements.
[0068] The representative color value of a layer element is one or more of the hue, lightness, and saturation corresponding to the color of the layer element. The representative color value of each layer element is used to determine the N key color values, and the representative color value of each layer element is determined according to the original color value of each layer element. Since hue is the primary characteristic of color, and the processing mode of lightness and saturation is consistent with that of hue, the present application takes the representative color value of a layer element as hue for illustration. It should be noted that when the representative color value of a layer element is hue, the original color value and the key color value of the layer element are also hue, and the same applies to saturation and lightness.
[0069] The target layer element is any layer element in the image to be processed. In an embodiment, the characteristic color value of the target layer element is obtained by: a single color layer refers to a layer element having only a single color. If the target layer element is a single color layer, the hue (and also the lightness or saturation) corresponding to the single color included in the target layer element is obtained as the original color value of the target layer element, and the original color value of the target layer element is taken as the characteristic color value of the target layer element.
[0070] A similar color layer refers to a layer element having a series of similar colors. When the differences between the hues, saturations, and lightnesses of the colors in the layer element are within a certain range, it can be determined that the layer element is a similar color layer, such as bright red, crimson, and pink. If the target layer element is a similar color layer, the hues (and also the lightnesses or saturations) corresponding to the colors included in the target layer element are obtained as the original color values of the target layer element, and the number of pixel points of the colors included in the target layer element in the target layer element is taken as the number of pixel points corresponding to the original color values of the target layer element. Further, the characteristic color value of the target layer element is determined according to the original color values of the target layer element and the number of pixel points corresponding to the original color values of the target layer element. Specifically, since the target layer element includes multiple colors, the original color values of the target layer element are also multiple, and the multiple original color values of the target layer element can be multiplied by the number of pixel points corresponding to each of the multiple original color values and summed, and then divided by the sum of the number of pixel points corresponding to the multiple original color values. For example, the multiple original color values of the target layer element are hue A1, hue A2, and hue A3, and the number of pixel points corresponding to hue A1, hue A2, and hue A3 are 100, 99, and 98, respectively. Then, the characteristic color value of the target layer element is (hue A1×100 + hue A2×99 + hue A3×98) / (100+99+98).
[0071] When the differences between the hues, saturations, and lightnesses of the colors in the layer element are not within a certain range, it can be determined that the layer element is a multi-color layer, such as red, blue, and green. If the target layer element is a multi-color layer, the original color values of the target layer element are processed according to an image theme color extraction algorithm to obtain the characteristic color value of the target layer element. The image theme color extraction algorithm can be an octree algorithm.
[0072] In a specific implementation, when the target layer element is a multi-color color layer, a hue (and also a lightness or a saturation) corresponding to a color included in the target layer element can be taken as an original color value of the target layer element, and a number of pixel points of the color in the target layer element can be taken as a number of pixel points corresponding to the original color value of the target layer element. Further, the multiple original color values of the target layer element can be subjected to clustering processing, which can be implemented by a k-Means algorithm, a density-based clustering method, or the like, to obtain R (a positive integer) clusters. Each cluster includes at least one original color value. For the R clusters, the at least one original color value included in each cluster is multiplied by a number of pixel points corresponding to the at least one original color value and summed, and after the summing, the sum is divided by a total of the numbers of pixel points corresponding to the at least one original color value, to obtain R representative color values of the target layer element.
[0073] It should be noted that the representative color value determined by using the hue (original color value) corresponding to the color in the target layer element is also a hue, the representative color value determined by using the lightness (original color value) corresponding to the color in the target layer element is also a lightness, and the representative color value determined by using the saturation (original color value) corresponding to the color in the target layer element is also a saturation.
[0074] S3022, acquire a number of pixel points corresponding to a representative color value of each layer element.
[0075] If the target layer element is a single-color layer, a number of pixel points of the single color included in the target layer element in the target layer element is taken as a number of pixel points corresponding to a representative color value of the target layer element. If the target layer element is a similar color layer, the number of pixel points corresponding to the representative color value of the target layer element is a total of numbers of pixel points corresponding to multiple original color values of the target layer element. If the target layer element is a multi-color color layer, as known from the above S3021, the target layer element has R representative color values, and each representative color value is determined according to at least one original color value included in a corresponding cluster in the R clusters, and then the number of pixel points corresponding to each representative color value is a total of numbers of pixel points corresponding to the at least one original color value included in the corresponding cluster of the each representative color value.
[0076] S3023, perform clustering processing on the representative color values of each layer element to obtain N clusters, and each cluster includes at least one representative color value.
[0077] S3024, determine a key color value of each cluster according to at least one representative color value included in the each cluster and a number of pixel points corresponding to the at least one representative color value.
[0078] Specifically, at least one representative color value included in each of the N clusters is multiplied by the number of pixel points corresponding to the at least one representative color value respectively, and then summed up, and after the summation, the sum of the number of pixel points corresponding to the at least one representative color value is divided to obtain the key color value of each cluster. Finally, the N clusters can obtain N key color values.
[0079] In an available embodiment, the position and size of each layer element can also be obtained. When the target layer element is mostly blocked by the upper layer element, or is located at a corner position, it can be determined that the position of the target layer element is at the reference position. When the position of the target layer element is at the reference position, the color of the target layer element can be considered to have no reference value. Therefore, when steps S3021-S3024 are executed, the target layer element can be removed from the image to be processed, that is, the color of the target layer element is not used to determine the representative color value and the key color value. In addition, when the size of the target layer element is smaller than the preset size, the color of the target layer element can also be considered to have no reference value. Therefore, when steps S3021-S3024 are executed, the target layer element can be removed from the image to be processed.
[0080] Processing mode 2:
[0081] In another embodiment, determining N key color values based on the representative color value of each layer element in one or more layer elements comprises: obtaining the representative color value of each layer element in one or more layer elements. For details, please refer to S3021 described above. This embodiment will not be described again.
[0082] Further, the color relationship model can be obtained by training a machine learning model using a plurality of training color samples and N labeled color values corresponding to each training color sample. The N labeled color values satisfy a target color matching relationship. The target color matching relationship can be a three-color color matching relationship, i.e., the relationship between a primary color, a secondary color, and a contrast color, wherein the primary color and the secondary color are similar, and the contrast color and the primary color are not similar. The target color matching relationship can also be other color matching relationships, such as three colors being similar, etc. In a feasible implementation, each training color sample can be used as an input of the machine learning model, and a regression learning is performed between the output of the machine learning model and the N labeled color values corresponding to each training color sample, so that the error between the output of the machine learning model and the N labeled color values corresponding to each training color sample becomes smaller and smaller. When the error is less than a preset error value, the trained machine learning model is used as the color relationship model. Finally, the color relationship model is used to process the representation color values of the elements of each layer, and N key color values can be obtained, and the N key color values satisfy the target color matching relationship. For example, the three key color values output by the color relationship model for the image to be processed are cyan, violet, and purple, wherein the cyan and violet are not similar, and the violet and purple are similar.
[0083] In addition, the elements of each layer in the target image generated using the N key color values also satisfy the target color matching relationship. For example, the N key color values satisfy the three-color color matching relationship, and the elements of each layer in the target image also satisfy the three-color color matching relationship. Therefore, determining the N key color values in this way can make the elements of each layer in the target image satisfy the preset color matching relationship.
[0084] It should be noted that when the representation color values of the elements of each layer are hues, the training color samples can include a plurality of hues, so that the key color values output by the color relationship model are also predicted hues. The same applies when the representation color values are saturations or luminances. When the representation color values of the elements of each layer include multiple ones of hues, luminances, and saturations, the training color samples can be a plurality of color pairs, each color pair including a hue, a luminance, and a saturation, so that the key feature values output by the color relationship model can include one or more of a hue, a luminance, and a saturation.
[0085] S303, determining a target color value interval based on the state indication data corresponding to the one or more layer elements.
[0086] In an embodiment, determining a target color value interval based on the state indication data corresponding to the one or more layer elements includes: obtaining the state indication data corresponding to the one or more layer elements, the state indication data including one or both of first state data and second state data.
[0087] The first state data is obtained by state recognition on text data included in each of the one or more layer elements. In an implementation, obtaining the first state data includes: obtaining a text layer element containing text from the one or more layer elements, and extracting text data included in the text layer element. Further, in state recognition on the text data, an emotion classification model can be obtained, such as shown in Figure 5 The training sample set includes a plurality of training texts and an emotion label (e.g., happy, passionate, sad, etc.) corresponding to each training text. Each training text is subjected to word vectorization processing to obtain a vector corresponding to each training text. The vector corresponding to each training text is input into a deep neural network + softmax layer, and the output of the softmax layer and the emotion label corresponding to each training text are used for classification learning, i.e., the output of the softmax layer and the emotion label corresponding to each training text are used to obtain a training loss value. If the training loss value is less than a preset loss value, the trained deep neural network + softmax layer is used as the emotion classification model. Finally, the vector corresponding to the text data is input into the emotion classification model. Since the output layer of the emotion classification model is a softmax layer, the classification probability of the text data belonging to each emotion can be obtained through the softmax layer. The emotion corresponding to the maximum classification probability or the emotion corresponding to the classification probability greater than a preset probability value can be taken as the first state data, and the emotion is described by the text.
[0088] In an implementation, when extracting the text data included by the text layer element, all the text included by the text layer element can be extracted as the text data, for example, "we are good friends" and "how many words in the work" in the image to be processed are all taken as the text data; or keywords can be extracted from all the text included by the text layer element, and the extracted keywords are taken as the text data, for example, the keywords "good friends" and "work" are extracted from "we are good friends" and "how many words in the work". When extracting the keywords, an unsupervised learning method such as a TF-IDF (Term Frequency-Inverse Document Frequency) algorithm, a TextRank algorithm, an LDA (Latent Dirichlet Allocation) algorithm, or the like can be used to extract the keywords from all the text included by the text layer element. Taking the TF-IDF algorithm as an example, all the text included by the text layer element can be subjected to word segmentation to obtain a plurality of segmented words, and then a TF-IDF value of each segmented word can be calculated according to the following formulas (1)-(3). The TF-IDF value can evaluate the importance of the segmented word in all the text included by the text layer element.
[0089] TF (Term Frequency) of segmented word A = frequency of segmented word A in all the text included by the text layer element / total number of segmented words in all the text included by the text layer element (1)
[0090] IDF (Inverse Document Frequency) of segmented word A = log[number of texts in a text library / (number of texts containing segmented word A + 1)] (2)
[0091] TF-IDF value of segmented word A = TF of segmented word A * IDF of segmented word A (3)
[0092] After the TF-IDF values of the plurality of segmented words are obtained, the specified number of segmented words with the highest TF-IDF values can be taken as the extracted keywords, that is, as the text data included by the text layer element.
[0093] In addition, the keywords can also be extracted according to the TextRank algorithm described in the following formula (4) to obtain the text data included by the text layer element.
[0094] (4)
[0095] wherein, representing the weight of the segmented word, and the summation on the right represents the contribution of each adjacent segmented word to the segmented word, i i representing the similarity of the two segmented words, representing the weight of the previous segmented word, j and d is a damping coefficient, generally 0.85. When the weights of multiple segmented words are obtained, the specified number of segmented words with the highest weights can be extracted as keywords, i.e., the text data included in the text layer element.
[0096] The second state data is obtained by performing state recognition on the image data included in each layer element. In a feasible implementation, obtaining the second state data includes: obtaining an image layer element containing an image from one or more layer elements, and extracting image data included in the image layer element. Then, an expression recognition model accessed through a face detection interface is used to perform expression recognition on the image data included in the image layer element, and the recognized expression, which is specifically described by text, is taken as the second state data. As shown in Figure 6 , a mobileNet+Polling+Softmax model can be classified and trained using multiple images and the expression labels corresponding to each image, and the trained mobileNet+Polling+Softmax model is taken as the expression recognition model. As shown in Figure 7 , the expression detected for the image Figure 7 is “angry”. It should be noted that the real face in the image data is used after obtaining the user’s permission or allowance.
[0097] Further, a state label corresponding to each reference color value interval in a plurality of reference color value intervals is obtained. As shown in Figure 8 , a color and emotion wheel is displayed, and some emotions represented by colors are illustrated in the color and emotion wheel, such as red representing passion, sexiness, authority, confidence, energy, self, and confidence; orange representing maternal love, elder sister, enthusiasm, kindness, frankness, cheerfulness, and health; green representing safety, coordination, freedom, peace, freshness, and comfort, etc. Each color is represented by a numerical interval on the color and emotion wheel, and the numerical intervals corresponding to the plurality of colors can be taken as the plurality of reference color value intervals, and the emotions represented by each color can be taken as the state label corresponding to each reference color value interval. Then, according to the feature similarity between the state indication data and the state label corresponding to each reference color value interval, a target color value interval is determined from the plurality of reference color value intervals.
[0098] Specifically, vectors of the state indication data and vectors of the state labels corresponding to each reference color value interval can be obtained by a word vector technology (for example, a wrod2vec word vector technology) to map the text to a high-dimensional space. Then, the feature similarity between the state indication data and the state labels corresponding to each reference color value interval is determined by using the vectors of the state indication data and the vectors of the state labels corresponding to each reference color value interval. If the text included in the state indication data is only one, and the state labels corresponding to each reference color value interval are also only one, a first similarity is obtained by a cosine similarity algorithm shown in the following formula (5), and the first similarity is taken as the feature similarity between the state indication data and the state labels corresponding to each reference color value interval. As shown in the following formula (5), the feature similarity obtained by the cosine similarity algorithm is actually the spatial distance of the text in the high-dimensional space. Figure 9
[0099] (5)
[0100] wherein, a , b represents two vectors, N represents the dimension of the two vectors is [1, N ], represents the similarity between a and b.
[0101] If the text included in the state indication data is only one, and the state labels corresponding to each reference color value interval are multiple, a second similarity between the one text and each state label can be obtained according to the cosine similarity algorithm shown in the formula (5), the average of the sum of the second similarities between the one text and all state labels is calculated, and the average is taken as the feature similarity between the state indication data and the state labels corresponding to each reference color value interval. If the text included in the state indication data is multiple, and the state labels corresponding to each reference color value interval are multiple, a third similarity between each text and each state label is obtained, the average of the sum of the third similarities between all texts and all state labels is calculated, and the average is taken as the feature similarity between the state indication data and the state labels corresponding to each reference color value interval.
[0102] Finally, the reference color value interval corresponding to the maximum feature similarity in the multiple reference color value intervals can be taken as the target color value interval, or the reference color value interval corresponding to the feature similarity greater than a preset similarity in the multiple reference color value intervals can be taken as the target color value interval.
[0103] S304, determining a target color card from a plurality of color cards included in a color card library based on the feature representation data.
[0104] In an embodiment, determining the target color palette from the plurality of color palettes included in the color palette library based on the feature representation data comprises: determining M candidate color palettes from the plurality of color palettes according to the target color value interval, each candidate color palette including N candidate color values, at least one of the N candidate color values matching the target color value interval, M being a positive integer.
[0105] It should be noted that a color palette includes N colors, each color corresponding to a hue (and can also correspond to a saturation or a lightness), so the color palette includes N color values, and the candidate color palette includes N candidate color values. The target color value interval refers to a numerical interval of colors in a hue circle, so that at least one of the N candidate color values matches the target color value interval, which means that the numerical interval of the color corresponding to the at least one candidate color value in the candidate color palette in the hue circle is located in the target color value interval, or is the same as the target color value interval. When the target color palette is subsequently determined from the M candidate color palettes, it can be ensured that at least one color in the target color palette can represent the above target emotion. In addition, a sufficient number of color palettes can be stored in the color palette library, and the number of color palettes determines how many different color matching relationships can be matched. If it is required that the color matching relationship between each layer element in the generated target image meets the target color matching relationship, such as a three-color color matching relationship, a color palette meeting the target color matching relationship can be added to the color palette library. For example, Figure 10 The three colors in the color palette in the above example meet the three color matching relationships, i.e., the red color is the primary color, the orange color is the auxiliary color, and the cyan color is the contrast color.
[0106] In an implementation, if the N candidate color values are determined by the above processing method 2, and the N candidate color values meet the three-color color matching relationship, it can be required that the candidate color value representing the primary color in the N candidate color values matches the target color value interval.
[0107] Further, a fitting degree value corresponding to each candidate color palette is determined according to a first difference value between any two of the N key color values and a second difference value between any two of the N candidate color values. Taking hue as an example of the key color values, for example, the N key color values are hue A1, hue A2, and hue A3, and the N candidate color values are hue B1, hue B2, and hue B3. The first difference values are |hue A1-hue A2|, |hue A1-hue A3|, and |hue A2-hue A3|, and the second difference values are |hue B1-hue B2|, |hue B1-hue B3|, and |hue B2-hue B3|. The fitting degree value corresponding to each candidate color palette is the sum of the absolute values of the first difference value minus the second difference value: ||hue A1-hue A2|-hue B1-hue B2||+||hue A1-hue A3|-hue B1-hue B3||+||hue A2-hue A3|-hue B2-hue B3||. Then, the target color palette is determined from the M candidate color palettes according to the fitting degree value corresponding to each candidate color palette. Specifically, the color palette corresponding to the smallest fitting degree value can be taken as the target color palette, or the color palette corresponding to the fitting degree value greater than a preset degree value can be taken as the target color palette. Because the smaller the fitting degree value, the closer the color matching relationship between the N color values included in the target color palette to the color matching relationship between the N key color values, and the N key color values describe the color matching relationship between the elements of each layer in the image to be processed, the N target color values included in the target color palette also describe similar or identical color matching relationships.
[0108] The above examples only illustrate that the key color value is hue, but since the key color value can include one or more of hue, lightness, and saturation, determining the fitting degree value corresponding to each candidate color palette includes: determining a first fitting degree value using the first difference between each pair of hues included in the N key color values and the second difference between the N hues included in each candidate color palette; determining a second fitting degree value using the first difference between each pair of saturations included in the N key color values and the second difference between each pair of saturations included in each candidate color palette; determining a third fitting degree value using the first difference between each pair of lightnesses included in the N key color values and the second difference between each pair of lightnesses included in each candidate color palette; and determining the fitting degree value corresponding to each color palette using one or more of the first fitting degree value, the second fitting degree value, and the third fitting degree value. For example, the hues included in the N key color values are hue A1, hue A2, and hue A3, the saturations included in the N key color values are saturation A1, saturation A2, and lightness A2, and the lightnesses included in the N key color values are lightness A1, lightness A2, and lightness A2. The hues, saturations, and lightnesses corresponding to the three colors included in color palette A in the color palette library are hue B1, hue B2, hue B3, saturation B1, saturation B2, saturation B3, lightness B1, lightness B2, and lightness B3. Then the first fitting degree value = ||hue A1 - hue A2| - |hue B1 - hue B2|| + ||hue A1 - hue A3| - |hue B1 - hue B3|| + ||hue A2 - hue A3| - |hue B2 - hue B3||, the second fitting degree value = ||saturation A1 - saturation A2| - |saturation B1 - saturation B2|| + ||saturation A1 - saturation A3| - |saturation B1 - saturation B3|| + ||saturation A2 - saturation A3| - |saturation B2 - saturation B3||, and the third fitting degree value = ||lightness A1 - lightness A2| - |lightness B1 - lightness B2|| + ||lightness A1 - lightness A3| - |lightness B1 - lightness B3|| + ||lightness A2 - lightness A3| - |lightness B2 - lightness B3||, and the fitting degree value corresponding to color palette A is obtained according to (weighting coefficient 1 x first fitting degree value + weighting coefficient 2 x second fitting degree value + weighting coefficient 3 x third fitting degree value) / 3. When the key color value does not include hue, the weighting coefficient 1 is 0; when the key color value does not include saturation, the weighting coefficient 2 is 0; and when the key color value does not include lightness, the weighting coefficient 3 is 0. In addition, when the key color value includes hue, lightness, and saturation, since hue is the primary characteristic of color, the weighting coefficient 1 can be set to be relatively large, and the weighting coefficients 2 and 3 can be set to be relatively small.
[0109] S305, color replacement processing is performed on each layer element in the to-be-processed image using the target color palette to obtain a target image.
[0110] It should be noted that the N key color values correspond one-to-one to the N target color values in the target color palette, for example, hue A1 corresponds to hue B1, hue A2 corresponds to hue B2, and hue A3 corresponds to hue B3.
[0111] In an embodiment, if the key feature values are obtained by using the above processing method 1, color replacement processing is performed on each layer element in the to-be-processed image using the target color palette to obtain a target image, including: taking a target layer element (any layer element in the to-be-processed image) as an example. The target cluster to which the representative color value of the target layer element belongs is obtained from the N clusters, and the first target color value corresponding to the key color value of the target cluster is determined from the N target color values in the target color palette, and then the first target color value is used to replace the original color value of the target layer element, and the representative color value of the target layer element is determined according to the original color value of the target layer element. Specifically, if the target layer element is a single layer element, the representative color value (hue) of the target layer element is the original color value (hue) corresponding to the single color in the target layer element, and the first target color value (hue) is used to replace the original color value (hue) corresponding to the single color in the target layer element. If the target layer element is a similar layer element, the representative color value (hue) of the target layer element is determined according to the original color value (hue) corresponding to the multiple colors in the target layer element, and the first target color value is used to replace the original color value (hue) corresponding to the multiple colors in the target layer element. If the target layer element is a multi-color layer element, the R representative color values (hue) of the target layer element are obtained according to at least one original color value (hue) included in each cluster in the R clusters, so that at least one original color value included in each cluster corresponds to one representative color value, and the first target color value (hue) can be used to replace at least one original color value (hue) included in the cluster corresponding to the representative color value in the target layer element. Finally, the same way is used to obtain the target image after color replacement processing is performed on each layer element. It should be noted that in this step, only hue replacement is described, but saturation and lightness replacement can also be performed, and the processing logic is consistent with that of hue, which will not be described again.
[0112] In another embodiment, if the key feature values are obtained by using the above processing mode 2, the color replacement processing is performed on each layer element in the target image by using the target color palette, and a target image is obtained, including: this embodiment takes a target layer element as an example for illustration. At least one auxiliary color value interval to which the N key color values belong is determined, and the at least one auxiliary color value interval is determined by each key color value in the N key color values, for example, the key color value 1 is 21, and the determined auxiliary color value interval can be 10-30. Since the key color value in this embodiment is taken as an example for illustration of hue, the auxiliary color value interval is actually a hue range interval, and for the same reason, when the key color value is lightness or saturation, the auxiliary color value interval is a lightness range interval or a saturation range interval. The target auxiliary color value interval to which the representative color value of the target layer element belongs can be obtained from the at least one auxiliary color value interval, and the second target color value corresponding to the key color value included in the target auxiliary color value interval is determined from the N target color values in the target color palette. For example, the auxiliary color value interval to which the key color value 1 belongs is (10-50), the representative color value 1 is 20, and the representative color value 1 belongs to the auxiliary color value interval (10-50), and the key color value 1 corresponds to the target color value 1 in the target color palette, so the target color value 1 is the second target color value.
[0113] It should be noted that multiple key color values in the N key color values can determine the same auxiliary color value interval, which can result in multiple second target color values, for example, the auxiliary color value intervals determined by the key color value 1 and the key color value 2 are both (10-50), and the representative color value 1 is 25, so the second target color value is the target color value corresponding to the key color value 1 and the target color value corresponding to the key color value 2. In order to solve this problem, three range intervals: hue range interval, lightness range interval and saturation range interval can be referred to determine the second target color value. For example, the hue included in the representative color value 1 is in the hue range interval to which the hue corresponding to the key color value 1 belongs, and the lightness included in the representative color value 1 is in the lightness range interval to which the lightness corresponding to the key color value 1 belongs, and only the hue included in the representative color value 1 is in the hue range interval to which the hue corresponding to the key color value 2 belongs, then the target color value 1 corresponding to the key color value 1 is taken as the second target color value.
[0114] Further, the representative color value of the target layer element is replaced by the second target color value, and the target image is obtained after the color replacement processing of each layer element. Specifically, if the target layer element is a single layer element, the representative color value (hue) of the target layer element is the original color value (hue) corresponding to the single color in the target layer element, and the original color value (hue) corresponding to the single color in the target layer element is replaced by the second target color value (hue). If the target layer element is a similar layer element, the representative color value (hue) of the target layer element is determined according to the original color values (hue) corresponding to the multiple colors in the target layer element, and the original color values (hue) corresponding to the multiple colors in the target layer element are replaced by the second target color value. If the target layer element is a multi-color layer element, the R representative color values (hue) of the target layer element are obtained according to at least one original color value (hue) included in each cluster in the R clusters, and therefore at least one original color value included in each cluster corresponds to a representative color value, and the at least one original color value (hue) included in the cluster corresponding to the representative color value in the target layer element can be replaced by the second target color value (hue). Finally, the target image is obtained after the color replacement processing of each layer element in the same way. It should be noted that in this step, only hue replacement is described, but saturation and lightness replacement can also be performed, and the processing logic is consistent with that of hue, which will not be described again.
[0115] By the embodiments of the present application, the production cost of image recoloring can be greatly reduced. For example, when the same image needs to present different colors in different use scenarios, only one design image with color matching needs to be produced, and then the image recoloring can be automatically performed by using the method provided by the present application. In addition, the N key color values describe the original color matching relationship of each layer element in the image to be processed, which can ensure that the image designed later also meets the design standards and specifications required by the color matching relationship, and can solve the problem of uneven design effect caused by manual color matching. At the same time, through the relationship between emotion and color, the target image can meet the requirements of emotional color, and the design intention can be better conveyed.
[0116] Please refer to Figure 11 , Figure 11 The flowchart of an image processing method provided by the embodiments of the present application Figure 4 . The method can be applied to the server 10 and / or the terminal device 11 in the image processing system described above, and the method comprises the following steps.
[0117] The target emotion can be manually inputted or determined by using the layer elements in the image to be processed. Specifically, the text layer element can be obtained from one or more layer elements included in the image to be processed, and the text data included in the text layer element can be extracted, and then the output emotion can be determined by using the text data and the emotion classification recognition. For details, please refer to S303. In addition, the image layer element can be obtained from one or more layer elements included in the image to be processed, and the image data included in the image layer element can be extracted, and then the output emotion (i.e. expression) can be determined by using the image data and the expression recognition model. For details, please refer to S303. The target color representing the target emotion can be obtained by the target emotion, and the target color representing the target emotion can be used to determine M candidate color panels from the plurality of color panels included in the color panel library, that is, at least one color in the candidate color panel matches the target color representing the target emotion. When two colors are consistent, or the hue, saturation and lightness of the two colors are within a preset range, the two colors match.
[0118] Further, the colors of each layer element in the image to be processed can be obtained, and it is determined whether the color of the target layer element (any layer element in the image to be processed) is a single color. If yes, the color of the target layer element is used as the main color of the target layer element. If not, the main color in the target layer element can be obtained by using the size and position of the target layer element. For example, if the color of the target layer element is blocked by the upper layer element, the main color in the target layer element can be determined according to the unblocked color, or the main color of the target layer element can be directly ignored in the subsequent processing. The reference color matching relationship can be determined by using the main color of each layer element, and the reference color matching relationship is the color matching relationship between each layer element in the image to be processed, which can be described by N key color values. The N key color values can be obtained by replacing the original color value of the target layer element in S302 with the color value (hue, saturation and lightness) corresponding to the main color of the target layer element, and then processing.
[0119] Further, the target color panel can be determined from the M candidate color panels by using the reference color matching relationship, that is, the process of determining the fitting degree value corresponding to each candidate color panel according to the first difference between any two key color values in the N key color values and the second difference between any two candidate color values in the N candidate color values, and taking the color panel corresponding to the smallest fitting degree value as the target color panel, or taking the color panel corresponding to the fitting degree value greater than the preset degree value as the target color panel in S304. Finally, the color replacement processing can be performed on each layer element in the image to be processed by using the target color panel, and the target image can be obtained, and the target image can be outputted.
[0120] By the method of the present application, the color effect and emotional expression of the image can be greatly enriched with less cost investment, and the design effect of the image is improved. In addition, the emotion provided by the image to be processed can be extracted, and then the color representing the emotion is corresponded to the color board in the color board library. The color board library can deposit design standards, and the color replacement processing can be realized by a controllable method.
[0121] It can be understood that in the specific embodiments of the present application, related data such as human faces are involved. When the above embodiments of the present application are applied to specific products or technologies, the user's permission or consent is required, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of the country and region.
[0122] The above describes the method of the embodiments of the present application in detail. In order to better implement the above method of the embodiments of the present application, correspondingly, the device of the embodiments of the present application is provided below. Please refer to Figure 12 , Figure 12 is a structural schematic diagram of an image processing device provided by the embodiments of the present application. The image processing device 120 can include:
[0123] The acquisition unit 1201 is configured to acquire an image to be processed, and the image to be processed includes one or more layer elements.
[0124] The processing unit 1202 is configured to determine feature representation data of the image to be processed based on the one or more layer elements, and the feature representation data includes one or both of N key color values and a target color value interval, and the N is a positive integer.
[0125] The processing unit 1202 is further configured to determine a target color board from a plurality of color boards included in a color board library based on the feature representation data.
[0126] The processing unit 1202 is further configured to perform color replacement processing on each layer element in the image to be processed by using the target color board, to obtain a target image.
[0127] In an embodiment, the processing unit 1202 is specifically configured to determine the N key color values based on the representative color values of each layer element in the one or more layer elements; and / or determine the target color value interval based on the state indication data corresponding to the one or more layer elements.
[0128] In an embodiment, the acquisition unit 1201 is specifically configured to acquire the representative color values of each layer element in the one or more layer elements, and the number of pixel points corresponding to the representative color values of the each layer element.
[0129] The processing unit 1202 is specifically configured to: perform clustering processing on the representative color values of the respective layer elements to obtain N clusters, each cluster including at least one representative color value; and determine a key color value of each cluster according to the at least one representative color value included in the cluster and a number of pixel points corresponding to the at least one representative color value.
[0130] In an embodiment, the acquisition unit 1201 is specifically configured to: acquire a target cluster to which a representative color value of a target layer element belongs from the N clusters, the target layer element being any layer element in the image to be processed, the representative color value of the target layer element being determined according to an original color value of the target layer element;
[0131] The processing unit 1202 is specifically configured to: determine a first target color value corresponding to the key color value of the target cluster from N target color values in the target color palette, wherein the N key color values and the N target color values in the target color palette correspond to each other in a one-to-one manner; replace the original color value of the target layer element with the first target color value, and obtain a target image after performing color replacement processing on the respective layer elements.
[0132] In an embodiment, the acquisition unit 1201 is specifically configured to: acquire a representative color value of each layer element in the one or more layer elements; and acquire a color relationship model, the color relationship model being obtained by training a plurality of training color samples and N labeled color values corresponding to each training color sample, the N labeled color values satisfying a target color matching relationship.
[0133] The processing unit 1202 is specifically configured to: process the representative color values of the respective layer elements by using the color relationship model to obtain N key color values, the N key color values satisfying the target color matching relationship.
[0134] In an embodiment, the processing unit 1202 is specifically configured to: determine at least one auxiliary color value interval to which the N key color values belong; acquire a target auxiliary color value interval to which a representative color value of a target layer element belongs from the at least one auxiliary color value interval, the target layer element being any layer element in the image to be processed, the representative color value of the target layer element being determined according to an original color value of the target layer element; determine a second target color value corresponding to a key color value included in the target auxiliary color value interval from N target color values in the target color palette, wherein the N key color values and the N target color values in the target color palette correspond to each other in a one-to-one manner; replace the original color value of the target layer element with the second target color value, and obtain a target image after performing color replacement processing on the respective layer elements.
[0135] In an embodiment, the processing unit 1202 is specifically configured to: if the target layer element is a single-color layer, taking the original color value of the target layer element as the representative color value of the target layer element, the target layer element being any layer element in the image to be processed; if the target layer element is a similar-color layer, determining the representative color value of the target layer element according to the original color value of the target layer element and the number of pixel points corresponding to the original color value of the target layer element; and if the target layer element is a multi-color layer, processing the original color value of the target layer element according to an image theme color extraction algorithm to obtain the representative color value of the target layer element.
[0136] In an embodiment, the processing unit 1202 is specifically configured to: determining M candidate color boards from the plurality of color boards according to the target color value interval, each candidate color board including N candidate color values, at least one candidate color value in the N candidate color values matching the target color value interval, the M being a positive integer; determining a fitting degree value corresponding to each candidate color board according to a first difference value between any two key color values in the N key color values and a second difference value between any two candidate color values in the N candidate color values; and determining a target color board from the M candidate color boards according to the fitting degree value corresponding to each candidate color board.
[0137] In an embodiment, the obtaining unit 1201 is specifically configured to: obtaining state indication data corresponding to the one or more layer elements, the state indication data including one or both of first state data and second state data, the first state data being obtained by performing state identification on text data included in each layer element in the one or more layer elements, and the second state data being obtained by performing state identification on image data included in the each layer element; and obtaining a state label corresponding to each reference color value interval in a plurality of reference color value intervals.
[0138] The processing unit 1202 is specifically configured to: determining a target color value interval from the plurality of reference color value intervals according to a feature similarity between the state indication data and the state label corresponding to each reference color value interval.
[0139] It can be understood that the functions of each functional unit of the image processing apparatus described in the embodiments of the present application can be specifically implemented according to the methods in the above method embodiments, and the specific implementation process can refer to the related description of the above method embodiments, which will not be described here in detail.
[0140] In the embodiment of the present application, a to-be-processed image including one or more layer elements can be acquired, feature representation data of the to-be-processed image is determined based on the one or more layer elements, the feature representation data including one or both of N key color values and a target color value interval, N being a positive integer, a target color palette is determined from a plurality of color palettes included in a color palette library based on the feature representation data, and each layer element in the to-be-processed image is subjected to color replacement processing by using the target color palette to obtain a target image. Through the method of the present application, image color changing can be automatically performed, and the design effect of the image is improved.
[0141] As Figure 13 shown, Figure 13 is a structural schematic diagram of a computer device provided by an embodiment of the present application, and the internal structure of the computer device 130 is as shown in Figure 13 , which includes one or more processors 1301, a memory 1302, and a communication interface 1303. The above-mentioned processor 1301, memory 1302, and communication interface 1303 can be connected through a bus 1304 or other means, and the present application takes the connection through the bus 1304 as an example.
[0142] The processor 1301 (or CPU (Central Processing Unit, Central Processing Unit)) is the computing core and control core of the computer device 130, which can parse various instructions in the computer device 130 and process various data of the computer device 130, for example: the CPU can be used to parse the on-off instructions sent by the user to the computer device 130, and control the computer device 130 to perform on-off operation; for another example: the CPU can transmit various interactive data between the internal structures of the computer device 130, and the like. The communication interface 1303 can optionally include a standard wired interface, a wireless interface (such as Wi-Fi, a mobile communication interface, etc.), and is controlled by the processor 1301 to receive and transmit data. The memory 1302 (Memory) is a memory device in the computer device 130, used to store computer programs and data. It can be understood that the memory 1302 here can include the built-in memory of the computer device 130, and of course can also include the expansion memory supported by the computer device 130. The memory 1302 provides a storage space that stores the operating system of the computer device 130, which can include but is not limited to: Windows system, Linux system, Android system, iOS system, etc., and the present application does not limit this. The processor 1301 executes the following operations by running the computer program stored in the memory 1302:
[0143] acquire a to-be-processed image, the to-be-processed image including one or more layer elements;
[0144] determine feature representation data of the to-be-processed image based on the one or more layer elements, the feature representation data including one or both of N key color values and a target color value interval, N being a positive integer;
[0145] determine a target color palette from a plurality of color palettes included in a color palette library based on the feature representation data;
[0146] perform color replacement processing on each layer element in the to-be-processed image using the target color palette to obtain a target image.
[0147] In an embodiment, the processor 1301 is specifically configured to: determine N key color values based on the representative color values of each layer element in the one or more layer elements; and / or determine a target color value interval based on the state indication data corresponding to the one or more layer elements.
[0148] In an embodiment, the processor 1301 is specifically configured to: obtain the representative color values of each layer element in the one or more layer elements and the number of pixel points corresponding to the representative color values of the each layer element; perform clustering processing on the representative color values of the each layer element to obtain N clusters, each cluster including at least one representative color value; and determine a key color value of each cluster according to the at least one representative color value included in the each cluster and the number of pixel points corresponding to the at least one representative color value.
[0149] In an embodiment, the processor 1301 is specifically configured to: obtain a target cluster to which a representative color value of a target layer element belongs from the N clusters, the target layer element being any layer element in the to-be-processed image, the representative color value of the target layer element being determined according to an original color value of the target layer element; determine a first target color value corresponding to a key color value of the target cluster from N target color values in the target color palette, wherein the N key color values and the N target color values in the target color palette correspond to each other in a one-to-one manner; and replace the original color value of the target layer element with the first target color value, and obtain a target image after performing color replacement processing on the each layer element.
[0150] In an embodiment, the processor 1301 is specifically configured to: obtain the representative color values of each layer element in the one or more layer elements; obtain a color relationship model, the color relationship model being obtained by training a plurality of training color samples and N labeled color values corresponding to each training color sample, the N labeled color values satisfying a target color matching relationship; and process the representative color values of the each layer element using the color relationship model to obtain N key color values, the N key color values satisfying the target color matching relationship.
[0151] In an embodiment, the processor 1301 is specifically configured to: determine at least one auxiliary color value interval to which the N key color values belong; obtain a target auxiliary color value interval to which a representative color value of a target layer element belongs from the at least one auxiliary color value interval, the target layer element being any layer element in the image to be processed, the representative color value of the target layer element being determined according to an original color value of the target layer element; determine, from the N target color values in the target color palette, a second target color value corresponding to a key color value included in the target auxiliary color value interval, wherein the N key color values and the N target color values in the target color palette are in one-to-one correspondence; replace the original color value of the target layer element with the second target color value, and obtain a target image after performing color replacement processing on the layer elements.
[0152] In an embodiment, the processor 1301 is specifically configured to: if the target layer element is a single-color layer, take the original color value of the target layer element as the representative color value of the target layer element, the target layer element being any layer element in the image to be processed; if the target layer element is a similar-color layer, determine the representative color value of the target layer element according to the original color value of the target layer element and a number of pixel points corresponding to the original color value of the target layer element; and if the target layer element is a multi-color layer, process the original color value of the target layer element according to an image theme color extraction algorithm to obtain the representative color value of the target layer element.
[0153] In an embodiment, the processor 1301 is specifically configured to: determine, according to the target color value interval, M candidate color palettes from the plurality of color palettes, each candidate color palette including N candidate color values, at least one candidate color value in the N candidate color values matching the target color value interval, the M being a positive integer; determine a fitting degree value corresponding to each candidate color palette according to a first difference value between any two key color values in the N key color values and a second difference value between any two candidate color values in the N candidate color values; and determine a target color palette from the M candidate color palettes according to the fitting degree value corresponding to each candidate color palette.
[0154] In an embodiment, the processor 1301 is specifically configured to: acquire state indication data corresponding to the one or more layer elements, the state indication data including one or both of first state data and second state data, the first state data being obtained by performing state identification on text data included in each layer element of the one or more layer elements; and the second state data being obtained by performing state identification on image data included in the each layer element; acquire a state label corresponding to each reference color value interval of a plurality of reference color value intervals; and determine a target color value interval from the plurality of reference color value intervals according to feature similarity between the state indication data and the state label corresponding to the each reference color value interval.
[0155] In a specific implementation, the processor 1301, the memory 1302, and the communication interface 1303 described in the embodiments of the present application can perform the implementation described in the image processing method provided by the embodiments of the present application, and can also perform the implementation described in the image processing apparatus provided by the embodiments of the present application, which will not be described here.
[0156] In the embodiments of the present application, a to-be-processed image including one or more layer elements can be acquired, feature representation data of the to-be-processed image is determined based on the one or more layer elements, the feature representation data including one or both of N key color values and a target color value interval, N being a positive integer, a target color plate is determined from a plurality of color plates included in a color plate library based on the feature representation data, and each layer element in the to-be-processed image is subjected to color replacement processing by using the target color plate to obtain a target image. Through the method of the present application, image color changing can be automatically performed, and the design effect of the image can be improved.
[0157] The embodiments of the present application further provide a computer readable storage medium, which stores a computer program. When the computer program is run on a computer device, the computer device performs the image processing method of any possible implementation manner described above. The specific implementation manners can be referred to the foregoing description, and will not be described here.
[0158] The embodiments of the present application further provide a computer program product, which includes a computer program or computer instructions. When the computer program or computer instructions are executed by a processor, the steps of the image processing method provided by the embodiments of the present application are implemented. The specific implementation manners can be referred to the foregoing description, and will not be described here.
[0159] The embodiment of the present application further provides a computer program, the computer program comprising computer instructions stored in a computer readable storage medium, a processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer device executes the image processing method provided by the embodiment of the present application. The specific implementation manner can be referred to the foregoing description, and details are not described herein.
[0160] It should be noted that, for each of the foregoing method embodiments, in order to simply describe, each is described as a series of action combinations, but those skilled in the art should know that the present application is not limited to the action sequence described, because according to the present application, some steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should know that the embodiments described in the specification all belong to preferred embodiments, and the actions and modules involved are not necessarily necessary for the present application.
[0161] Those skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the relevant hardware through a program, and the program can be stored in a computer readable storage medium, and the storage medium can include a flash disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0162] The above only discloses some embodiments of the present application, and of course cannot limit the scope of the rights of the present application, so equivalent changes made according to the claims of the present application still fall within the scope of the present application.
Claims
1. An image processing method, characterized by, The method comprises: acquiring a to-be-processed image, the to-be-processed image comprising one or more layer elements; determining feature representation data of the to-be-processed image based on the one or more layer elements, the feature representation data comprising N key color values and a target color value interval; the target color value interval being a numerical interval of colors of a target emotion on a color wheel, the target emotion being an emotion expressed by a target image corresponding to the to-be-processed image; the target emotion being artificially inputted or determined by using layer elements in the to-be-processed image, the N being a positive integer; determining M candidate color panels from a plurality of color panels included in a color panel library according to the target color value interval, each candidate color panel comprising N candidate color values, at least one candidate color value in the N candidate color values matching the target color value interval, the M being a positive integer; determining a fitting degree value corresponding to each candidate color panel according to a first difference value between any two key color values in the N key color values and a second difference value between any two candidate color values in the N candidate color values; determining a target color panel from the M candidate color panels according to the fitting degree value corresponding to each candidate color panel; wherein at least one color in the target color panel corresponds to representing the target emotion; performing color replacement processing on each layer element in the to-be-processed image by using the target color panel to obtain a target image.
2. The method of claim 1, wherein, The method comprises: determining N key color values based on representative color values of each layer element in the one or more layer elements; and / or determining a target color value interval based on state indication data corresponding to the one or more layer elements.
3. The method of claim 2, wherein, The method comprises: acquiring representative color values of each layer element in the one or more layer elements and pixel point quantities corresponding to the representative color values of the each layer element; performing clustering processing on the representative color values of the each layer element to obtain N clusters, each cluster comprising at least one representative color value; determining a key color value of each cluster according to at least one representative color value included in the each cluster and a pixel point quantity corresponding to the at least one representative color value.
4. The method of claim 3, wherein, The method comprises: acquiring a target cluster to which a representative color value of a target layer element belongs from the N clusters, the target layer element being any layer element in the to-be-processed image, the representative color value of the target layer element being determined according to an original color value of the target layer element; determining a first target color value corresponding to a key color value of the target cluster from N target color values in the target color panel, wherein the N key color values and the N target color values in the target color panel correspond to each other in a one-to-one manner. Replace the original color value of the target layer element with the first target color value, and obtain a target image after color replacement processing of each layer element.
5. The method of claim 2, wherein, The determining of the N key color values based on the representative color values of each layer element in the one or more layer elements comprises: Obtaining the representative color value of each layer element in the one or more layer elements; Obtain a color relationship model, wherein the color relationship model is obtained by training a plurality of training color samples and N labeled color values corresponding to each training color sample, and the N labeled color values satisfy a target color matching relationship; Process the representative color value of each layer element using the color relationship model to obtain N key color values, wherein the N key color values satisfy the target color matching relationship.
6. The method of claim 5, wherein, The color replacement processing of each layer element in the target image using the target color palette to obtain a target image comprises: Determine at least one auxiliary color value interval to which the N key color values belong; Obtain a target auxiliary color value interval to which the representative color value of a target layer element belongs from the at least one auxiliary color value interval, wherein the target layer element is any layer element in the image to be processed, and the representative color value of the target layer element is determined according to the original color value of the target layer element; From the N target color values in the target color palette, determine the second target color value corresponding to the key color value included in the target auxiliary color value interval, wherein the N key color values and the N target color values in the target color palette are one-to-one corresponding; Replace the original color value of the target layer element with the second target color value, and obtain a target image after color replacement processing of each layer element.
7. The method according to any one of claims 3-6, characterized in that, The obtaining of the representative color value of each layer element in the one or more layer elements comprises: If the target layer element is a single color layer, the original color value of the target layer element is taken as the representative color value of the target layer element, wherein the target layer element is any layer element in the image to be processed; If the target layer element is a similar color layer, the representative color value of the target layer element is determined according to the original color value of the target layer element and the number of pixel points corresponding to the original color value of the target layer element; If the target layer element is a multi-color layer, the original color value of the target layer element is processed according to an image theme color extraction algorithm to obtain the representative color value of the target layer element.
8. The method of claim 2, wherein, The determination of the target color value interval based on the state indication data corresponding to the one or more layer elements comprises: Obtain the state indication data corresponding to the one or more layer elements, wherein the state indication data comprises one or both of first state data and second state data, the first state data is obtained by state identification on text data included in each layer element in the one or more layer elements, and the second state data is obtained by state identification on image data included in each layer element. obtaining a state label corresponding to each of the plurality of reference color value intervals; determining a target color value interval from the plurality of reference color value intervals according to a feature similarity between the state indication data and the state label corresponding to each of the plurality of reference color value intervals.
9. An image processing apparatus characterized by comprising: The device comprises: an obtaining unit, configured to obtain a to-be-processed image, the to-be-processed image comprising one or more layer elements; a processing unit, configured to determine feature representation data of the to-be-processed image based on the one or more layer elements, the feature representation data comprising N key color values and a target color value interval; the target color value interval being a numerical interval of a color of a target emotion on a hue circle, the target emotion being an emotion expressed by a target image corresponding to the to-be-processed image; the target emotion being artificially input or determined by using layer elements in the to-be-processed image, the N being a positive integer; the processing unit is further configured to determine M candidate color palettes from a plurality of color palettes included in a color palette library according to the target color value interval, each candidate color palette comprising N candidate color values, at least one candidate color value in the N candidate color values matching the target color value interval, the M being a positive integer; determine a fitting degree value corresponding to each candidate color palette according to a first difference between any two key color values in the N key color values and a second difference between any two candidate color values in the N candidate color values; and determine a target color palette from the M candidate color palettes according to the fitting degree value corresponding to each candidate color palette; wherein at least one color in the target color palette corresponds to the target emotion; the processing unit is further configured to perform color replacement processing on each layer element in the to-be-processed image by using the target color palette to obtain a target image.
10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the image processing method in any one of claims 1-8.
11. A computer device, comprising: The computer device comprises a memory, a communication interface, and a processor, which are connected to each other; the memory stores a computer program, and the processor invokes the computer program stored in the memory to implement the image processing method in any one of claims 1-8.
12. A computer program product, characterised in that, The computer program product comprises a computer program or computer instructions, and the computer program or computer instructions are executed by a processor to implement the image processing method in any one of claims 1-8.
Citation Information
Patent Citations
Image color matching relationship determination method and device
CN111292394A