Summary of the invention
In view of the above problems, the present invention is proposed to provide a kind of method of adding watermark in picture, device and the computing equipment that overcome the problems referred to above or solve the problem at least in part.
According to an aspect of the present invention, provide a kind of method of adding watermark in picture, described method performs in computing equipment, and comprises the steps: from Target Photo, mark off multiple region; For each region in described multiple region, the color value based on pixel each in this region calculates the color value variance in this region; Watermark picture as target area, and is added to the described target area of described Target Photo by the minimum region of the value variance that gets colors from described multiple region.
Alternatively, adding in picture in the method for watermark according to of the present invention, described multiple region is positioned at four limits of described Target Photo, or described multiple region is positioned at the corner of described Target Photo.
Alternatively, adding in the method for watermark according to of the present invention in picture, the size in each region marked off equals the size of described watermark picture.
Alternatively, adding in picture in the method for watermark according to of the present invention, according to the color value variance s in following this region of formulae discovery2:
Wherein, xifor the color value of i-th pixel in this region, x is the mean value of the color value of all pixels in this region, and N is the pixel number that this region comprises.
Alternatively, adding in the method for watermark according to of the present invention in picture, the color value of each pixel adopts gray-scale value.
According to a further aspect in the invention, provide a kind of device adding watermark in picture, described device resides in computing equipment, and comprises: Region dividing module, is suitable for from Target Photo, mark off multiple region; Variance computing module, be suitable for for each region in described multiple region, the color value based on pixel each in this region calculates the color value variance in this region; Module is added in watermark, and watermark picture as target area, and is added to the described target area of described Target Photo by the minimum region of the value variance that is suitable for getting colors from described multiple region.
Alternatively, adding in picture in the device of watermark according to of the present invention, described multiple region is positioned at four limits of described Target Photo, or described multiple region is positioned at the corner of described Target Photo.
Alternatively, adding in the device of watermark according to of the present invention in picture, the size in each region marked off equals the size of described watermark picture.
Alternatively, adding in picture in the device of watermark according to of the present invention, described variance computing module is according to the color value variance s in following this region of formulae discovery2:
Wherein, xifor the color value of i-th pixel in this region, x is the mean value of the color value of all pixels in this region, and N is the pixel number that this region comprises.
Alternatively, adding in the device of watermark according to of the present invention in picture, the color value of each pixel adopts gray-scale value.
According to another aspect of the invention, provide a kind of computing equipment, the resident with good grounds device adding watermark in picture of the present invention in this computing equipment.
According to scheme of adding watermark in picture of the present invention, by calculating the color value variance in each region in picture, the region that picture information quantity is minimum can be automatically identified, watermark is added to the propagation that this region can not affect picture self-information, and save manpower and time cost.
Above-mentioned explanation is only the general introduction of technical solution of the present invention, in order to technological means of the present invention can be better understood, and can be implemented according to the content of instructions, and can become apparent, below especially exemplified by the specific embodiment of the present invention to allow above and other objects of the present invention, feature and advantage.
Embodiment
Below with reference to accompanying drawings exemplary embodiment of the present disclosure is described in more detail.Although show exemplary embodiment of the present disclosure in accompanying drawing, however should be appreciated that can realize the disclosure in a variety of manners and not should limit by the embodiment set forth here.On the contrary, provide these embodiments to be in order to more thoroughly the disclosure can be understood, and complete for the scope of the present disclosure can be conveyed to those skilled in the art.
Fig. 1 shows the method flow diagram adding watermark according to an embodiment of the invention in picture, and the method is suitable for performing in computing equipment.With reference to Fig. 1, the method starts from step S102, in step s 102, according to the size of watermark picture, to needing the Target Photo adding watermark to carry out Region dividing, to mark off multiple region from this Target Photo, follow-up, can from marked off multiple regions, select a suitable region to add watermark picture.In one implementation, the size in each region marked off equals the size of described watermark picture.Certainly, the size in each region marked off also can slightly larger than the size of described watermark picture.Wherein, described Target Photo can be the picture of arbitrary format, such as, be the forms such as Jpg, Gif.
Region dividing can be carried out to whole Target Photo, be divided into the region of multiple pre-sizing by whole Target Photo.Generally speaking, the quantity of information of center picture is larger, the quantity of information of picture surrounding (such as four limits or corner) is less, and, according to custom or the style of website, generally can not add watermark to center picture, therefore, for saving calculated amount and keeping the attractive in appearance of picture, only Region dividing can be carried out to the predetermined portions of Target Photo, such as only carry out Region dividing to four limits of Target Photo or corner, namely marked off multiple regions are positioned at four limits or the corner of described Target Photo.
In step S104, for each region in described multiple region, the color value based on pixel each in this region calculates the color value variance in this region, wherein, and color value variance s2computing formula as follows:
In formula (1), xifor the color value of i-th pixel in this region, x is the mean value of the color value of all pixels in this region, and N is the pixel number that this region comprises.
The concrete computation process of color value variance can comprise:
First, the color value of each pixel in this region is obtained.Color space in picture generally adopts RGB model, in RGB model, often kind of color has R, G, B tri-components, and the span of each component is 0 ~ 255, R, G, B component, according to the mixing of different ratios, can represent that 16777216 (256*256*256) plant color.
Secondly, gray processing process is carried out to the RGB color value of each pixel, obtain corresponding gray-scale value.Common picture is all generally bright and colourful, but often has many interference for calculating, carries out the operation of gray processing dimensionality reduction to it, is more conducive to like this calculate.In the gray space of color, there being black-ash-Bai continually varying gray-scale value to be quantified as 256 gray levels, the scope of gray-scale value is 0 ~ 255, represents that brightness is from dark to shallow, and the color in correspondence image is from black in vain.Can adopt and carry out gray processing process in various manners, such as, following formula can be adopted to carry out gray processing process:
Gray-scale value=0.299*R component+0.587*G component+0.114*B component (2)
Then, the mean value of the gray-scale value of all pixels in this region is calculated.
Finally, using pixel gray-scale value each in this region as its color value, using the mean value of the mean value of gray-scale value as color value, be brought in formula (1), obtain the color value variance in this region.
In step s 106, watermark picture as target area, and is added to the described target area of described Target Photo by the minimum region of the value variance that gets colors from described multiple region.
In theory of probability and mathematical statistics, variance (Variance) is used to the index of the departure degree between tolerance one group of its mathematical expectation of random sum (i.e. mean value), and variance is less, then departure degree is less.And picture is made up of the pixel of shades of colour, calculate the color value variance in certain region of picture, what in fact reflect is whether the color value of each pixel in this region fluctuates greatly, color value variance is large, then illustrate that this region is combined by shades of colour, varied, inevitable polymorphic colourful, the quantity of information comprised is just large.That is, color value variance is larger, represent the quantity of information that this region comprises larger, otherwise color value variance is less, represents the quantity of information that this region comprises less.
Therefore, in the present invention, by calculating the color value variance in each region in picture, automatically identifying the region that picture information quantity is minimum, watermark being added to the propagation that this region can not affect picture self-information, and save manpower and time cost.
Below provide and utilize the example adding the method for watermark in picture of the present invention.Wherein, as shown in Figure 3, watermark picture as shown in Figure 4 for the Target Photo of watermark to be added.
First, Region dividing is carried out.For saving calculated amount, not adopting and carry out Region dividing to whole pictures, but mark off four regions from the corner of Target Photo, is upper left side, upper right side, lower left, region, four, lower right respectively, the size in each region equals the size of watermark picture, is 50 × 50.
Then, calculate the color value variance in each region respectively, result of calculation is as follows:
Color value variance=10097665251117.729, upper left side
Color value variance=64154924124.5772, upper right side
Color value variance=1141743232163.3313, lower left
Color value variance=641944151052.47559, lower right
Finally, through comparing, find that the color value variance in region, upper right side is minimum, so, add watermark picture to this region.With the addition of the Target Photo after watermark as shown in Figure 5.
According to above-mentioned example, the upper right side field color value variance calculated is minimum, and lower right field color value variance is taken second place, and it is the most reasonable that watermark picture is added on region, upper right side, and this is consistent with the recognition result of artificial naked eyes.
Corresponding with above-mentioned method of adding watermark in picture, the embodiment of the present invention also provides a kind of device realizing said method.
Fig. 2 shows the structure drawing of device adding watermark according to an embodiment of the invention in picture, and this device resides in computing equipment.With reference to Fig. 2, this device comprises Region dividing module 210, variance computing module 220 and watermark and adds module 230.
Region dividing module 210 is suitable for from Target Photo, mark off multiple region.Can according to the size of watermark picture, to needing the Target Photo adding watermark to carry out Region dividing, to mark off multiple region from this Target Photo, follow-up, can from marked off multiple regions, select a suitable region to add watermark picture.In one implementation, the size in each region marked off equals the size of described watermark picture.Certainly, the size in each region marked off also can slightly larger than the size of described watermark picture.Wherein, described Target Photo can be the picture of arbitrary format, such as, be the forms such as Jpg, Gif.
Region dividing can be carried out to whole Target Photo, be divided into the region of multiple pre-sizing by whole Target Photo.Generally speaking, the quantity of information of center picture is larger, the quantity of information of picture surrounding (such as four limits or corner) is less, and, according to custom or the style of website, generally can not add watermark to center picture, therefore, for saving calculated amount and keeping the attractive in appearance of picture, only Region dividing can be carried out to the predetermined portions of Target Photo, such as only carry out Region dividing to four limits of Target Photo or corner, namely marked off multiple regions are positioned at four limits or the corner of described Target Photo.
Variance computing module 220 is suitable for for each region in described multiple region, and the color value based on pixel each in this region calculates the color value variance in this region.The computing formula of color value variance and computation process can refer to above-mentioned embodiment of the method, do not repeat here.
Watermark is added module 230 and is suitable for getting colors the minimum region of value variance from described multiple region as target area, and watermark picture is added to the described target area of described Target Photo.
Fig. 6 is arranged as to realize according to the block diagram adding the Example Computing Device 900 of the method for watermark in picture of the present invention.
In basic configuration 902, computing equipment 900 typically comprises system storage 906 and one or more processor 904.Memory bus 908 may be used for the communication between processor 904 and system storage 906.
Depend on the configuration of expectation, processor 904 can be the process of any type, includes but not limited to: microprocessor (μ P), microcontroller (μ C), digital information processor (DSP) or their any combination.Processor 904 can comprise the high-speed cache of one or more rank of such as on-chip cache 910 and second level cache 912 and so on, processor core 914 and register 916.The processor core 914 of example can comprise arithmetic and logical unit (ALU), floating-point unit (FPU), digital signal processing core (DSP core) or their any combination.The Memory Controller 918 of example can use together with processor 904, or in some implementations, Memory Controller 918 can be an interior section of processor 904.
Depend on the configuration of expectation, system storage 906 can be the storer of any type, includes but not limited to: volatile memory (such as RAM), nonvolatile memory (such as ROM, flash memory etc.) or their any combination.System storage 906 can comprise operating system 920, one or more application 922 and routine data 924.Application 922 can comprise the device 926 adding watermark in picture being configured to realize adding the method for watermark in picture.Routine data 924 can comprise and can be used for color value variance 928 as described here.In some embodiments, application 922 can be arranged as and utilize routine data 924 to operate on an operating system.
Computing equipment 900 can also comprise the interface bus 940 communicated contributed to from various interfacing equipment (such as, output device 942, Peripheral Interface 944 and communication facilities 946) to basic configuration 902 via bus/interface controller 930.The output device 942 of example comprises Graphics Processing Unit 948 and audio treatment unit 950.They can be configured to contribute to communicating with the various external units of such as display or loudspeaker and so on via one or more A/V port 952.Example Peripheral Interface 944 can comprise serial interface controller 954 and parallel interface controller 956, they can be configured to the external unit contributed to via one or more I/O port 958 and such as input equipment (such as, keyboard, mouse, pen, voice-input device, touch input device) or other peripheral hardwares (such as printer, scanner etc.) and so on and communicate.The communication facilities 946 of example can comprise network controller 960, and it can be arranged to is convenient to via one or more communication port 964 and the communication of one or more other computing equipments 962 by network communication link.
Network communication link can be an example of communication media.Communication media can be presented as computer-readable instruction, data structure, program module in the modulated data signal of such as carrier wave or other transmission mechanisms and so on usually, and can comprise any information delivery media." modulated data signal " can be such signal, the change of one or more or it of its data centralization can the mode of coded message in the signal be carried out.As nonrestrictive example, communication media can comprise the wire medium of such as cable network or private line network and so on, and such as sound, radio frequency (RF), microwave, infrared (IR) or other wireless medium are at interior various wireless mediums.Term computer-readable medium used herein can comprise both storage medium and communication media.
Computing equipment 900 can be implemented as a part for small size portable (or mobile) electronic equipment, and these electronic equipments can be such as cell phone, personal digital assistant (PDA), personal media player equipment, wireless network browsing apparatus, individual helmet, application specific equipment or the mixing apparatus that can comprise any function above.Computing equipment 900 can also be embodied as the personal computer comprising desktop computer and notebook computer configuration.
Intrinsic not relevant to any certain computer, virtual system or miscellaneous equipment with display at this algorithm provided.Various general-purpose system also can with use based on together with this teaching.According to description above, the structure constructed required by this type systematic is apparent.In addition, the present invention is not also for any certain programmed language.It should be understood that and various programming language can be utilized to realize content of the present invention described here, and the description done language-specific is above to disclose preferred forms of the present invention.
In instructions provided herein, describe a large amount of detail.But can understand, embodiments of the invention can be put into practice when not having these details.In some instances, be not shown specifically known method, structure and technology, so that not fuzzy understanding of this description.
Similarly, be to be understood that, in order to simplify the disclosure and to help to understand in each inventive aspect one or more, in the description above to exemplary embodiment of the present invention, each feature of the present invention is grouped together in single embodiment, figure or the description to it sometimes.But, the method for the disclosure should be construed to the following intention of reflection: namely the present invention for required protection requires feature more more than the feature clearly recorded in each claim.Or rather, as claims below reflect, all features of disclosed single embodiment before inventive aspect is to be less than.Therefore, the claims following embodiment are incorporated to this embodiment thus clearly, and wherein each claim itself is as independent embodiment of the present invention.
Those skilled in the art are appreciated that and adaptively can change the module in the equipment in embodiment and they are arranged in one or more equipment different from this embodiment.Module in embodiment or unit or assembly can be combined into a module or unit or assembly, and multiple submodule or subelement or sub-component can be put them in addition.Except at least some in such feature and/or process or unit be mutually repel except, any combination can be adopted to combine all processes of all features disclosed in this instructions (comprising adjoint claim, summary and accompanying drawing) and so disclosed any method or equipment or unit.Unless expressly stated otherwise, each feature disclosed in this instructions (comprising adjoint claim, summary and accompanying drawing) can by providing identical, alternative features that is equivalent or similar object replaces.
In addition, those skilled in the art can understand, although embodiments more described herein to comprise in other embodiment some included feature instead of further feature, the combination of the feature of different embodiment means and to be within scope of the present invention and to form different embodiments.Such as, in the following claims, the one of any of embodiment required for protection can use with arbitrary array mode.
All parts embodiment of the present invention with hardware implementing, or can realize with the software module run on one or more processor, or realizes with their combination.It will be understood by those of skill in the art that the some or all functions of adding the some or all parts in the device of watermark in picture that microprocessor or digital signal processor (DSP) can be used in practice to realize according to the embodiment of the present invention.The present invention can also be embodied as part or all equipment for performing method as described herein or device program (such as, computer program and computer program).Realizing program of the present invention and can store on a computer-readable medium like this, or the form of one or more signal can be had.Such signal can be downloaded from internet website and obtain, or provides on carrier signal, or provides with any other form.
The present invention will be described instead of limit the invention to it should be noted above-described embodiment, and those skilled in the art can design alternative embodiment when not departing from the scope of claims.In the claims, any reference symbol between bracket should be configured to limitations on claims.Word " comprises " not to be got rid of existence and does not arrange element in the claims or step.Word "a" or "an" before being positioned at element is not got rid of and be there is multiple such element.The present invention can by means of including the hardware of some different elements and realizing by means of the computing machine of suitably programming.In the unit claim listing some devices, several in these devices can be carry out imbody by same hardware branch.Word first, second and third-class use do not represent any order.Can be title by these word explanations.