Summary of the invention
For addressing the above problem, the object of the present invention is to provide a kind of digital watermark method and system based on the DWT territory, to realize embedding and extraction, guarantee the disguise and the security of watermark for the blind watermarking images of gray scale.
For realizing above-mentioned purpose, technical scheme of the present invention is:
A kind of digital watermark method based on the DWT territory comprises the embedding of watermark and the extraction of watermark, and wherein, the embedding of watermark comprises the steps:
S10: obtain the original color image of treating embed watermark and the gray scale watermarking images that will embed;
S12: original color image is carried out the color space conversion of YUV, and the Y component of the original color image after the conversion is carried out the secondary wavelet transformation;
S13: to the pre-service of gray scale watermarking images inverse, the later gray scale watermarking images of inverse pre-service is carried out wavelet transformation one time, and cast out high frequency diagonal subband part wherein;
S14: the wavelet coefficient low frequency sub-band behind the gray scale watermarking images wavelet transformation is carried out difference preserve;
S15: carry out carrying out sequence permutation together with watermark inverse pre-service variable again after low frequency coefficient, other wavelet conversion coefficients that difference preserves multiply by coefficient separately, and putting in order as a close spoon;
S16: the size through calculating original color image and gray scale watermarking images is confirmed the number of times that coefficient sequence need repeat to embed;
S17: the sequence among the step S15 set by step the multiplicity that calculates of S16 be embedded in the original image secondary wavelet conversion coefficient diagonal angle subband;
S18: will embed coloured image behind the coefficient and carry out the secondary inverse wavelet transform and obtain the Y component, and carry out the conversion of color space, and obtain the later image of embed watermark with the Cr and the Cb component of original image;
The extraction of watermark comprises the steps:
S20: the image behind the embed watermark is carried out the YUV color space conversion, and carry out the secondary wavelet transformation to Y component wherein;
S21: each subband and the inverse pre-service decision variable ε ' that extract the diagonal angle high-frequency sub-band part of secondary wavelet transformation according to the close spoon among the step S15 gray scale watermarking images.
S22: the full spot patch of gray scale watermarking images wavelet coefficient diagonal angle subband is complete, carry out inverse wavelet transform to the diagonal angle subband of each sub-band coefficients mean value that obtains and full zero setting one time, the gray scale watermarking images that obtains extracting.
A kind of digital watermarking system based on the DWT territory; Comprise watermark embedded part and watermark extracting part; Wherein, The watermark embedded part comprises: be used to obtain the original color image of treating embed watermark and the gray scale watermarking images that will embed image acquisition unit, be connected the color space conversion that image acquisition unit is used for the original color image of obtaining is carried out YUV; And the color space conversion that the Y component of the original color image after the conversion is carried out the secondary wavelet transformation is with the secondary wavelet transform unit, be connected with the secondary wavelet transform unit with color space conversion; In order to the pre-service of gray scale watermarking images inverse; The later gray scale watermarking images of inverse pre-service is carried out wavelet transformation one time; And the inverse pre-service of casting out high frequency diagonal subband part wherein is connected with wavelet transform unit to be used for that the wavelet coefficient low frequency sub-band behind the gray scale watermarking images wavelet transformation is carried out difference that difference preserves with wavelet transform unit, with the inverse pre-service and preserves the unit, preserves the unit with difference and be connected and carry out sequence permutation with watermark inverse pre-service variable again after multiply by coefficient separately with low frequency coefficient, other wavelet conversion coefficients with the difference preservation; And be connected size as the sequence permutation unit of a close spoon, with the sequence permutation unit putting in order with calculating original color image and gray scale watermarking images; Confirm number of times that coefficient sequence need repeat to embed repeat embed the number of times computing unit, with repeat to embed the number of times computing unit and be connected so that the sequence in the sequence permutation unit is embedded the unit, is connected with sequence embedding unit will embed coloured image behind the coefficient and carries out the secondary inverse wavelet transform and obtain the Y component by repeating to embed sequence in the secondary wavelet conversion coefficient diagonal angle subband that multiplicity that the number of times computing unit calculates is embedded into original image, and the inverse transformation and the color space converting unit of carrying out color space conversion with the Cr and the Cb component of original image;
Complete and the inverse wavelet transform unit of the full spot patch of diagonal angle subband that watermark extracting partly includes converter unit, the extraction unit that is connected with converter unit, is connected with extraction unit; Wherein, The image of converter unit after with embed watermark carries out the YUV color space conversion, and carries out the secondary wavelet transformation to Y component wherein; Extraction unit extracts the diagonal angle high-frequency sub-band part of secondary wavelet transformation each subband and the inverse pre-service decision variable ε ' of gray scale watermarking images according to the close spoon in the sequence permutation unit of embed watermark part; Complete and the inverse wavelet transform unit is complete with the full spot patch of the wavelet coefficient diagonal angle subband of gray scale watermarking images by the full spot patch of diagonal angle subband then; Carry out inverse wavelet transform to the diagonal angle subband of each sub-band coefficients that obtains and full zero setting one time, the gray scale watermarking images that obtains extracting.
The digital watermark method that the present invention is based on the DWT territory is through the secondary wavelet transformation diagonal components sub-band coefficients with watermarking images wavelet coefficient replacement carrier image; Watermark information is embedded in the diagonal components of secondary wavelet transformation; Use the method for replacement watermark wavelet coefficient rather than employing quantification commonly used; Make again that when having realized blind watermark extracting the stability of this system is improved, guarantee the disguise and the security of watermark.
Embodiment
In order to make the object of the invention, technical scheme and advantage clearer,, the present invention is further elaborated below in conjunction with accompanying drawing and embodiment.Should be appreciated that specific embodiment described herein only in order to explanation the present invention, and be not used in qualification the present invention.
Please with reference to Fig. 1, shown in Figure 2, the digital watermark method that the present invention is based on the DWT territory comprises the embedding of watermark and the extraction of watermark.Wherein, The telescopiny of watermark is: original color image is carried out the conversion of YUV color space, the Y component is carried out the secondary wavelet transformation, carry out the inverse pre-service to the gray scale watermarking images then; Preserve its wavelet conversion coefficient through difference again; Encrypt to arrange the secondary wavelet transformation diagonal angle sub-band coefficients that replaces the Y component, at last the Y component after the replacement is carried out the secondary inverse wavelet transform, obtain the coloured image behind the embed watermark.And the leaching process of watermark is: the image of embed watermark is carried out the conversion of YUV color space; Then the Y component is carried out the secondary wavelet transformation; Carry out inverse wavelet transform then, the gray scale watermarking images that obtains extracting according to each Wavelet Component that obtains the gray scale watermark that puts in order of the encryption in the telescopiny.
As shown in Figure 1, it shows the embedding flow process diagram of watermark, and the embedding of watermark comprises the steps:
S10: obtain the original color image of treating embed watermark and the gray scale watermarking images that will embed;
S12: original color image is carried out the color space conversion of YUV, and the Y component of the original color image after the conversion is carried out the secondary wavelet transformation;
S13: to the pre-service of gray scale watermarking images inverse, the later gray scale watermarking images of inverse pre-service is carried out wavelet transformation one time, and cast out high frequency diagonal subband part wherein;
S14: the wavelet coefficient low frequency sub-band behind the gray scale watermarking images wavelet transformation is carried out difference preserve;
S15: carry out carrying out sequence permutation together with watermark inverse pre-service variable again after low frequency coefficient, other wavelet conversion coefficients that difference preserves multiply by coefficient separately, and putting in order as a close spoon;
S16: the size through calculating original color image and gray scale watermarking images is confirmed the number of times that coefficient sequence need repeat to embed;
S17: the sequence among the step S15 set by step the multiplicity that calculates of S16 be embedded in the original image secondary wavelet conversion coefficient diagonal angle subband;
S18: will embed coloured image behind the coefficient and carry out the secondary inverse wavelet transform and obtain the Y component, and carry out the conversion of color space, and obtain the later image of embed watermark with the Cr and the Cb component of original image.
Wherein,
In step S12, be that the original image of M * N carries out the conversion of color space to size, with the RGB color space conversion to the YUV color space; Y component is wherein carried out the secondary wavelet transformation, and the secondary wavelet transformation subband that obtains is designated as LL2 respectively, HL2, and LH2, HH2, as shown in Figure 3.
In step S13, the size that will embed is that the gray scale watermarking images of m * n carries out the inverse pre-service, and whether the positive and negative value record watermarking images through inverse variable ε had carried out inverse is handled.Image after then inverse being handled carries out wavelet transformation one time, and the low frequency coefficient matrix behind the wavelet transformation that obtains is designated as wLL, and the high frequency coefficient matrix is designated as wLH, wHL, and wHH, as shown in Figure 4.Wherein, through the gray scale watermarking images is carried out the calculating of average gray, whether determine whether carrying out inverse according to this mean value and handle greater than 127.Described inverse variable ε is a positive integer, if watermarking images by inverse, then set ε=-ε, otherwise keep initial value.In practical application, get ε=13, can obtain effect preferably.
In step S14, S15, wLL is carried out difference preserve, with each component and corresponding multiplication, obtain α wLL, β wLH, γ wHL again.Afterwards, α wLL, β wLH, coefficient among the γ wHL and ε are arranged in the sequence that becomes mn * 1 together, the order of wherein arranging can be used as a kind of means of encryption, when extracting watermark in order to the protection watermark information.It is a kind of way that former and later two coefficient differences replace the original coefficient value of preserving that described difference is preserved, and every separated δ coefficient value obtains raw value once more.In the practical application, get δ=4.The described cryptographic means that puts in order refers to α wLL, β wLH, and coefficient among the γ wHL and ε put in order, and through different putting in order, can produce the sequence of different mn * 1.When extracting, just can't not obtain correct α wLL, β wLH, γ wHL if know correct putting in order.
In step S16, S17; Calculate the number of times that repeat to embed according to
, the mn among the step S15 * 1 sequence is repeated the HH2 diagonal angle high-frequency sub-band that the inferior replacement of N ' finishes the secondary wavelet conversion coefficient of the Y component that obtains among the step S12.
In step S18, the image after the replacement is carried out the secondary inverse wavelet transform, obtain the Y component, combine with before Cr and Cb component again and carry out the conversion of color space, obtain the watermark embedded images of RGB form.
As shown in Figure 2, it shows the extraction flow process diagram of watermark, and the extraction of watermark comprises the steps:
S20: the image behind the embed watermark is carried out the YUV color space conversion, and carry out the secondary wavelet transformation to Y component wherein;
S21: each subband and the inverse pre-service decision variable ε ' that extract the diagonal angle high-frequency sub-band part of secondary wavelet transformation according to the close spoon among the step S15 gray scale watermarking images.
S22: the full spot patch of gray scale watermarking images wavelet coefficient diagonal angle subband is complete, carry out inverse wavelet transform to the diagonal angle subband of each sub-band coefficients mean value that obtains and full zero setting one time, the gray scale watermarking images that obtains extracting.
Wherein,
In step S20, S21; Image behind the embed watermark is carried out the YUV color space conversion; Wherein Y component through row secondary wavelet transformation, is extracted HH2 diagonal angle subband component wherein, and extract wavelet coefficient α wLL ' respectively according to the close spoon among the step S15; β wLH ', γ wHL ' and inverse processing parameter ε '.
In step S22, try to achieve the mean value that all repeat to embed coefficient according to repeating to embed number of times, with α wLL ', β wLH '; γ wHL ' corresponding average multiply by coefficient 1/ α, 1/ β, and 1/ γ obtains corresponding watermark wavelet transformation wLL '; WLH ' and wHL ' subband part, with wLL ', wLH '; WHL ' is combined into corresponding watermark wavelet sub-band, and the wHH that is not embedded into part just replaces with full zero coefficient subband, these coefficients is carried out an inverse wavelet transform obtain watermarking images.Wherein,, whether greater than zero, whether judge watermark, determine whether the watermarking images that needs inverse to obtain, so far obtain the gray scale watermarking images of required extraction by result of determination by inverse according to its value for the inverse variable ε ' mean value that obtains.Described alpha, beta, gamma are to be used for and wLL, wLH, and wHL subband matrix coefficient multiplies each other, and in the practical application, gets α=0.08, β=γ=0.12.
Please with reference to Fig. 5, shown in Figure 6, the Lena coloured image with 512 * 512 is an original image, and the gray level image with 32 * 32 is that the example of watermarking images comes the present invention's creation is described.
At first carrying out the embedding of watermark, is that M * N (512 * 512) Lena original image carries out the conversion of color space to size, and the RGB color space is converted to the YUV color space.Y component in the YUV color space is carried out the secondary wavelet transformation, obtain size and be four secondary wavelet transformation subband LL2 of 128 * 128, HL2, LH2, HH2, concrete sub-band division is as shown in Figure 3.Calculated size is the average gray value of m * n (64 * 64) gray scale watermarking images, and computing formula is following:
Wherein, Y
w(i, j) expression gray scale watermarking images is at (i, j) locational grey scale pixel value.If
Greater than 127, Y then
w(i, j)=| 255-Y
w(i, j) |, and be the inverse variable assignments ε=-13; If
Smaller or equal to 127, then keep Y
w(i, j) value is constant, and the inverse variable assignments is ε=13.
Image to after the inverse processing carries out wavelet transformation one time, and the low frequency coefficient matrix behind the wavelet transformation that obtains is designated as wLL, and the high frequency coefficient matrix is designated as wLH, wHL, wHH.Concrete sub-band division is as shown in Figure 4.The low frequency coefficient matrix wLL that obtains is carried out difference preserve, wherein, define the coefficient number interval that a variable δ representes to obtain once more non-difference watermark wavelet coefficient.Concrete grammar is following: establishing the original coefficient sequence is W
i(i representes i coefficient value in the sequence), δ=4, it is W that difference is preserved coefficient sequence
i', W then
1'=W
1, W
2'=W
1-W
2, W
3'=W
2-W
3, W
4'=W
3-W
4, W
5'=W
5....With watermark wavelet conversion coefficient value and corresponding alpha=0.08, multiplying each other in β=γ=0.12, obtains α wLL, β wLH, γ wHL.Afterwards, α wLL, β wLH, coefficient among the γ wHL and inverse variable ε are arranged in the sequence that becomes mn * 1 together.The order of wherein arranging can be used as a kind of means of encryption, when extracting watermark, can protect watermark information.Got α wLL (1,1) in the present embodiment, β wLH (1,1), γ wHL (1,1), ε, α wLL (1,2), β wLH (1,2)
The mode of ε arrange (wLL (and i, j) the coefficient value wLH of the capable j row of i in the expression wLL matrix of coefficients (i, j), wHL (i, j) in like manner).The mn that obtains * 1 sequence basis
What calculate repeats to embed number of times, repeats sequence to replace for 4 times the HH2 diagonal angle sub-band coefficients value of original image Y component.Wavelet coefficient image after the replacement is carried out the secondary inverse wavelet transform, obtain the Y component, combine with before Cr and Cb component again and carry out the conversion of color space, obtain the watermark embedded images of RGB form.
Secondly, carry out the extraction of watermarking images, the leaching process of watermarking images is: carry out the conversion of RGB color space to the YUV color space to containing watermarking images, and then Y color component is wherein carried out the secondary wavelet transformation.Obtain corresponding LL2 ', HL2 ', LH2 ', HH2 '.Put in order according to the encryption in the watermark embed process and to extract wavelet coefficient.Owing in implementation process, repeat to have embedded 4 times, institute is in the hope of α wLL ', β wLH '; γ wHL ', the mean value that these coefficients embed for 4 times, and ε ' is owing to replaced the embedding coefficient positions of wHH; So be embedded into 4096 times, equally also tried to achieve the mean value of ε '.With α wLL ', β wLH ', γ wHL ' and 1/ α, 1/ β, 1/ γ multiply each other and obtain to extract the wLL ' of watermarking images, wLH ', and wHL ' wavelet transformation sub-band coefficients, and the wHH that is not embedded into part just replaces with the full zero coefficient subband that waits size.This wavelet transformation time subband coefficient image is carried out inverse wavelet transform obtain the gray scale watermarking images.Whether greater than zero, judge that with this whether gray scale watermarking images is by inverse according to the mean value of ε '.If by inverse then Y
w' (i, j)=| 255-Y
w' (i, j) |, otherwise keep initial value constant.So far obtain the gray scale watermarking images of required extraction.Y wherein
w' (i, j) the gray scale watermarking images of expression extraction is at (i, j) locational grey scale pixel value.The extraction effect of watermarking images is shown in Fig. 6 (b).
To the result of the present embodiment test that makes an experiment, adopt Y-PSNR (PSNR) estimate embed watermark picture and original image between difference.PSNR is defined as:
Wherein I is an original image, and I ' is the image of embed watermark, and M and N are respectively the length and the wide pixel count of image.
Aspect evaluation watermark extracting effect, the watermark after use normalized correlation coefficient NC extracts in the test and the similarity of original watermark are passed judgment on.Corresponding formulas defines as follows:
Wherein, W representes original watermark, the watermark that W ' expression is extracted, and n and m are respectively the length and the wide pixel count of watermarking images.
According to the parameter value in the implementation process, the BMP image is embedded and extracts test, the PSNR=37.03 of the image behind the embed watermark, the NC=0.998 of the watermark that extracts, effect is shown in Fig. 6 (b).Shown in following table 1, table 2, table 3, its shown this digital watermarking system for JPEG compression, filtering, add and make an uproar and the 1/4 watermarking images extraction effect cut out under the attack condition.Wherein, table 1 for JPEG lossy compression method test, table 2 for add the attack test of making an uproar, table 3 is cut out test for medium filtering and 1/4.
Table 1
Can find out that from the result of table 1, table 2, table 3 digital watermark method of the present invention attacks for JPEG and add to make an uproar to attack better anti-attack effect is arranged; Is to have good resisting attacks ability at 3 * 3 o'clock for medium filtering in the wave filter size, also has good robustness to cutting out attack simultaneously.
See also shown in Figure 7ly,, a kind of digital watermarking system based on the DWT territory is provided also, comprise watermark embedded part and watermark extracting part as another embodiment of the present invention.The watermark embedded part includes image acquisition unit; The color space conversion and the secondary wavelet transform unit that connect image acquisition unit; Inverse pre-service and a wavelet transform unit of being connected with the secondary wavelet transform unit with color space conversion; Preserve the unit with the difference that the inverse pre-service is connected with wavelet transform unit; Preserve the sequence permutation unit that the unit is connected with difference; What be connected with the sequence permutation unit repeats to embed the number of times computing unit; With repeat to embed the sequence that the number of times computing unit is connected and embed the unit; Embed inverse transformation and the color space converting unit that the unit is connected with sequence.Wherein, Said image acquisition unit is used to obtain the original color image of treating embed watermark and the gray scale watermarking images that will embed; Color space conversion and secondary wavelet transform unit are carried out the color space conversion of YUV to the original color image of obtaining, and the Y component of the original color image after the conversion is carried out the secondary wavelet transformation; Simultaneously; Inverse pre-service and a wavelet transform unit are to the pre-service of gray scale watermarking images inverse; The later gray scale watermarking images of inverse pre-service is carried out wavelet transformation one time; And cast out high frequency diagonal subband part wherein, preserve the wavelet coefficient low frequency sub-band of unit after by difference then and carry out difference and preserve gray scale watermarking images wavelet transformation; After multiply by coefficient separately, low frequency coefficient, other wavelet conversion coefficients that difference is preserved in the sequence permutation unit carry out sequence permutation together with watermark inverse pre-service variable again, and putting in order as a close spoon; Repeat to embed the number of times computing unit and confirm the number of times that coefficient sequence need repeat to embed through the size of calculating original color image and gray scale watermarking images; Sequence embeds the unit sequence in the sequence permutation unit is embedded in the original image secondary wavelet conversion coefficient diagonal angle subband by repeating to embed the multiplicity that the number of times computing unit calculates; At last will embed coloured image behind the coefficient by inverse transformation and color space converting unit carries out the secondary inverse wavelet transform and obtains the Y component; And carry out the conversion of color space with the Cr and the Cb component of original image, obtain the later image of embed watermark.
Complete and the inverse wavelet transform unit of the full spot patch of diagonal angle subband that watermark extracting partly includes converter unit, the extraction unit that is connected with converter unit, is connected with extraction unit.Wherein, the image of converter unit after with embed watermark carries out the YUV color space conversion, and carries out the secondary wavelet transformation to Y component wherein; Extraction unit extracts the diagonal angle high-frequency sub-band part of secondary wavelet transformation each subband and the inverse pre-service decision variable ε ' of gray scale watermarking images according to the close spoon in the sequence permutation unit of embed watermark part; Complete and the inverse wavelet transform unit is complete with the full spot patch of gray scale watermarking images wavelet coefficient diagonal angle subband by the full spot patch of diagonal angle subband then; Carry out inverse wavelet transform to the diagonal angle subband of each sub-band coefficients that obtains and full zero setting one time, the gray scale watermarking images that obtains extracting.
The above is merely preferred embodiment of the present invention, not in order to restriction the present invention, all any modifications of within spirit of the present invention and principle, being done, is equal to and replaces and improvement etc., all should be included within protection scope of the present invention.