CN110503695A - Acquisition methods, device, storage medium and the electronic device of the main color of picture - Google Patents

Acquisition methods, device, storage medium and the electronic device of the main color of picture Download PDF

Info

Publication number
CN110503695A
CN110503695A CN201810473591.2A CN201810473591A CN110503695A CN 110503695 A CN110503695 A CN 110503695A CN 201810473591 A CN201810473591 A CN 201810473591A CN 110503695 A CN110503695 A CN 110503695A
Authority
CN
China
Prior art keywords
picture
gaussian blur
client
information
pixel
Prior art date
Legal status (The legal status 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 status listed.)
Granted
Application number
CN201810473591.2A
Other languages
Chinese (zh)
Other versions
CN110503695B (en
Inventor
陈霖炜
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201810473591.2A priority Critical patent/CN110503695B/en
Publication of CN110503695A publication Critical patent/CN110503695A/en
Application granted granted Critical
Publication of CN110503695B publication Critical patent/CN110503695B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • G06T5/70
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics

Abstract

The invention discloses a kind of acquisition methods of the main color of picture, device, storage medium and electronic devices.Wherein, this method comprises: client obtains the first pictorial information;Client call Gaussian Blur script carries out Gaussian Blur processing to the first pictorial information, obtains second picture information;Client extracts the main color of picture from second picture information.The present invention solves the lower technical problem of efficiency for obtaining the main color of picture in the related technology.

Description

Acquisition methods, device, storage medium and the electronic device of the main color of picture
Technical field
The present invention relates to computer fields, in particular to the acquisition methods, device, storage of a kind of main color of picture Medium and electronic device.
Background technique
The mode for extracting the main color of picture in the related technology is the color extraction that picture is carried out by server, and before returning to Platform, foreground show color.This mode is very low to the efficiency of image procossing.
For above-mentioned problem, currently no effective solution has been proposed.
Summary of the invention
The embodiment of the invention provides a kind of acquisition methods of the main color of picture, device, storage medium and electronic device, with At least solve to obtain the lower technical problem of the efficiency of the main color of picture in the related technology.
According to an aspect of an embodiment of the present invention, a kind of acquisition methods of main color of picture are provided, comprising: client Obtain the first pictorial information;The client call Gaussian Blur script carries out at Gaussian Blur first pictorial information Reason, obtains second picture information;The client extracts the main color of picture from the second picture information.
According to another aspect of an embodiment of the present invention, a kind of acquisition device of main color of picture, the picture are additionally provided The acquisition device of main color is applied to client, and the acquisition device of the main color of picture includes: acquisition module, for obtaining the One pictorial information;Processing module is obtained for calling Gaussian Blur script to carry out Gaussian Blur processing to first pictorial information To second picture information;Extraction module, for extracting the main color of picture from the second picture information.
According to another aspect of an embodiment of the present invention, a kind of storage medium is additionally provided, which is characterized in that the storage is situated between Computer program is stored in matter, wherein the computer program is arranged to execute described in any of the above-described when operation Method.
According to another aspect of an embodiment of the present invention, a kind of electronic device, including memory and processor are additionally provided, It is characterized in that, computer program is stored in the memory, and the processor is arranged to hold by the computer program Method described in row any of the above-described.
In embodiments of the present invention, the first pictorial information is obtained using client;Client call Gaussian Blur script pair First pictorial information carries out Gaussian Blur processing, obtains second picture information;Client extracts picture from second picture information The mode of main color, is compiled into Gaussian Blur script for the function of Gaussian Blur, directly by client call Gaussian Blur script Gaussian Blur processing is carried out to the first pictorial information got, then second picture information carries out the main color of picture to treated Extraction avoid front end to realize all processes that the main color of picture extracts automatically by client and background server be multiple Miscellaneous interactive process to realize the technical effect for improving treatment effeciency when obtaining the main color of picture, and then solves phase The lower technical problem of the efficiency of the main color of picture is obtained in the technology of pass.
Detailed description of the invention
The drawings described herein are used to provide a further understanding of the present invention, constitutes part of this application, this hair Bright illustrative embodiments and their description are used to explain the present invention, and are not constituted improper limitations of the present invention.In the accompanying drawings:
Fig. 1 is a kind of schematic diagram of the acquisition methods of optional main color of picture according to an embodiment of the present invention;
Fig. 2 is a kind of application environment signal of the acquisition methods of optional main color of picture according to an embodiment of the present invention Figure;
Fig. 3 is a kind of signal of the acquisition methods of optional main color of picture of optional embodiment according to the present invention Figure;
Fig. 4 is a kind of schematic diagram of the acquisition device of optional main color of picture according to an embodiment of the present invention;
Fig. 5 is a kind of application scenarios schematic diagram of the acquisition methods of optional main color of picture according to an embodiment of the present invention One;
Fig. 6 is a kind of application scenarios schematic diagram of the acquisition methods of optional main color of picture according to an embodiment of the present invention Two;And
Fig. 7 is a kind of schematic diagram of optional electronic device according to an embodiment of the present invention.
Specific embodiment
In order to enable those skilled in the art to better understand the solution of the present invention, below in conjunction in the embodiment of the present invention Attached drawing, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that described embodiment is only The embodiment of a part of the invention, instead of all the embodiments.Based on the embodiments of the present invention, ordinary skill people The model that the present invention protects all should belong in member's every other embodiment obtained without making creative work It encloses.
It should be noted that description and claims of this specification and term " first " in above-mentioned attached drawing, " Two " etc. be to be used to distinguish similar objects, without being used to describe a particular order or precedence order.It should be understood that using in this way Data be interchangeable under appropriate circumstances, so as to the embodiment of the present invention described herein can in addition to illustrating herein or Sequence other than those of description is implemented.In addition, term " includes " and " having " and their any deformation, it is intended that cover Cover it is non-exclusive include, for example, the process, method, system, product or equipment for containing a series of steps or units are not necessarily limited to Step or unit those of is clearly listed, but may include be not clearly listed or for these process, methods, product Or other step or units that equipment is intrinsic.
According to an aspect of an embodiment of the present invention, a kind of acquisition methods of main color of picture are provided, as shown in Figure 1, This method comprises:
S102, client obtain the first pictorial information;
S104, client call Gaussian Blur script carry out Gaussian Blur processing to the first pictorial information, obtain the second figure Piece information;
S106, client extract the main color of picture from second picture information.
Optionally, in the present embodiment, the acquisition methods of the main color of above-mentioned picture can be applied to client as shown in Figure 2 In the hardware environment that end 202 is constituted.As shown in Fig. 2, client 202 obtains the first pictorial information, Gaussian Blur script is called Gaussian Blur processing is carried out to the first pictorial information, obtains second picture information, then extracts picture master from second picture information Want color.
Optionally, in the present embodiment, the acquisition methods of the main color of above-mentioned picture can be, but not limited to be applied to picture The scene that is obtained of main color in.Wherein, above-mentioned client can be, but not limited to as various types of applications, for example, In It is line educational applications, instant messaging application, community space application, game application, shopping application, browser application, financial application, more Media application, live streaming application, image processing application etc..Specifically, can be, but not limited to applied to right in above-mentioned game application In the scene that the main color of picture is obtained, or can with but be not limited to be applied in above-mentioned image processing application to picture The scene that is obtained of main color in, treatment effeciency when the main color of picture is obtained to improve.Above-mentioned is only a kind of example, this Any restriction is not done in embodiment to this.
Optionally, in the present embodiment, above-mentioned client can be, but not limited to include: PC computer, tablet computer, hand Machine, intelligent wearable device, controlling intelligent household appliances, smart home device etc..
Optionally, in the present embodiment, the first pictorial information can be, but not limited to be picture file, or can also with but not It is limited to be the Pixel Information in picture file.
Optionally, in the present embodiment, second picture information can be, but not limited to be picture file, or can also with but not It is limited to be the Pixel Information in picture file.
Optionally, in the present embodiment, the treatment process of Gaussian Blur is compiled into Gaussian Blur foot in the form of code This, when needing to carry out Gaussian Blur to pictorial information, client can call directly the Gaussian Blur script, the Gaussian Blur Script can carry out Gaussian Blur processing to the first pictorial information of input automatically.It avoids technician and uses drawing software The process that artificial Gauss processing is carried out to picture, to improve treatment effeciency.
Optionally, in the present embodiment, after the main color of picture can refer in picture all pixels classification, most concentrate that Color value.
Optionally, in the present embodiment, Gaussian Blur is also Gaussian smoothing, and picture noise and drop are usually reduced with it Low level of detail.The image that this fuzzy technology generates, visual effect is like by a translucent screen in observation figure Picture, this is all significantly different with the effect in the scattered scape of camera lens afocal imaging effect and general lighting shade.Gaussian smoothing is also used for The pre-processing stage in computer vision algorithms make, to enhance image effect of the image under different proportion size.From mathematics From the point of view of angle, the Gaussian Blur process of image is exactly that convolution is done in image and normal distribution.Make Gauss point since normal distribution is called Cloth, so this technology is just called Gaussian Blur.
In an optional embodiment, as shown in figure 3, customer end A gets the first pictorial information to be processed is The picture element matrix B of picture B calls Gaussian Blur script to carry out Gaussian Blur processing to picture element matrix B, obtains second picture letter Breath is picture element matrix C, then extracting the main color of picture from picture element matrix C is color D.
As it can be seen that through the above steps, the function of Gaussian Blur is compiled into Gaussian Blur script, directly by client call Gaussian Blur script carries out Gaussian Blur processing to the first pictorial information for getting, then to treated second picture information into The extraction of the main color of row picture mentions to realize all processes that the main color of picture extracts automatically by client to realize The technical effect for the treatment of effeciency when height obtains picture main color, and then solve the effect for obtaining the main color of picture in the related technology The lower technical problem of rate.
As a kind of optional scheme, client obtains the first pictorial information and includes:
S1, client obtain the first picture to be processed;
S2, client obtain the first Pixel Information of each pixel on the first picture, obtain the first Pixel Information set;
First Pixel Information set is determined as the first pictorial information by S3, client.
Optionally, in the present embodiment, the first pictorial information can be, but not limited to be a picture Pixel Information.Client The first Pixel Information of each pixel in the first picture to be processed that will acquire is held to extract to obtain the first pixel letter Breath set, which is the first pictorial information.
Optionally, in the present embodiment, the first Pixel Information set can be, but not limited to be in the form of picture element matrix into Row record.
As a kind of optional scheme, client obtains the first Pixel Information of each pixel on the first picture, obtains First Pixel Information set includes:
First picture is plotted in the first canvas element by S1, client, wherein the first canvas element is drawn for carrying Image information in the first canvas element;
S2, client is from the first Pixel Information for extracting each pixel on the first picture in the first canvas element;
First Pixel Information of pixel each on the first picture is determined as the first Pixel Information set by S3, client.
Optionally, in the present embodiment, above-mentioned first canvas element can be, but not limited to include canvas label.Client The pixel data of image is extracted from image using canvas element.
As a kind of optional scheme, client call Gaussian Blur script carries out at Gaussian Blur the first pictorial information Reason, obtaining second picture information includes:
S1, client call Gaussian Blur script carry out Gaussian Blur processing to the first Pixel Information set, obtain second Pixel Information set, wherein the second Pixel Information set includes each pixel by Gaussian Blur treated the second pixel Information;
Second Pixel Information set is determined as second picture information by S2, client;Alternatively, client believes the second pixel Breath set is converted to second picture, and second picture is determined as second picture information.
Optionally, in the present embodiment, second picture information can be, but not limited to also can be, but not limited to for Pixel Information For picture.
Optionally, in the present embodiment, in the case where second picture is determined as second picture information by client, client End can be, but not limited to extract the main color of picture: the main color of client call picture from second picture information in the following manner Script is obtained, script is obtained by the main color of operation picture and obtains the main color of picture from second picture.
Optionally, in the present embodiment, the main color of picture obtains script and can be, but not limited to include rgbaster.js letter Number.The principle of rgbaster.js is exactly to intercept out by the pixel data on picture, and a non-computational pixel is then arranged, Such as black white;Its allochromatic colour is compared, that value of most colors is exactly the main of the picture after Gaussian Blur Color.
Optionally, in the present embodiment, the second Pixel Information set is determined as to the feelings of second picture information in client Under condition, client can be, but not limited to extract the main color of picture from second picture information in the following manner: client will be every Second Pixel Information of a pixel is compared with object pixel, obtains the corresponding comparison value of each second Pixel Information, visitor Family end counts the distribution of comparison value, obtains the frequency of occurrence of each comparison value in comparison value, client is highest by frequency of occurrence Comparison value is determined as target comparison value, and corresponding second Pixel Information of target comparison value is determined as the main color of picture by client.
Optionally, in the present embodiment, object pixel can be, but not limited to be arranged to black or white.
Optionally, in the present embodiment, after obtaining the data after Gaussian Blur, the side of rgbaster.js can be used Method takes the main color of picture, this library needs incoming picture, so data are plotted on canvas, then canvas is converted to Picture;And the principle of rgbster.js, it is the pixel data that picture is converted to canvas, then takes canvas.It therefore can be with It directly by the data of canvas, compares, takes out main color of the most color value of color as picture.
As a kind of optional scheme, the second Pixel Information set is converted to second picture and includes: by client
Second Pixel Information set is plotted in the second canvas element by S1, client, wherein the second canvas element is used for Carry the image information being plotted in the second canvas element;
The the second Pixel Information set carried in second canvas element is converted into second picture by S2, client.
Optionally, in the present embodiment, above-mentioned second canvas element can be, but not limited to include canvas label.Client Picture is converted pixel data into using canvas element.
As a kind of optional scheme, client call Gaussian Blur script carries out at Gaussian Blur the first pictorial information Reason, obtaining second picture information includes:
S1, client receives target Gaussian Blur radius, and calls Gaussian Blur script;
The Gaussian Blur radius for including in the Gaussian Blur parameter of Gaussian Blur script is set target height by S2, client This blur radius;
S3, client are arranged to the Gaussian Blur script of target Gaussian Blur radius to first using Gaussian Blur radius Pictorial information carries out Gaussian Blur processing, obtains second picture information.
Optionally, in the present embodiment, Gaussian Blur is a kind of algorithm that normal distribution is used for image procossing, Gaussian mode The radius of paste is bigger, and a point takes the point range of surrounding bigger, and blur effect is stronger.Target Gaussian Blur radius can be by Engineer is configured, and engineer can be set different target Gaussian Blur radiuses and handle same group of picture.It is related Technical costs it is relatively high, needed on manpower first three aspect manpower, not only need designer, it is also necessary to foreground and backstage take Business device develops manpower;Designer requires whole flow process and walks again one time when modifying different Gaussian Blur radiuses.In In the present embodiment, designer only need out original image be given to foreground client, blur radius can be modified at any time, without that will scheme Piece uploads to background server, then the step for recalculated by server.That is by foreground client to picture into Row Gaussian Blur extracts main color, and all operations such as displaying on dom element.
Optionally, in the present embodiment, in the operation for obtaining the main color value of picture, it is no longer necessary to give at server Reason.Picture can be at foreground client after Gaussian Blur, black and white processing, transparency or contrast processing, can also To obtain the main color of picture.Reduce manpower in this way, while reducing the request initiated to backstage, in process also more It is easy.
Optionally, in the present embodiment, client can be, but not limited to be arranged to target height using Gaussian Blur radius The Gaussian Blur script of this blur radius carries out Gaussian Blur processing to the first pictorial information in the following manner, to obtain the Two pictorial informations: it is target Gaussian Blur half that client, which obtains target pixel points in Gaussian Blur radius by Gaussian Blur script, Corresponding first weight matrix in the case where diameter, wherein the first pictorial information includes the corresponding Pixel Information of target pixel points, visitor Family end is normalized the first weight matrix by Gaussian Blur script, obtains the second weight matrix, and client passes through Gaussian Blur script carries out operation to the second weight matrix Pixel Information corresponding with target pixel points, obtains target pixel points pair The Gaussian Blur processing result answered, wherein second picture information includes the corresponding Gaussian Blur processing result of target pixel points.
Optionally, in the present embodiment, client can be, but not limited to obtain target pixel points correspondence in the following manner Gaussian Blur processing result: client obtains target from the corresponding Pixel Information of target pixel points by Gaussian Blur script The corresponding multiple picture element matrixs of pixel, wherein multiple picture element matrixs include the picture of each Color Channel in multiple Color Channels Prime matrix, by Gaussian Blur script respectively by element corresponding in the picture element matrix of the second weight matrix and each Color Channel Carry out multiplying, obtain with multiple Color Channels multiple object pixel matrixes correspondingly, by multiple object pixel matrixes It is determined as the corresponding Gaussian Blur processing result of target pixel points.
Optionally, in the present embodiment, Color Channel can be, but not limited to include: red (R), green (G), blue (B) Channel.
It should be noted that for the various method embodiments described above, for simple description, therefore, it is stated as a series of Combination of actions, but those skilled in the art should understand that, the present invention is not limited by the sequence of acts described because According to the present invention, some steps may be performed in other sequences or simultaneously.Secondly, those skilled in the art should also know It knows, the embodiments described in the specification are all preferred embodiments, and related actions and modules is not necessarily of the invention It is necessary.
Through the above description of the embodiments, those skilled in the art can be understood that according to above-mentioned implementation The method of example can be realized by means of software and necessary general hardware platform, naturally it is also possible to by hardware, but it is very much In the case of the former be more preferably embodiment.Based on this understanding, technical solution of the present invention is substantially in other words to existing The part that technology contributes can be embodied in the form of software products, which is stored in a storage In medium (such as ROM/RAM, magnetic disk, CD), including some instructions are used so that a terminal device (can be mobile phone, calculate Machine, server or network equipment etc.) execute method described in each embodiment of the present invention.
Other side according to an embodiment of the present invention additionally provides a kind of for implementing the acquisition of the main color of above-mentioned picture The acquisition device of the main color of the picture of method is applied to client, as shown in figure 4, the device includes:
Module 42 is obtained, for obtaining the first pictorial information;
Processing module 44 obtains for calling Gaussian Blur script to carry out Gaussian Blur processing to the first pictorial information Two pictorial informations;
Extraction module 46, for extracting the main color of picture from second picture information.
Optionally, in the present embodiment, the acquisition device of the main color of above-mentioned picture can be applied to client as shown in Figure 2 In the hardware environment that end 202 is constituted.As shown in Fig. 2, client 202 obtains the first pictorial information, Gaussian Blur script is called Gaussian Blur processing is carried out to the first pictorial information, obtains second picture information, then extracts picture master from second picture information Want color.
Optionally, in the present embodiment, the acquisition device of the main color of above-mentioned picture can be, but not limited to be applied to picture The scene that is obtained of main color in.Wherein, above-mentioned client can be, but not limited to as various types of applications, for example, In It is line educational applications, instant messaging application, community space application, game application, shopping application, browser application, financial application, more Media application, live streaming application, image processing application etc..Specifically, can be, but not limited to applied to right in above-mentioned game application In the scene that the main color of picture is obtained, or can with but be not limited to be applied in above-mentioned image processing application to picture The scene that is obtained of main color in, treatment effeciency when the main color of picture is obtained to improve.Above-mentioned is only a kind of example, this Any restriction is not done in embodiment to this.
Optionally, in the present embodiment, above-mentioned client can be, but not limited to include: PC computer, tablet computer, hand Machine, intelligent wearable device, controlling intelligent household appliances, smart home device etc..
Optionally, in the present embodiment, the first pictorial information can be, but not limited to be picture file, or can also with but not It is limited to be the Pixel Information in picture file.
Optionally, in the present embodiment, second picture information can be, but not limited to be picture file, or can also with but not It is limited to be the Pixel Information in picture file.
Optionally, in the present embodiment, the treatment process of Gaussian Blur is compiled into Gaussian Blur foot in the form of code This, when needing to carry out Gaussian Blur to pictorial information, client can call directly the Gaussian Blur script, the Gaussian Blur Script can carry out Gaussian Blur processing to the first pictorial information of input automatically.It avoids technician and uses drawing software The process that artificial Gauss processing is carried out to picture, to improve treatment effeciency.
Optionally, in the present embodiment, after the main color of picture can refer in picture all pixels classification, most concentrate that Color value.
Optionally, in the present embodiment, Gaussian Blur is also Gaussian smoothing, and picture noise and drop are usually reduced with it Low level of detail.The image that this fuzzy technology generates, visual effect is like by a translucent screen in observation figure Picture, this is all significantly different with the effect in the scattered scape of camera lens afocal imaging effect and general lighting shade.Gaussian smoothing is also used for The pre-processing stage in computer vision algorithms make, to enhance image effect of the image under different proportion size.From mathematics From the point of view of angle, the Gaussian Blur process of image is exactly that convolution is done in image and normal distribution.Make Gauss point since normal distribution is called Cloth, so this technology is just called Gaussian Blur.
In an optional embodiment, as shown in figure 3, customer end A gets the first pictorial information to be processed is The picture element matrix B of picture B calls Gaussian Blur script to carry out Gaussian Blur processing to picture element matrix B, obtains second picture letter Breath is picture element matrix C, then extracting the main color of picture from picture element matrix C is color D.
As it can be seen that the function of Gaussian Blur is compiled into Gaussian Blur script, directly by client call by above-mentioned apparatus Gaussian Blur script carries out Gaussian Blur processing to the first pictorial information for getting, then to treated second picture information into The extraction of the main color of row picture mentions to realize all processes that the main color of picture extracts automatically by client to realize The technical effect for the treatment of effeciency when height obtains picture main color, and then solve the effect for obtaining the main color of picture in the related technology The lower technical problem of rate.
As a kind of optional scheme, obtaining module includes:
First acquisition unit, for obtaining the first picture to be processed;
Second acquisition unit obtains the first pixel for obtaining the first Pixel Information of each pixel on the first picture Information aggregate;
First determination unit, for the first Pixel Information set to be determined as the first pictorial information.
Optionally, in the present embodiment, the first pictorial information can be, but not limited to be a picture Pixel Information.Client The first Pixel Information of each pixel in the first picture to be processed that will acquire is held to extract to obtain the first pixel letter Breath set, which is the first pictorial information.
Optionally, in the present embodiment, the first Pixel Information set can be, but not limited to be in the form of picture element matrix into Row record.
As a kind of optional scheme, second acquisition unit includes:
First draws subelement, for the first picture to be plotted to the first canvas element, wherein the first canvas element is used In the image information that carrying is plotted in the first canvas element;
Subelement is extracted, for believing from the first pixel for extracting each pixel on the first picture in the first canvas element Breath;
Subelement is determined, for the first Pixel Information of pixel each on the first picture to be determined as the first Pixel Information Set.
Optionally, in the present embodiment, above-mentioned first canvas element can be, but not limited to include canvas label.Client The pixel data of image is extracted from image using canvas element.
As a kind of optional scheme, processing module includes:
First processing units, for calling Gaussian Blur script to carry out Gaussian Blur processing to the first Pixel Information set, Obtain the second Pixel Information set, wherein the second Pixel Information set includes each pixel treated by Gaussian Blur Second Pixel Information;
Second determination unit, for the second Pixel Information set to be determined as second picture information;Alternatively, by the second pixel Information aggregate is converted to second picture, and second picture is determined as second picture information.
Optionally, in the present embodiment, second picture information can be, but not limited to also can be, but not limited to for Pixel Information For picture.
Optionally, in the present embodiment, extraction module includes: call unit, for second picture to be determined as second In the case where pictorial information, the main color of picture is called to obtain script;Third acquiring unit, for being obtained by running the main color of picture Script is taken to obtain the main color of picture from second picture.
Optionally, in the present embodiment, the main color of picture obtains script and can be, but not limited to include rgbaster.js letter Number.The principle of rgbaster.js is exactly to intercept out by the pixel data on picture, and a non-computational pixel is then arranged, Such as black white;Its allochromatic colour is compared, that value of most colors is exactly the main of the picture after Gaussian Blur Color.
Optionally, in the present embodiment, extraction module includes: comparing unit, for the second Pixel Information set is true In the case where being set to second picture information, the second Pixel Information of each pixel is compared with object pixel, is obtained every The corresponding comparison value of a second Pixel Information;Statistic unit obtains each comparison in comparison value for counting the distribution of comparison value The frequency of occurrence of value;Third determination unit, for the highest comparison value of frequency of occurrence to be determined as target comparison value;4th determines Unit, for corresponding second Pixel Information of target comparison value to be determined as the main color of picture.
Optionally, in the present embodiment, object pixel can be, but not limited to be arranged to black or white.
Optionally, in the present embodiment, after obtaining the data after Gaussian Blur, the side of rgbaster.js can be used Method takes the main color of picture, this library needs incoming picture, so data are plotted on canvas, then canvas is converted to Picture;And the principle of rgbster.js, it is the pixel data that picture is converted to canvas, then takes canvas.It therefore can be with It directly by the data of canvas, compares, takes out main color of the most color value of color as picture.
As a kind of optional scheme, the second determination unit includes:
Second draws subelement, for the second Pixel Information set to be plotted to the second canvas element, wherein second draws Cloth element is for carrying the image information being plotted in the second canvas element;
Conversion subunit, the second Pixel Information set for will carry in the second canvas element are converted into second picture.
Optionally, in the present embodiment, above-mentioned second canvas element can be, but not limited to include canvas label.Client Picture is converted pixel data into using canvas element.
As a kind of optional scheme, processing module includes:
Receiving unit for receiving target Gaussian Blur radius, and calls Gaussian Blur script;
Setting unit, the Gaussian Blur radius for including in the Gaussian Blur parameter by Gaussian Blur script are set as mesh This blur radius of absolute altitude;
The second processing unit, for being arranged to the Gaussian Blur foot of target Gaussian Blur radius using Gaussian Blur radius This carries out Gaussian Blur processing to the first pictorial information, obtains second picture information.
Optionally, in the present embodiment, Gaussian Blur is a kind of algorithm that normal distribution is used for image procossing, Gaussian mode The radius of paste is bigger, and a point takes the point range of surrounding bigger, and blur effect is stronger.Target Gaussian Blur radius can be by Engineer is configured, and engineer can be set different target Gaussian Blur radiuses and handle same group of picture.It is related Technical costs it is relatively high, needed on manpower first three aspect manpower, not only need designer, it is also necessary to foreground and backstage take Business device develops manpower;Designer requires whole flow process and walks again one time when modifying different Gaussian Blur radiuses.In In the present embodiment, designer only need out original image be given to foreground client, blur radius can be modified at any time, without that will scheme Piece uploads to background server, then the step for recalculated by server.That is by foreground client to picture into Row Gaussian Blur extracts main color, and all operations such as displaying on dom element.
Optionally, in the present embodiment, in the operation for obtaining the main color value of picture, it is no longer necessary to give at server Reason.Picture can be at foreground client after Gaussian Blur, black and white processing, transparency or contrast processing, can also To obtain the main color of picture.Reduce manpower in this way, while reducing the request initiated to backstage, in process also more It is easy.
Optionally, in the present embodiment, the second processing unit includes: acquisition subelement, for passing through Gaussian Blur script Target pixel points corresponding first weight matrix in the case where Gaussian Blur radius is target Gaussian Blur radius is obtained, In, the first pictorial information includes the corresponding Pixel Information of target pixel points;Subelement is handled, for passing through Gaussian Blur script pair First weight matrix is normalized, and obtains the second weight matrix;Operation subelement, for passing through Gaussian Blur script pair Second weight matrix Pixel Information corresponding with target pixel points carries out operation, obtains at the corresponding Gaussian Blur of target pixel points Manage result, wherein second picture information includes the corresponding Gaussian Blur processing result of target pixel points.
Optionally, in the present embodiment, operation subelement is used for: corresponding from target pixel points by Gaussian Blur script The corresponding multiple picture element matrixs of target pixel points are obtained in Pixel Information, wherein multiple picture element matrixs include multiple Color Channels In each Color Channel picture element matrix;By Gaussian Blur script respectively by the picture of the second weight matrix and each Color Channel Corresponding element carries out multiplying in prime matrix, obtains and multiple Color Channels multiple object pixel matrixes correspondingly; Multiple object pixel matrixes are determined as the corresponding Gaussian Blur processing result of target pixel points.
Optionally, in the present embodiment, Color Channel can be, but not limited to include: red (R), green (G), blue (B) Channel.
The application environment of the embodiment of the present invention can be, but not limited to referring to the application environment in above-described embodiment, the present embodiment In this is repeated no more.The embodiment of the invention provides the optional tools of one kind of the connection method for implementing above-mentioned real time communication Body application example.
As a kind of optional embodiment, the acquisition methods of the above-mentioned main color of picture can be, but not limited to be applied to such as Fig. 5 Shown in acquisition the main color of picture scene in.In this scene, as shown in figure 5, the treatment process of Gaussian Blur is applied to In the processes pixel of picture, picture is first changed into canvas, then takes out all array of pixels, each pixel is subjected to Gauss After fuzzy, a new array is generated, drawing changes into picture on canvas, then by canvas, comes with the library rgbaster.js Calculate the main color of picture.
By the above process, designer only need out original image be given to foreground client, blur radius can be modified at any time, and Not the step for not needing to upload to picture into background server, then being recalculated by server.That is by foreground client End carries out Gaussian Blur processing to picture, extracts main color, and displaying etc. on dom element.Reduce manpower, reduces simultaneously One request initiated to backstage, it is also easier in process.
Optionally, in the present embodiment, using the pixel data in canvas, carry out Gaussian Blur, reconvert at picture, The main color of picture is obtained using rgbaster.js.
The principle of rgbaster.js is exactly to intercept out by the pixel data on picture, be then arranged one it is non-computational Pixel, such as black white;Its allochromatic colour is compared, that value of most colors is exactly the picture after Gaussian Blur Main color.
Optionally, in the present embodiment, as shown in fig. 6, the extraction process of the main color of picture the following steps are included:
Step 1, picture is changed into canvas, and sets blur radius.
Step 2, Gaussian Blur processing is carried out to the pixel data in canvas, obtains the rgb value after each pixel obscures.
Step 3, rgb value of each pixel after fuzzy is redrawn on canvas.
Step 4, canvas is changed into picture.
Step 5, the main color of picture is obtained with rgbaster.js.
The above process makes designer when modification blur radius sees effect, can quickly obtain main color, and The step that picture is uploaded to backstage is not needed.Server can reduce the step of calculating, while foreground is not needed to clothes The interface for device request color of being engaged in;Designer does not need to go out again figure to backstage when modifying blur radius yet.Reach and has subtracted Few manpower, reduces step, reduces the effect of the time of calculating.
Another aspect according to an embodiment of the present invention additionally provides a kind of for implementing the acquisition of the main color of above-mentioned picture Electronic device, as shown in fig. 7, the electronic device includes: one or more (only showing one in figure) processors 702, storage Device 704, sensor 706, encoder 708 and transmitting device 710 are stored with computer program in the memory, the processor It is arranged to execute the step in any of the above-described embodiment of the method by computer program.
Optionally, in the present embodiment, above-mentioned electronic device can be located in multiple network equipments of computer network At least one network equipment.
Optionally, in the present embodiment, above-mentioned processor can be set to execute following steps by computer program:
S1, client obtain the first pictorial information;
S2, client call Gaussian Blur script carry out Gaussian Blur processing to the first pictorial information, obtain second picture Information;
S3, client extract the main color of picture from second picture information.
Optionally, it will appreciated by the skilled person that structure shown in Fig. 7 is only to illustrate, electronic device can also To be smart phone (such as Android phone, iOS mobile phone), tablet computer, palm PC and mobile internet device The terminal devices such as (Mobile Internet Devices, MID), PAD.Fig. 7 it does not cause to the structure of above-mentioned electronic device It limits.For example, electronic device may also include more or less component (such as network interface, display device than shown in Fig. 7 Deng), or with the configuration different from shown in Fig. 7.
Wherein, memory 702 can be used for storing software program and module, such as the main color of picture in the embodiment of the present invention Acquisition methods and the corresponding program instruction/module of device, processor 704 pass through the software that is stored in memory 702 of operation Program and module realize the control method of above-mentioned target element thereby executing various function application and data processing. Memory 702 may include high speed random access memory, can also include nonvolatile memory, such as one or more magnetic storage Device, flash memory or other non-volatile solid state memories.In some instances, memory 702 can further comprise relative to The remotely located memory of processor 704, these remote memories can pass through network connection to terminal.The example of above-mentioned network Including but not limited to internet, intranet, local area network, mobile radio communication and combinations thereof.
Above-mentioned transmitting device 710 is used to that data to be received or sent via a network.Above-mentioned network specific example It may include cable network and wireless network.In an example, transmitting device 710 includes a network adapter (Network Interface Controller, NIC), can be connected by cable with other network equipments with router so as to interconnection Net or local area network are communicated.In an example, transmitting device 710 is radio frequency (Radio Frequency, RF) module, For wirelessly being communicated with internet.
Wherein, specifically, memory 702 is for storing application program.
The embodiments of the present invention also provide a kind of storage medium, computer program is stored in the storage medium, wherein The computer program is arranged to execute the step in any of the above-described embodiment of the method when operation.
Optionally, in the present embodiment, above-mentioned storage medium can be set to store by executing based on following steps Calculation machine program:
S1, client obtain the first pictorial information;
S2, client call Gaussian Blur script carry out Gaussian Blur processing to the first pictorial information, obtain second picture Information;
S3, client extract the main color of picture from second picture information.
Optionally, storage medium is also configured to store for executing step included in the method in above-described embodiment Computer program, this is repeated no more in the present embodiment.
Optionally, in the present embodiment, those of ordinary skill in the art will appreciate that in the various methods of above-described embodiment All or part of the steps be that the relevant hardware of terminal device can be instructed to complete by program, the program can store in In one computer readable storage medium, storage medium may include: flash disk, read-only memory (Read-Only Memory, ROM), random access device (Random Access Memory, RAM), disk or CD etc..
The serial number of the above embodiments of the invention is only for description, does not represent the advantages or disadvantages of the embodiments.
If the integrated unit in above-described embodiment is realized in the form of SFU software functional unit and as independent product When selling or using, it can store in above-mentioned computer-readable storage medium.Based on this understanding, skill of the invention Substantially all or part of the part that contributes to existing technology or the technical solution can be with soft in other words for art scheme The form of part product embodies, which is stored in a storage medium, including some instructions are used so that one Platform or multiple stage computers equipment (can be personal computer, server or network equipment etc.) execute each embodiment institute of the present invention State all or part of the steps of method.
In the above embodiment of the invention, it all emphasizes particularly on different fields to the description of each embodiment, does not have in some embodiment The part of detailed description, reference can be made to the related descriptions of other embodiments.
In several embodiments provided herein, it should be understood that disclosed client, it can be by others side Formula is realized.Wherein, the apparatus embodiments described above are merely exemplary, such as the division of the unit, and only one Kind of logical function partition, there may be another division manner in actual implementation, for example, multiple units or components can combine or It is desirably integrated into another system, or some features can be ignored or not executed.Another point, it is shown or discussed it is mutual it Between coupling, direct-coupling or communication connection can be through some interfaces, the INDIRECT COUPLING or communication link of unit or module It connects, can be electrical or other forms.
The unit as illustrated by the separation member may or may not be physically separated, aobvious as unit The component shown may or may not be physical unit, it can and it is in one place, or may be distributed over multiple In network unit.It can select some or all of unit therein according to the actual needs to realize the mesh of this embodiment scheme 's.
It, can also be in addition, the functional units in various embodiments of the present invention may be integrated into one processing unit It is that each unit physically exists alone, can also be integrated in one unit with two or more units.Above-mentioned integrated list Member both can take the form of hardware realization, can also realize in the form of software functional units.
The above is only a preferred embodiment of the present invention, it is noted that for the ordinary skill people of the art For member, various improvements and modifications may be made without departing from the principle of the present invention, these improvements and modifications are also answered It is considered as protection scope of the present invention.

Claims (15)

1. a kind of acquisition methods of the main color of picture characterized by comprising
Client obtains the first pictorial information;
The client call Gaussian Blur script carries out Gaussian Blur processing to first pictorial information, obtains second picture Information;
The client extracts the main color of picture from the second picture information.
2. the method according to claim 1, wherein client acquisition first pictorial information includes:
The client obtains the first picture to be processed;
The client obtains the first Pixel Information of each pixel on first picture, obtains the first Pixel Information collection It closes;
The first Pixel Information set is determined as first pictorial information by the client.
3. according to the method described in claim 2, it is characterized in that, the client obtains each pixel on first picture First Pixel Information of point, obtaining the first Pixel Information set includes:
First picture is plotted in the first canvas element by the client, wherein first canvas element is for holding Carry the image information being plotted in first canvas element;
The client is from the first Pixel Information for extracting each pixel on first picture in first canvas element;
First Pixel Information of each pixel on first picture is determined as first Pixel Information by the client Set.
4. according to the method described in claim 2, it is characterized in that, Gaussian Blur script is to described described in the client call First pictorial information carries out Gaussian Blur processing, and obtaining second picture information includes:
Gaussian Blur script described in the client call carries out Gaussian Blur processing to the first Pixel Information set, obtains Second Pixel Information set, wherein the second Pixel Information set includes that each pixel is handled by Gaussian Blur The second Pixel Information afterwards;
The second Pixel Information set is determined as the second picture information by the client;Alternatively, the client will The second Pixel Information set is converted to second picture, and the second picture is determined as the second picture information.
5. according to the method described in claim 4, it is characterized in that, the client converts the second Pixel Information set Include: for the second picture
The second Pixel Information set is plotted in the second canvas element by the client, wherein the second painting canvas member Element is for carrying the image information being plotted in second canvas element;
The the second Pixel Information set carried in second canvas element is converted into second figure by the client Piece.
6. according to the method described in claim 4, it is characterized in that, the second picture is determined as in the client described In the case where second picture information, the client extracts the main color of the picture from the second picture information and includes:
The main color of client call picture obtains script;
The client obtains script to obtain the picture from the second picture main by running the main color of the picture Color.
7. according to the method described in claim 4, it is characterized in that, in the client that the second Pixel Information set is true In the case where being set to the second picture information, the client extracts the main color of the picture from the second picture information Include:
Second Pixel Information of each pixel is compared the client with object pixel, obtains each institute State the corresponding comparison value of the second Pixel Information;
The client counts the distribution of the comparison value, obtains the frequency of occurrence of each comparison value in the comparison value;
The highest comparison value of the frequency of occurrence is determined as target comparison value by the client;
Corresponding second Pixel Information of the target comparison value is determined as the main color of the picture by the client.
8. the method according to claim 1, wherein the client call Gaussian Blur script is to described first Pictorial information carries out Gaussian Blur processing, and obtaining second picture information includes:
The client receives target Gaussian Blur radius, and calls the Gaussian Blur script;
The client sets described for the Gaussian Blur radius for including in the Gaussian Blur parameter of the Gaussian Blur script Target Gaussian Blur radius;
The client is arranged to the Gaussian Blur script of the target Gaussian Blur radius using Gaussian Blur radius Gaussian Blur processing is carried out to first pictorial information, obtains second picture information.
9. according to the method described in claim 8, it is characterized in that, the client is arranged to institute using Gaussian Blur radius It states the Gaussian Blur script of target Gaussian Blur radius and Gaussian Blur processing is carried out to first pictorial information, obtain the Two pictorial informations include:
It is the target Gauss that the client, which obtains target pixel points in Gaussian Blur radius by the Gaussian Blur script, Corresponding first weight matrix in the case where blur radius, wherein first pictorial information includes the target pixel points pair The Pixel Information answered;
The client is normalized first weight matrix by the Gaussian Blur script, obtains the second power Weight matrix;
The client is by the Gaussian Blur script to second weight matrix picture corresponding with the target pixel points Prime information carries out operation, obtains the corresponding Gaussian Blur processing result of the target pixel points, wherein the second picture information Including the corresponding Gaussian Blur processing result of the target pixel points.
10. according to the method described in claim 9, it is characterized in that, the client is by the Gaussian Blur script to institute It states the second weight matrix Pixel Information corresponding with the target pixel points and carries out operation, it is corresponding to obtain the target pixel points Gaussian Blur processing result includes:
The client obtains the mesh from the corresponding Pixel Information of the target pixel points by the Gaussian Blur script Mark the corresponding multiple picture element matrixs of pixel, wherein the multiple picture element matrix include in multiple Color Channels each color it is logical The picture element matrix in road;
The client is by the Gaussian Blur script respectively by second weight matrix and each Color Channel Corresponding element carries out multiplying in picture element matrix, obtains and the multiple Color Channel multiple object pixels correspondingly Matrix;
The multiple object pixel matrix is determined as the corresponding Gaussian Blur processing knot of the target pixel points by the client Fruit.
11. a kind of acquisition device of the main color of picture, which is characterized in that the acquisition device of the main color of picture is applied to client End, the acquisition device of the main color of picture include:
Module is obtained, for obtaining the first pictorial information;
Processing module obtains second for calling Gaussian Blur script to carry out Gaussian Blur processing to first pictorial information Pictorial information;
Extraction module, for extracting the main color of picture from the second picture information.
12. device according to claim 11, which is characterized in that obtaining module includes:
First acquisition unit, for obtaining the first picture to be processed;
Second acquisition unit obtains the first pixel for obtaining the first Pixel Information of each pixel on first picture Information aggregate;
First determination unit, for the first Pixel Information set to be determined as first pictorial information.
13. device according to claim 11, which is characterized in that processing module includes:
Receiving unit for receiving target Gaussian Blur radius, and calls the Gaussian Blur script;
Setting unit, for setting institute for the Gaussian Blur radius for including in the Gaussian Blur parameter of the Gaussian Blur script State target Gaussian Blur radius;
The second processing unit, for being arranged to the Gaussian mode of the target Gaussian Blur radius using Gaussian Blur radius It pastes script and Gaussian Blur processing is carried out to first pictorial information, obtain second picture information.
14. a kind of storage medium, which is characterized in that be stored with computer program in the storage medium, wherein the computer Program is arranged to execute method described in any one of claims 1 to 10 when operation.
15. a kind of electronic device, including memory and processor, which is characterized in that be stored with computer journey in the memory Sequence, the processor are arranged to execute side described in any one of claims 1 to 10 by the computer program Method.
CN201810473591.2A 2018-05-17 2018-05-17 Picture primary color acquisition method and device, storage medium and electronic device Active CN110503695B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810473591.2A CN110503695B (en) 2018-05-17 2018-05-17 Picture primary color acquisition method and device, storage medium and electronic device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810473591.2A CN110503695B (en) 2018-05-17 2018-05-17 Picture primary color acquisition method and device, storage medium and electronic device

Publications (2)

Publication Number Publication Date
CN110503695A true CN110503695A (en) 2019-11-26
CN110503695B CN110503695B (en) 2023-05-30

Family

ID=68584867

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810473591.2A Active CN110503695B (en) 2018-05-17 2018-05-17 Picture primary color acquisition method and device, storage medium and electronic device

Country Status (1)

Country Link
CN (1) CN110503695B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106339983A (en) * 2016-08-17 2017-01-18 乐视控股(北京)有限公司 Blurring animation realization method through Gaussian blurring and blurring animation realization device thereof
US20170154450A1 (en) * 2015-11-30 2017-06-01 Le Shi Zhi Xin Electronic Technology (Tianjin) Limited Multimedia Picture Generating Method, Device and Electronic Device
CN106898026A (en) * 2017-03-15 2017-06-27 腾讯科技(深圳)有限公司 The dominant hue extracting method and device of a kind of picture
CN107610063A (en) * 2017-09-04 2018-01-19 广州优视网络科技有限公司 A kind of method and apparatus for carrying out Gaussian Blur processing under Android system to picture

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170154450A1 (en) * 2015-11-30 2017-06-01 Le Shi Zhi Xin Electronic Technology (Tianjin) Limited Multimedia Picture Generating Method, Device and Electronic Device
CN106339983A (en) * 2016-08-17 2017-01-18 乐视控股(北京)有限公司 Blurring animation realization method through Gaussian blurring and blurring animation realization device thereof
CN106898026A (en) * 2017-03-15 2017-06-27 腾讯科技(深圳)有限公司 The dominant hue extracting method and device of a kind of picture
CN107610063A (en) * 2017-09-04 2018-01-19 广州优视网络科技有限公司 A kind of method and apparatus for carrying out Gaussian Blur processing under Android system to picture

Also Published As

Publication number Publication date
CN110503695B (en) 2023-05-30

Similar Documents

Publication Publication Date Title
CN107463949B (en) Video action classification processing method and device
CN111833340B (en) Image detection method, device, electronic equipment and storage medium
CN103973977B (en) Virtualization processing method, device and the electronic equipment of a kind of preview interface
CN108765278A (en) A kind of image processing method, mobile terminal and computer readable storage medium
CN110310229A (en) Image processing method, image processing apparatus, terminal device and readable storage medium storing program for executing
CN105118027B (en) A kind of defogging method of image
CN111985281B (en) Image generation model generation method and device and image generation method and device
CN111783803B (en) Image processing method and device for realizing privacy protection
CN108304839A (en) A kind of image processing method and device
CN110599554A (en) Method and device for identifying face skin color, storage medium and electronic device
CN110084765A (en) A kind of image processing method, image processing apparatus and terminal device
CN107808109A (en) A kind of image in 2 D code recognition methods and mobile terminal
CN108805873A (en) Image processing method and device
CN110838088B (en) Multi-frame noise reduction method and device based on deep learning and terminal equipment
CN105678834B (en) Method and device for distinguishing objects
CN108377372B (en) A kind of white balancing treatment method, device, terminal device and storage medium
CN104010134B (en) For forming the system and method with wide dynamic range
CN112489144A (en) Image processing method, image processing apparatus, terminal device, and storage medium
CN114257730A (en) Image data processing method and device, storage medium and computer equipment
CN113538304A (en) Training method and device of image enhancement model, and image enhancement method and device
CN110414596A (en) Video processing, model training method and device, storage medium and electronic device
CN110503695A (en) Acquisition methods, device, storage medium and the electronic device of the main color of picture
CN112836706A (en) Processing method, device and equipment for clothes color identification and storage medium
CN112831982A (en) Processing method, device and equipment for clothes color identification and storage medium
EP3384673B1 (en) Noise-cancelling filter for video images

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant