WO2017136996A1 - 图片主色提取方法及装置、计算系统和机器可读存储介质 - Google Patents

图片主色提取方法及装置、计算系统和机器可读存储介质 Download PDF

Info

Publication number
WO2017136996A1
WO2017136996A1 PCT/CN2017/071759 CN2017071759W WO2017136996A1 WO 2017136996 A1 WO2017136996 A1 WO 2017136996A1 CN 2017071759 W CN2017071759 W CN 2017071759W WO 2017136996 A1 WO2017136996 A1 WO 2017136996A1
Authority
WO
WIPO (PCT)
Prior art keywords
color
space
picture
type
dimension
Prior art date
Application number
PCT/CN2017/071759
Other languages
English (en)
French (fr)
Inventor
叶新
卢申朋
吴飞
Original Assignee
广州神马移动信息科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 广州神马移动信息科技有限公司 filed Critical 广州神马移动信息科技有限公司
Publication of WO2017136996A1 publication Critical patent/WO2017136996A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/40Analysis of texture

Definitions

  • the present invention relates to the field of picture data processing, and more particularly to a method and apparatus for extracting dominant colors in picture data, a computing system, and a machine readable storage medium.
  • Common image data processing includes image display, image search, image storage, and the like.
  • image display especially when the image is displayed through a web browser or an application software interface, the background or foreground control of the image is usually displayed by using a fixed color scheme, but the image is not adaptive according to the content of the image. Adjustments will affect the coordination of the interface and the relevance of the topic.
  • some prior art technologies optimize the display mode when the display interface includes the image content, extract the main color from the main image or the core image included in the display interface, and adapt the display of the background or foreground control of the displayed image based on the main color. Adjustment.
  • the inventors have found that since the prior art of this part of the optimization does not extract the main color according to the actual display requirement, the color of the adaptively adjusted background or foreground control has a problem that the user's sensory experience is not good, and the color of the text conflicts. Meet the individualized factors in the display demand or the harmonious display effect.
  • a picture main color extraction method comprising the following steps:
  • a color sorting step for each display unit included in the picture to be extracted from the main color Performing classification processing in a color space, and classifying the display units having the same color characteristics into the same type of color to obtain a plurality of color categories, and calculating the number of display units corresponding to each type of color;
  • a color weight calculation step configured to convert each type of color from the first color space to the second color space, and obtain a value for each type of color in each dimension of the second color space, according to the display requirement and the second color space. Determining a weight function for each dimension of the second color space, calculating each color according to a value of each dimension of each color in the second color space and a weight function of each dimension the weight of;
  • the main color extraction step is configured to calculate a color score according to the number of display units corresponding to each type of color and the weight of the color of the type, and extract the color of the color with the highest color score as the main color of the picture.
  • the color weight calculation step comprises:
  • the higher the correlation with a certain factor in the display demand the larger the result value calculated by the dimension weight function.
  • the first color space is an RGB space
  • the second color space is an HSV space
  • S is the value of saturation, and A is a positive integer.
  • the color weight calculation step is used when the display requirement is related to the HSV
  • the factor corresponding to the brightness of the space is to avoid the extreme color that is not conducive to text display, and the weight function for configuring the brightness is
  • V is the value of the brightness
  • p2 can be obtained according to the maximum value 2 p2 -1 of the value V of the HSV spatial brightness.
  • the color sorting step further comprises: displaying a display unit included in the picture for extracting the main color by using the following formula
  • T is the number of dimensions of the first color space
  • [S 1 , . . . , S T ] is a value of a single display unit in the first color space
  • q1 is an integer greater than 0 and less than p1
  • p1 may be The maximum value of each dimension in the first color space is 2 p1 -1.
  • the color score of each type of color is multiplied by the number of display units corresponding to each type of color and the weight.
  • the main color extraction step comprises: extracting an intermediate color value of the color of the color with the highest color score as a main color of the picture.
  • the method further includes: a picture reducing step for reducing the picture side long pixel to a suitable value.
  • the method further comprises a template matching step of matching the extracted picture main color with the preset template color, and selecting the template color closest to the main color of the picture as the final output picture main color.
  • a primary color extraction device comprising:
  • An input module configured to input a picture of a primary color to be extracted, the picture comprising a plurality of display units;
  • a color classification module configured to classify each display unit included in the picture to be extracted the main color in the first color space, and obtain the color categories by classifying the display units having the same color characteristics into the same type of color, And calculating the number of display units corresponding to each type of color;
  • a color weight calculation module configured to convert each type of color from the first color space to the second color space, and obtain a value for each type of color in each dimension of the second color space, according to the display requirement and the second color space. Determining a weight function for each dimension of the second color space, calculating each color according to a value of each dimension of each color in the second color space and a weight function of each dimension the weight of;
  • the main color extraction module is configured to calculate a color score according to the number of display units corresponding to each type of color and the weight of the color of the type, and extract the color of the color with the highest color score as the main color of the picture.
  • the color weight calculation module is configured to:
  • the color weight calculation module is configured to configure the weight function such that a dimension having a higher correlation with a certain factor in the display requirement has a larger result value calculated by the dimension weight function.
  • the first color space is an RGB space
  • the second color space is an HSV space
  • S is the value of saturation, and A is a positive integer.
  • the color weight calculation module is configured to: when the factor corresponding to the brightness of the HSV space in the display requirement is to avoid an extreme color that is not conducive to text display, Degree weight function is
  • V is the value of the brightness, and p2 can be obtained according to the maximum value 2 p2 -1 of the HSV spatial brightness V.
  • the color classification module is configured to: the display unit included in the picture to be extracted the main color passes the following formula
  • T is the number of dimensions of the first color space
  • [S 1 , . . . , S T ] is a value of a single display unit in the first color space
  • q1 is an integer greater than 0 and less than p1
  • p1 may be each of the first color space 2 p1 -1 acquired maximum dimension.
  • the primary color extraction module is further configured to multiply the number of display units corresponding to each type of color by a weight as a color score of each type of color.
  • the primary color extraction module is further configured to extract an intermediate color value of the color of the color with the highest color score as the primary color of the image.
  • a picture reduction module is further included for reducing the picture side pixels to a suitable value.
  • the device further comprises a template matching module, configured to match the extracted picture main color with the preset template color, and select a template color closest to the main color of the picture as the final output picture main color.
  • a template matching module configured to match the extracted picture main color with the preset template color, and select a template color closest to the main color of the picture as the final output picture main color.
  • a programmable device comprising a memory and a processor, wherein the memory is for storing instructions for controlling the processor to operate to perform the aforementioned picture main color Extraction Method.
  • a computing system comprising:
  • processing unit communicatively coupled to the monitor and the memory, The processing unit performs the following operations when the program instructions are executed:
  • Each display unit included in the picture to be extracted with the primary color is classified in the first color space, and the display units of the same color characteristic are classified into the same type of color to obtain a plurality of color categories, and each color corresponding is calculated. Number of display units;
  • the color score is calculated according to the number of display units corresponding to each type of color and the weight of the color of the type, and the color of the color with the highest color score is extracted as the main color of the picture.
  • a non-transitory machine readable storage medium having stored thereon executable code for causing said processor to perform a method according to the present invention when said executable code is executed by a processor The picture main color extraction method described on the one hand.
  • the inventors of the present invention have found that, in the prior art, there has not been proposed a method of performing picture main color extraction according to display requirements. Therefore, the technical task to be achieved by the present invention or the technical problem to be solved is not thought of or expected by those skilled in the art, so the present invention is a new technical solution.
  • FIG. 1 illustrates a block diagram of an example of a hardware configuration of a computing system 1000 that can be used to implement embodiments of the present invention.
  • FIG. 2 is a flow chart showing a method for extracting a main color of a picture according to an embodiment of the present invention.
  • FIG. 3 is a block diagram showing a picture main color extracting apparatus according to an embodiment of the present invention.
  • FIG. 4 shows an example of a main color picture to be extracted in an embodiment of the present invention.
  • Fig. 5 shows an example of application of the real-time example of the present invention after extracting the main color of the picture.
  • FIG. 1 is a block diagram showing an example of a hardware configuration of a computing system 1000 that can be used to implement embodiments of the present invention.
  • the computing system includes computing device 1110.
  • the computing device 1110 includes a processing unit 1120, a system memory 1130, a non-removable non-volatile memory interface 1140, a detachable non-volatile memory interface 1150, a user input interface 1160, a network interface 1170, and a video interface 1190 connected by a system bus 1121. And output peripheral interface 1195.
  • the system memory 1130 includes a ROM (Read Only Memory) 1131 and a RAM (Random Access Memory) 1132.
  • a BIOS (Basic Input Output System) 1133 resides in the ROM 1131.
  • Operating system 1134, application 1135, other program modules 1136, and some program data 1137 reside in RAM 1132.
  • Non-removable non-volatile memory 1141 such as a hard disk and non-removable non-volatile storage
  • the interface 1140 is connected.
  • the non-removable non-volatile memory 1141 can store an operating system 1144, an application 1145, other program modules 1146, and some program data 1147.
  • a detachable non-volatile memory such as a floppy disk drive 1151 and a CD-ROM drive 1155 is coupled to the detachable non-volatile memory interface 1150.
  • a floppy disk can be inserted into the floppy disk drive 1151
  • a CD Compact Disc
  • Input devices such as mouse 1161 and keyboard 1162 are coupled to user input interface 1160.
  • Computing device 1110 can be coupled to remote computing device 1180 via network interface 1170.
  • network interface 1170 can be coupled to remote computing device 1180 via local area network 1171.
  • network interface 1170 can be coupled to a modem (modulator-demodulator) 1172, and modem 1172 is coupled to remote computing device 1180 via wide area network 1173.
  • modem modulator-demodulator
  • Remote computing device 1180 can include a memory 1181, such as a hard disk, that stores remote application 1185.
  • Video interface 1190 is coupled to monitor 1191.
  • Output peripheral interface 1195 is coupled to printer 1196 and speaker 1197.
  • a computing system embodying the present invention may include only some of the components of the system shown in FIG.
  • a computing system embodying the present invention may include only a memory, a processing unit, and a monitor, and the processing unit may execute program instructions stored in the memory to execute a picture master in accordance with an embodiment of the present invention as described in detail below. Color extraction scheme.
  • a picture main color extraction method including the following steps:
  • step S2100 a picture of the main color to be extracted is input, and the picture includes a plurality of display units.
  • the picture to be extracted the main color is generally the main picture displayed by the webpage content during web browsing, or the main picture displayed by a software application such as a mobile phone application interface, for example, FIG.
  • the program interface of the application "God Horse Search" is shown, and the circular picture in the area A in the interface is the picture to be extracted the main color.
  • the picture to be extracted the main color includes a plurality of display units, and the display unit may be the smallest pixel unit of the picture display, and may be a minimum array of picture data, or may be a display area of picture processing divided according to application requirements, for example, according to implementation.
  • the computing power supported by the device of the main color extraction method of the picture divides the minimum display area of the picture that can support the operation.
  • step S2200 the picture reduction step is used to reduce the picture side pixels to a suitable value.
  • the side length of the picture of the main color to be extracted may be reduced to an appropriate value by step S2200, so that the size of the picture is reduced.
  • the size of the processing power of the device that implements the method of extracting the main color of the picture is suitable for the size or adaptation of the processing.
  • the suitable value can be selected according to application requirements or implementation experience. In a general application, it is suitable to reduce the picture to a side length of 200 pixels.
  • step S2100 the process directly proceeds to step S2300, where the color classification step is performed, and each display included in the picture of the main color is to be extracted.
  • the unit performs classification processing in the first color space, and the plurality of color categories are obtained by classifying the display units having the same color characteristics into the same type of color, and calculating the number of display units corresponding to each type of color.
  • the first color space may be an RGB space, R represents red, G represents green, B represents blue, and in RGB space, through three pairs of red (R), green (G), and blue (B) Color changes and their superposition to each other to obtain a variety of colors, so in the three-dimensional color space of RGB space can be combined by three different values of R, G, B to characterize human vision can be perceived Various colors.
  • the first color space may also be other color spaces that can represent various colors that can be perceived by human vision through a combination of their dimensional values, such as LAB space.
  • L represents brightness (value 0-100)
  • A represents The range from magenta to green (value range 127 to -128, 127 corresponds to red, -128 corresponds to green)
  • B represents the range from yellow to blue (value range 127 to -128, 127 corresponds to blue, -128 Corresponding to green)
  • all colors in the LAB space can be composed of three values of L, A, and B.
  • the color characteristic is a color that can independently represent a plurality of display units in the first color space
  • the characteristic of the color common point may be a numerical range of a certain dimension in the first color space, or a combination of numerical ranges including at least two dimensions of the first color space, or other equivalent characteristics.
  • the first color space is an RGB space
  • the display unit of the color characteristic conforming to the value of R in the range of 16-31 can be classified into the same type of color, and the color characteristic of the value of R is in the range of 0-15.
  • the display unit is classified into another type of color, and so on, and the display unit included in the picture is classified only according to the color characteristic of the value of the dimension R.
  • the display units of the color characteristics in which the values of R and G are all in the range of 16-31 are classified into the same type of color, and will conform to R, G.
  • the display unit whose value is in the range of 0-15 is classified into another type of color, and so on, and the classification is completed. Or at the same time, according to the color characteristics of the values of the three dimensions of R, G, and B, for example, the display unit that matches the color characteristics of the R, G, and B values in the range of 16-31 is classified into the same color. The display unit that matches the color characteristics of the R, G, and B values in the range of 0-15 is classified into another type of color, and so on, and the classification is completed.
  • the color sorting step of step S2300 specifically, each display unit included in the picture to be extracted the main color is classified in the RGB space, and will be in the RGB space.
  • the display units having the same color characteristics are classified into the same type of color to obtain a plurality of color categories, and the number of display units corresponding to each type of color is calculated.
  • the color characteristic is a certain numerical range of any dimension in the RGB space or a combination of numerical ranges including at least two dimensions of RGB.
  • the classification method may include a plurality of methods, as described above, which may be a method of segmenting values according to a range of intervals of at least one dimension of the first color space.
  • the display unit in the picture may also be downsampled by the following formula 1 to classify the display unit:
  • the same display unit that is downsampled to obtain [S' 1 , S' 2 , ... S' T ] is classified into the same color;
  • T is the number of the first color space dimensions, [S 1, ..., S T] values in the first color space unit for a single display, q1 is an integer greater than 0 and less than p1, p1 can The maximum value of each dimension in the first color space is 2 p1 -1.
  • the first color space is an RGB space
  • the display unit included in the picture of the main color to be extracted is passed through a formula
  • [S R , S G , S B ] is the value of a single display unit in the RBG space
  • q1 is an integer greater than 0 and less than p1
  • p1 may be based on the maximum value of each dimension in the RGB space 2 p1 -1 Obtain.
  • the color weight calculation step is used to convert each type of color from the first color space to the second color space, and obtain a value for each type of color in each dimension of the second color space, according to the display requirement and the second Determining, by a factor corresponding to each dimension of the color space, a weight function of each dimension of the second color space, according to a value of each dimension of each color in the second color space and a weight function of each dimension, Calculate the weight of each type of color.
  • the second color space is generally a color space different from the first color space.
  • the first color space is an RGB space or a LAB space
  • the second color space may be an HSV space, a HIS space, or a YUV space.
  • the HSV space is a three-dimensional color space with three dimensions: hue H, saturation S, and brightness V.
  • the HSI space represents a color by a combination of three dimensions of H, S, and I, where H defines the wavelength hue (ie, hue) of the color, S represents the degree of lightness (ie, saturation), and I represents intensity or brightness.
  • the YUV space Y represents brightness (i.e., grayscale value), and U and V represent chromaticity, which describes the color and saturation of the color, and constitutes two components of color.
  • a well-known color space conversion algorithm can be used, for example, when converting from the RGB color space to the HSV color space,
  • the opencv algorithm library is used, and the present invention is not limited.
  • the display requirement may be diversified.
  • the display requirement may include one or more factors, such as a picture with a brighter color, or an extreme color such as avoiding discomfort, such as blood red, or avoiding text display. Extreme colors, etc.
  • the display requirement may include one or more factors, such as a picture with a brighter color, or an extreme color such as avoiding discomfort, such as blood red, or avoiding text display. Extreme colors, etc.
  • image display there may be only a single factor display requirement, or multiple display requirements may coexist.
  • the HSV space is a three-dimensional space with three dimensions of hue H, saturation S, and brightness V.
  • the factor corresponds to the HSV space.
  • the saturation S you need to configure the saturation weight function.
  • the requirement includes a picture in which no extreme color such as blood red is present, and the factor corresponds to the HSV spatial hue H, and a hue weight function needs to be configured.
  • the requirement includes a factor that avoids extreme colors that are not conducive to text display, then the factor corresponds to the HSV spatial brightness V, and a brightness weight function needs to be configured.
  • the weight function of the saturation S needs to be configured, and the saturation weight function can be configured as the square function of the saturation value S, so that the result value calculated by the saturation function can be highlighted. Shows the brighter colors of the images contained in the requirements.
  • the display requirement includes a softer color of the picture, and the weight function of the saturation S needs to be configured.
  • the saturation weight function can be configured as a linear function or a constant term of the saturation value S, so that the result value calculated by the saturation function is calculated. Can highlight the softer colors of the images included in the demand.
  • the requirement includes a picture in which no extreme color such as blood red is present, and the factor corresponds to the HSV spatial hue H, and the factor requires that the color falling within the range of the H corresponding to the blood red cannot be the main color, and needs to be configured.
  • the hue weight function causes the hue weight function to calculate the result value to eliminate blood red.
  • the requirement includes a factor that avoids extreme colors that are not conducive to text display, then the factor corresponds to the HSV spatial brightness V, and the weight function of the brightness V needs to be configured.
  • the brightness weight function can be configured as a linear function to calculate the brightness weight function. The resulting value avoids extreme colors that are not conducive to text display.
  • the N-type color classified in the step S2300 is converted from the first color space to the second color space having the M-dimensional, and the value of each color in the second color space is obtained, where the i-th color
  • the weight of each type of color is calculated according to the value and weight function of the second color space according to each type of color, wherein the weight W i of the i-th color is:
  • C is a constant that is not zero.
  • the first color space is RGB space
  • the second color space is HSV space.
  • Each type of color sorted in RGB space is converted from RGB space to HSV space.
  • the HSV space is a 3-dimensional color space.
  • the H space color hue
  • the S space color saturation
  • the value of V space color brightness
  • the value of V space color brightness
  • step S2300 Converting the N-type colors classified in step S2300 from the RGB space to the HSV space having the 3-dimensional, and obtaining the hue H, the saturation S, and the brightness V of each type of color in the HSV space, wherein the i-th color
  • the value is [H i , S i , V i ], and the weight function of each dimension of the HSV is configured according to the factors corresponding to each dimension of the HSV space, wherein the hue weight function is F(H), and the saturation weight function is F(S), the brightness weight function is F(V), and the weight of each type of color is calculated according to the value of each type of color in the HSV space and the weight function, wherein the weight of the i-th color is W i :
  • C is a constant that is not zero.
  • the weight function is configured such that the higher the correlation with a certain factor in the display requirement, the larger the result value calculated by the dimension weight function.
  • the saturation weight function can be configured as the square function of the saturation value S, and the hue weight function can be configured.
  • the brightness weight function is a one-term or constant term, even 0, so that the result value calculated by the saturation weight function is larger than the result value calculated by the hue weight function and the result value calculated by the brightness weight function.
  • the brightness weight function can be configured as the brightness value.
  • the linear function of V and configure the hue weight function, the saturation weight function to be a term or a constant term, or even 0, so that the result value calculated by the brightness weight function is more than the result value calculated by the hue weight function and the result value of the saturation weight function calculation. Bigger.
  • a factor corresponding to the saturation of the HSV space in the display requirement is that when the display color is more vivid, the weight function for configuring the saturation is
  • S is the value of saturation and A is a positive integer.
  • the factor that makes the display color more vivid in the display demand has a higher correlation with the saturation of the HSV space, that is, higher than the correlation between the corresponding hue H and the brightness V in the display requirement, and F(H) can be used.
  • F(V) is set as a one-term expression or a constant term, so that the obtained result value calculated by F(S) is large.
  • the configuration F(H) and F(V) are both 0, according to the formula. 3.
  • a factor corresponding to the brightness of the HSV space in the display requirement is to avoid an extreme color that is not conducive to text display, and the weight function for configuring the brightness is
  • V is the value of the brightness
  • p2 can be obtained according to the maximum value 2 p2 -1 of the brightness value V in the HSV space.
  • the correlation corresponding to the brightness of the HSV space is higher, that is, higher than the correlation between the corresponding hue H and the saturation S in the display requirement, F(H) and F(S) are set as one-time expression or constant term, so that the obtained result value calculated by F(S) is large.
  • V i is the brightness value of the i-th color.
  • the main color extraction step is configured to calculate a color score according to the number of display units corresponding to each type of color and the weight of the color of the type, and extract the color with the highest color score as the main color of the picture.
  • the color score indicates the evaluation of each type of color, and the weight of each type of color obtained according to the display requirement and the number of display units corresponding to each type of color are comprehensively determined.
  • the color with the highest color score is the color that most includes the number of display units (that is, the corresponding number of display units) in the picture, so the color of the type is the main color of the picture.
  • the value may be a value obtained by simply multiplying the number of display units corresponding to each type of color by the weight of the color of the type of color, or by multiplying or dividing the number of display units corresponding to each type of color by the weight of the color of the type.
  • the value obtained by the proportional coefficient wherein the proportional coefficient may be selected according to the application requirement or selected according to the device processing capability of the implementation calculation, and other equivalent calculation methods may be adopted, as long as the result of calculating the color score of each type of color obtained, It is a weight that reflects the weight of each type of color obtained according to the display requirements and the number of display units corresponding to each type of color, and evaluates each type of color based on the same evaluation criteria.
  • the number of display units corresponding to each type of color is multiplied by the weight as a color score for each type of color.
  • the intermediate color value of the color of the color with the highest color score is extracted as the main color of the picture.
  • the intermediate color value of the color with the highest color score may be the display unit with the highest number of color points corresponding to the color of the display unit after sorting in the middle position after numerical sorting or other sorting methods.
  • the corresponding color value may be the display unit with the highest number of color points corresponding to the color of the display unit after sorting in the middle position after numerical sorting or other sorting methods.
  • step S2600 the template matching step is used to match the extracted picture main color with the preset template color, and select the template color closest to the main color of the picture as the final output picture main color.
  • step S2500 If the main color of the picture extracted in step S2500 has a color unattractive or does not completely meet the display requirement, the method may proceed to step S2600 to perform template matching on the main color of the picture, and select the template color closest to the main color of the picture as the final output picture main. Color, so that the final output picture color is in line with the user's aesthetic or fully meet the display requirements.
  • the preset template color can be selected according to the display requirements, for example, selecting a color set with a better user experience as the template color, and eliminating the glare of the blood red.
  • the algorithm for matching the main color of the picture with the color of the template can use the color similarity calculation method proposed by John R. Smith and Shih-Fu Chang in "a fully automated content-based image query system".
  • the main color of the picture extracted in step S2500 does not have the problem of unsightly or inconsistent with the display requirement, the main color of the picture extracted in step S2500 is the final picture main color, and there is no need to proceed to step S2600.
  • the method for extracting the main color of the picture according to the present invention can apply the extracted main color of the picture to the background, controls (such as buttons, progress bars, icons, etc.) and text of the display picture interface, so that the interface elements are matched in the sense of appearance. More harmonious, avoiding the interface style is the same or the color has nothing to do with the display content, more prominently display the style attributes of the content.
  • controls such as buttons, progress bars, icons, etc.
  • text of the display picture interface so that the interface elements are matched in the sense of appearance. More harmonious, avoiding the interface style is the same or the color has nothing to do with the display content, more prominently display the style attributes of the content.
  • the circular picture of the interface A area is the core picture of the interface
  • the main color of the picture is replaced by the progress bar in the interface
  • the progress bar is the original color of the long strip control in the B area in Fig. 5, and the effect shown in Fig. 5 is obtained, so that the color of the progress bar on the "Shenma Search
  • FIG. 3 is a block diagram of a picture main color extracting apparatus 3000 according to an embodiment of the present invention.
  • the picture primary color extraction device 3000 can be used to implement the method shown in FIG. 2, so the repeated portions will not be described in detail.
  • the functional blocks of the picture primary color extraction device may be implemented by hardware, software or a combination of hardware and software that implements the principles of the present invention. It will be understood by those skilled in the art that the functional modules described in FIG. 3 can be combined or divided into sub-modules to implement the principles of the above described invention. Accordingly, the description herein may support any possible combination, or division, or further limitation of the functional modules described herein.
  • the picture primary color extraction device 3000 includes an input module 3100, a color classification module 3300, a color weight calculation module 3400, and a primary color extraction module 3500.
  • the image reduction module 3200 and/or the template matching module 3600 are further included.
  • the input module 3100 is configured to input a picture of a main color to be extracted, where the picture includes a plurality of display units.
  • a picture reduction module 3200 is further included for reducing the picture side pixels to a suitable value.
  • the color classification module 3300 is configured to perform classification processing in each of the display units included in the picture for extracting the main color in the first color space, and obtain the color categories by classifying the display units having the same color characteristics into the same type of color. And calculate the number of display units corresponding to each type of color.
  • the color classification module 3300 is configured to display a display unit included in the picture to be extracted by the main color by using the following formula
  • T is the number of dimensions of the first color space
  • [S 1 , . . . , S T ] is a value of a single display unit in the first color space
  • q1 is an integer greater than 0 and less than p1
  • p1 may be The maximum value of each dimension in the first color space is 2 p1 -1.
  • the color weight calculation module 3400 is configured to convert each type of color from the first color space to the second color space, and obtain a value for each type of color in each dimension of the second color space, according to the display requirement and the second color space. Determining a weight function for each dimension of the second color space according to a factor corresponding to a dimension, and calculating each class according to a value of each dimension of each color in the second color space and a weight function of each dimension The weight of the color.
  • the color weight calculation module 3400 is configured to:
  • the color weight calculation module 3400 is configured to configure the weight function such that the higher the correlation with a certain factor in the display requirement, the larger the result value calculated by the dimension weight function.
  • S is the value of saturation, and A is a positive integer.
  • the color weight calculation module 3400 is configured to: when the display requirement corresponds to a brightness of the HSV space, avoid When the extreme color of the text display is facilitated, the weight function for configuring the brightness is
  • V is the lightness value
  • p2 V may be based on the brightness maximum value of the HSV space 2 p2 -1 acquired.
  • the main color extraction module 3500 is configured to calculate a color score according to the number of display units corresponding to each type of color and the weight of the color of the type, and extract the color of the color with the highest color score as the main color of the picture.
  • the primary color extraction module 3500 is further configured to multiply the number of display units corresponding to each type of color by a weight as a color score of each type of color.
  • the primary color extraction module 3500 is further configured to extract an intermediate color value of the color of the color with the highest color score as the main color of the picture.
  • the device further includes a template matching module 3600, configured to match the extracted picture main color with the preset template color, and select a template color that is closest to the main color of the picture as the final output picture main color.
  • a template matching module 3600 configured to match the extracted picture main color with the preset template color, and select a template color that is closest to the main color of the picture as the final output picture main color.
  • a programmable device comprising a memory and a processor, wherein the memory is for storing instructions for controlling the processor to operate to perform the operation of FIG. The method described.
  • a method and apparatus for extracting a main color of a picture are provided.
  • the plurality of display units included in the picture are classified according to the color characteristics in the first color space, and the plurality of color categories having the same color characteristics are obtained, and the number of display units corresponding to each type of color is calculated, and each type of color is obtained from the first
  • the color space is converted into the second color space, and the weight function of each dimension of the second color space is configured according to the display requirement and the corresponding factor of each dimension in the second color space, thereby calculating the color weight of each color, according to each color
  • the color weight and the number of display units of each type of color, the color score of each type of color is calculated, and the color with the highest color score is extracted as the main color of the picture.
  • the program extracts the main color of the picture according to the display requirement, and can adaptively adjust the picture background or the foreground control display according to the extracted main color, so that the overall picture display is harmonious and beautiful, and avoids the unsightly color or the non-conformity that does not meet the display requirement.
  • the picture primary color extraction device can be implemented in a variety of ways.
  • the picture primary color extraction device can be implemented by an instruction configuration processor.
  • the instructions may be stored in the ROM, and when the device is booted, the instructions are read from the ROM into the programmable device to implement the picture primary color extraction device.
  • the picture primary color extraction device can be cured into a dedicated device (eg, an ASIC).
  • the picture primary color extraction device can be divided into mutually independent units, or they can be combined and implemented.
  • the picture primary color extraction device may be implemented by one of the various implementations described above, or may be implemented by a combination of two or more of the various implementations described above.
  • the invention can be a system, method and/or computer program product.
  • the computer program product can comprise a computer readable storage medium having computer readable program instructions embodied thereon for causing a processor to implement various aspects of the present invention.
  • the computer readable storage medium can be a tangible device that can hold and store the instructions used by the instruction execution device.
  • the computer readable storage medium can be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing.
  • Non-exhaustive list of computer readable storage media include: portable computer disks, hard disks, random access memory (RAM), read only memory (ROM), erasable programmable read only memory (EPROM) Or flash memory), static random access memory (SRAM), portable compact disk read only memory (CD-ROM), digital versatile disk (DVD), memory stick, floppy disk, mechanical encoding device, for example, with instructions stored thereon A raised structure in the hole card or groove, and any suitable combination of the above.
  • a computer readable storage medium as used herein is not to be interpreted as a transient signal itself, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (eg, a light pulse through a fiber optic cable), or through a wire The electrical signal transmitted.
  • the computer readable program instructions described herein can be downloaded from a computer readable storage medium to various computing/processing devices or downloaded to an external computer or external storage device over a network, such as the Internet, a local area network, a wide area network, and/or a wireless network.
  • the network may include copper transmission cables, fiber optic transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and/or edge servers.
  • a network adapter card or network interface in each computing/processing device receives the computer from the network
  • the program instructions are readable and forwarded for storage in a computer readable storage medium in each computing/processing device.
  • Computer program instructions for performing the operations of the present invention may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine related instructions, microcode, firmware instructions, state setting data, or in one or more programming languages.
  • the computer readable program instructions can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer, partly on the remote computer, or entirely on the remote computer or server. carried out.
  • the remote computer can be connected to the user's computer through any kind of network, including a local area network (LAN) or wide area network (WAN), or can be connected to an external computer (eg, using an Internet service provider to access the Internet) connection).
  • the customized electronic circuit such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), can be customized by utilizing state information of computer readable program instructions.
  • Computer readable program instructions are executed to implement various aspects of the present invention.
  • the computer readable program instructions can be provided to a general purpose computer, a special purpose computer, or a processor of other programmable data processing apparatus to produce a machine such that when executed by a processor of a computer or other programmable data processing apparatus Means for implementing the functions/acts specified in one or more of the blocks of the flowcharts and/or block diagrams.
  • the computer readable program instructions can also be stored in a computer readable storage medium that causes the computer, programmable data processing device, and/or other device to operate in a particular manner, such that the computer readable medium storing the instructions includes An article of manufacture that includes instructions for implementing various aspects of the functions/acts recited in one or more of the flowcharts.
  • Computer readable program instructions can also be loaded into a computer, other programmable data processing equipment Or a device, such that a series of operational steps are performed on a computer, other programmable data processing device, or other device to produce a computer-implemented process for use on a computer, other programmable data processing device, or other device
  • the executed instructions implement the functions/acts specified in one or more of the flowcharts and/or block diagrams.
  • each block in the flowchart or block diagram can represent a module, a program segment, or a portion of an instruction that includes one or more components for implementing the specified logical functions.
  • Executable instructions can also occur in a different order than those illustrated in the drawings. For example, two consecutive blocks may be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending upon the functionality involved.
  • each block of the block diagrams and/or flowcharts, and combinations of blocks in the block diagrams and/or flowcharts can be implemented in a dedicated hardware-based system that performs the specified function or function. Or it can be implemented by a combination of dedicated hardware and computer instructions. It is well known to those skilled in the art that implementation by hardware, implementation by software, and implementation by a combination of software and hardware are equivalent.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Image Processing (AREA)
  • Color Image Communication Systems (AREA)
  • Facsimile Image Signal Circuits (AREA)

Abstract

一种图片主色提取的方法及装置,包括:输入待提取主色的图片;对图片所包含的显示单元在第一颜色空间中根据颜色特性进行分类,得到若干类颜色,并计算每类颜色对应的显示单元数目;将每类颜色从第一颜色空间转换至第二颜色空间,获取每类颜色在第二颜色空间每一维度取值;根据显示需求与第二颜色空间每一维度对应的因素,确定第二颜色空间每一维度的权重函数;根据每类颜色在第二颜色空间每一维度的取值与每一维度的权重函数,计算每类颜色的权重;根据每类颜色对应的显示单元数目以及权重计算颜色分值,提取颜色分值最高的该类颜色作为图片主色。该方法及装置根据显示需求提取图片主色,应用于界面展示时效果更和谐或更个性化。

Description

图片主色提取方法及装置、计算系统和机器可读存储介质 技术领域
本发明涉及图片数据处理领域,更具体地,涉及一种在图片数据中提取主色的方法及装置、计算系统和机器可读存储介质。
背景技术
常见的图片数据处理包括图片显示、图片搜索、图片存储等。现有技术在展示界面进行图片显示时,特别是通过网页浏览器或者应用软件界面显示图片时,通常采用固定的配色方案显示图片的背景或者前景控件,但由于没有根据图片的内容进行自适应的调整,会影响界面的协调性和主题相关性。
因而部分现有技术对展示界面包含图片内容时的展示方式进行了优化,从展示界面包含的主要图片或核心图片中提取主色,基于主色对显示图片的背景或前景控件的显示进行自适应调整。但发明人发现,由于这部分优化的现有技术未根据实际的显示需求提取主色,导致自适应调整后的背景或前景控件颜色存在用户感官体验不佳、与文字颜色出现冲突等问题,不能满足显示需求中个性化因素或得不到和谐的展示效果。
发明内容
本发明的一个目的是提供一种根据显示需求提取图片主色的新技术方案。
根据本发明的第一方面,提供了一种图片主色提取方法,包括如下步骤:
输入步骤,用于输入待提取主色的图片,所述图片包括多个显示单元;
颜色分类步骤,用于对待提取主色的图片所包含的每个显示单元在第 一颜色空间中进行分类处理,通过将颜色特性相同的所述显示单元归入同一类颜色从而得到若干颜色类别,并计算每类颜色对应的显示单元数目;
颜色权重计算步骤,用于将每类颜色从第一颜色空间转换至第二颜色空间,获取每类颜色在第二颜色空间每一维度取值,根据显示需求与所述第二颜色空间每一维度对应的因素,确定所述第二颜色空间每一维度的权重函数,根据每类颜色在所述第二颜色空间每一维度的取值与所述每一维度的权重函数,计算每类颜色的权重;
主色提取步骤,用于根据每类颜色对应的显示单元数目以及该类颜色的权重计算颜色分值,提取所述颜色分值最高的该类颜色作为图片主色。
优选地,所述颜色权重计算步骤包括:
将分类得到的N类颜色,从所述第一颜色空间转换至具有M维的第二颜色空间,得到每类颜色在所述第二颜色空间的取值,其中第i类颜色在所述第二颜色空间的第j维取值为Pij(i=1,...,N;j=1,...,M);
根据显示需求与所述第二颜色空间每一维度对应的因素,配置第二颜色空间每一维度的权重函数,其中第j维的权重函数为F(xj)(j=1,…,M)
根据每类颜色在所述第二颜色空间取值和权重函数计算每类颜色的权重,其中第i类颜色的权重Wi为:
Figure PCTCN2017071759-appb-000001
其中C为不为0的常数。
优选地,与显示需求中某个因素相关性越高的维度,其维度权重函数计算得到的结果值越大。
优选地,所述第一颜色空间为RGB空间,和/或所述第二颜色空间为HSV空间。
优选地,所述颜色权重计算步骤,用于当所述显示需求中与所述HSV空间的饱和度对应的因素为使显示颜色更鲜艳时,配置所述饱和度的权重函数为F(S)=(S/2A)2,其中
S为饱和度取值,A为正整数。
优选地,所述颜色权重计算步骤,用于当所述显示需求中与所述HSV 空间的明度对应的因素为避免不利于文字展示的极端颜色时,配置所述明度的权重函数为
Figure PCTCN2017071759-appb-000002
其中
V为明度取值,p2可以根据所述HSV空间明度取值V的最大值2p2-1获取。
优选地,所述颜色分类步骤还包括:用于对待提取主色的图片所包含的显示单元通过下述公式
Figure PCTCN2017071759-appb-000003
进行下采样,将下采样得到[S′1,S′2,...S′T]相同的显示单元归为同类颜色;其中
T为所述第一颜色空间维度数目,[S1,...,ST]为单个显示单元在所述第一颜色空间的取值,q1为大于0且小于p1的整数,p1可以根据所述第一颜色空间中每一维最大值2p1-1获取。
优选地,所述主色提取步骤中,所述每类颜色的颜色分值为每类颜色对应的显示单元数目与权重相乘。
优选地,所述主色提取步骤包括:提取所述颜色分值最高的该类颜色的中间颜色值作为图片主色。
优选地,在所述颜色分类步骤之前还包括:图片缩小步骤,用于将图片边长像素缩小至合适值。
优选地,所述方法还包括模板匹配步骤,用于将提取的图片主色与预置的模板颜色进行匹配,选取与图片主色最相近的模板颜色作为最终输出的图片主色。
根据本发明的第二方面,提供了一种主色提取装置,包括:
输入模块,用于输入待提取主色的图片,所述图片包括多个显示单元;
颜色分类模块,用于对待提取主色的图片所包含的每个显示单元在第一颜色空间中进行分类处理,通过将颜色特性相同的所述显示单元归入同一类颜色从而得到若干颜色类别,并计算每类颜色对应的显示单元数目;
颜色权重计算模块,用于将每类颜色从第一颜色空间转换至第二颜色空间,获取每类颜色在第二颜色空间每一维度取值,根据显示需求与所述第二颜色空间每一维度对应的因素,确定所述第二颜色空间每一维度的权重函数,根据每类颜色在所述第二颜色空间每一维度的取值与所述每一维度的权重函数,计算每类颜色的权重;
主色提取模块,用于根据每类颜色对应的显示单元数目以及该类颜色的权重计算颜色分值,提取所述颜色分值最高的该类颜色作为图片主色。
优选地,所述颜色权重计算模块用于:
将分类得到的N类颜色,从所述第一颜色空间转换至具有M维的第二颜色空间,得到每类颜色在所述第二颜色空间的取值,其中第i类颜色在所述第二颜色空间的第j维取值为Pij(i=1,...,N;j=1,...,M);
根据显示需求与所述第二颜色空间每一维度对应的因素,配置第二颜色空间每一维度的权重函数,其中第j维的权重函数为F(xj)(j=1,…,M)
根据每类颜色在所述第二颜色空间取值和权重函数计算每类颜色的权重,其中第i类颜色的权重Wi为:
Figure PCTCN2017071759-appb-000004
其中C为不为0的常数。
优选地,所述颜色权重计算模块,用于配置所述权重函数,使得与显示需求中某个因素相关性越高的维度,其维度权重函数计算得到的结果值越大。
优选地,所述第一颜色空间为RGB空间,和/或所述第二颜色空间为HSV空间。
优选地,所述颜色权重计算模块,用于当所述显示需求中与所述HSV空间的饱和度对应的因素为使显示颜色更鲜艳时,配置所述饱和度的权重函数为F(S)=(S/2A)2,其中
S为饱和度取值,A为正整数。
优选地,所述颜色权重计算模块,用于当所述显示需求中与所述HSV空间的明度对应的因素为避免不利于文字展示的极端颜色时,配置所述明 度的权重函数为
Figure PCTCN2017071759-appb-000005
其中
V为明度取值,p2可以根据所述HSV空间明度V的最大取值2p2-1获取。
优选地,所述颜色分类模块,用于对待提取主色的图片所包含的显示单元通过下述公式
Figure PCTCN2017071759-appb-000006
进行下采样,将下采样得到[S′1,S′2,...S′T]相同的显示单元归为同类颜色;其中
T为所述第一颜色空间维度数目,[S1,...,ST]为单个显示单元在所述第一颜色空间的取值,q1为大于0且小于p1的整数,p1可以根据所述第一颜色空间中每一维最大值2p1-1获取。
优选地,所述主色提取模块,还用于将每类颜色对应的显示单元数目与权重相乘作为每类颜色的颜色分值。
优选地,所述主色提取模块,还用于提取所述颜色分值最高的该类颜色的中间颜色值作为图片主色。
优选地,在颜色分类模块之前,还包括图片缩小模块,用于将图片边长像素缩小至合适值。
优选地,所述装置还包括模板匹配模块,用于将提取的图片主色与预置的模板颜色进行匹配,选取与图片主色最相近的模板颜色作为最终输出的图片主色。
根据本发明的第三方面,提供一种可编程设备,包括存储器和处理器,其中,所述存储器用于存储指令,所述指令用于控制所述处理器进行操作以执行前述的图片主色提取方法。
根据本发明的第四方面,提供一种计算系统,包括:
监视器,用于显示图片;
存储器,所述存储器中存储有程序指令;以及
处理单元,所述处理单元与所述监视器和所述存储器通信连接,所述 处理单元在运行所述程序指令时执行以下操作:
输入待提取主色的图片,所述图片包括多个显示单元;
对待提取主色的图片所包含的每个显示单元在第一颜色空间中进行分类处理,通过将颜色特性相同的所述显示单元归入同一类颜色从而得到若干颜色类别,并计算每类颜色对应的显示单元数目;
将每类颜色从第一颜色空间转换至第二颜色空间,获取每类颜色在第二颜色空间每一维度取值,根据显示需求与所述第二颜色空间每一维度对应的因素,确定所述第二颜色空间每一维度的权重函数,根据每类颜色在所述第二颜色空间每一维度的取值与所述每一维度的权重函数,计算每类颜色的权重;
根据每类颜色对应的显示单元数目以及该类颜色的权重计算颜色分值,提取所述颜色分值最高的该类颜色作为图片主色。
根据本发明的第五方面,提供一种非暂时性机器可读存储介质,其上存储有可执行代码,当所述可执行代码被处理器执行时,使所述处理器执行根据本发明第一方面所述的图片主色提取方法。
本发明的发明人发现,在现有技术中,还没有提出一种根据显示需求进行图片主色提取的方法。因此,本发明所要实现的技术任务或者所要解决的技术问题是本领域技术人员从未想到的或者没有预期到的,故本发明是一种新的技术方案。
通过以下参照附图对本发明的示例性实施例的详细描述,本发明的其它特征及其优点将会变得清楚。
附图说明
被结合在说明书中并构成说明书的一部分的附图示出了本发明的实施例,并且连同其说明一起用于解释本发明的原理。
图1示出可用于实现本发明的实施例的计算系统1000的硬件配置的例子的框图。
图2示出本发明实施例的图片主色提取方法的流程图。
图3示出本发明实施例的图片主色提取装置的框图。
图4示出本发明实施例待提取主色图片的一个例子。
图5示出本发明实时例提取图片主色后进行应用的一个例子。
具体实施方式
现在将参照附图来详细描述本发明的各种示例性实施例。应注意到:除非另外具体说明,否则在这些实施例中阐述的部件和步骤的相对布置、数字表达式和数值不限制本发明的范围。
以下对至少一个示例性实施例的描述实际上仅仅是说明性的,决不作为对本发明及其应用或使用的任何限制。
对于相关领域普通技术人员已知的技术、方法和设备可能不作详细讨论,但在适当情况下,所述技术、方法和设备应当被视为说明书的一部分。
在这里示出和讨论的所有例子中,任何具体值应被解释为仅仅是示例性的,而不是作为限制。因此,示例性实施例的其它例子可以具有不同的值。
应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步讨论。
<硬件配置>
图1是显示可用于实现本发明的实施例的计算系统1000的硬件配置的例子的框图。
如图1所示,计算系统包括计算装置1110。计算装置1110包含通过系统总线1121连接的处理单元1120、系统存储器1130、不可拆卸非易失性存储器接口1140、可拆卸非易失性存储器接口1150、用户输入接口1160、网络接口1170、视频接口1190和输出外设接口1195。
系统存储器1130包含ROM(只读存储器)1131和RAM(随机存取存储器)1132。BIOS(基本输入输出系统)1133驻留于ROM 1131中。操作系统1134、应用程序1135、其它的程序模块1136和一些程序数据1137驻留于RAM 1132中。
诸如硬盘的不可拆卸非易失性存储器1141与不可拆卸非易失性存储 器接口1140连接。例如,不可拆卸非易失性存储器1141可存储操作系统1144、应用程序1145、其它的程序模块1146和一些程序数据1147。
诸如软盘驱动器1151和CD-ROM驱动器1155的可拆卸非易失性存储器与可拆卸非易失性存储器接口1150连接。例如,软盘可被插入软盘驱动器1151中,并且,CD(光盘)可被插入CD-ROM驱动器1155中。
诸如鼠标1161和键盘1162的输入设备与用户输入接口1160连接。
计算装置1110可通过网络接口1170与远程计算装置1180连接。例如,网络接口1170可通过局域网络1171与远程计算装置1180连接。作为替代方案,网络接口1170可与调制解调器(调制器-解调器)1172连接,并且调制解调器1172通过广域网络1173与远程计算装置1180连接。
远程计算装置1180可包含存储远程应用程序1185的诸如硬盘的存储器1181。
视频接口1190与监视器1191连接。
输出外设接口1195与打印机1196和扬声器1197连接。
图1所示的计算系统仅是解释性的,并且决不是为了要限制本发明、其应用或用途。本领域普通技术人员将会理解,并非图1所示的本发明计算系统中的每个部件对于实现本发明都是必需的,例如,在很多情况下,打印机1196和扬声器1197可以不是必需的。实现本发明的计算系统可以仅仅包含图1所示系统中的部分部件。例如,在一个实施例中,实现本发明的计算系统可以仅包括存储器、处理单元和监视器,处理单元可以运行存储器中存储的程序指令而执行下面将详细描述的根据本发明实施例的图片主色提取方案。
<实施例>
根据本发明的第一实施例,如图2所示,提供了一种图片主色提取方法,包括如下步骤:
首先在步骤S2100,输入待提取主色的图片,图片中包含多个显示单元。
其中,待提取主色的图片一般是在网页浏览时网页内容显示的主要图片,或是软件应用程序例如手机应用程序界面显示的主要图片,例如图4 中所示为应用程序“神马搜索”的程序界面,界面中区域A中的圆形图片为待提取主色的图片。
待提取主色的图片包含多个显示单元,所述显示单元可以是图片显示的最小像素单元,可以是图片数据的最小阵列,也可以是根据应用需求划分的图片处理的显示区域,例如根据实现图片主色提取方法的装置支持的运算能力,划分可支持运算的图片最小显示区域。
此后可选地,进入步骤S2200,图片缩小步骤,用于将图片边长像素缩小至合适值。
若待提取主色的图片尺寸较大或者实现提取图片主色方法的装置处理能力受限,则可以通过步骤S2200,将待提取主色的图片边长像素缩小至合适值,使得图片的尺寸缩小为适合处理的尺寸或适配实现提取图片主色方法的装置处理能力的尺寸。所述合适值可以根据应用需求或者实现经验选取,一般应用中,将图片缩小至边长为200像素比较合适。
若待提取主色的图片尺寸合适或提取图片主色方法的装置处理能力不受限,则在步骤S2100后,直接进入步骤S2300,颜色分类步骤,对待提取主色的图片所包含的每个显示单元在第一颜色空间中进行分类处理,通过将颜色特性相同的所述显示单元归入同一类颜色从而得到若干颜色类别,并计算每类颜色对应的显示单元数目。
其中所述的第一颜色空间,可以是RGB空间,R代表红色、G代表绿色、B代表蓝色,在RGB空间中,通过对红(R)、绿(G)、蓝(B)三个颜色变化以及它们相互之间的叠加来得到各式各样的颜色的,因而在RGB空间这个三维颜色空间中可以通过三个维度R、G、B的不同取值来组合表征人类视力所能察觉的各种颜色。第一颜色空间还可以是其他可以通过其维度取值组合表征人类视力所能察觉的各种颜色的颜色空间,例如LAB空间,在LAB空间中L表示明度(取值0-100)、A表示洋红色至绿色的范围(取值范围127至-128,127对应红色,-128对应绿色)、B表示从黄色至蓝色的范围(取值范围127至-128,127对应蓝色,-128对应绿色),所有的颜色在LAB空间中可以以L、A、B这三个值交互变化所组成。
所述颜色特性,是可以在第一颜色空间中独立表征多个显示单元的颜 色共同点的特性,可以是第一颜色空间中某个维度的数值范围,也可以是至少包含第一颜色空间中任意两个维度的数值范围的组合,或者其他等同的特性。
例如第一颜色空间为RGB空间,可以将符合R的取值在16-31范围这一颜色特性的显示单元归入同一类颜色,将符合R的取值在0-15范围这一颜色特性的显示单元归入另一类颜色,以此类推,只根据维度R的取值这一颜色特性对图片包含的显示单元进行分类。又或者根据R、G两个维度的取值的颜色特性进行分类,例如将R、G的取值均在16-31范围这一颜色特性的显示单元归入同一类颜色,将符合R、G的取值均在0-15范围这一颜色特性的显示单元归入另一类颜色,以此类推,完成分类。又或者同时根据R、G、B三个维度的取值的颜色特性进行分类,例如将符合R、G、B的取值均在16-31范围这一颜色特性的显示单元归入同一类颜色,将符合R、G、B的取值均在0-15范围这一颜色特性的显示单元归入另一类颜色,以此类推,完成分类。
因此当所述的第一颜色空间为RGB空间时,所述步骤S2300的颜色分类步骤,具体为对待提取主色的图片包含的每个显示单元在RGB空间进行分类处理,通过将在RGB空间中颜色特性相同的所述显示单元归入同一类颜色从而得到若干颜色类别,并计算每类颜色对应的显示单元数目。所述颜色特性,为RGB空间中任一维度的一定数值范围或至少包含RGB中任意两个维度的数值范围的组合。
分类方法可以包括多种,如上所述,可以为根据第一颜色空间至少一个维度的区间范围进行分段取值的方式。优选地,也可以通过下述公式1对图片中的显示单元进行下采样,从而对显示单元进行分类:
Figure PCTCN2017071759-appb-000007
将下采样得到[S′1,S′2,...S′T]相同的显示单元归为同类颜色;其中
T为所述第一颜色空间维度数目,[S1,...,ST]为单个显示单元在所述第一颜色空间的取值,q1为大于0且小于p1的整数,p1可以根据所述第一颜色空间中每一维最大值2p1-1获取。
例如,所述第一颜色空间为RGB空间,将待提取主色的图片所包含 的显示单元通过公式
Figure PCTCN2017071759-appb-000008
进行下采样,
将下采样得到[S'R,S'G,S'B]相同的显示单元归为同类颜色;其中
[SR,SG,SB]为单个显示单元在所述RBG空间的取值,q1为大于0且小于p1的整数,p1可以根据所述RGB空间中每一维最大值2p1-1获取。
以第一颜色空间为RGB256空间(R、G、B的取值范围均为0-255)进一步详细说明,假设待提取主色的图片中一个显示单元A在RGB空间取值[SR,SG,SB]=[120,56,56],另一显示单元B在RGB空间取值[SR,SG,SB]=[124,50,60],通过上述方法对显示单元A、B进行下采样,其中可通过RGB空间每一维取值范围为0-255确定p1取值为8,选取q1的值为4(大于0且小于8的整数):
对于显示单元A:
Figure PCTCN2017071759-appb-000009
对于显示单元B:
Figure PCTCN2017071759-appb-000010
两个显示单元通过下采样得到的[S'R,S'G,S'B]相等,因而归为同类颜色。
进入步骤S2400,颜色权重计算步骤,用于将每类颜色从第一颜色空间转换至第二颜色空间,获取每类颜色在第二颜色空间每一维度取值,根据显示需求与所述第二颜色空间每一维度对应的因素,确定所述第二颜色空间每一维度的权重函数,根据每类颜色在所述第二颜色空间每一维度的取值与所述每一维度的权重函数,计算每类颜色的权重。
其中所述第二颜色空间一般为不同于第一颜色空间的颜色空间。例如第一颜色空间为RGB空间或LAB空间,第二颜色空间可以为HSV空间、HIS空间或YUV空间。其中HSV空间为三维颜色空间,具有色相H、饱和度S、明度V三个维度。HSI空间用H、S、I三个维度组合表示颜色,其中H定义颜色的波长色调(即色调),S表示颜色的深浅程度(即饱和度),I表示强度或亮度。YUV空间Y表示明亮度(即灰阶值),而U和V表示的则是色度,描述颜色的色彩及饱和度,构成彩色的两个分量。
当从第一颜色空间转换到第二颜色空间时,可以采用公知的颜色空间转换算法来进行,例如当从RGB颜色空间转换到HSV颜色空间时,可以 采用opencv算法库,这些本发明均不做限制。
所述显示需求,可以是多样化的,如显示需求可能包含一种或多种因素,例如图片颜色较鲜艳,或是避免观看不适的极端颜色例如血红色等,或是避免不利于文字展示的极端颜色等。在进行图片显示时,可能只存在单一因素的显示需求,也可能多种因素的显示需求同时并存的。
以第二颜色空间为HSV空间为例,HSV空间为三维空间,具有色相H、饱和度S、明度V三个维度,若显示需求中包含图片颜色较鲜艳的因素,而该因素对应于HSV空间的饱和度S,则需要配置饱和度权重函数。又例如显示需求中包含图片不出现极端颜色例如血红色的因素,而该因素对应于HSV空间色相H,则需要配置色相权重函数。再例如显示需求中包含避免不利于文字展示的极端颜色的因素,则该因素对应于HSV空间明度V,需要配置明度权重函数。
进一步地,若显示需求中包含图片颜色较鲜艳的因素,需要配置饱和度S的权重函数,可以配置饱和度权重函数为饱和度值S的平方函数,使得饱和度函数计算得到的结果值能突出显示需求中包含的图片颜色较鲜艳的因素。又例如,显示需求中包含图片颜色较柔和的因素,需要配置饱和度S的权重函数,可以配置饱和度权重函数为饱和度值S的一次函数或常数项,使得饱和度函数计算得到的结果值能突出显示需求中包含的图片颜色较柔和的因素。又例如显示需求中包含图片不出现极端颜色例如血红色的因素,而该因素对应于HSV空间色相H,该因素要求落入血红色对应的H的取值范围的颜色不能为主色,需要配置色相权重函数,使得色相权重函数计算结果值可以剔除血红色。再例如显示需求中包含避免不利于文字展示的极端颜色的因素,则该因素对应于HSV空间明度V,需要配置明度V的权重函数,可以配置明度权重函数为线性函数,使得明度权重函数的计算结果值可以避免不利于文字展示的极端颜色。以上举例仅为示意性举例,本发明中并不仅局限于此,本领域技术人员可以根据实际应用场景或需求变换实现本发明所述方法。
优选地,将步骤S2300中分类得到的N类颜色,从所述第一颜色空间转换至具有M维的第二颜色空间,得到每类颜色在所述第二颜色空间的取 值,其中第i类颜色在所述第二颜色空间的第j维取值为Pij(i=1,...,N;j=1,...,M),根据显示需求与所述第二颜色空间每一维度对应的因素,配置第二颜色空间每一维度的权重函数,其中第j维的权重函数为F(xj)(j=1,…,M)。
而后,根据每类颜色在所述第二颜色空间取值和权重函数计算每类颜色的权重,其中第i类颜色的权重Wi为:
Figure PCTCN2017071759-appb-000011
其中C为不为0的常数。
可以根据应用需求或者实现经验选取C的取值,例如C=1。
以所述第一颜色空间为RGB空间、第二颜色空间为HSV空间进一步举例说明。在RGB空间中分类得到的每类颜色,从RGB空间转换至HSV空间。HSV空间为3维颜色空间,本例中H空间(颜色色相)的取值范围为[0,179],表示一个色环;S空间(颜色饱和度)的取值范围为[0,255],值越大饱和度越高;V空间(颜色明度)的取值范围为[0,255],值越大明度越高。
将在步骤S2300中分类得到的N类颜色,从RGB空间转换至具有3维的HSV空间,得到每类颜色在HSV空间的色相H、饱和度S、明度V取值,其中第i类颜色的取值为[Hi,Si,Vi],根据显示需求与HSV空间每一维度对应的因素,配置HSV每一维度权重函数,其中色相权重函数为F(H),饱和度权重函数为F(S),明度权重函数为F(V),根据每类颜色在HSV空间的取值和权重函数计算每类颜色的权重,其中第i类颜色的权重Wi为:
Wi=F(Hi)+F(Si)+F(Vi)+C           (公式3)
其中,C为不为0的常数。
可以根据应用需求或者实现经验选取C的取值,例如C=1。
优选地,所述权重函数被配置为使得与显示需求中某个因素相关性越高的维度,其维度权重函数计算得到的结果值越大。
以第二颜色空间为HSV空间为例,如显示需求中包含图片颜色较鲜 艳的因素,则HSV空间中色相H、饱和度S、明度V中,饱和度S与该因素相关性最高,因此可以配置饱和度权重函数为饱和度值S的平方函数,并配置色相权重函数、明度权重函数为一次项或常数项,甚至为0,使得饱和度权重函数计算的结果值比色相权重函数计算的结果值以及明度权重函数计算的结果值更大。
又例如显示需求中包含避免不利于文字展示的极端颜色的因素,则HSV空间中色相H、饱和度S、明度V中,明度V与该因素相关性最高,因此可以配置明度权重函数为明度值V的线性函数,并配置色相权重函数、饱和度权重函数为一次项或常数项,甚至为0,使得明度权重函数计算的结果值比色相权重函数计算的结果值以及饱和权重函数计算的结果值更大。
以上举例仅为示意性举例,本发明中并不仅局限于此,本领域技术人员可以根据实际应用场景或需求变换实现本发明所述方法。
优选地,所述显示需求中与所述HSV空间的饱和度对应的因素为使显示颜色更鲜艳时,配置所述饱和度的权重函数为
F(S)=(S/2A)2           (公式4)
其中,S为饱和度取值,A为正整数。
例如根据应用经验选取A=3,则根据公式4,饱和度权重函数为F(S)=(S/8)2
并且,显示需求中使显示颜色更鲜艳的因素,与所述HSV空间的饱和度对应的相关性较高,即高于显示需求中对对应色相H以及明度V的相关性,可将F(H)、F(V)设置为一次项表达式或者常数项,使得F(S)计算出的得到的结果值较大。
例如在某些应用中,显示需求中若不存在对应色相、明度的因素,只有对应饱和度的因素为使显示颜色更鲜艳,则配置F(H)、F(V)均为0,根据公式3、公式4,第i类颜色的权重Wi为:Wi=(Si/A)2+C,其中Si为第i类颜色的饱和度值。
优选地,所述显示需求中与所述HSV空间的明度对应的因素为避免不利于文字展示的极端颜色时,配置所述明度的权重函数为
Figure PCTCN2017071759-appb-000012
其中,V为明度取值,p2可以根据所述HSV空间中明度取值V的最大值2p2-1获取。
例如,所举例中HSV空间中明度取值V的最大值为255,则对应p2=8,则根据公式5,明度权重函数为:
Figure PCTCN2017071759-appb-000013
并且,显示需求中为避免不利于文字展示的极端颜色的因素,与所述HSV空间的明度对应的相关性较高,即高于显示需求中对应色相H以及饱和度S的相关性,可将F(H)、F(S)设置为一次项表达式或者常数项,使得F(S)计算出的得到的结果值较大。
例如在某些应用中,显示需求中若不存对应色相、饱和度的因素,只有对应明度的因素,则配置F(H)、F(S)均为0,根据公式3、公式5,第i类颜色的权重Wi为:
Figure PCTCN2017071759-appb-000014
其中Vi为第i类颜色的明度值。
随后进入步骤S2500,主色提取步骤,用于根据每类颜色对应的显示单元数目以及该类颜色的权重计算颜色分值,提取所述颜色分值最高的该类颜色作为图片主色。
本发明中,颜色分值表征对每类颜色的评价,根据显示需求所获取的每类颜色的权重和每类颜色对应的显示单元数目综合决定。颜色分值最高的颜色,是最符合显示需求情况下在图片中包含显示单元数目(即对应的显示单元数目)最多的颜色,因此该类颜色作为图片的主色。
根据每类颜色对应的显示单元数目以及该类颜色的权重计算颜色分 值,可以是每类颜色对应的显示单元数目与该类颜色的权重简单相乘的数值,也可以是每类颜色对应的显示单元数目与该类颜色的权重相乘后再乘以或除以比例系数得到的数值,其中比例系数可以是根据应用需求选取或根据实现计算的装置处理能力选取,还可以采用其他等同的计算方法,只要能使得计算获取的每类颜色的颜色分值的结果,是体现根据显示需求所获取的每类颜色的权重以及每类颜色对应的显示单元数目,基于相同的评价标准对每类颜色进行的评价。
优选地,将每类颜色对应的显示单元数目与权重相乘作为每类颜色的颜色分值。
更优选地,提取所述颜色分值最高的该类颜色的中间颜色值作为图片主色。
所述颜色分值最高的该类颜色的中间颜色值,可以是对颜色分值最高的该类颜色所对应的显示单元数目在经过数值排序或其他排序方法后,得到排序在中间位置的显示单元对应的颜色值。
可选地,进入步骤S2600,模板匹配步骤,用于将提取的图片主色与预置的模板颜色进行匹配,选取与图片主色最相近的模板颜色作为最终输出的图片主色。
若经过步骤S2500提取的图片主色存在颜色不美观或者未完全符合显示需求等问题,可进入步骤S2600对图片主色进行模板匹配,选取与图片主色最相近的模板颜色作为最终输出的图片主色,使得最终输出的图片主色符合用户审美或者完全符合显示需求。
其中预置的模板颜色可以根据显示需求选取,例如选取用户体验较为良好的颜色集合作为模板颜色,排除刺眼的血红色等。将图片主色与模板颜色匹配的算法,可以采用John R.Smith和Shih-Fu Chang在《a fully automated content-based image query system》中提出的颜色相似性计算方法。
若经过步骤S2500提取的图片主色不存在不美观或不符合显示需求的问题,则经过步骤S2500提取的图片主色为最终输出的图片主色,无需再进入步骤S2600。
通过本发明所述的提取图片主色的方法,可以将提取的图片主色应用在展示图片界面的背景、控件(如按钮、进度条、图标等)、文字等上,使得界面元素搭配在观感上更和谐,避免界面风格千篇一律或颜色与展示内容无关,更加突出展示内容的风格属性。例如,在图4所示“神马搜索”界面中,界面A区域圆形图片为界面的核心图片,对A区域圆形图片提取图片主色后,将图片主色替换界面中的进度条(进度条为见图5中B区域中长条状控件)的原有颜色,得到如图5所示效果,使得“神马搜索”界面上进度条颜色与界面的核心图片颜色风格一致,观感更和谐。
图3为本发明实施例的图片主色提取装置3000的框图。图片主色提取装置3000可以用来实现图2所示的方法,故重复部分不再详细描述。图片主色提取装置的功能模块可以由实现本发明原理的硬件、软件或硬件和软件的结合来实现。本领域技术人员可以理解的是,图3中所描述的功能模块可以组合起来或者划分成子模块,从而实现上述发明的原理。因此,本文的描述可以支持对本文描述的功能模块的任何可能的组合、或者划分、或者更进一步的限定。
图片主色提取装置3000,包括:输入模块3100、颜色分类模块3300、颜色权重计算模块3400和主色提取模块3500,优选地,还包括图片缩小模块3200和/或模板匹配模块3600。
输入模块3100,用于输入待提取主色的图片,所述图片包括多个显示单元。
可选地,还包括图片缩小模块3200,用于将图片边长像素缩小至合适值。
颜色分类模块3300,用于对待提取主色的图片所包含的每个显示单元在第一颜色空间中进行分类处理,通过将颜色特性相同的所述显示单元归入同一类颜色从而得到若干颜色类别,并计算每类颜色对应的显示单元数目。
优选地,所述颜色分类模块3300,用于对待提取主色的图片所包含的显示单元通过下述公式
Figure PCTCN2017071759-appb-000015
进行下采样,将下采样得到[S′1,S′2,...S′T]相 同的显示单元归为同类颜色;其中
T为所述第一颜色空间维度数目,[S1,...,ST]为单个显示单元在所述第一颜色空间的取值,q1为大于0且小于p1的整数,p1可以根据所述第一颜色空间中每一维最大值2p1-1获取。
颜色权重计算模块3400,用于将每类颜色从第一颜色空间转换至第二颜色空间,获取每类颜色在第二颜色空间每一维度取值,根据显示需求与所述第二颜色空间每一维度对应的因素,确定所述第二颜色空间每一维度的权重函数,根据每类颜色在所述第二颜色空间每一维度的取值与所述每一维度的权重函数,计算每类颜色的权重。
优选地,所述颜色权重计算模块3400用于:
将分类得到的N类颜色,从所述第一颜色空间转换至具有M维的第二颜色空间,得到每类颜色在所述第二颜色空间的取值,其中第i类颜色在所述第二颜色空间的第j维取值为Pij(i=1,...,N;j=1,...,M);
根据显示需求与所述第二颜色空间每一维度对应的因素,配置第二颜色空间每一维度的权重函数,其中第j维的权重函数为F(xj)(j=1,…,M)
计算每类颜色在所述第二颜色空间取值和权重函数计算每类颜色的权重,其中第i类颜色的权重Wi为:
Figure PCTCN2017071759-appb-000016
其中C为不为0的常数。
优选地,所述颜色权重计算模块3400,用于配置所述权重函数,使得与显示需求中某个因素相关性越高的维度,其维度权重函数计算得到的结果值越大。
优选地,所述第二颜色空间为HSV空间时,所述颜色权重计算模块3400,用于当所述显示需求中与所述HSV空间的饱和度对应的因素为使显示颜色更鲜艳时,配置所述饱和度的权重函数为F(S)=(S/2A)2,其中
S为饱和度取值,A为正整数。
优选地,所述第二颜色空间为HSV空间时,所述颜色权重计算模块3400,用于当所述显示需求中与所述HSV空间的明度对应的因素为避免不 利于文字展示的极端颜色时,配置所述明度的权重函数为
Figure PCTCN2017071759-appb-000017
其中
V为明度取值,p2可以根据所述HSV空间明度V的最大取值2p2-1获取。
主色提取模块3500,用于根据每类颜色对应的显示单元数目以及该类颜色的权重计算颜色分值,提取所述颜色分值最高的该类颜色作为图片主色。
优选地,所述主色提取模块3500,还用于将每类颜色对应的显示单元数目与权重相乘作为每类颜色的颜色分值。
更优选地,所述主色提取模块3500,还用于提取所述颜色分值最高的该类颜色的中间颜色值作为图片主色。
可选地,所述装置还包括模板匹配模块3600,用于将提取的图片主色与预置的模板颜色进行匹配,选取与图片主色最相近的模板颜色作为最终输出的图片主色。
根据本发明的再一个实施例,还提供一种可编程设备,包括存储器和处理器,其中,所述存储器用于存储指令,所述指令用于控制所述处理器进行操作以执行图2所述的方法。
以上已经结合附图描述了本发明的第一实施例,根据本实施例,提供一种图片主色提取方法及装置。对图片所包含的多个显示单元根据其在第一颜色空间中的颜色特性进行分类,得到多个颜色特性相同的颜色类别,计算每类颜色对应的显示单元数目,将每类颜色从第一颜色空间转化至第二颜色空间,根据显示需求与第二颜色空间中每一维度对应的因素配置第二颜色空间每一维度的权重函数,进而计算每类颜色的颜色权重,根据每类颜色的颜色权重与每类颜色的显示单元数目,计算每类颜色的颜色分值,提取颜色分值最高的颜色作为图片的主色。本方案根据显示需求提取图片的主色,进而可以根据提取的主色自适应地调整图片背景或前景控件显示,使得图片整体显示协调美观,避免出现不符合显示需求的不美观颜色或与 文字颜色冲突等现象,满足显示需求中个性化因素。
本领域技术人员应当明白,可以通过各种方式来实现图片主色提取装置。例如,可以通过指令配置处理器来实现图片主色提取装置。例如,可以将指令存储在ROM中,并且当启动设备时,将指令从ROM读取到可编程器件中来实现图片主色提取装置。例如,可以将图片主色提取装置固化到专用器件(例如ASIC)中。可以将图片主色提取装置分成相互独立的单元,或者可以将它们合并在一起实现。图片主色提取装置可以通过上述各种实现方式中的一种来实现,或者可以通过上述各种实现方式中的两种或更多种方式的组合来实现。
本发明可以是系统、方法和/或计算机程序产品。计算机程序产品可以包括计算机可读存储介质,其上载有用于使处理器实现本发明的各个方面的计算机可读程序指令。
计算机可读存储介质可以是可以保持和存储由指令执行设备使用的指令的有形设备。计算机可读存储介质例如可以是――但不限于――电存储设备、磁存储设备、光存储设备、电磁存储设备、半导体存储设备或者上述的任意合适的组合。计算机可读存储介质的更具体的例子(非穷举的列表)包括:便携式计算机盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、静态随机存取存储器(SRAM)、便携式压缩盘只读存储器(CD-ROM)、数字多功能盘(DVD)、记忆棒、软盘、机械编码设备、例如其上存储有指令的打孔卡或凹槽内凸起结构、以及上述的任意合适的组合。这里所使用的计算机可读存储介质不被解释为瞬时信号本身,诸如无线电波或者其他自由传播的电磁波、通过波导或其他传输媒介传播的电磁波(例如,通过光纤电缆的光脉冲)、或者通过电线传输的电信号。
这里所描述的计算机可读程序指令可以从计算机可读存储介质下载到各个计算/处理设备,或者通过网络、例如因特网、局域网、广域网和/或无线网下载到外部计算机或外部存储设备。网络可以包括铜传输电缆、光纤传输、无线传输、路由器、防火墙、交换机、网关计算机和/或边缘服务器。每个计算/处理设备中的网络适配卡或者网络接口从网络接收计算机 可读程序指令,并转发该计算机可读程序指令,以供存储在各个计算/处理设备中的计算机可读存储介质中。
用于执行本发明操作的计算机程序指令可以是汇编指令、指令集架构(ISA)指令、机器指令、机器相关指令、微代码、固件指令、状态设置数据、或者以一种或多种编程语言的任意组合编写的源代码或目标代码,所述编程语言包括面向对象的编程语言—诸如Smalltalk、C++等,以及常规的过程式编程语言—诸如“C”语言或类似的编程语言。计算机可读程序指令可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络—包括局域网(LAN)或广域网(WAN)—连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。在一些实施例中,通过利用计算机可读程序指令的状态信息来个性化定制电子电路,例如可编程逻辑电路、现场可编程门阵列(FPGA)或可编程逻辑阵列(PLA),该电子电路可以执行计算机可读程序指令,从而实现本发明的各个方面。
这里参照根据本发明实施例的方法、装置(系统)和计算机程序产品的流程图和/或框图描述了本发明的各个方面。应当理解,流程图和/或框图的每个方框以及流程图和/或框图中各方框的组合,都可以由计算机可读程序指令实现。
这些计算机可读程序指令可以提供给通用计算机、专用计算机或其它可编程数据处理装置的处理器,从而生产出一种机器,使得这些指令在通过计算机或其它可编程数据处理装置的处理器执行时,产生了实现流程图和/或框图中的一个或多个方框中规定的功能/动作的装置。也可以把这些计算机可读程序指令存储在计算机可读存储介质中,这些指令使得计算机、可编程数据处理装置和/或其他设备以特定方式工作,从而,存储有指令的计算机可读介质则包括一个制造品,其包括实现流程图和/或框图中的一个或多个方框中规定的功能/动作的各个方面的指令。
也可以把计算机可读程序指令加载到计算机、其它可编程数据处理装 置、或其它设备上,使得在计算机、其它可编程数据处理装置或其它设备上执行一系列操作步骤,以产生计算机实现的过程,从而使得在计算机、其它可编程数据处理装置、或其它设备上执行的指令实现流程图和/或框图中的一个或多个方框中规定的功能/动作。
附图中的流程图和框图显示了根据本发明的多个实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段或指令的一部分,所述模块、程序段或指令的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个连续的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或动作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。对于本领域技术人员来说公知的是,通过硬件方式实现、通过软件方式实现以及通过软件和硬件结合的方式实现都是等价的。
以上已经描述了本发明的各实施例,上述说明是示例性的,并非穷尽性的,并且也不限于所披露的各实施例。在不偏离所说明的各实施例的范围和精神的情况下,对于本技术领域的普通技术人员来说许多修改和变更都是显而易见的。本文中所用术语的选择,旨在最好地解释各实施例的原理、实际应用或对市场中的技术改进,或者使本技术领域的其它普通技术人员能理解本文披露的各实施例。本发明的范围由所附权利要求来限定。

Claims (25)

  1. 一种图片主色提取方法,其特征在于,包括如下步骤:
    输入步骤,用于输入待提取主色的图片,所述图片包括多个显示单元;
    颜色分类步骤,用于对待提取主色的图片所包含的每个显示单元在第一颜色空间中进行分类处理,通过将颜色特性相同的所述显示单元归入同一类颜色从而得到若干颜色类别,并计算每类颜色对应的显示单元数目;
    颜色权重计算步骤,用于将每类颜色从第一颜色空间转换至第二颜色空间,获取每类颜色在第二颜色空间每一维度取值,根据显示需求与所述第二颜色空间每一维度对应的因素,确定所述第二颜色空间每一维度的权重函数,根据每类颜色在所述第二颜色空间每一维度的取值与所述每一维度的权重函数,计算每类颜色的权重;
    主色提取步骤,用于根据每类颜色对应的显示单元数目以及该类颜色的权重计算颜色分值,提取所述颜色分值最高的该类颜色作为图片主色。
  2. 根据权利要求1所述的方法,其特征在于,所述颜色权重计算步骤包括:
    将分类得到的N类颜色,从所述第一颜色空间转换至具有M维的第二颜色空间,得到每类颜色在所述第二颜色空间的取值,其中第i类颜色在所述第二颜色空间的第j维取值为Pij(i=1,...,N;j=1,...,M);
    根据显示需求与所述第二颜色空间每一维度对应的因素,配置第二颜色空间每一维度的权重函数,其中第j维的权重函数为F(xj)(j=1,…,M);
    根据每类颜色在所述第二颜色空间取值和权重函数计算每类颜色的权重,其中第i类颜色的权重Wi为:
    Figure PCTCN2017071759-appb-100001
    其中C为不为0的常数。
  3. 根据权利要求1所述的方法,其特征在于,与显示需求中某个因素相关性越高的维度,其维度权重函数计算得到的结果值越大。
  4. 根据权利要求1所述的方法,其特征在于,所述第一颜色空间为RGB空间,和/或所述第二颜色空间为HSV空间。
  5. 根据权利要求4所述的方法,其特征在于,在所述颜色权重计算步骤中,用于当所述显示需求中与所述HSV空间的饱和度对应的因素为使显示颜色更鲜艳时,配置所述饱和度的权重函数为F(S)=(S/2A)2,其中
    S为饱和度取值,A为正整数。
  6. 根据权利要求4所述的方法,其特征在于,在所述颜色权重计算步骤中,用于当所述显示需求中与所述HSV空间的明度对应的因素为避免不利于文字展示的极端颜色时,配置所述明度的权重函数为
    Figure PCTCN2017071759-appb-100002
    其中
    V为明度取值,p2可以根据所述HSV空间明度取值V的最大值2p2-1获取。
  7. 根据权利要求1所述的方法,其特征在于,所述颜色分类步骤还包括:用于对待提取主色的图片所包含的显示单元通过下述公式
    Figure PCTCN2017071759-appb-100003
    进行下采样,将下采样得到[S′1,S′2,...S′T]相同的显示单元归为同类颜色;其中
    T为所述第一颜色空间维度数目,[S1,...,ST]为单个显示单元在所述第一颜色空间的取值,q1为大于0且小于p1的整数,p1可以根据所述第一颜色空间中每一维最大值2p1-1获取。
  8. 根据权利要求1所述的方法,其特征在于,所述主色提取步骤中,所述每类颜色的颜色分值为每类颜色对应的显示单元数目与权重相乘。
  9. 根据权利要求8所述的方法,其特征在于,所述主色提取步骤包括:提取所述颜色分值最高的该类颜色的中间颜色值作为图片主色。
  10. 根据权利要求1所述的方法,其特征在于,在所述颜色分类步骤之前还包括:图片缩小步骤,用于将图片边长像素缩小至合适值。
  11. 根据权利要求1所述的方法,其特征在于,所述方法还包括模板匹配步骤,用于将提取的图片主色与预置的模板颜色进行匹配,选取与图片主色最相近的模板颜色作为最终输出的图片主色。
  12. 一种主色提取装置,其特征在于,包括如下模块:
    输入模块,用于输入待提取主色的图片,所述图片包括多个显示单元;
    颜色分类模块,用于对待提取主色的图片所包含的每个显示单元在第一颜色空间中进行分类处理,通过将颜色特性相同的所述显示单元归入同一类颜色从而得到若干颜色类别,并计算每类颜色对应的显示单元数目;
    颜色权重计算模块,用于将每类颜色从第一颜色空间转换至第二颜色空间,获取每类颜色在第二颜色空间每一维度取值,根据显示需求与所述第二颜色空间每一维度对应的因素,确定所述第二颜色空间每一维度的权重函数,根据每类颜色在所述第二颜色空间每一维度的取值与所述每一维度的权重函数,计算每类颜色的权重;
    主色提取模块,用于根据每类颜色对应的显示单元数目以及该类颜色的权重计算颜色分值,提取所述颜色分值最高的该类颜色作为图片主色。
  13. 根据权利要求12所述的装置,其特征在于,所述颜色权重计算模块用于:
    将分类得到的N类颜色,从所述第一颜色空间转换至具有M维的第二颜色空间,得到每类颜色在所述第二颜色空间的取值,其中第i类颜色在所述第二颜色空间的第j维取值为Pij(i=1,...,N;j=1,...,M);
    根据显示需求与所述第二颜色空间每一维度对应的因素,配置第二颜色空间每一维度的权重函数,其中第j维的权重函数为F(xj)(j=1,…,M);
    根据每类颜色在所述第二颜色空间取值和权重函数计算每类颜色的权重,其中第i类颜色的权重Wi为:
    Figure PCTCN2017071759-appb-100004
    其中C为不为0的常数。
  14. 根据权利要求12所述的装置,其特征在于,所述颜色权重计算模块,用于配置所述权重函数,使得与显示需求中某个因素相关性越高的维度,其维度权重函数计算得到的结果值越大。
  15. 根据权利要求12所述的装置,其特征在于,所述第一颜色空间为RGB空间,和/或所述第二颜色空间为HSV空间。
  16. 根据权利要求15所述的装置,其特征在于,所述颜色权重计算模块,用于当所述显示需求中与所述HSV空间的饱和度对应的因素为使显示颜色更鲜艳时,配置所述饱和度的权重函数为F(S)=(S/2A)2,其中
    S为饱和度取值,A为正整数。
  17. 根据权利要求15所述的装置,其特征在于,所述颜色权重计算模块,用于当所述显示需求中与所述HSV空间的明度对应的因素为避免不利于文字展示的极端颜色时,配置所述明度的权重函数为
    Figure PCTCN2017071759-appb-100005
    其中
    V为明度取值,p2可以根据所述HSV空间明度取值V的最大值2p2-1获取。
  18. 根据权利要求12所述的装置,其特征在于,所述颜色分类模块,用于对待提取主色的图片所包含的显示单元通过下述公式
    Figure PCTCN2017071759-appb-100006
    进行下采样,将下采样得到[S′1,S′2,...S′T]相同的显示单元归为同类颜色;其中
    T为所述第一颜色空间维度数目,[S1,...,ST]为单个显示单元在所述第一颜色空间的取值,q1为大于0且小于p1的整数,p1可以根据所述第一颜色空间中每一维最大值2p1-1获取。
  19. 根据权利要求12所述的装置,其特征在于,所述主色提取模块,还用于将每类颜色对应的显示单元数目与权重相乘作为每类颜色的颜色分值。
  20. 根据权利要求19所述的装置,其特征在于,所述主色提取模块,还用于提取所述颜色分值最高的该类颜色的中间颜色值作为图片主色。
  21. 根据权利要求12所述的装置,其特征在于,在颜色分类模块之前,还包括图片缩小模块,用于将图片边长像素缩小至合适值。
  22. 根据权利要求12所述的装置,其特征在于,所述装置还包括模板匹配模块,用于将提取的图片主色与预置的模板颜色进行匹配,选取与图片主色最相近的模板颜色作为最终输出的图片主色。
  23. 一种可编程设备,包括存储器和处理器,其中,所述存储器用于存储指令,所述指令用于控制所述处理器进行操作以执行根据权利要求1-11中任意一项所述的方法。
  24. 一种计算系统,其特征在于,包括:
    监视器,用于显示图片;
    存储器,所述存储器中存储有程序指令;以及
    处理单元,所述处理单元与所述监视器和所述存储器通信连接,所述处理单元在运行所述程序指令时执行以下操作:
    输入待提取主色的图片,所述图片包括多个显示单元;
    对待提取主色的图片所包含的每个显示单元在第一颜色空间中进行分类处理,通过将颜色特性相同的所述显示单元归入同一类颜色从而得到若干颜色类别,并计算每类颜色对应的显示单元数目;
    将每类颜色从第一颜色空间转换至第二颜色空间,获取每类颜色在第二颜色空间每一维度取值,根据显示需求与所述第二颜色空间每一维度对应的因素,确定所述第二颜色空间每一维度的权重函数,根据每类颜色在所述第二颜色空间每一维度的取值与所述每一维度的权重函数,计算每类颜色的权重;
    根据每类颜色对应的显示单元数目以及该类颜色的权重计算颜色分值,提取所述颜色分值最高的该类颜色作为图片主色。
  25. 一种非暂时性机器可读存储介质,其上存储有可执行代码,当所述可执行代码被处理器执行时,使所述处理器执行根据权利要求1至11中任一项所述的图片主色提取方法。
PCT/CN2017/071759 2016-02-14 2017-01-19 图片主色提取方法及装置、计算系统和机器可读存储介质 WO2017136996A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610084742.6A CN105761283B (zh) 2016-02-14 2016-02-14 一种图片主色提取方法及装置
CN201610084742.6 2016-02-14

Publications (1)

Publication Number Publication Date
WO2017136996A1 true WO2017136996A1 (zh) 2017-08-17

Family

ID=56330745

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/071759 WO2017136996A1 (zh) 2016-02-14 2017-01-19 图片主色提取方法及装置、计算系统和机器可读存储介质

Country Status (2)

Country Link
CN (1) CN105761283B (zh)
WO (1) WO2017136996A1 (zh)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110728722A (zh) * 2019-09-18 2020-01-24 苏宁云计算有限公司 图像颜色迁移方法、装置、计算机设备和存储介质
CN113204658A (zh) * 2021-05-27 2021-08-03 北京字跳网络技术有限公司 一种页面显示更新方法、装置、电子设备及存储介质
CN113223041A (zh) * 2021-06-25 2021-08-06 上海添音生物科技有限公司 用于自动提取图像中目标区域的方法、系统及存储介质
CN113379595A (zh) * 2020-03-09 2021-09-10 北京沃东天骏信息技术有限公司 一种页面图片合成方法和装置
CN113867659A (zh) * 2020-06-30 2021-12-31 西安诺瓦星云科技股份有限公司 图像输出方法和装置以及模组控制器
CN115861055A (zh) * 2022-11-24 2023-03-28 湖北帅锐服装贸易有限公司 基于图像识别处理技术的服装设计版面拼接分析方法
CN116229188A (zh) * 2023-05-08 2023-06-06 腾讯科技(深圳)有限公司 图像处理显示方法、分类模型的生成方法及其设备

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105761283B (zh) * 2016-02-14 2018-12-25 广州神马移动信息科技有限公司 一种图片主色提取方法及装置
CN106331536B (zh) * 2016-08-30 2019-09-17 北京奇艺世纪科技有限公司 一种传感器图像编码、解码方法及装置
CN108320312B (zh) * 2017-01-18 2022-01-11 阿里巴巴集团控股有限公司 图片的配色方法及装置、计算机终端
CN107578451A (zh) * 2017-09-20 2018-01-12 太原工业学院 一种面向自然图像的自适应主色提取方法
CN107977999B (zh) * 2017-12-04 2021-01-08 北京百度网讯科技有限公司 智能取色方法和装置
CN109460440B (zh) * 2018-09-18 2023-10-27 平安科技(深圳)有限公司 一种基于权重值的画像处理方法、装置及设备
CN109491739B (zh) * 2018-10-30 2023-04-07 北京字节跳动网络技术有限公司 一种主题色动态确定方法、装置、电子设备及存储介质
CN110210532B (zh) * 2019-05-15 2022-03-01 北京字节跳动网络技术有限公司 背景色生成方法、装置及电子设备
CN111158826B (zh) * 2019-12-27 2022-04-05 腾讯科技(深圳)有限公司 一种界面皮肤生成方法、装置、设备及存储介质
CN112114929B (zh) * 2020-09-29 2023-11-17 青岛海信移动通信技术有限公司 显示设备及其图像显示方法
CN113470125B (zh) * 2021-07-21 2024-01-12 杭州万事利丝绸文化股份有限公司 一种对图案进行颜色搭配的方法及系统

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060204082A1 (en) * 2005-03-11 2006-09-14 Honeywell International Inc. Fusion of color space data to extract dominant color
CN101714257A (zh) * 2009-12-23 2010-05-26 公安部第三研究所 图像主颜色特征提取和结构化描述的方法
CN103366178A (zh) * 2012-03-30 2013-10-23 北京百度网讯科技有限公司 一种用于对目标图像进行颜色分类的方法与设备
CN104093010A (zh) * 2013-11-15 2014-10-08 腾讯科技(深圳)有限公司 一种图像处理方法及装置
CN105761283A (zh) * 2016-02-14 2016-07-13 广州神马移动信息科技有限公司 一种图片主色提取方法及装置

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100568283C (zh) * 2007-12-07 2009-12-09 北京搜狗科技发展有限公司 一种图片主色调分析方法及其装置
CN102592272B (zh) * 2011-01-12 2017-01-25 深圳市世纪光速信息技术有限公司 一种图片主色调提取方法及装置
KR101893191B1 (ko) * 2011-11-11 2018-08-29 삼성전자주식회사 주요 색상을 이용하는 영상 분석 장치 및 그 제어 방법
CN104281849B (zh) * 2013-07-03 2017-09-19 广州盖特软件有限公司 一种布料图像颜色特征提取方法
CN203405832U (zh) * 2013-08-19 2014-01-22 公安部第三研究所 一种车辆颜色分类装置

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060204082A1 (en) * 2005-03-11 2006-09-14 Honeywell International Inc. Fusion of color space data to extract dominant color
CN101714257A (zh) * 2009-12-23 2010-05-26 公安部第三研究所 图像主颜色特征提取和结构化描述的方法
CN103366178A (zh) * 2012-03-30 2013-10-23 北京百度网讯科技有限公司 一种用于对目标图像进行颜色分类的方法与设备
CN104093010A (zh) * 2013-11-15 2014-10-08 腾讯科技(深圳)有限公司 一种图像处理方法及装置
CN105761283A (zh) * 2016-02-14 2016-07-13 广州神马移动信息科技有限公司 一种图片主色提取方法及装置

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110728722A (zh) * 2019-09-18 2020-01-24 苏宁云计算有限公司 图像颜色迁移方法、装置、计算机设备和存储介质
CN113379595A (zh) * 2020-03-09 2021-09-10 北京沃东天骏信息技术有限公司 一种页面图片合成方法和装置
CN113379595B (zh) * 2020-03-09 2024-04-09 北京沃东天骏信息技术有限公司 一种页面图片合成方法和装置
CN113867659A (zh) * 2020-06-30 2021-12-31 西安诺瓦星云科技股份有限公司 图像输出方法和装置以及模组控制器
CN113867659B (zh) * 2020-06-30 2024-02-06 西安诺瓦星云科技股份有限公司 图像输出方法和装置以及模组控制器
CN113204658A (zh) * 2021-05-27 2021-08-03 北京字跳网络技术有限公司 一种页面显示更新方法、装置、电子设备及存储介质
CN113223041A (zh) * 2021-06-25 2021-08-06 上海添音生物科技有限公司 用于自动提取图像中目标区域的方法、系统及存储介质
CN113223041B (zh) * 2021-06-25 2024-01-12 上海添音生物科技有限公司 用于自动提取图像中目标区域的方法、系统及存储介质
CN115861055A (zh) * 2022-11-24 2023-03-28 湖北帅锐服装贸易有限公司 基于图像识别处理技术的服装设计版面拼接分析方法
CN115861055B (zh) * 2022-11-24 2023-12-01 武汉所见科技有限公司 基于图像识别处理技术的服装设计版面拼接分析方法
CN116229188A (zh) * 2023-05-08 2023-06-06 腾讯科技(深圳)有限公司 图像处理显示方法、分类模型的生成方法及其设备
CN116229188B (zh) * 2023-05-08 2023-07-25 腾讯科技(深圳)有限公司 图像处理显示方法、分类模型的生成方法及其设备

Also Published As

Publication number Publication date
CN105761283B (zh) 2018-12-25
CN105761283A (zh) 2016-07-13

Similar Documents

Publication Publication Date Title
WO2017136996A1 (zh) 图片主色提取方法及装置、计算系统和机器可读存储介质
US10304408B2 (en) Method and apparatus for changing background color of toolbar with dominant color of picture
US10937200B2 (en) Object-based color adjustment
US9552656B2 (en) Image-based color palette generation
US9177391B1 (en) Image-based color palette generation
US8965119B2 (en) Color balance tools for editing images
US9311889B1 (en) Image-based color palette generation
US20160335784A1 (en) Image-based color palette generation
He et al. Image color transfer to evoke different emotions based on color combinations
WO2014200644A1 (en) Content adjustment in graphical user interface based on background content
CN112328345B (zh) 用于确定主题色的方法、装置、电子设备及可读存储介质
US20240046531A1 (en) Systems and methods for recolouring vector graphics
CN107408401A (zh) 用于图像的简化调整的用户滑块
JP2023537262A (ja) 空間イメージ分析基盤配色推薦装置及び方法
JP2012174273A (ja) 画像処理装置及び画像処理方法
JP7145358B2 (ja) 改良型カラーホイールインターフェース
CN111383289A (zh) 图像处理方法、装置、终端设备及计算机可读存储介质
KR20150100113A (ko) 영상 처리 장치 및 이의 영상 처리 방법
EP3246878A1 (en) Method to determine chromatic component of illumination sources of an image
US11392762B2 (en) Technologies for managing dynamic design templates
JP7027288B2 (ja) 決定装置、決定方法および決定プログラム
JP6033988B2 (ja) 情報処理装置
Chen et al. A low complexity automatic white balance algorithm for AMOLED hardware driving using histogram shifting with compensation
CN118053002A (zh) 图像处理方法及装置
WO2021209978A1 (en) Technologies for modifying design templates across online services

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17749887

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 29.01.19)

122 Ep: pct application non-entry in european phase

Ref document number: 17749887

Country of ref document: EP

Kind code of ref document: A1