Patent Description:
In editing a file, a user often adds a picture for additional explanation of the file or creates an atmosphere, and also sets a color of the file by a font color, a title color, a paragraph color, a background color and the like, so as to highlight the content of the file, beautify the display of the file, and improve the visual effect of the file. However, for a user in a non-design industry, it is very difficult to make a file with good color matching overall and better visual experience.

In order to solve this problem, at present, a user can select a color scheme better matched with the file when issuing a file, wherein the color scheme includes a font color, a title color, a paragraph color, a background color, and the like. However, when the user modifies/adds a picture in the file, the selected color scheme may not match the modified/added picture in the file, thus affecting the visual effect of the file. At this time, in order to improve the visual effect of the file, the user needs to adjust the selected color scheme to generate a new color scheme, which greatly increases workload.

<CIT> relates to AutoLayout, an automated algorithm to generate scrapbook layout color schemes. The algorithm determines the dominant colors in an image or images and outputs one or more colors that match the dominant colors of the image or images for the purpose of producing colored scrapbook layouts.

<CIT> relates to methods, systems, and computer-readable media for creating customized color schemes for user interfaces. An avatar editing environment associated with a user is provided and user input specifying colors for the avatar is received. A color profile of the avatar can be created based on the colors associated with the avatar. Customized color schemes associated with a software application can be created based on the color profile of the user's avatar. An application selection interface can present a respective user interface element for each application available for selection. The application selection interface and user interface element for each available application can be rendered in a respective color scheme selected based on the color profile of the user's avatar and one or more characteristic colors extracted from an icon of the application.

The object of the embodiment of the present application is to provide a method and apparatus for generating a file color scheme, which can achieve the generation of a color scheme based on a color of a picture in a file, reduce the workload of generating the color scheme, and improve the visual effect of the file. Specifically, the technical solutions are as follows.

The above-mentioned object is achieved with the features of independent claims.

In the method and apparatus for generating a file color scheme according to embodiments of the present application, a collocated color set is determined for a color set of a picture in the target file, and then a color scheme of the target file is generated using the collocated color set. In this way, the method and apparatus can achieve the generation of a color scheme according to the colors of the picture in the file, reduce the workload of the user in generating a color scheme, and improve the visual effect of the file. It should be understood that any product or method of the present application does not necessarily have all of the advantages described above.

In order to more clearly describe the technical solution of the embodiments of the application or of the prior art, drawings needed in the embodiments and the prior art will be briefly described below. Apparently, the drawings described below are for only some embodiments of the present application. One of ordinary skills in the art can also obtain other drawings based on these drawings without any creative efforts.

The technical solution of the application will be described clearly and completely with reference to the drawings of embodiments of the present application.

In order to solve the problem in the prior art, embodiments of the present application provide a method and an apparatus for generating a file color scheme, which is capable of achieving the generation of a color scheme based on a color of a picture in a file, reducing the workload of the user in generating a color scheme, and improving the visual effect of the file.

The method for generating a file color scheme may be applied to electronic devices such as mobile phones, tablet computers, computers, and the like. The method for generating a file color scheme includes: acquiring a target color set of a picture in a target file; determining a collocated color set matching the target color set; generating a color scheme of the target file using a color matching set.

In an embodiment of the present application, by determining the collocated color set for the color set of the picture in the target file, and then generating a target file color scheme using the collocated color set, the generation of a color scheme based on the color of the picture in the file is achieved, the workload of the user is reduced in generating the color scheme, and the visual effect of the target file is improved.

Hereafter, a method for generating a file color scheme according to an embodiment of the present application is introduced. As shown in <FIG> is a flowchart of a method for generating a file color scheme according to an embodiment of the present application. The method may include:
S101, acquiring a picture in a target file.

In the S101, a changed picture in the target file is obtained. The changed picture may be understood as a picture that has changed in the target file. The change may be the new addition of a picture, or may be a change in the content of an existing picture. The changed picture may be a newly added picture, or may be an existing picture which has changed in the target file.

The acquired picture may be one or more pictures in the target file.

In an implementation, in order to acquire a changed picture in the target file in the S101, it is possible to detect whether a changed picture exists in the target file in real time. When it is detected that a changed picture exists in the target file, the changed picture in the target file is acquired. In this way, it is not necessary to perform color analysis on all the pictures in the target file in subsequent steps, which reduces the number of pictures on which the color analysis will be performed in the subsequent steps, the memory usage of the electronic device during the color analysis, the time of the color analysis and the time overhead.

According to the foregoing description of the method for generating a file color scheme, it is necessary to acquire a target color set to generate a file color scheme. In view of this, all colors of an unchanged picture in the target file may be stored in an apparatus using the method for generating a file color scheme according to the embodiment of the present application. In the subsequent steps, the target color set can be obtained based on the colors of the changed picture and the colors of the unchanged picture.

That is, all the colors of an unchanged picture in the target file may be acquired in advance, and the acquired colors may be stored. In this way, in subsequently obtaining the target color set, it is not necessary to acquire the unchanged picture in the target file, but it is possible to directly use the stored colors of the unchanged picture to obtain the target color set.

For example, the target file is a file A, and the file A includes a picture A, a picture B, and a picture C. The user adds a picture D to the file A, and thus the picture D is a changed picture. Therefore, the acquired picture is the picture D.

In another implementation of the present application, in the S101, all pictures in the target file are acquired.

In an implementation, in order to acquire all pictures in the target file in the S101, a "generate color scheme" button may be preset. After adding all the pictures in the file, the user clicks the preset "generate color scheme" button. At this time, all the pictures in the file are acquired. With this implementation, the number of times of performing subsequent steps and the memory usage of the electronic device in the subsequent steps can be reduced.

The electronic device, when detecting that the user clicks the "generate color scheme" button, determines that the user inputs an instruction indicating the completion of the file, and acquires all the pictures in the file.

For example, the target file is a file B, and there is no picture in the file B before adding a picture in the file B. The user adds three pictures E, F, and G in file B, and clicks the preset "generate color scheme" button. At this time, three pictures E, F, and G in the file B are acquired.

S102, performing color analysis on the picture to obtain a color set in the picture.

In an implementation of the present application, in case a changed picture in the target file is acquired in the S101, the S102 includes performing the color analysis on the changed picture to obtain a first color set of the changed picture, and determining a target color set of the picture in the target file according to the first color set.

The first color set may include all colors of the changed picture, and may also include a part of the colors of the changed picture. This is not limited in the embodiment of the present application.

Here, the performance of the color analysis on the changed picture is to obtain the target color set in the picture in the target file. Then the color scheme can be generated in the subsequent steps.

Due to the variety of picture formats, the color analysis of pictures may be performed using different color modes according to different picture formats. For example, a RGB mode may be used to perform the color analysis on a picture, or a YUV mode may be used to perform the color analysis on a picture.

For example, in performing the color analysis through the RGB mode, the picture can be analyzed using three primary colors, so that RGB value corresponding to each of the colors in the picture can be obtained in detail and accurately. The three primary colors of the paint are yellow, magenta and cyan, and the three primary colors of light are red, green and blue. In theory, any color can be obtained using these primary colors.

Considering the hardware limitation of the electronic device, in order to reduce the complexity of color analysis, the color analysis of a picture can be performed by reference colors. Hereafter, Table <NUM> shows a correspondence between a reference color and a RGB value provided by the embodiment of the present application.

In an implementation of the present application, in case all the pictures in the target file are acquired in the S101, the S102 includes acquiring colors included in each picture in the target file, and determining the target color set based on the obtained colors.

S103, determining a collocated color set that matches the color set.

The S103 is to determine a collocated color set that matches the target color set.

Each of the colors collocates with at least one color, that is, at least one collocated color.

After obtaining the target color set of the picture in the target file in step S102, in order to obtain a color scheme collocated with the picture, it is necessary to determine a collocated color set that matches the target color set.

Specifically, a collocated color of each of the colors in the target color set may be determined first, and then a collocated color set is established based on the collocated color of each of the colors.

By establishing the collocated color set, a plurality of collocation schemes are provided for selection in generating a color scheme, thereby improving the selectivity in generating a color scheme.

In the embodiment of the present application, the collocated color may be obtained according to a large amount of color collocation data.

S104, generating a color scheme of the target file using the collocated color set.

In this step, the color scheme may assign a color to parts of the target file except for the pictures, for example, assign a font color and a background color. The color scheme includes colors that are assigned to each part in the target file.

Specifically, one collocated color may be selected in the collocated color set, and the selected collocated color is used for each part of the target file except for the pictures, thereby obtaining a color scheme.

It is also possible to select a plurality of collocated colors in the collocated color set, and select a corresponding collocated color for each part in the target file except for the pictures from the selected collocated colors, thereby obtaining a color scheme.

It is also possible to select a color that is close to the colors in the collocated color set to generate a color scheme.

In the embodiment of the present application, the foregoing several examples of generating a color scheme are used to illustrate the process of the S104 more clearly, and do not limit the S104.

In the method for generating a file color scheme according to an embodiment of the present application, a collocated color set is determined for a color set of the picture in the target file, and then a color scheme of the target file is generated using the collocated color set. In this way, the method can achieve the generation of a color scheme according to the colors of the picture in the file, reduce the workload of the user in generating the color scheme, and improve the visual effect of the file. In addition, the color scheme can be flexibly changed according to the change of the picture, so that the user can use the color scheme more flexibly.

When there are a lot of colors in the picture in the file, more colors will be obtained after the color analysis. If a color set is composed of all the colors of the changed picture, the complexity of generating a color scheme will increase. Therefore, the embodiment of the present application provides the following implementation.

The color analysis is performed on the changed picture to obtain colors included in the changed picture and a color ratio of each of the colors; and a first color set of the changed picture is determined based on the colors included in the changed picture and the color ratio of each of the colors. By way of this implementation, the number of colors included in the first color set is reduced, thereby reducing the number of colors included in the target color set, and reducing the complexity of generating a color scheme.

Based on the implementation of determining the first color set, in one possible implementation, the performing of the color analysis on the changed picture to obtain a first color set of the changed picture may include the following steps.

At first step, the color analysis is performed on the changed picture to obtain the colors included in the changed picture and the color ratio of each of the colors.

In the color analysis of the changed picture, the changed picture may be decomposed in pixels to obtain a color of each of the pixels in the changed picture, and then statistics is made on colors of all the pixels in the picture to obtain the area of pixels for each of the colors in the picture, that is, the color ratio of the number of pixels for each of the colors to the total number of pixels in the picture is calculated, thereby obtaining the color ratio of each of the colors.

Here, a color of a pixel may be represented by an RGB value, or may be represented by a YUV value, which is not limited in the embodiment of the present application.

At second step, from the colors included in the changed picture, at least one color whose color ratio is greater than a preset color ratio threshold is selected to obtain a first color set of the changed picture.

The preset color ratio threshold may be set according to an actual application. The number of colors in the first color set can be reduced by selecting a color whose color ratio is greater than a preset color ratio threshold.

However, when the ratios of the various colors in the changed picture are relatively balanced, and the preset color ratio threshold is relatively large, no color for establishing a first color set may be selected, that is, the first color set includes no element; or when the preset color ratio threshold is relatively small, more colors may be selected, and thus the established first color set includes more colors.

In this regard, the embodiment of the present application also provides another possible implementation.

Based on the foregoing implementation of determining the first color set, in this possible implementation, performing the color analysis on the changed picture to obtain a first color set of the changed picture in step S102 may include the following steps.

At second step, from the colors included in the changed picture, a preset threshold number of colors having the highest color ratios are selected, to obtain the first color set of the changed picture.

In one embodiment, in order to select a preset threshold number of colors having the highest color ratios, this second step may include:
arranging the colors in the picture based on their color ratios from high to low; and selecting the first preset threshold number of colors starting from a color with the highest color ratio, to obtain the first color set.

The preset threshold number is pre-set to select a preset number of colors.

For example, the file A includes changed pictures A, B and C. By performing color analysis on pictures A, B and C, it is determined that the picture A contains black, blue, red and purple, the picture B contains blue, cyan, yellow, orange and white, and the picture C contains pink, purple, brown, magenta; and the ratio of black is <NUM>%, the ratio of blue is <NUM>%, the ratio of red is <NUM>%, the ratio of purple is <NUM>%, the ratio of cyan is <NUM>%, the ratio of yellow is <NUM>%, the ratio of orange is <NUM>%, the ratio of white is <NUM>%, the ratio of pink is <NUM>%, and the ratio of brown is <NUM>%. Here, the preset threshold number is <NUM>.

The above colors are arranged based on their color ratios from high to low, i.e., black → blue → yellow → purple → cyan → red → orange → brown → pink → white.

Since the preset threshold number is <NUM>, the selected colors are in sequence: black, blue, yellow and purple, and then these four colors form the first color set.

With this implementation, the preset threshold number of colors can be selected according to actual needs, thereby further reducing the number of colors in the first color set.

In the present invention, determining a target color set of a picture in the target file according to the first color set includes:.

In the embodiment of the present application, in order to reduce the complexity of implementing the embodiment of the present application, the collocated color set that matches the color set may be determined by the following steps.

At first step, a collocated color corresponding to each of the colors in the target color set is determined.

A collocated color library including the correspondence between a color and a collocated color is pre-established. After obtaining the target color set, a collocated color corresponding to each of the colors in the target color set is determined by searching the pre-established collocated color library.

At second step, a collocated color whose matching degree with each of the colors in the target color set is greater than a preset matching degree threshold is selected to obtain a collocated color set.

That is, for each of the determined collocated colors, a matching degree of this collocated color with each of the colors in the target color set is determined. A collocated color whose matching degree with each of the colors in the target color set is greater than a preset matching degree threshold is selected to obtain a collocated color set.

The preset matching degree threshold is pre-set in actual applications, and the matching degree indicates the similarity of one color and the other color which is a reference color.

In the calculation of matching degrees, one of the collocated colors corresponding to the colors in the target color set is taken as a reference color, and a matching degree of this collocated color with each of the colors in the target color set may be calculated, respectively. This is repeated until the matching degrees of each of the collocated colors with all the colors in the color set have been calculated. Then, a collocated color(s) is selected from the collocated colors by the preset matching degree threshold to obtain a collocated color set. The obtained collocated color set is more suitable for generating a color scheme.

For example, the determined collocated colors include red, green and blue, the target color set includes three colors: yellow, orange and white, and the preset matching degree threshold is <NUM>.

In the calculation of matching degrees, firstly, the collocated color of red is taken as a reference color, and the matching degrees of the red and the three colors of yellow, orange and white in the target color set are calculated, respectively; secondly, the collocated color of green is taken as a reference color, and the matching degrees of the green and the three colors of yellow, orange and white in the target color set are calculated, respectively; and finally, the collocated color of blue is taken as a reference color, and the matching degrees of the blue and the three colors of yellow, orange and white in the target color set are calculated, respectively.

For example, the matching degree of the red and the yellow is <NUM>, the matching degree of the red and the orange is <NUM>, and the matching degree of the red and the white is <NUM>; the matching degree of the green and the yellow is <NUM>, the matching degree of the green and the orange is <NUM>, and the matching degree of the green and the white is <NUM>; the matching degree of the blue and the yellow is <NUM>, the matching degree of the blue and the orange is <NUM>, and the matching degree of the blue and the white is <NUM>.

It can be seen that the matching degrees of the red and the yellow, orange and white in the target color set are greater than the preset matching degree threshold of <NUM>, and the matching degrees of the green and the yellow, orange and white in target color set are also greater than the preset matching degree threshold of <NUM>, the red and the green may be selected as elements in the target color set. Since the matching degree of the blue and the white is <NUM>, which is less than the preset matching degree threshold, the blue cannot be determined as an element in the target color set.

Therefore, the red and the green may be selected to establish a collocated color set.

In an embodiment of the present application, a matching degree between colors may be calculated by various methods. For example, a matching degree between different colors may be calculated by mapping RGB values of different colors into a three-dimensional space and calculating a Euclidean distance between the different colors. For example, a matching degree between different colors may be calculated by the HSV (Hue Saturation Value) spatial model.

In a possible implementation, the color scheme includes at least one of a font color, a title color, a background color, and a paragraph color. The electronic device configures the target file according to the color included in the color scheme. For example, if the color scheme includes a font color of red, the electronic device configures a font color in the target file to be red.

At this time, generating a color scheme of the target file using the collocated color set may include:
determining at least one of a font color, a background color and a paragraph color of the target file by using a collocated color in the collocated color set to obtain the color scheme of the target file.

For example, one collocated color is selected from the collocated color set as one of the font color, the title color, the background color, and the paragraph color. For another example, two collocated colors are selected from the collocated color set as two colors of the font color, the title color, the background color and the paragraph color.

In case the color scheme includes at least one of a font color, a background color, a title color and a paragraph color, the collocated color set may correspondingly include a collocated color subset of the font color, a collocated color subset of the background color, a collocated color subset of the title color and a collocated color subset of the paragraph color.

In order to illustrate the implementation effect of the embodiment of the present application more clearly, the embodiment of the present application is described below with reference to <FIG> and <FIG>. <FIG> is a schematic diagram of a file to which the method for generating a file color scheme according to the embodiment of the present application is not applied.

In <FIG>, a file <NUM> is a file to which the method for generating a file color scheme according to the embodiment of the present application is not applied. A title <NUM> is a title to which the method for generating a file color scheme according to the embodiment of the present application is not applied. A text <NUM> is a text to which the method for generating a file color scheme according to the embodiment of the present application is not applied. A picture <NUM> and a picture <NUM> are in the file <NUM>.

In the method for generating a file color scheme according to the embodiment of the present application, firstly, the picture <NUM> and the picture <NUM> are acquired and color analysis is performed on the picture <NUM> and the picture <NUM> to obtain all colors included in the picture <NUM> and the picture <NUM>; a target color set is then established based on all the colors; a collocated color set that matches the target color set is then determined; and a color scheme of the target file is then generated by using the collocated color set.

In a possible implementation, in the generated color scheme of the target file, the background color, the text color and the title color of the file may be different colors. For example, as shown in <FIG> is a schematic diagram of a file to which the method of generating a file color scheme according to the embodiment of the present application is applied.

In <FIG>, a file <NUM> has a background color generated by the method of generating a file color scheme according to the embodiment of the present application. A title <NUM> has a title color generated by the method of generating a file color scheme according to the embodiment of the present application. A text <NUM> has a text color generated by the method of generating a file color scheme according to the embodiment of the present application.

<FIG> and <FIG> are only used for more clearly explaining the embodiment of the present application. In practical applications, the portions indicated by reference signs in <FIG> and <FIG> may have different colors.

Corresponding to the embodiment of the above method for generating a file color scheme, an embodiment of the present application provides an apparatus for generating a file color scheme. <FIG> is a structural diagram of an apparatus for generating a file color scheme according to an embodiment of the present application. The apparatus may include:.

The color analysis submodule may be specifically configured for:.

In a possible implementation, the color analysis submodule may be specifically configured for:.

In a possible implementation, the color set determining submodule may be specifically configured for:.

In a possible implementation, the collocated color determining module <NUM> may be specifically configured for:.

In a possible implementation, the color scheme generating module <NUM> may be specifically configured for determining at least one of a font color, a title color, a background color and a paragraph color of the target file by using a collocated color in the collocated color set, to obtain the color scheme of the target file.

In the embodiment of the present application, a collocated color set is determined for a color set of a picture in the target file, and then a color scheme of the target file is generated using the collocated color set. In this way, the generation of a color scheme according to the colors of the picture in the file is achieved, the workload of the user in generating a color scheme is reduced, and the visual effect of the file is improved.

Based on the same inventive concept, an embodiment of the present application further provides an electronic device. As shown in <FIG>, the electronic device includes a processor <NUM> and a memory <NUM>. The memory <NUM> stores a computer program, and the processor <NUM> executes the program stored on the memory <NUM>, to perform the method of claim <NUM>.

Based on the same inventive concept, an embodiment of the present application further provides a machine readable storage medium. A computer program is stored in the machine readable storage medium. The computer program, when executed by a processor, performs the method of claim <NUM>.

In the embodiment of the present application, a collocated color set is determined for a color set of a picture in the target file, and then a color scheme of the target file is generated using the collocated color set. In this way, the generation of a color scheme according to the colors of the picture in the file is generated, the workload of the user in generating a color scheme is reduced, and the visual effect of the file is improved.

Based on the same inventive concept, an embodiment of the present application further provides a computer program which, when executed by the processor, performs the method of claim <NUM>.

It should be noted that the relationship terms use here, such as "first," "second," and the like are only used to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply that there is actual relationship or order between these entities or operations. Moreover, the terms "include," "comprise," or any variants thereof are intended to cover a non-exclusive inclusion, such that processes, methods, articles, or devices, including a series of elements, include not only those elements that have been listed, but also other elements that have not specifically been listed or the elements intrinsic to these processes, methods, articles, or devices. Without further limitations, elements limited by the wording "comprise(s) a/an. " and "include(s) a/an. " do not exclude additional identical elements in the processes, methods, articles, or devices, including the listed elements.

All of the embodiments in the description are described in a correlated manner, and identical or similar parts in various embodiments can refer to one another. In addition, the description for each embodiment focuses on the differences from other embodiments. In particular, the embodiments of the apparatus for generating a file color scheme, the electronic device, machine readable storage medium and the computer program are described briefly, since they are substantially similar to the embodiment of the method for generating a file color scheme, and the related contents can refer to the description of the embodiment of the method for generating a file color scheme.

Claim 1:
A computer implemented method for generating a file color scheme, which is applied to an electronic device, wherein the method comprises:
acquiring (S101) at least one changed picture in a target file, wherein the at least one changed picture is a picture newly added into the target file, or an existing picture which has changed in the target file;
performing (S102) color analysis on the at least one changed picture to obtain a first color set of the at least one changed picture; and
determining a target color set of the target file according to the first color set;
determining a collocated color corresponding to each of colors in the target color set by searching a pre-established collocated color library, which includes a correspondence between a color and a collocated color;
determining (S103) a collocated color set that matches the target color set based on the determined collocated colors; and
generating (S104) a color scheme of the target file using the collocated color set,
wherein, performing (<NUM>) color analysis on the at least one changed picture to obtain a first color set of the at least one changed picture comprises:
performing color analysis on the at least one changed picture to obtain colors included in the at least one changed picture and a color ratio of each of the colors; and
determining the first color set of the at least one changed picture according to the colors included in the at least one changed picture and the color ratio of each of the colors,
wherein the color ratio of each of the colors is a ratio of the number of pixels for each of the colors to the total number of pixels in the at least one changed picture;
wherein determining a target color set of the target file according to the first color set comprises:
if the at least one changed picture are all the pictures in the target file, determining the first color set as the target color set of the target file; and
if the at least one changed picture is a part of pictures in the target file, merging the first color set and a second color set to obtain the target color set of the target file, wherein the second color set is a color set of an unchanged picture in the target file.