Image processing method, device, electronic device and storage medium

By analyzing the color value information in the poster image, automatically adjusting the basic color value of the mask layer and performing transparent processing, the problems of high cost and unstable quality of manual customization mask layer are solved, and the poster text information is clearly displayed and the poster aesthetics is improved.

CN114240733BActive Publication Date: 2025-03-28SHENZHEN KUKAI SOFTWARE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111300660.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-04
Publication Date
2025-03-28
Estimated Expiration
2041-11-04

AI Technical Summary

Technical Problem

In the prior art, manual custom poster coating is expensive and of uneven quality, resulting in blurred or hidden poster text information.

Method used

By analyzing the color value information in the image to be processed, determining the target color value, and adjusting the basic color value of the mask layer according to the target color value, performing transparent processing to generate a target mask layer suitable for the current image.

Benefits of technology

It realizes automatic generation of masks suitable for poster text information display, solves the problems of high cost and unstable quality of manual custom masks, and improves the aesthetics and user experience of the poster.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114240733B_ABST
    Figure CN114240733B_ABST
Patent Text Reader

Abstract

The present application relates to an image processing method, device, electronic device and storage medium, the image processing method comprising: determining a target color value according to color value information in an image to be processed; determining a basic color value of a mask layer according to the target color value; performing transparent processing on the mask layer based on the basic color value of the mask layer to obtain a target mask layer; synthesizing the image to be processed, the target mask layer and an information layer to obtain a target image, wherein the information layer includes text information. The present application determines a target color value according to the color value information of the image to be processed, and based on the basic color value of the mask layer determined according to the target color value, performs transparent processing on the mask layer to obtain a target mask layer, synthesizes the image to be processed, the target mask layer and the information layer, thereby realizing automatic generation of a target image (i.e., a poster), and solving the problem of high cost and uneven mask quality caused by manually customizing the mask layer in the prior art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] In the scenario of providing content distribution services to users through the Internet, that is, in the content distribution scenario (over the top, OTT), posters are one of the main carriers of content output. For posters, in addition to the main image, there is often text information in the poster, such as the main title and subtitle of the film. Because the background image of the text information in the poster may be more complex, or the color of the background image of the text information in the poster may be similar to the color of the text information, the text information displayed on the poster may be blurred or directly hidden.

[0003] In the prior art, a semi-transparent gray-black mask is usually added to the area on the poster where text information needs to be displayed, so that the text information is displayed on the preset background color, that is, gray-black, so that the text information displayed on the poster is clearer, and the problem that the display of the text information may be blurry or the text information is directly hidden is solved. However, the gray-black mask may make the picture look heavy and "dirty". Using a gray-black mask for all posters may reduce the aesthetics of the picture and affect the user experience. In order to solve the problems of heavy, dirty and low aesthetics of the picture caused by the gray-black mask, a mask can be manually customized for each poster. However, when the number of posters is large, the labor cost is high, and due to the different color selection standards of different designers, the quality of the produced masks may be uneven. Summary of the invention

[0004] The present application provides an image processing method, device, electronic device and storage medium, which are used to solve the problems of high cost and uneven quality of mask layers caused by manually customized mask layers.

[0005] In a first aspect, an embodiment of the present application provides an image processing method, comprising:

[0006] Determine the target color value according to the color value information in the image to be processed;

[0007] Determine the basic color value of the mask layer according to the target color value;

[0008] Based on the basic color value of the mask layer, the mask layer is transparently processed to obtain a target mask layer;

[0009] The image to be processed, the target mask layer and the information layer are synthesized to obtain a target image, wherein the information layer includes text information.

[0010] Optionally, the color value information in the image to be processed includes the occurrence frequency of the color value and the distribution of the color value;

[0011] The target color value includes a first target color value and a second target color value;

[0012] Determining the target color value according to the color value information in the image to be processed includes:

[0013] Determine the color value whose appearance frequency in the image to be processed exceeds the first preset frequency as the first target color value; the number of the first target color value is at least one;

[0014] The color values ​​in the preset area of ​​the image to be processed whose differences do not exceed the preset difference are merged, and the color values ​​whose frequency of appearance after merging exceeds the second preset frequency are determined as the second target color values; the preset area of ​​the image to be processed is the area corresponding to the text information in the image to be processed.

[0015] Optionally, determining a basic color value of the mask layer according to the target color value includes:

[0016] If each color value in the first target color value is discretely distributed, the brightness and saturation of the second target color value are adjusted according to a first preset rule to obtain a basic color value of the mask layer;

[0017] or,

[0018] If the color values ​​in the first target color values ​​are non-discretely distributed, the second target color values ​​are adjusted according to the hue and / or brightness in the second target color values ​​to obtain the basic color value of the mask layer.

[0019] Optionally, adjusting the second target color value according to the hue and / or brightness in the second target color value to obtain the basic color value of the mask layer includes:

[0020] If the hue of the second target color value is white, and / or the brightness of the second target color value is greater than a first preset brightness, the value of the second target color value is adjusted to the first preset value, and the second target color value is determined as the basic color value of the mask layer;

[0021] or,

[0022] If the hue in the second target color value is not white and the brightness in the second target color value is less than or equal to a second preset brightness, the brightness and saturation of the second target color value are adjusted according to a second preset rule to obtain a basic color value of the mask layer; the first preset brightness is greater than the second preset brightness;

[0023] or,

[0024] If the hue of the second target color value is not white, the brightness of the second target color value is less than or equal to the first preset brightness, and the brightness of the second target color value is greater than the second preset brightness, then at least one of brightness adjustment, saturation adjustment and hue adjustment is performed on the second target color value according to a third preset rule to obtain the basic color value of the mask.

[0025] Optionally, adjusting the second target color value according to the hue and / or brightness in the second target color value to obtain the basic color value of the mask layer includes:

[0026] If the hue in the second target color value is white, the second target color value is updated according to the image to be processed to obtain an updated second target color value, and if the updated second target color value is white, the value of the updated second target color value is adjusted to a second preset value, and the updated second target color value is determined as the basic color value of the mask layer;

[0027] or,

[0028] If the hue in the second target color value is white, the second target color value is updated according to the image to be processed to obtain an updated second target color value, and if the updated second target color value is not white, the brightness and saturation of the updated second target color value are adjusted according to a fourth preset rule;

[0029] or,

[0030] If the hue of the second target color value is not white and the brightness of the second target color value is greater than a third preset brightness value, the value of the second target color value is adjusted to a second preset value, and the second target color value is determined as the basic color value of the mask layer;

[0031] or,

[0032] If the hue in the second target color value is not white and the brightness in the second target color value is less than or equal to the fourth preset brightness, the brightness and saturation of the second target color value are adjusted according to the fifth preset rule to obtain the basic color value of the mask layer; the third preset brightness is greater than the fourth preset brightness;

[0033] or,

[0034] If the hue of the second target color value is not white, the brightness of the second target color value is less than or equal to the third preset brightness, and the brightness of the second target color value is greater than the fourth preset brightness, then the second target color value is adjusted according to the sixth preset rule to perform at least one of brightness adjustment, saturation adjustment and hue adjustment to obtain the basic color value of the mask.

[0035] Optionally, updating the second target color value according to the image to be processed to obtain an updated second target color value includes:

[0036] The color values ​​in the to-be-processed image whose difference does not exceed the preset difference are merged, and the color values ​​whose occurrence frequency after merging exceeds the second preset frequency are determined as the updated second target color values.

[0037] Optionally, performing transparent processing on the mask layer based on the basic color value of the mask layer to obtain a target mask layer includes:

[0038] Based on the basic color value of the mask layer, the entire mask layer is transparently processed according to a preset transparency to obtain the target mask layer.

[0039] Optionally, performing transparent processing on the mask layer based on the basic color value of the mask layer to obtain a target mask layer includes:

[0040] Based on the basic color value of the mask layer, the entire mask layer is transparently processed according to a preset transparency to obtain a transition mask layer;

[0041] The preset area of ​​the transition mask is subjected to a gradual transparency process to obtain the target mask; the preset area of ​​the transition mask is the area corresponding to the text information in the mask.

[0042] Optionally, synthesizing the image to be processed, the target mask layer and the information layer to obtain a target image includes:

[0043] The image to be processed, the target mask layer and the information layer are superimposed in a preset order, the information layer is located at the top layer, the target mask layer is located between the image to be processed and the information layer, and the image layer is located at the bottom layer.

[0044] In a second aspect, an embodiment of the present application provides an image processing device, the image processing device comprising:

[0045] A determination unit, used to determine a target color value according to color value information in the image to be processed;

[0046] The determining unit is further used to determine the basic color value of the mask layer according to the target color value;

[0047] A processing unit, configured to perform transparent processing on the mask layer based on a basic color value of the mask layer to obtain a target mask layer;

[0048] The synthesis unit is used to synthesize the image to be processed, the target mask layer and the information layer to obtain a target image, wherein the information layer includes text information.

[0049] In a third aspect, an embodiment of the present application provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;

[0050] Memory, used to store computer programs;

[0051] The processor is used to implement the steps of the image processing method described in any embodiment of the first aspect when executing the program stored in the memory.

[0052] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the image processing method as described in any embodiment of the first aspect are implemented.

[0053] The above-mentioned technical scheme provided by the embodiment of the present application has the following advantages over the prior art: the image processing method provided by the embodiment of the present application uses the target color value determined according to the color value information in the image to be processed to determine the basic color value of the mask layer that is more suitable for the current image to be processed, and based on the basic color value, the mask layer is transparently processed to obtain the target mask layer that can make the text information more clearly displayed on the image to be processed, and then synthesize the image to be processed, the target mask layer and the information layer to realize the automatic generation of the target image (i.e., the poster), thereby solving the problem of high cost and uneven mask quality caused by manually customized masks in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0055] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0056] Figure 1 A flowchart of an image processing method provided in an embodiment of the present application;

[0057] Figure 2 A schematic diagram of a basic color value of a mask provided in an embodiment of the present application;

[0058] Figure 3 A schematic diagram of a target mask provided in an embodiment of the present application;

[0059] Figure 4A schematic diagram of a synthetic target image provided in an embodiment of the present application;

[0060] Figure 5 A schematic diagram of a target image provided in an embodiment of the present application Figure 3 ;

[0061] Figure 6 A schematic diagram of an image processing device provided in an embodiment of the present application;

[0062] Figure 7 A schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0063] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0064] In order to solve the problem of high cost and uneven quality of the mask caused by manually customized mask in the prior art, the embodiment of the present application provides an image processing method, which is applied to a processor, and the processor can be located in a server or other device. Figure 1 As shown, the image processing method includes steps S101 to S104 as shown below:

[0065] S101, determining a target color value according to color value information in an image to be processed;

[0066] The image to be processed is an image that does not contain text information, such as the main image in the poster mentioned in the above background technology.

[0067] The color value information in the image to be processed includes the frequency of occurrence of the color value and the distribution of the color value. Among them, the RGB value of each pixel in the image is the above color value, and the frequency of occurrence of pixels with the same RGB value is the frequency of occurrence of the corresponding color value. In addition, the distribution of the color value is the position of the color value in the image to be processed.

[0068] Exemplarily, the color value in the image to be processed includes three color values, namely color value a, color value b and color value c. At this time, the color value information in the image to be processed includes the occurrence frequency of color value a, the occurrence frequency of color value b, the occurrence frequency of color value c, the distribution position of color value a in the image to be processed, the distribution position of color value b in the image to be processed, and the distribution position of color value c in the image to be processed.

[0069] Specifically, the color value information in the image to be processed can be represented in the form of a two-dimensional array, which contains the RGB value of each pixel and the position of each pixel in the image to be processed. Exemplarily, an element in the two-dimensional array is ((r, g, b), (x, y)), where (r, g, b) is the RGB value of the pixel, and (x, y) is the position of the pixel in the two-dimensional coordinate system established according to the image to be processed.

[0070] Optionally, the target color value includes a first target color value and a second target color value.

[0071] At this time, in a possible implementation, a color value that appears more than a first preset frequency in the image to be processed is determined as a first target color value. The number of the first target color values ​​is at least one. It should be noted that the first preset frequency is predetermined and can also be determined according to actual working conditions. In addition, when the number of the first target color values ​​is one, the first target color value may be the same as the second target color value.

[0072] In one possible manner, color values ​​whose difference does not exceed a preset difference in a preset area of ​​the image to be processed are merged, and the color value whose frequency of occurrence after merging exceeds a second preset frequency is determined as the second target color value. The preset area of ​​the image to be processed is the area corresponding to the text information in the image to be processed. It should be noted that the second preset frequency and the preset difference are predetermined and can also be determined according to actual working conditions.

[0073] Exemplarily, the preset area of ​​the image to be processed may be obtained by cropping the image to be processed using the crop image() function.

[0074] Exemplarily, the preset area of ​​the image to be processed is the area in the lower half of the image to be processed, that is, the length of the preset area is the same as the length of the image to be processed, but the width of the preset area is 0.5 times the width of the image to be processed.

[0075] Specifically, regression processing is performed on the color values ​​whose differences in the preset area to be processed do not exceed the preset difference to obtain the color values ​​after regression processing, and based on the occurrence frequency of the color values ​​after regression processing, the color values ​​whose occurrence frequency exceeds the second preset frequency are determined as the second target color values.

[0076] For example, the frequency of occurrence of the color value (255, 182, 193) in the image to be processed is 2000, and the frequency of occurrence of the color value (255, 180, 189) in the image to be processed is 3000. If the difference between the two color values ​​is less than the preset threshold, the two color values ​​are regressed to obtain, for example, the color value (255, 181, 191). The frequency of occurrence of the color value (255, 181, 191) is 5000.

[0077] Or, specifically, the color values ​​whose differences in the preset area to be processed do not exceed the preset difference are taken as the median to obtain the color value after median processing, and based on the frequency of occurrence of the color value after regression processing, the color value whose occurrence frequency exceeds the second preset frequency is determined as the second target color value.

[0078] Exemplarily, the process of picking the color of the preset area of ​​the image to be processed, that is, determining the second target color value according to the preset area of ​​the image to be processed, can be implemented by a get max color() function.

[0079] Generally, the second preset frequency is greater than the first preset frequency, but the second preset frequency may be equal to or even less than the first preset frequency. When the second preset frequency is equal to or less than the first preset frequency, the number of first target color values ​​is one, and the first target color value may be the same as the second target color value.

[0080] In another possible implementation, determining the first target color value may also be to merge color values ​​whose differences in a preset area of ​​the image to be processed do not exceed a preset difference, and determine the color value whose appearance frequency after merging exceeds a first preset frequency as the first target color value.

[0081] It should be noted that, through the above process, the most widely distributed color value in the image to be processed, namely the second target color value, can be determined, and in the subsequent processing process, the second target color value is processed to obtain the basic color value of the mask layer, so that the mask layer and the image to be processed can be better integrated after synthesis, thereby improving the aesthetics of the target image.

[0082] It should be noted that, in general, the target color value is determined by the RGB color value of the pixel, but the basic color value of the mask is determined according to the HSB value of the target color value. Since the RGB color value is the value of the three primary colors, adjusting the basic color value of the mask according to the RGB color value may make the color of the mask roughly the same as the background color, that is, the color of the image to be processed, so that the mask is mixed with the image to be processed, and the text information cannot be separated from the image to be processed, so that the text information is displayed on the image to be processed in a fuzzy manner, or is directly hidden. Therefore, in the subsequent processing process, the second target color value is usually converted from the RGB color value to the HSB color value, and the hue, brightness and saturation in the second target color value are processed to obtain the basic color value of the mask that can make the text information clearly displayed on the image to be processed, so as to ensure the clear display of the text information on the basis of ensuring the beauty of the target image.

[0083] S102: Determine the basic color value of the mask layer according to the target color value.

[0084] Optionally, the environment in the image to be processed is determined according to the first target color value and the second target color value in the target color value, and the second target color value is processed according to the environment in the image to be processed to obtain the basic color value of the mask layer.

[0085] In a possible implementation, the environment in the image to be processed includes a complex environment and a simple environment. In general, the frequency of occurrence of each color value in a complex environment is discretely distributed according to a certain aggregation function or the distribution position of each color value in the image to be processed is discrete. In other words, the basic color value of the mask layer can be determined based on whether each color value in the first target color value is discretely distributed. If each color value in the first target color value is discretely distributed, the brightness and saturation of the second target color value are adjusted according to the first preset rule to obtain the basic color value of the mask layer. Alternatively, if each color value in the first target color value is non-discretely distributed, the second target color value is adjusted according to the hue and / or brightness in the second target color value to obtain the basic color value of the mask layer.

[0086] Among them, if the color values ​​in the first target color value are non-discretely distributed, the second target color value is adjusted according to the hue in the second target color value to obtain the basic color value of the mask layer; if the color values ​​in the first target color value are non-discretely distributed, the second target color value is adjusted according to the brightness in the second target color value to obtain the basic color value of the mask layer; if the color values ​​in the first target color value are non-discretely distributed, the second target color value is adjusted according to the hue and brightness in the second target color value to obtain the basic color value of the mask layer.

[0087] Specifically, for each color value in the first target color value, according to the position distribution of the color value in the image to be processed, it is determined whether the color value is discretely distributed in the image to be processed, that is, whether the distribution of the color value in the image to be processed is relatively messy. If the color value is discretely distributed in the image to be processed, that is, the distribution of the color value in the image to be processed is relatively messy, it is determined that the environment in the image to be processed is relatively complex, that is, the environment in the image to be processed is a complex environment, and then the second target color value is adjusted in brightness and saturation according to the first preset rule to obtain the basic color value of the mask layer. If the color value is non-discretely distributed in the image to be processed, it is determined that the environment in the image to be processed is a simple environment, and then the second target color value is adjusted according to the hue and / or brightness in the second target color value to obtain the basic color value of the mask layer.

[0088] Alternatively, for all color values ​​in the first target color value, if the occurrence frequency of each color value in the first target color value is discretely distributed, it is determined that the environment in the image to be processed is a complex environment, and the brightness and saturation of the second target color value are adjusted according to the first preset rule to obtain the basic color value of the mask layer; if the occurrence frequency of each color value of the first target color value is non-discretely distributed, it is determined that the environment in the image to be processed is a simple environment, and the second target color value is adjusted according to the hue and / or brightness in the second target color value to obtain the basic color value of the mask layer.

[0089] The method of determining whether each color value in the first target color value is discretely distributed may refer to the prior art, which will not be elaborated here.

[0090] The above-mentioned first preset rule adjusts the brightness and saturation in the second target color value according to the first preset weight and the second preset weight respectively, that is, the brightness in the second target color value is adjusted according to the first preset weight, and the saturation in the second target color value is adjusted according to the second preset weight.

[0091] Exemplarily, the first preset weight is 0.4, the second preset weight is 1.5, and the second target color value is (H1, S1, B1). The second target color value is adjusted for brightness and saturation according to the first preset rule, and the basic color value of the mask layer is obtained as (H2, S2, B2). Among them, H2=H1, S2=1.5*S1, B2=0.4*B1.

[0092] The first preset weight and the second preset weight may be predetermined or determined according to actual working conditions.

[0093] Through this process, when the environment in the image to be processed is a complex environment, according to the first preset rule, the brightness of the second target color value is reduced and the saturation of the second target color value is increased, that is, the brightness of the mask layer is reduced and the saturation of the mask layer is increased to ensure the purity of the target image synthesized by the target mask layer determined according to the basic color value of the mask layer, and avoid the fragmentation of the target image.

[0094] In a possible implementation, the above-mentioned simple environment can be further divided into a bright environment, a dark environment and a normal environment. At this time, the second target color value is adjusted according to the hue and / or brightness in the second target color value to obtain the basic color value of the mask layer. The detailed description of the process can be found in the following content.

[0095] Specifically, if the hue of the second target color value is white, and / or the brightness of the second target color value is greater than the first preset brightness, the value of the second target color value is adjusted to the first preset value, and the second target color value is determined as the basic color value of the mask. The first preset value and the first preset brightness can be predetermined or determined according to actual working conditions.

[0096] Exemplarily, the first preset value is (h, s, b), where hue h=360, saturation s=40, and brightness b=0. At this time, the basic color value of the mask is (h, s, b). The first preset value represents dark gray.

[0097] That is, if the hue in the second target color value is white, the environment in the image to be processed is determined to be a bright environment; if the brightness in the second target color value is greater than the first preset brightness, the environment in the image to be processed is determined to be a bright environment; if the hue in the second target color value is white, and the brightness in the second target color value is greater than the first preset brightness, the environment in the image to be processed is determined to be a bright environment. Subsequently, when the environment in the image to be processed is a bright environment, the value of the second target color value is adjusted to the first preset value, and the second target color value adjusted to the first preset value is determined as the basic color value of the mask.

[0098] Through this process, when the environment in the image to be processed is a bright environment, by referring to the WCAG2.0 specification, the first preset value is directly used as the basic color value of the mask layer, so as to ensure a high degree of recognition of the text information in the target image.

[0099] Or, specifically, if the hue in the second target color value is not white, and the brightness in the second target color value is less than or equal to the second preset brightness, then the environment in the image to be processed is a dark environment, and the second target color value is adjusted for brightness and saturation according to the second preset rule to obtain the basic color value of the mask. Among them, the first preset brightness is greater than the second preset brightness. It should be noted that the second preset brightness can be predetermined or determined according to actual working conditions.

[0100] The above-mentioned second preset rule adjusts the brightness and saturation in the second target color value according to the third preset weight and the fourth preset weight respectively, that is, the brightness in the second target color value is adjusted according to the third preset weight, and the saturation in the second target color value is adjusted according to the fourth preset weight.

[0101] Exemplarily, the third preset weight is 0.3, the fourth preset weight is 1.6, and the second target color value is (H1, S1, B1). The second target color value is adjusted for brightness and saturation according to the second preset rule, and the basic color value of the mask layer is obtained as (H2, S2, B2). Among them, H2=H1, S2=1.6*S1, B2=0.3*B1.

[0102] The third preset weight and the fourth preset weight may be predetermined or determined according to actual working conditions.

[0103] Through this process, when the environment in the image to be processed is a dark environment, according to the second preset rule, the brightness of the second target color value is reduced, and the saturation of the second target color value is increased, that is, the brightness of the mask layer is reduced, and the saturation of the mask layer is increased, so as to ensure the purity of the target image synthesized according to the target mask layer determined by the base color value of the mask layer and avoid the splitting of the target image.

[0104] Alternatively, specifically, if the hue and / or brightness in the second target color value do not meet the above conditions, the environment in the image to be processed is a normal environment. That is to say, the second target color value is not white, the brightness in the second target color value is less than or equal to the first preset brightness, and the brightness in the second target color value is greater than the second preset brightness, then the environment in the image to be processed is a normal environment. At this time, at least one of brightness adjustment, saturation adjustment, and hue adjustment is performed on the second target color value according to the third preset rule to obtain the base color value of the mask layer.

[0105] Among them, the third preset rule is: h1 <= H1 <= h2, H2 = H1 - △h; s1 <= S1 <= s2, H2 = h3, S2 = s3, B2 = b1; S1 < s1 or S1 > s2, S2 = S1 + △s; B > b2, B = b2. Where H1, S1, and B1 are the hue, saturation, and brightness in the second target color value respectively, h1 is the first preset hue, h2 is the second preset hue, s1 is the first preset saturation, △h is the preset hue difference value, s1 is the first preset saturation, s2 is the second preset saturation, s3 is the third preset saturation, b1 is the fifth preset brightness, b2 is the sixth preset brightness, and H2, S2, and B2 are the hue, saturation, and brightness in the adjusted second target color value respectively, that is, the hue, saturation, and brightness in the base color value of the mask layer. It should be noted that h1, h2, △h, s1, s2, s3, △s, b1, and b2 can all be pre-determined or determined according to the actual working conditions.

[0106] Exemplarily, the third preset rule is 35 <= H <= 55, H = H - 10; 0 <= S <= 10, H = 0, S = 0, B = 0; S < 0 or S > 10, S = S + 40; B > 20, B = 20.

[0107] Exemplarily, as Figure 2 shown, the color value obtained by processing the second target color value according to the third preset rule, that is, the base color value of the mask layer can be H: 191, S: 85, B: 20; or H: 236, S: 85, B: 20.

[0108] In another possible implementation, the simple environment can be further divided into a first bright environment, a second bright environment, a dark environment, and a normal environment. At this time, the second target color value is adjusted according to the hue and / or brightness in the second target color value to obtain the basic color value of the mask layer. The detailed description of the process can be found in the following content.

[0109] Specifically, if the hue in the second target color value is white, the second target color value is updated according to the image to be processed to obtain an updated second target color value, and if the updated second target color value is white, then the environment in the image to be processed is the first bright environment, and the value of the updated second target color value is adjusted to the second preset value, and the updated second target color value is determined as the basic color value of the mask, that is, the second preset value is determined as the basic color value of the mask. It should be noted that the second preset value can be predetermined or determined according to actual working conditions. For an introduction to the second preset value, please refer to the above introduction to the first preset value, which will not be repeated here. For the process of updating the second target color value according to the image to be processed and obtaining the updated second target color value, please refer to the following content, which will not be repeated here.

[0110] Through this process, when the environment in the image to be processed is the first bright environment, by referring to the WCAG2.0 specification, the second preset value is directly used as the basic color value of the mask layer, so as to ensure a high degree of recognition of the text information in the target image.

[0111] Or, specifically, the hue in the second target color value is white, the second target color value is updated according to the image to be processed to obtain an updated second target color value, and the updated second target color value is not white, then the environment in the image to be processed is the second bright environment, and the brightness and saturation of the updated second target color value are adjusted according to the fourth preset rule.

[0112] The above-mentioned fourth preset rule adjusts the brightness and saturation of the second target color value according to the fifth preset weight and the sixth preset weight respectively, that is, adjusts the brightness of the second target color value according to the fifth preset weight, and adjusts the saturation of the second target color value according to the sixth preset weight.

[0113] For example, the fifth preset weight is 0.3, the sixth preset weight is 1.6, and the second target color value is (H1, S1, B1). The second target color value is adjusted for brightness and saturation according to the fourth preset rule, and the basic color value of the mask layer is obtained as (H2, S2, B2). Among them, H2=H1, S2=1.6*S1, B2=0.3*B1.

[0114] That is to say, the fourth preset rule may be the same as the second preset rule. Of course, the fourth preset rule may also be different from the second preset rule.

[0115] Among them, the fifth preset weight and the sixth preset weight can be predetermined or determined according to actual working conditions.

[0116] Through this process, when the environment in the image to be processed is the second bright environment, according to the fourth preset rule, the brightness of the second target color value is reduced and the saturation of the second target color value is increased, that is, the brightness of the mask layer is reduced and the saturation of the mask layer is increased to ensure the purity of the target image synthesized by the target mask layer determined according to the basic color value of the mask layer, and avoid the appearance of black text and the fragmentation of the target image.

[0117] Or, specifically, if the hue in the second target color value is not white, and the brightness in the second target color value is greater than the third preset brightness value, then the environment in the image to be processed is the first bright environment, the value of the second target color value is adjusted to the second preset value, and the second target color value is determined as the basic color value of the mask layer. In other words, the second preset value is determined as the basic color value of the mask layer.

[0118] Or, specifically, if the hue in the second target color value is not white, and the brightness in the second target color value is less than or equal to the fourth preset brightness, then the environment in the image to be processed is a dark environment, and the second target color value is adjusted for brightness and saturation according to the fifth preset rule to obtain the basic color value of the mask. The third preset brightness is greater than the fourth preset brightness. Both the third preset brightness and the fourth preset brightness can be predetermined or determined according to working conditions.

[0119] The above-mentioned fifth preset rule adjusts the brightness and saturation of the second target color value according to the seventh preset weight and the eighth preset weight respectively, that is, the brightness of the second target color value is adjusted according to the seventh preset weight, and the saturation of the second target color value is adjusted according to the eighth preset weight.

[0120] For example, the seventh preset weight is 0.4, the eighth preset weight is 1.5, and the second target color value is (H1, S1, B1). The second target color value is adjusted for brightness and saturation according to the fifth preset rule, and the basic color value of the mask layer is obtained as (H2, S2, B2). Among them, H2=H1, S2=1.5*S1, B2=0.4*B1.

[0121] That is to say, the fifth preset rule may be the same as the first preset rule. Of course, the fifth preset rule may also be different from the first preset rule.

[0122] Among them, the seventh preset weight and the eighth preset weight can be predetermined or determined according to actual working conditions.

[0123] In a possible implementation, the third preset brightness is the same as the first preset brightness. And in a possible implementation, the fourth preset brightness is the same as the second preset brightness.

[0124] Through this process, when the environment in the image to be processed is a dark environment, according to the second preset rule, the brightness of the second target color value is reduced and the saturation of the second target color value is increased, that is, the brightness of the mask layer is reduced and the saturation of the mask layer is increased to ensure the purity of the target image synthesized by the target mask layer determined according to the basic color value of the mask layer, and avoid the fragmentation of the target image.

[0125] Or, specifically, the hue in the second target color value is not white, the brightness in the second target color value is less than or equal to the third preset brightness and the brightness in the second target color value is greater than the fourth preset brightness, then the environment in the image to be processed is an ordinary environment, and the second target color value is adjusted according to the sixth preset rule by at least one of brightness adjustment, saturation adjustment and hue adjustment to obtain the basic color value of the mask.

[0126] For the introduction of the sixth preset rule, please refer to the introduction of the third preset rule, which will not be repeated here. That is to say, the sixth preset rule can be the same as the third preset rule.

[0127] Exemplarily, the process of processing the second target color value to obtain the basic color value of the mask layer may be implemented by an adjust color() function.

[0128] The following describes a process of updating the second target color value according to the image to be processed to obtain the updated second target color value:

[0129] In a possible implementation, color values ​​in the image to be processed whose difference does not exceed a preset difference are merged, and the color values ​​whose frequency of occurrence after merging exceeds a second preset frequency are determined as updated second target color values. Different from the above process of merging color values ​​and determining the second target color value according to the frequency of occurrence of the merged color values, the second target color value is determined based on the color value information in the preset area of ​​the image to be processed, and the updated second target color value is determined based on the color value information in the entire image to be processed.

[0130] In another possible implementation, the updated second target color value may also be determined based on the color value information in an area in the image to be processed that is larger than a preset area. For example, the length of the area in the image to be processed that is larger than the preset area is the same as the length of the image to be processed, and the width of the area in the image to be processed that is larger than the preset area is 0.8 times the width of the image to be processed.

[0131] Exemplarily, the above process of extracting color from the image to be processed or an area larger than the preset area in the image to be processed, that is, determining the second target color value based on the image to be processed or an area larger than the preset area in the image to be processed, can also be implemented by a get max color() function.

[0132] Through the above process, when the environment in the image to be processed is dark or complex,

[0133] S103 . Based on the basic color value of the mask layer, perform transparency processing on the mask layer to obtain a target mask layer.

[0134] In a possible implementation, based on the basic color value of the mask layer, the entire mask layer is transparently processed according to a preset transparency to obtain a target mask layer. It should be noted that the preset transparency is predetermined and can also be determined according to actual working conditions. Exemplarily, the preset transparency is 80%.

[0135] In another possible implementation, based on the basic color value of the mask, the entire mask is transparently processed according to a preset transparency to obtain a transition mask. Subsequently, a preset area of ​​the transition mask is gradually transparently processed to obtain a target mask. The preset area of ​​the transition mask is the area corresponding to the text information in the mask. Compared with the above process of only transparently processing the entire mask according to the preset transparency, this process can obtain a target mask that can display text information better and more clearly, and ensure that the final synthesized target image has a high aesthetic level.

[0136] For example, Figure 3 As shown, Figure 3 For example, after obtaining the basic color value of the mask layer, the entire mask layer is first processed according to a preset transparency, such as 80%, to obtain a transition mask layer, and then a preset area, such as an area in the mask layer with a width of 0.5 times the width of the mask layer (i.e. 50% in the figure) and a length of 1 times the length of the mask layer, is processed. Among them, 0%-100% is used to indicate that the transition mask layer is processed with a gradual transparency of 0%-100% from top to bottom. Finally, the target mask layer b is obtained.

[0137] Exemplarily, this step S103 may be implemented by a get cover() function.

[0138] It should be noted that, through the above process, based on the basic color value of the mask, the mask is gradually transparently processed, which can avoid the final target mask from showing the effect of being light on the top and heavy on the bottom. In addition, by adjusting the transparency of the mask, the contrast between the text information in the target image and the image to be processed can be enhanced, so that the contrast between the text information and the image to be processed is closer to the WCAG standard, and the problem of high text contrast and difficulty in reading when the transparency of the black mask is directly used is solved. Finally, the problem of the overall color of the target image being dirty due to the low transparency of the black mask is reduced, and the interference of the black mask on the target image is reduced.

[0139] S104, synthesizing the image to be processed, the target mask layer and the information layer to obtain a target image.

[0140] The image to be processed, the target mask layer and the information layer are superimposed in a preset order, wherein the information layer is located at the top layer, the target mask layer is located between the image to be processed and the information layer, and the image to be processed is located at the bottom layer.

[0141] Exemplarily, the image is synthesized by using the Python image processing library PIL, where the information layer, the target mask layer, and the image to be processed are arranged from top to bottom.

[0142] For example, Figure 4 As shown, the above information layer is Figure 4 The information layer containing text information shown in FIG. 1 is the target mask layer. Figure 4 The mask shown in , the above image to be processed is Figure 4 The image layer shown in .

[0143] Exemplarily, this step S104 may be implemented by a merge image() function.

[0144] For example, the target image obtained by the prior art and the target image obtained by the technical solution of the present application are as follows: Figure 5 As shown. Figure 5 It can be seen that, compared with the prior art, the text information in the target image obtained after being processed by the technical solution of the present application can be displayed more clearly, and the aesthetics of the target image is also well guaranteed.

[0145] It should be noted that the above steps S101-S104 can be directly executed by the processor. That is to say, through the above process, the target color value determined according to the color value information in the image to be processed is used to determine the basic color value of the mask layer that is more suitable for the current image to be processed, and the mask layer is transparently processed based on the basic color value to obtain the target mask layer that can make the text information more clearly displayed on the image to be processed, and then the image to be processed, the target mask layer and the information layer are synthesized, so that the target image (i.e., the poster) can be automatically generated, solving the problem of high cost and uneven mask quality caused by manually customizing the mask layer in the prior art.

[0146] In order to solve the problem of high cost and uneven quality of the mask caused by manually customizing the mask in the prior art, based on the same concept, an image processing device is also provided in the embodiment of the present application. The specific implementation of the device can be found in the description of the method embodiment part, and the repeated parts will not be repeated. Figure 6 As shown, the device mainly includes:

[0147] The determination unit 801 is used to determine the target color value according to the color value information in the image to be processed;

[0148] The determining unit 801 is further used to determine the basic color value of the mask layer according to the target color value;

[0149] A processing unit 802 is used to perform transparent processing on the mask layer based on the basic color value of the mask layer to obtain a target mask layer;

[0150] The synthesis unit 803 is used to synthesize the image to be processed, the target mask layer and the information layer to obtain a target image, wherein the information layer includes text information.

[0151] In order to solve the problem of high cost and uneven quality of the covering layer caused by manually customizing the covering layer in the prior art, based on the same concept, an electronic device is also provided in the embodiment of the present application, such as Figure 7 As shown, the electronic device includes a processor 901, a communication interface 902, a memory 903 and a communication bus 904, wherein the processor 901, the communication interface 902, and the memory 903 communicate with each other through the communication bus 904.

[0152] Memory 903, used for storing computer programs;

[0153] In one embodiment of the present application, the processor 901 is used to implement the steps of the image processing method provided by any one of the aforementioned method embodiments when executing the program stored in the memory 903.

[0154] An embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the image processing method provided in any of the aforementioned method embodiments are implemented.

[0155] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0156] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.

Claims

1. An image processing method, characterized in that: The method comprises: Determine the target color value according to the color value information in the image to be processed; Determine the basic color value of the mask layer according to the target color value; Based on the basic color value of the mask layer, the mask layer is transparently processed to obtain a target mask layer; synthesizing the image to be processed, the target mask layer and the information layer to obtain a target image, wherein the information layer includes text information; The color value information in the image to be processed includes the occurrence frequency of the color value and the distribution of the color value; The target color value includes a first target color value and a second target color value; Determining the target color value according to the color value information in the image to be processed includes: Determine the color value whose appearance frequency in the image to be processed exceeds the first preset frequency as the first target color value; the number of the first target color value is at least one; The color values ​​in the preset area of ​​the image to be processed whose difference does not exceed the preset difference are merged, and the color values ​​whose frequency of appearance after merging exceeds the second preset frequency are determined as the second target color values; the preset area of ​​the image to be processed is the area corresponding to the text information in the image to be processed; Determining the basic color value of the mask layer according to the target color value includes: If each color value in the first target color value is discretely distributed, the brightness and saturation of the second target color value are adjusted according to a first preset rule to obtain a basic color value of the mask layer; or, If each color value in the first target color value is non-discretely distributed, the second target color value is adjusted according to the hue and / or brightness in the second target color value to obtain the basic color value of the mask layer; The step of adjusting the second target color value according to the hue and / or brightness in the second target color value to obtain the basic color value of the mask layer includes: If the hue of the second target color value is white, and / or the brightness of the second target color value is greater than a first preset brightness, the value of the second target color value is adjusted to the first preset value, and the second target color value is determined as the basic color value of the mask layer; or, If the hue in the second target color value is not white and the brightness in the second target color value is less than or equal to a second preset brightness, the brightness and saturation of the second target color value are adjusted according to a second preset rule to obtain a basic color value of the mask layer; the first preset brightness is greater than the second preset brightness; or, If the hue of the second target color value is not white, the brightness of the second target color value is less than or equal to the first preset brightness, and the brightness of the second target color value is greater than the second preset brightness, then at least one of brightness adjustment, saturation adjustment and hue adjustment is performed on the second target color value according to a third preset rule to obtain the basic color value of the mask.

2. The image processing method according to claim 1, characterized in that: The step of adjusting the second target color value according to the hue and / or brightness in the second target color value to obtain the basic color value of the mask layer includes: If the hue in the second target color value is white, the second target color value is updated according to the image to be processed to obtain an updated second target color value, and if the updated second target color value is white, the value of the updated second target color value is adjusted to a second preset value, and the updated second target color value is determined as the basic color value of the mask layer; or, If the hue in the second target color value is white, the second target color value is updated according to the image to be processed to obtain an updated second target color value, and if the updated second target color value is not white, the brightness and saturation of the updated second target color value are adjusted according to a fourth preset rule; or, If the hue of the second target color value is not white and the brightness of the second target color value is greater than a third preset brightness value, the value of the second target color value is adjusted to a second preset value, and the second target color value is determined as the basic color value of the mask layer; or, If the hue in the second target color value is not white and the brightness in the second target color value is less than or equal to the fourth preset brightness, the brightness and saturation of the second target color value are adjusted according to the fifth preset rule to obtain the basic color value of the mask layer; the third preset brightness is greater than the fourth preset brightness; or, If the hue of the second target color value is not white, the brightness of the second target color value is less than or equal to the third preset brightness, and the brightness of the second target color value is greater than the fourth preset brightness, then the second target color value is adjusted according to the sixth preset rule to perform at least one of brightness adjustment, saturation adjustment and hue adjustment to obtain the basic color value of the mask.

3. The image processing method according to claim 2, characterized in that: The updating of the second target color value according to the image to be processed to obtain an updated second target color value includes: The color values ​​in the to-be-processed image whose difference does not exceed the preset difference are merged, and the color values ​​whose occurrence frequency after merging exceeds the second preset frequency are determined as the updated second target color values.

4. The image processing method according to claim 1, characterized in that: The method of performing transparent processing on the mask layer based on the basic color value of the mask layer to obtain a target mask layer includes: Based on the basic color value of the mask layer, the entire mask layer is transparently processed according to a preset transparency to obtain the target mask layer.

5. An image processing device, characterized in that: The device comprises: A determination unit, used to determine a target color value according to color value information in the image to be processed; The determining unit is further used to determine the basic color value of the mask layer according to the target color value; A processing unit, configured to perform transparent processing on the mask layer based on a basic color value of the mask layer to obtain a target mask layer; A synthesis unit, used for synthesizing the image to be processed, the target mask layer and the information layer to obtain a target image, wherein the information layer includes text information; The color value information in the image to be processed includes the occurrence frequency of the color value and the distribution of the color value; The target color value includes a first target color value and a second target color value; Determining the target color value according to the color value information in the image to be processed includes: Determine the color value whose appearance frequency in the image to be processed exceeds the first preset frequency as the first target color value; the number of the first target color value is at least one; The color values ​​in the preset area of ​​the image to be processed whose difference does not exceed the preset difference are merged, and the color values ​​whose frequency of appearance after merging exceeds the second preset frequency are determined as the second target color values; the preset area of ​​the image to be processed is the area corresponding to the text information in the image to be processed; Determining the basic color value of the mask layer according to the target color value includes: If each color value in the first target color value is discretely distributed, the brightness and saturation of the second target color value are adjusted according to a first preset rule to obtain a basic color value of the mask layer; or, If each color value in the first target color value is non-discretely distributed, the second target color value is adjusted according to the hue and / or brightness in the second target color value to obtain the basic color value of the mask layer; The step of adjusting the second target color value according to the hue and / or brightness in the second target color value to obtain the basic color value of the mask layer includes: If the hue of the second target color value is white, and / or the brightness of the second target color value is greater than a first preset brightness, the value of the second target color value is adjusted to the first preset value, and the second target color value is determined as the basic color value of the mask layer; or, If the hue in the second target color value is not white and the brightness in the second target color value is less than or equal to a second preset brightness, the brightness and saturation of the second target color value are adjusted according to a second preset rule to obtain a basic color value of the mask layer; the first preset brightness is greater than the second preset brightness; or, If the hue of the second target color value is not white, the brightness of the second target color value is less than or equal to the first preset brightness, and the brightness of the second target color value is greater than the second preset brightness, then at least one of brightness adjustment, saturation adjustment and hue adjustment is performed on the second target color value according to a third preset rule to obtain the basic color value of the mask.

6. An electronic device, characterized in that: include: A processor, a memory and a communication bus, wherein the processor and the memory communicate with each other via the communication bus; The memory is used to store computer programs; The processor is used to execute the program stored in the memory to implement the image processing method according to any one of claims 1 to 4.

7. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the image processing method described in any one of 1 to 4 is implemented.

Citation Information

Patent Citations

  • Image processing apparatus, radar apparatus, image processing method, and image processing program

    CN103975249A

  • Method and system for adjusting screen brightness

    CN104347051A