Image processing method, electronic device and computer storage medium
By identifying and calculating the dominant color channel ratio of the sampling point in the picture, the problem of low efficiency of image theme color extraction in the prior art is solved, and an efficient and simple theme color extraction method is realized, which is suitable for large-scale applications.
Patent Information
- Application Number
- CN202111495719.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-08
- Publication Date
- 2025-05-06
- Estimated Expiration
- 2041-12-08
AI Technical Summary
The implementation process of the existing picture theme color extraction method is cumbersome, the extraction efficiency is inefficient, and it is not suitable for large-scale applications.
By obtaining the target picture, identify the dominant color channels of each sampling point, calculate the sample point ratio of each color channel as the dominant color channel, calculate the values of each color channel in the theme color, and determine the theme color of the target picture.
It realizes a simple and easy-to-use image theme color extraction process, with small calculation amount and high extraction efficiency, and is suitable for large-scale applications.
Smart Images

Figure CN114119783B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a picture processing method, electronic equipment and computer storage medium. Background Art
[0002] The theme color of a picture refers to the color that reflects the overall characteristics of the picture. By extracting the theme color of the picture, it is easy to classify, search, and identify the picture.
[0003] The commonly used methods for extracting theme colors from images are clustering-based theme color extraction methods and feature modeling-based theme color extraction methods. However, the two theme color extraction methods in the prior art are cumbersome to implement and have low extraction efficiency, which is not conducive to large-scale application and implementation. Summary of the invention
[0004] In view of the above problems, the present invention is proposed to provide a picture processing method, electronic device and computer storage medium that overcome the above problems or at least partially solve the above problems.
[0005] According to one aspect of the present invention, there is provided a method for processing an image, comprising:
[0006] Get the target image;
[0007] Identify the dominant color channel of each sampling point in the target image;
[0008] For any color channel, calculate the proportion of sampling points that use the color channel as the dominant color channel; and calculate the color channel value of the color channel in the theme color of the target image according to the proportion of sampling points corresponding to the color channel;
[0009] The theme color of the target image is determined according to the color channel values of each color channel in the theme color.
[0010] According to another aspect of the present invention, there is provided an electronic device, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus;
[0011] The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform the following operations:
[0012] Get the target image;
[0013] Identify the dominant color channel of each sampling point in the target image;
[0014] For any color channel, calculate the proportion of sampling points that use the color channel as the dominant color channel; and calculate the color channel value of the color channel in the theme color of the target image according to the proportion of sampling points corresponding to the color channel;
[0015] The theme color of the target image is determined according to the color channel values of each color channel in the theme color.
[0016] According to another aspect of the present invention, a computer storage medium is provided, wherein the storage medium stores at least one executable instruction, and the executable instruction enables a processor to perform operations corresponding to the above-mentioned image processing method.
[0017] The image processing method, electronic device and computer storage medium disclosed in the present invention include: obtaining a target image; identifying the dominant color channel of each sampling point in the target image; for any color channel, calculating the proportion of sampling points that use the color channel as the dominant color channel; and calculating the color channel value of the color channel in the theme color of the target image according to the proportion of sampling points corresponding to the color channel; determining the theme color of the target image according to the color channel values of each color channel in the theme color. The theme color obtained by this scheme can reflect the overall color characteristics of the target image. In addition, the implementation process of this scheme is simple and easy, the amount of calculation is small, the theme color extraction efficiency is high, and it is suitable for large-scale application and implementation.
[0018] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0020] Figure 1 A schematic diagram showing a flow chart of a picture processing method provided by Embodiment 1 of the present invention;
[0021] Figure 2 A schematic diagram showing a flow chart of a picture processing method provided by Embodiment 2 of the present invention;
[0022] Figure 3 A schematic structural diagram of an electronic device provided in a fourth embodiment of the present invention is shown. DETAILED DESCRIPTION
[0023] The exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present invention and to enable the scope of the present invention to be fully communicated to those skilled in the art.
[0024] Embodiment 1
[0025] Figure 1 The flowchart of a picture processing method provided by the first embodiment of the present invention is shown. Specifically, a method for extracting the theme color of a picture is provided.
[0026] like Figure 1 As shown, the method comprises the following steps:
[0027] Step S110, obtaining a target image.
[0028] The target image is the image to be subjected to theme color extraction. The embodiment of the present invention does not limit the specific type, size, format, and source of the target image. For example, in an e-book platform, the target image may be a book cover; in an album application, the target image may be an album photo, and so on.
[0029] Step S120, identifying the dominant color channel of each sampling point in the target image.
[0030] First, a sampling method is used to extract sampling points from the target image, where each sampling point corresponds to a pixel point in the target image. The sampling method may include one or more of the following methods:
[0031] Sampling method 1 extracts sampling points from the target image according to a preset sampling frequency. For example, 1 sampling point can be selected for every 5 pixels, etc. Optionally, in order to improve the extraction efficiency of the sampling points, the sampling frequency is dynamically determined according to the size of the target image. For example, the preset number of standard sampling points is 320*320. If the size of the target image is 640*640, 1 sampling point is selected for every (640*640) / (320*320) pixel points; if the size of the target image is 1280*320, 1 sampling point is selected for every (1280*320) / (320*320) pixel points. This sampling method can improve the extraction efficiency of the sampling points, and then improve the extraction efficiency of the theme color.
[0032] Sampling method 2, identifying the entity object area and the background area in the target image; determining sampling points from the entity object area and the background area respectively; wherein the number of sampling points per unit area in the entity object area is greater than the number of sampling points per unit area in the background area. Specifically, the entity object area refers to the area where the relevant entities (such as people, animals, objects, etc.) are located in the target image, and the background area refers to the area outside the entity object area. In the process of identifying the entity object area and the background area, contour recognition, machine learning recognition and other recognition algorithms can be specifically used, and the embodiment of the present invention does not limit this. After obtaining the entity object area and the background area, sampling points are selected from the entity object area according to a first sampling frequency, and sampling points are selected from the background area according to a second sampling frequency, and the first sampling frequency is higher than the second sampling frequency, so that the number of sampling points per unit area in the entity object area is greater than the number of sampling points per unit area in the background area.
[0033] Generally, users pay different attention to different areas of the target image. Users tend to pay more attention to areas containing entities such as people and objects, and pay less attention to the background area. Therefore, in this sampling method, different sampling frequencies are used in the entity object area and the background area, so that the number of sampling points per unit area in the entity object area is greater than the number of sampling points per unit area in the background area, thereby increasing the proportion of pixel color in the entity object area, so that the theme color of the target image finally determined is more in line with the user's visual experience.
[0034] Sampling method three, identifying the central area and the edge area in the target image; determining sampling points from the central area and the edge area respectively; wherein the number of sampling points per unit area in the central area is greater than the number of sampling points per unit area in the edge area. Specifically, the method is to select sampling points from the central area according to a third sampling frequency, and to select sampling points from the edge area according to a fourth sampling frequency, wherein the third sampling frequency is higher than the fourth sampling frequency, so that the number of sampling points per unit area in the central area is greater than the number of sampling points per unit area in the edge area.
[0035] Since users tend to pay more attention to the central area of the target image and less attention to the edge area, this sampling method can increase the proportion of pixel color in the central area, so that the theme color of the target image finally determined is more in line with the user's visual experience.
[0036] After extracting the sampling points of the target image, identify the dominant color channel of each sampling point. Specifically, the target image is a color image, and in the RGB color space, each sampling point corresponds to three color channels, namely, the R channel, the G channel, and the B channel. For any sampling point, obtain the color channel values of the sampling point; and determine the maximum color channel value among the color channel values of the sampling point, and use the color channel corresponding to the maximum color channel value as the dominant color channel of the sampling point.
[0037] In an optional implementation, if there are multiple maximum color channel values corresponding to the sampling point, the color channels corresponding to each maximum color channel value are all used as the dominant color channels of the sampling point, so that one sampling point can correspond to one or more dominant color channels. For example, if the color channel value of sampling point 1 is (240, 120, 52), the color channel (R channel) corresponding to the maximum value 240 is used as the dominant color channel of sampling point 1; if the color channel value of sampling point 2 is (120, 120, 52), the color channels (R channel and G channel) corresponding to the maximum value 120 are used as the dominant color channels of sampling point 2; if the color channel value of sampling point 3 is (120, 120, 120), the color channels (R channel, G channel, B channel) corresponding to the maximum value 120 are used as the dominant color channels of sampling point 3.
[0038] In another optional implementation, if there are multiple maximum color channel values corresponding to the sampling point, a maximum color channel value is randomly selected, and the color channels corresponding to the selected maximum color channel value are all used as the dominant color channels of the sampling point, so that one sampling point corresponds to one dominant color channel. For example, if the color channel value of sampling point 1 is (240, 120, 52), the color channel (R channel) corresponding to the maximum value 240 is used as the dominant color channel of sampling point 1; if the color channel value of sampling point 2 is (120, 120, 52), the color channel (G channel) corresponding to the maximum value 120 is randomly used as the dominant color channel of sampling point 2; if the color channel value of sampling point 3 is (120, 120, 120), the color channel (B channel) corresponding to the maximum value 120 is randomly used as the dominant color channel of sampling point 3.
[0039] Step S130 , for any color channel, calculate the proportion of sampling points that use the color channel as the dominant color channel.
[0040] For any color channel, the number of sampling points that use the color channel as the dominant color channel is counted. The proportion of sampling points that use the color channel as the dominant color channel is further calculated using but not including the following two methods.
[0041] Ratio calculation method 1: If a sampling point can correspond to one or more dominant color channels, the sampling points corresponding to different color channels will overlap. Based on this, this calculation method specifically counts the number of sampling points that use each color channel as the dominant color channel; calculates the sum of the number of sampling points corresponding to each color channel; for any color channel, the ratio of the number of sampling points that use the color channel as the dominant color channel to the sum is used as the ratio of the sampling points that use the color channel as the dominant color channel.
[0042] Ratio calculation method 2: If a sampling point corresponds to only one dominant color channel, then there is no overlap in the sampling points corresponding to different color channels. Based on this, this calculation method specifically counts the total number of sampling points in the target image; for any color channel, the ratio of the number of sampling points that use the color channel as the dominant color channel to the total number is used as the ratio of the sampling points that use the color channel as the dominant color channel.
[0043] In addition, in an optional implementation, in order to reduce the influence of the color with a relatively small proportion in the target image on the theme color, the embodiment of the present invention counts the number of sampling points of any color channel as the dominant color channel, and then uses the integer quotient of the number of sampling points and the preset parameter as the sampling point count corresponding to the color channel. For example, if the preset parameter is 180 and the number of sampling points is 361, the sampling point count is 2 (361 / 180 is rounded down).
[0044] Corresponding to the first ratio calculation method is to count the sampling point counts corresponding to each color channel; calculate the sum of the sampling point counts corresponding to each color channel; for any color channel, use the ratio of the sampling point count corresponding to the color channel to the sum as the ratio of the sampling points of the color channel as the dominant color channel; corresponding to the second ratio calculation method is to count the total number of sampling points in the target image, and calculate the integer quotient of the total number and the preset parameter; for any color channel, use the ratio of the sampling point count corresponding to the color channel to the integer quotient corresponding to the total number as the ratio of the sampling points of the color channel as the dominant color channel.
[0045] Step S140 , for any color channel, calculate the color channel value of the color channel in the theme color of the target image according to the ratio of sampling points corresponding to the color channel.
[0046] Specifically, for any color channel, the maximum value of the color channel is determined, and the color channel value of the color channel in the theme color is determined according to the product of the ratio of the sampling points corresponding to the color channel and the maximum value.
[0047] For example, the proportions of sampling points corresponding to the R channel, G channel, and B channel are 60%, 30%, and 10%, respectively. The maximum values of the R channel, G channel, and B channel are all 255, so 255*60% is rounded to 153, 255*30% is rounded to 76, and 255*10% is rounded to 25. Finally, the color channel values of the R channel, G channel, and B channel of the theme color are 153, 76, and 25, respectively, that is, the theme color is (153, 76, 25).
[0048] Step S150, determining the theme color of the target image according to the color channel values of each color channel in the theme color.
[0049] In an optional implementation, the transparency of each sampling point is counted, and the average value of the transparency of the sampling points is calculated, and the transparency of the theme color is determined based on the average value (for example, the transparency of the theme color is directly determined by the average value, or the average value is rounded to two decimal places as the transparency of the theme color), and the theme color of the target image is determined based on the color channel values of each color channel in the theme color and the transparency of the theme color.
[0050] It can be seen that the embodiment of the present invention identifies the dominant color channel of the sampling points in the target image, and then calculates the proportion of the sampling points that use the color channel as the dominant color channel. According to the proportion of the sampling points corresponding to the color channel, the color channel value of the color channel in the theme color of the target image is calculated, and the theme color obtained thereby can reflect the overall color characteristics of the target image. In addition, the implementation process of the embodiment of the present invention is simple and easy, the amount of calculation is small, the theme color extraction efficiency is high, and it is suitable for large-scale application and implementation.
[0051] Embodiment 2
[0052] Figure 2 A schematic flow chart of a method for processing an image provided by the second embodiment of the present invention is shown. Specifically, a method for processing a target image using the theme color of the image is provided.
[0053] Step S210, determining the theme color of the target image.
[0054] The specific execution process of this step can refer to the description in Example 1 and will not be repeated here.
[0055] Step S220, generating a first layer whose filling color is the theme color, and setting the transparency of the first layer to a preset transparency.
[0056] The first layer is a solid color layer, and the fill color of the solid color layer is the theme color of the target image. In order to make the final filter effect image reflect the information in the target image, this step also adjusts the transparency of the first layer so that the user can observe the content of the target image through the first layer.
[0057] Step S230, generating a second layer with the target image rendered.
[0058] Step S240, overlaying the first layer onto the second layer to generate a filter effect image corresponding to the target image.
[0059] After the first layer with a certain degree of transparency is overlaid on the second layer, the target image will be blurred, achieving the effect of adding a filter to the target image. Further optionally, in order to improve the display effect, the first layer and the second layer can be Gaussian blurred, etc.
[0060] It can be seen that the present invention generates a first layer whose fill color is the theme color, sets the transparency of the first layer to the preset transparency, and covers the first layer to the second layer rendered with the target image, thereby generating a filter effect image corresponding to the target image. Since the first layer is filled with the theme color of the target image, the visual effect matching degree between the first layer and the second layer can be improved, the display effect of the filter effect image finally generated can be improved, and the user's visual experience can be improved.
[0061] In addition, as an optional implementation of the present invention, after determining the theme color of the target image, when displaying the target image, the background of the page where the target image is located is adjusted according to the theme color of the target image. For example, when displaying the target image in a book details page, the background of the book details page can be adjusted to the theme color of the target image, thereby improving the display effect of the book details page and improving the user experience.
[0062] Embodiment 3
[0063] A third embodiment of the present invention provides a non-volatile computer storage medium, wherein the computer storage medium stores at least one executable instruction, and the computer executable instruction can execute the method in any of the above method embodiments.
[0064] In an optional implementation, the executable instructions may be specifically used to cause the processor to perform the following operations:
[0065] Get the target image;
[0066] Identify the dominant color channel of each sampling point in the target image;
[0067] For any color channel, calculate the proportion of sampling points that use the color channel as the dominant color channel; and calculate the color channel value of the color channel in the theme color of the target image according to the proportion of sampling points corresponding to the color channel;
[0068] The theme color of the target image is determined according to the color channel values of each color channel in the theme color.
[0069] In an optional implementation, the executable instruction causes the processor to perform the following operations:
[0070] After acquiring the target image, identifying the entity object area and the background area in the target image;
[0071] Determine sampling points from the physical object area and the background area respectively;
[0072] The number of sampling points per unit area in the physical object region is greater than the number of sampling points per unit area in the background region.
[0073] In an optional implementation, the executable instruction causes the processor to perform the following operations:
[0074] After acquiring the target image, identifying a central area and an edge area in the target image;
[0075] Determine sampling points from the central area and the edge area respectively;
[0076] The number of sampling points per unit area in the central region is greater than the number of sampling points per unit area in the edge region.
[0077] In an optional implementation, the executable instruction causes the processor to perform the following operations:
[0078] For any sampling point, obtain the values of each color channel of the sampling point;
[0079] The maximum color channel value among the color channel values of the sampling point is determined, and the color channel corresponding to the maximum color channel value is used as the dominant color channel of the sampling point.
[0080] In an optional implementation, the executable instruction causes the processor to perform the following operations:
[0081] If there are multiple maximum color channel values corresponding to the sampling point, the color channels corresponding to the respective maximum color channel values are all used as the dominant color channels of the sampling point.
[0082] In an optional implementation, the executable instruction causes the processor to perform the following operations:
[0083] If there are multiple maximum color channel values corresponding to the sampling point, a maximum color channel value is randomly selected, and the color channel corresponding to the selected maximum color channel value is used as the dominant color channel of the sampling point.
[0084] In an optional implementation, the executable instruction causes the processor to perform the following operations:
[0085] Count the number of sampling points that use each color channel as the dominant color channel respectively;
[0086] Calculate the sum of the number of sampling points corresponding to each color channel;
[0087] The ratio of the number of sampling points in which the color channel is used as the dominant color channel to the sum is used as the proportion of sampling points in which the color channel is used as the dominant color channel.
[0088] In an optional implementation, the executable instruction causes the processor to perform the following operations:
[0089] Counting the total number of sampling points in the target image;
[0090] The ratio of the number of sampling points in which the color channel is used as the dominant color channel to the total number of sampling points is used as the proportion of sampling points in which the color channel is used as the dominant color channel.
[0091] In an optional implementation, the executable instruction causes the processor to perform the following operations:
[0092] The maximum value of the color channel is determined, and the color channel value of the color channel in the theme color is determined according to the product of the ratio of the sampling points corresponding to the color channel and the maximum value.
[0093] In an optional implementation, the executable instruction causes the processor to perform the following operations:
[0094] Counting the transparency of each sampling point, and calculating the average transparency of all sampling points, and determining the transparency of the theme color according to the average transparency;
[0095] The theme color of the target image is determined according to the color channel values of each color channel in the theme color and the transparency of the theme color.
[0096] In an optional implementation, the executable instruction causes the processor to perform the following operations:
[0097] After determining the theme color of the target image, generating a first layer whose fill color is the theme color, and setting the transparency of the first layer to a preset transparency;
[0098] Generate a second layer with the target image rendered;
[0099] The first layer is overlaid onto the second layer to generate a filter effect image corresponding to the target image.
[0100] In an optional implementation, the executable instruction causes the processor to perform the following operations:
[0101] After determining the theme color of the target image, when displaying the target image, the background of the page where the target image is located is adjusted according to the theme color of the target image.
[0102] It can be seen that the theme color obtained by the embodiment of the present invention can reflect the overall color characteristics of the target image. In addition, the implementation process of this solution is simple and easy, the amount of calculation is small, the theme color extraction efficiency is high, and it is suitable for large-scale application and implementation.
[0103] Embodiment 4
[0104] Figure 3 The schematic diagram of the structure of an electronic device provided by the fourth embodiment of the present invention is shown. The specific embodiment of the present invention does not limit the specific implementation of the electronic device.
[0105] like Figure 3 As shown, the electronic device may include: a processor (processor) 302 , a communication interface (Communications Interface) 304 , a memory (memory) 306 , and a communication bus 308 .
[0106] The processor 302, the communication interface 304, and the memory 306 communicate with each other via the communication bus 308. The communication interface 304 is used to communicate with other devices such as a client or other server network elements. The processor 302 is used to execute the program 310, which can specifically execute the relevant steps in the above-mentioned picture processing method embodiment.
[0107] Specifically, the program 310 may include program codes, which include computer operation instructions.
[0108] The processor 302 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention. The one or more processors included in the electronic device may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.
[0109] The memory 306 is used to store the program 310. The memory 306 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0110] The program 310 may be specifically configured to enable the processor 302 to perform the following operations:
[0111] Get the target image;
[0112] Identify the dominant color channel of each sampling point in the target image;
[0113] For any color channel, calculate the proportion of sampling points that use the color channel as the dominant color channel; and calculate the color channel value of the color channel in the theme color of the target image according to the proportion of sampling points corresponding to the color channel;
[0114] The theme color of the target image is determined according to the color channel values of each color channel in the theme color.
[0115] In an optional implementation, the program 310 may be specifically configured to enable the processor 302 to perform the following operations:
[0116] After acquiring the target image, identifying the entity object area and the background area in the target image;
[0117] Determine sampling points from the physical object area and the background area respectively;
[0118] The number of sampling points per unit area in the physical object region is greater than the number of sampling points per unit area in the background region.
[0119] In an optional implementation, the program 310 may be specifically configured to enable the processor 302 to perform the following operations:
[0120] After acquiring the target image, identifying a central area and an edge area in the target image;
[0121] Determine sampling points from the central area and the edge area respectively;
[0122] The number of sampling points per unit area in the central region is greater than the number of sampling points per unit area in the edge region.
[0123] In an optional implementation, the program 310 may be specifically configured to enable the processor 302 to perform the following operations:
[0124] For any sampling point, obtain the values of each color channel of the sampling point;
[0125] The maximum color channel value among the color channel values of the sampling point is determined, and the color channel corresponding to the maximum color channel value is used as the dominant color channel of the sampling point.
[0126] In an optional implementation, the program 310 may be specifically configured to enable the processor 302 to perform the following operations:
[0127] If there are multiple maximum color channel values corresponding to the sampling point, the color channels corresponding to the respective maximum color channel values are all used as the dominant color channels of the sampling point.
[0128] In an optional implementation, the program 310 may be specifically configured to enable the processor 302 to perform the following operations:
[0129] If there are multiple maximum color channel values corresponding to the sampling point, a maximum color channel value is randomly selected, and the color channel corresponding to the selected maximum color channel value is used as the dominant color channel of the sampling point.
[0130] In an optional implementation, the program 310 may be specifically configured to enable the processor 302 to perform the following operations:
[0131] Count the number of sampling points that use each color channel as the dominant color channel respectively;
[0132] Calculate the sum of the number of sampling points corresponding to each color channel;
[0133] The ratio of the number of sampling points in which the color channel is used as the dominant color channel to the sum is used as the proportion of sampling points in which the color channel is used as the dominant color channel.
[0134] In an optional implementation, the program 310 may be specifically configured to enable the processor 302 to perform the following operations:
[0135] Counting the total number of sampling points in the target image;
[0136] The ratio of the number of sampling points in which the color channel is used as the dominant color channel to the total number of sampling points is used as the proportion of sampling points in which the color channel is used as the dominant color channel.
[0137] In an optional implementation, the program 310 may be specifically configured to enable the processor 302 to perform the following operations:
[0138] The maximum value of the color channel is determined, and the color channel value of the color channel in the theme color is determined according to the product of the ratio of the sampling points corresponding to the color channel and the maximum value.
[0139] In an optional implementation, the program 310 may be specifically configured to enable the processor 302 to perform the following operations:
[0140] Counting the transparency of each sampling point, and calculating the average transparency of all sampling points, and determining the transparency of the theme color according to the average transparency;
[0141] The theme color of the target image is determined according to the color channel values of each color channel in the theme color and the transparency of the theme color.
[0142] In an optional implementation, the program 310 may be specifically configured to enable the processor 302 to perform the following operations:
[0143] After determining the theme color of the target image, generating a first layer whose fill color is the theme color, and setting the transparency of the first layer to a preset transparency;
[0144] Generate a second layer with the target image rendered;
[0145] The first layer is overlaid onto the second layer to generate a filter effect image corresponding to the target image.
[0146] In an optional implementation, the program 310 may be specifically configured to enable the processor 302 to perform the following operations:
[0147] After determining the theme color of the target image, when displaying the target image, the background of the page where the target image is located is adjusted according to the theme color of the target image.
[0148] It can be seen that the theme color obtained by the embodiment of the present invention can reflect the overall color characteristics of the target image. In addition, the implementation process of this solution is simple and easy, the amount of calculation is small, the theme color extraction efficiency is high, and it is suitable for large-scale application and implementation.
[0149] The algorithm or display provided herein is not inherently related to any particular computer, virtual system or other equipment. Various general purpose systems can also be used together with the teachings based on this. According to the above description, it is obvious to construct the structure required for this type of system. In addition, the embodiment of the present invention is not directed to any specific programming language yet. It should be understood that various programming languages can be utilized to realize the content of the present invention described herein, and the description made to specific languages above is for disclosing the best mode of the present invention.
[0150] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.
[0151] Similarly, it should be understood that in order to streamline the present invention and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, the various features of the embodiments of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this disclosed method should not be interpreted as reflecting the following intention: that the claimed invention requires more features than the features explicitly recited in each claim. More specifically, as reflected in the claims below, inventive aspects lie in less than all the features of the individual embodiments disclosed above. Therefore, the claims that follow the specific embodiment are hereby expressly incorporated into the specific embodiment, with each claim itself serving as a separate embodiment of the present invention.
[0152] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and in addition they may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this manner may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.
[0153] In addition, those skilled in the art will appreciate that, although some embodiments herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of the present invention and form different embodiments. For example, in the claims below, any one of the claimed embodiments may be used in any combination.
[0154] The various component embodiments of the present invention can be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or digital signal processor (DSP) can be used in practice to implement some or all functions of some or all components according to embodiments of the present invention. The present invention can also be implemented as a device or apparatus program (e.g., computer program and computer program product) for executing part or all of the methods described herein. Such a program implementing the present invention can be stored on a computer-readable medium, or can have the form of one or more signals. Such a signal can be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.
[0155] It should be noted that the above embodiments illustrate the present invention rather than limit it, and that those skilled in the art may devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets shall not be construed as a limitation on the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention may be implemented by means of hardware comprising a number of different elements and by means of a suitably programmed computer. In a unit claim enumerating a number of devices, several of these devices may be embodied by the same hardware item. The use of the words first, second, and third, etc. does not indicate any order. These words may be interpreted as names. The steps in the above embodiments, unless otherwise specified, should not be understood as limitations on the order of execution.
Claims
1. A method for processing an image, comprising: Get the target image; For any sampling point of the target image, obtain the color channel values of the sampling point, determine the maximum color channel value among the color channel values of the sampling point, and use the color channel corresponding to the maximum color channel value as the dominant color channel of the sampling point; For any color channel, calculate the proportion of sampling points that take the color channel as the dominant color channel; and determining a maximum value of the color channel, and calculating a color channel value of the color channel in the theme color of the target image according to the product of the ratio of the sampling points corresponding to the color channel and the maximum value; Counting the transparency of each sampling point, and calculating the average value of the transparency of all sampling points, and determining the transparency of the theme color according to the average value; determining the theme color of the target image according to the color channel value of each color channel in the theme color and the transparency of the theme color; Generate a first layer whose fill color is the theme color, and set the transparency of the first layer to a preset transparency; Generate a second layer with the target image rendered; and cover the first layer with the second layer to generate a filter effect image corresponding to the target image.
2. The method according to claim 1, wherein: After acquiring the target image, the method further includes: Identify the physical object area and the background area in the target image; Determine sampling points from the physical object area and the background area respectively; The number of sampling points per unit area in the physical object region is greater than the number of sampling points per unit area in the background region.
3. The method according to claim 1, wherein: After acquiring the target image, the method further includes: Identify a central area and an edge area in the target image; Determine sampling points from the central area and the edge area respectively; The number of sampling points per unit area in the central region is greater than the number of sampling points per unit area in the edge region.
4. The method according to claim 1, wherein: Determining the maximum color channel value among the color channel values of the sampling point, and using the color channel corresponding to the maximum color channel value as the dominant color channel of the sampling point further includes: If there are multiple maximum color channel values corresponding to the sampling point, the color channels corresponding to the respective maximum color channel values are all used as the dominant color channels of the sampling point.
5. The method according to claim 1, wherein: Determining the maximum color channel value among the color channel values of the sampling point, and using the color channel corresponding to the maximum color channel value as the dominant color channel of the sampling point further includes: If there are multiple maximum color channel values corresponding to the sampling point, a maximum color channel value is randomly selected, and the color channel corresponding to the selected maximum color channel value is used as the dominant color channel of the sampling point.
6. The method according to any one of claims 1 to 5, wherein: The calculating of the proportion of sampling points that use the color channel as the dominant color channel further comprises: Count the number of sampling points that use each color channel as the dominant color channel respectively; Calculate the sum of the number of sampling points corresponding to each color channel; The ratio of the number of sampling points in which the color channel is used as the dominant color channel to the sum is used as the proportion of sampling points in which the color channel is used as the dominant color channel.
7. The method according to any one of claims 1 to 5, wherein: The calculating of the proportion of sampling points that use the color channel as the dominant color channel further comprises: Counting the total number of sampling points in the target image; The ratio of the number of sampling points in which the color channel is used as the dominant color channel to the total number of sampling points is used as the proportion of sampling points in which the color channel is used as the dominant color channel.
8. The method according to any one of claims 1 to 5, wherein: After determining the theme color of the target image, the method further includes: When displaying the target image, the background of the page where the target image is located is adjusted according to the theme color of the target image.
9. An electronic device, comprising: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform the following operations: Get the target image; For any sampling point of the target image, obtain the color channel values of the sampling point, determine the maximum color channel value among the color channel values of the sampling point, and use the color channel corresponding to the maximum color channel value as the dominant color channel of the sampling point; For any color channel, calculate the proportion of sampling points that take the color channel as the dominant color channel; and determining a maximum value of the color channel, and calculating a color channel value of the color channel in the theme color of the target image according to the product of the ratio of the sampling points corresponding to the color channel and the maximum value; Counting the transparency of each sampling point, and calculating the average transparency of all sampling points, and determining the transparency of the theme color according to the average transparency; Determining the theme color of the target image according to the color channel values of each color channel in the theme color and the transparency of the theme color; Generate a first layer whose fill color is the theme color, and set the transparency of the first layer to a preset transparency; Generate a second layer with the target image rendered; and cover the first layer with the second layer to generate a filter effect image corresponding to the target image.
10. The electronic device according to claim 9, wherein: The executable instructions cause the processor to perform the following operations: After acquiring the target image, identifying the entity object area and the background area in the target image; Determine sampling points from the physical object area and the background area respectively; The number of sampling points per unit area in the physical object region is greater than the number of sampling points per unit area in the background region.
11. The electronic device according to claim 9, wherein: The executable instructions cause the processor to perform the following operations: After acquiring the target image, identifying a central area and an edge area in the target image; Determine sampling points from the central area and the edge area respectively; The number of sampling points per unit area in the central region is greater than the number of sampling points per unit area in the edge region.
12. The electronic device according to claim 9, wherein: The executable instructions cause the processor to perform the following operations: If there are multiple maximum color channel values corresponding to the sampling point, the color channels corresponding to the respective maximum color channel values are all used as the dominant color channels of the sampling point.
13. The electronic device according to claim 9, wherein: The executable instructions cause the processor to perform the following operations: If there are multiple maximum color channel values corresponding to the sampling point, a maximum color channel value is randomly selected, and the color channel corresponding to the selected maximum color channel value is used as the dominant color channel of the sampling point.
14. The electronic device according to any one of claims 9 to 13, wherein: The executable instructions cause the processor to perform the following operations: Count the number of sampling points that use each color channel as the dominant color channel respectively; Calculate the sum of the number of sampling points corresponding to each color channel; The ratio of the number of sampling points in which the color channel is used as the dominant color channel to the sum is used as the proportion of sampling points in which the color channel is used as the dominant color channel.
15. The electronic device according to any one of claims 9 to 13, wherein: The executable instructions cause the processor to perform the following operations: Counting the total number of sampling points in the target image; The ratio of the number of sampling points in which the color channel is used as the dominant color channel to the total number of sampling points is used as the proportion of sampling points in which the color channel is used as the dominant color channel.
16. The electronic device according to any one of claims 9 to 13, wherein: The executable instructions cause the processor to perform the following operations: After determining the theme color of the target image, when displaying the target image, the background of the page where the target image is located is adjusted according to the theme color of the target image.
17. A computer storage medium, wherein at least one executable instruction is stored in the storage medium, and the executable instruction enables a processor to perform an operation corresponding to the image processing method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Page background setting method and device and electronic device
CN110865862A
Image theme color extraction method and device and electronic equipment
CN110969170A