Sie sind auf Seite 1von 7

DigitalImageWatermarkingUsingTheDiscreteCosine TransformAndTheMD5CryptographicHashFunction

WahyuPrakosaAdi & VolkerM ller

DutaWacanaChristianUniversity FacultyofComputerScience Jl.Dr.Wahidin519 Yogyakarta,55242,Indonesia Email:{wpadhi,vmueller}@ukdw.ac.id Website:http://lecturer.ukdw.ac.id/vmueller Summary Wedescribeanimagewatermarkingalgorithm that uses the Discrete Cosine Transform to gether with a cryptographic hash function to embedcopyrightinformationoflimitedsizeinto animage. Keywords Digital Image Watermark, Discrete Cosine Transform,CryptographicHashFunction.

Awatermark ofadigitalimage isapseudo randombitsequenceaddedtoanimage.Itis knownonlytotheownerofthatimagesothat otherscannotduplicateorremoveit.There foreitcanserveasproofthattheownerre allyownsthisimage.Thereshouldbenoper ceptualdegradationoftheimage,andthewa termarkshouldbedetectableevenafterma nipulationoftheimage.Therearetwomain modelsfordigitalimagewatermarks: 1. Theowneroftheimagestoressomeinfor mationabouteveryimagethathepublish es.Thisinformationisneededforverifica tionofthewatermarkbitsequence. 2. Thereisnoextrainformationavailableex cept the watermark information added to theimage. Obviously,thesecondmodelismoredifficult torealize,sincetheuseroftheimagecanal waystrytodestroythe complete watermark information by manipulating the image. In this paper, we use a slightly modified ap proachwhichneedsverylittleextrainforma tion.Thisinformationcanbesharedbetween differentimages.Theownerofthecopyright hastorememberapasswordusedinthewa termarkingalgorithmtocheckwhetherawa termarkisembeddedinsideanimageornot. 1

1. Introduction
Imagewatermarkinghasbecomeveryimpor tantwiththeincreasingusageoftheInternet fordistributionofimages.Onlinenewspapers andpressagenciesreportfromallareasofthe world, publishing lot's of photographs. Obvi ouslythephotographersareconcernedabout copyright issues to get royalty if these pho tographs are used by others for commercial purposes.However,downloadingimagesfrom the Internet is extremely easy, and without restricting access to a website contrapro ductivewithfreeInternetaccessitisal most impossibletoassure copyright.Embed dingdigitalimagewatermarksinsideanim agegivesthephotographerawaytomarkhis photoandtoproveacopyrightviolation.

Thegeneralprocedureforembeddingthewa termarkinformationintotheimageisasfol lows:Wetransformtheimageusingthewell known Discrete Cosine Transform (DCT), thenweaddthewatermarktoselectedcoeffi cients of the transformed image, and finally weinverttheDCTtogetanimageverysimi lar to the original one with included water mark.Thedetectionprocedurestartsbyfirst transformingtheinputimage withDCTand thentriestoextractthewatermarkinforma tionfromsomeselectedcoefficients.Inoural gorithm,weuseacryptographichashfunction todetermine which of the coefficients of the resultoftheDCTtransformareusedforem beddingthewatermarkinformation. We restrict our observation in this paper to watermark information of size at most 96 character(byte).Thepaperstartswithsome theoreticalbackgroundmaterialaboutseveral aspectsofourwatermarkingalgorithm,before we shortly report on practical experiences achievedwithatestimplementationoftheal gorithm.

verse transformation) can be computed with thefollowingsimplelinearformulas: Y=77/256R+150/ R = Y + 1.371 (Cr 256G+29/256B 128) Cb = 44 / 256 R G = Y 0.692 (Cr 87/256G+131/256 128) 0.336 (Cb B+128 128) Cr = 131 / 256 R B = Y + 1.732 (Cb 110/256G21/256 128) B+128 The YCbCr modelstorescolorinformationin a luminance (component Y with value be tween 16 235) and two chrominance parts (chromaCbandCr,valuesintherange112 to 112 each). The main advantage of the YCbCrcolormodelincomparisontotheRGB modelisthefactthatsimpleimagemanipula tionslikechangingtheluminanceorcontrast of an image will not change the Cb and Cr componentssignificantly.Thereforethesetwo components are well suited for watermark hiding.

2. TheoreticalBackground
2.1. ImageColorRepresentation
The input to any image watermarking algo rithm is necessarily a digital image. In this paper,we assume that we use color images.

2.2. DiscreteCosineTransform
TheDiscreteCosineTransform(DCT)isa wellknownimagetransformationwhichisof tenusedforimagecompression(e.g.,thelossy image compression format JPEG uses DCT, see [8]). The importance of DCT lays in the factthat the result ofthis transformation is muchbettersuitedforimagemanipulationas theoriginalcolorcomponents.Weshortlyre viewthebasictheoryofthisalgorithm. LetNbeapoweroftwo,andassumethatx= /N.ThenwecandefinetheDCTmatrixas

The 24bit Truecolor (or RGB) representa

tionforthecolorofapixelstoresinformation abouttheRed,Green,andBluecolorcompo nentinonebyteeach,suchthatthecolorin formationforonepixelneeds3byte.Thisrep resentationissimple,butwechooseadiffer ent approach. We start by transforming the RGB color model to the YCbCr color model usedalsobytheJPEGstandard[8].Thiscolor transformation (and the corresponding in

W = cicos 2 j1 ix 0i N , 0 jN (1)
with constants ci = 0.5 for i > 0 and

c0=1 / 8 .Assumethatwehaveasubma
2

trixPofthepixelmatrixofdimensionNN. TheDCTforPiscomputedasH=WPWt. Since the matrix W is orthonormal, the in verseoftheDCTcansimplybedeterminedas P=WtHW. The practical importance of the DCT comes from the fact that a pixel matrix P with N2 values that may all be large is transformed intoaresultmatrixHwithonlyonelargeele mentintheupperleftcorner(whichstoreses sentially all the image energy). All other matrixelementsareclosetozero.Onefurther importantaspectofDCTisthefactthatthe small values of H can be slightly changed without visible effect afterusing the inverse DCtransformation.Thereforewecanuseall thematrixelementsexcepttheelementinthe upper left corner for insertion of watermark information.

Wethereforechooseadifferentapproachand storetheonebitinformationinthedifference betweentwoDCTcoefficients.LetHbethe result matrix of the DC transform. We com parethevaluesofthetwocoefficientsH1,2and H2,1.IfH1,2 H2,1 isbiggerthansomeconstant C,thenthesetwovaluesstoreaonebit,ifitis smallerthanC,thenazerobitisstored.For valuesinbetweenCandCwecannotdecide whetheritsaoneorazerobit.Thereforewe canembedasinglebitinformationinsidethe matrix H by slightly changing both coeffi cientsH1,2andH2,1.Sincethebitisstoredasa difference,smallchangestothevaluesofH1,2 andH2,1 duetoroundingerrorsdonotchange thebitinformation. Forevenbetterreliability,westoreeverybit threetimesinthematrixH.Weusetheposi tions(1,2)(2,1)togetherwiththepositions (1,3) (3,1). The same information isstored forthethirdtimeinthesinglecoefficientH2,2, depending whether its value is positive or negative.Thuswegetthreepossibletestsin the extracting phase, and usually we choose the majority result. The choice of the coeffi cientsintheupperleftcornerofHissimilar tothesuggestiondonein[1]. Acrucialpointforthisstrategyisthechoice ofaappropriateconstantC.Wedonothave anytheoreticalsuggestionshowCcanbecho senoptimally.Practicalresultsshowthattoo smallvaluesofCleadtodifficultiesintheex tractingprocess,whereastoolargevaluesofC leadtodistortionoftheimage.

2.3. InsertingInformationInsideThe DCTResult


WatermarkingusingtheRGBcolormodelof teninsertsdataintotheleastsignificantbit ofeachcolorcomponent.Thistechniqueisap propriate for the RGB color representation sincetheleast significant bitdoes notinflu encethevisiblecolorsignificantly,suchthat thehumaneyeusuallydoesnotseeanydif ference between the original and the water markedimage. HoweverwatermarkingusingtheDCTtrans formisdifferent.TheelementsintheDCTre sultmatrixarenolongerintegervalues,but areoffloatingpointtype. Ifweinsertaone bit information at some bit position inside such a floating point number, we risk total lossofthebitinformationduetoroundinger rorsduringtheprocess.

2.4. CryptographicHashFunction
Acryptographichashfunctiontakesasinput a message and produces as output as hash valuewhichusuallyisabitstringoffixedsize [7]. Cryptographic hash functions have the special property that for essentially all pre 3

specifiedoutputsitiscomputationallyinfeasi bleto determine anyinput withthat output (onewayfunctions).Thetwomostwellknown cryptographic hash functions are the MD5 andtheSHA1hashfunction(formoreinfor mationandtheexactdefinitionofboththese hashfunctions,see[7]).Inourapplication,we useanimplementationoftheMDhashfunc tion available in the open source project mhash[6]. Cryptographic hash functions are often used fordataintegrity,butcanalsobeusedasba sis for a pseudorandom number generator. Assume that h is some cryptographic hash function,andpissomepasswordwhichisin putofauser.Thenthesequence p0 =pand pi+1 =h(pi)fori 0determinesasequenceof pseudorandombitstringspioffixedsizeeach. Iterating this procedure,wecangenerate as manypseudorandombitsaswelikestarting from the password information which is the user's input. We will use this application of hash functions in our watermarking algo rithm.

OnepropertyoftheDCTisthefactthatfora input matrix P we have the symmetry DCT (P)=W P Wt =(W Pt Wt )t =DCT(Pt)t. Therefore if some permutation generates an inputmatrixPwhoseDCTmatrixhassome specificbehaviorforthecoefficientsatspecific positions, then the permutation that deter mines Pt gives exactly the opposite behavior forthesetwocoefficients.Thereforethispseu dorandompermutationofthepixelmatrixef fectivelyrandomizesthepossiblepositionsfor suchanattack.

2.6. RSErrorCorrectingCode
Althoughwealreadyanticipatedsmallerrors during the several transformation processes, wecannotassurethatthespecificcoefficients chosenfortheembedding arenotverydiffer ent after a possible manipulation done by a malicioususer.Thereforewecombineouridea with a wellknown technology, error correct ing codes. Error correcting codes are special codesthatenablethecorrectionofafewer rors that happen during the transformation process.Weusea(127,117)ReedSolomoner rorcorrectingcodewith7bitsymbolswhich adds10byteofredundancytoa117 symbol blockinputdata(96byte),thereforecancor rectupto15symbolerrors.Anotherpossible errorcorrectingcodeisthe(255,223)RScode givenin[2]. Forbackgroundonerrorcorrectingcodes,we referthereadertoanybookonthistopic.Our watermarkingalgorithmimplementationma kesuseofanopensourceimplementationof theseRScodesavailableat[5].

2.5. RandomizingtheDCTResult
AsdescribedinSection2.3,weusefivecoeffi cientsintheupperleftcornerofHtoembeda singlebitinformation.Thisfixedchoiceofpo sition makesthe algorithm vulnerable to an attack which randomly disturbs these coeffi cientsinall88submatrices.Toanticipate suchanattack,wefirstdetermineapermuta tion of the 8 8 pixel submatrix before we applytheDCtransform.Thispermutationis determinedwiththehelpofasecretpassword anditeratedhashing(seeSection2.4).There fore this permutation is only known to the owner of the secret password which secures thecopyrightinformation.

3. TheWatermarkingAlgorithm
Inthissectionwedescribethebasicstepsper formedbytheimagewatermarkingalgorithm

of this paper. The algorithm consists of the followingsteps: 1. This watermarking algorithm starts by scalingtheinputpicturetothepredefined fixed defaultsizeof256 256pixel.The purposeofthisscalingstepistheanticipa tionofamanipulationofthesizeofthewa termarked image. This image scaling is doneusingthestandardinterpolationalgo rithm, butwithoutrounding the result to integervalues. 2. The second step is the conversion of the scaledinputimage(withnowfloatingpoint colorvalues)fromtheRGBcolormodelto theYCbCrcolormodelasdescribedinSec tion2.1. 3. Inthethirdstepwesplittwomatriceswith the Cb and Cr components of the image intoblocksofsize88pixeleach.Nowwe have21024positionswherewecaninsert onebiteach. 4. Everysuchblockispermutedwithadiffer entpseudorandompermutation.Allthese permutationsaredeterminedbyaniterat edhashingofasecretpasswordusingthe MD5 algorithm. These permutations are storedsuchthattheycanbeinvertedina laterstep. 5. Everypermutedblockistransformedusing theDCTalgorithm. 6. Thecopyrightmessageofmaximalsize96 byteisencodedusingthechosenerrorcor recting code. The data length after the computationoftheerrorcorrectingcodeis 127bytesuchthatthedatacanbestored in either the Cb or the Cr component (or twiceinboth,addingevenmoreredundan cy). If we use the (255, 223) RS code, we

havetousebothcomponentstoembedthe encodedcopyrightinformation. 7. Theexpandedcopyrightmessageisembed dedintotheDCTresult,onebitperblock. Thisbitisstoredinsidefivedifferentcoeffi cientsasdescribedinSection2.3. 8. ThefinalstepistheinverseDCTtransfor mationforalltheblocks,thenapplyingthe inversepermutationforeveryblock,andfi nallythecombinationofalltheblocksinto theCbandCrcomponentoftheresulting watermarkedimage. Thisdescriptionofthebasicideadoesofcour se not describe our implemented solution in alldetails.

4. TestingTheWatermark
Inthis section, wedescribe how auserthat knowsthesecretpasswordusedinthewater marking process can check whether a valid watermarkisembeddedinsidesomeimageor not.Thistestprocedureworksverysimilarto theembeddingprocedurethatwedescribedin Section3: 1. This watermarking algorithm starts by scalingtheinputpicturetothepredefined fixeddefault size of256 256pixel.The purposeofthisscalingstepistheanticipa tionofamanipulationofthesizeofthewa termarked image. This image scaling is doneusingthestandardinterpolationalgo rithm, but withoutrounding the result to integervalues. 2. The second step is the conversion of the scaledinputimage(withnowfloatingpoint colorvalues)fromtheRGBcolormodelto theYCbCrcolormodelasdescribedinSec tion2.1.

3. Inthethirdstepwesplittwomatriceswith the Cb and Cr components of the image intoblocksofsize88pixeleach. 4. Everysuchblockispermutedwithadiffer entpseudorandompermutation.Allthese permutationsaredeterminedbyaniterat ed hashing of the secret password using theMD5algorithm. 5. Everypermutedblockistransformedusing theDCTalgorithm. 6. Foreachblock,wedetermineaonebitof the expanded copyright message by com paring five selected coefficients as de scribedinSection2.3.Ifthereisnoequal resultforallthesethreepositions,wetake amajoritydecision. 7. Finally,weusethedecodinganderrorcor rectingprocedureofthe(127,117)RScode to correct possible errors in the extracted data.Ifthecorrectedandextractedoutput message isequaltotheoriginalcopyright message,thenweknowthattheimagewas copyrighted,otherwisewegetnoinforma tionaboutapossiblecopyright.

shows the size of the input image, C is the constant described in Section 2.3, Cb/Cr de scribeswhethertheextractingproceduresuc ceeded(S)orfailed(F)forthatcomponent,and RSMEshowstherootsquaremeanerrorbet ween the original and the watermarked im age.
Table1:ExperimentsdonewiththeLenaimage.

Size 128128 128128 128128 256256 256256 512512 512512 512512

C 30 45 60 15 30 15 30 60

Cb/Cr F/S F/S S/S S/S S/S S/S S/S S/S

RSME 5.43 8.02 10.6 3.01 5.49 7.72 8.44 11.24

5. PracticalResults
Weimplementedthewatermarkingalgorithm ofthispaper using the Linux operating sys temwiththeC++programminglanguage.For support,weusedcodefromseveralopensour ceprojects,e.g.theImageMagickopensour celibrary [3] forreadingandwritingimages ofdifferentformats,theMHashproject [6], andRSerrorcorrectingcode[4].Duetospace restrictions,wecannotreportindetailabout theachievedresults. The following Table 1 shows some results whenweusetheimplementationofthealgo rithm with the famous Lena Image. Size

Thistablesuggeststhatitseemstobemore complicated to extract the watermark infor mation for input images smaller than 256 256thanforlargerimages.Itshouldbenoted thatboththeembeddingandtheextractionof the watermark information can be done in lessthanonesecond. Thistimedoesnotde pend on the image (except for the scaling step),butonlyonthenumberofbitsthatare goingtobeembedded/extracted. Itshouldbenoted that thefewpractical re sultsforthealgorithmproposedinthispaper showthatthealgorithmisstillfarfromper fect.Furtherresearchandintensiveanalysis andpracticaltestsprobablycanimprovethe quality of the algorithm. The choice of the constantCanddifferentstrategiesforstoring a single bit information inside DCT coeffi cients should be considered in more detail. Theusederrorcorrectingcodeshouldbeeval uatedinmoredetail,maybesomeothererror 6

correcting code is better suited in the given context. Moreover, possible attack scenarios should be tested more intensively, e.g. crop ping the image, extreme scaling, converting theimagetotheJPEGformatwithverylow quality,andsoon.

availableathttp://mhash.sourceforge.net/. [7] A.J. Menezes, P.C. Oorschot, and S.A. Vanstone, "Handbook of Applied Cryptogra phy",1996,CRCPress. [8]D.Salomon,"DataCompression,TheCom pleteReference",2000,Springer. In 1997, Wahyu Prakosa Adi received a Bachelor degree from the Computer Science Faculty of Duta Wacana Uni versity, Yogyakarta, where he currently works as part time lecturer.Heisalsoastudentin the Master Program of the Faculty of Elec tricalEngineeringatGadjahMadaUniversity inYogyakarta,Indonesia.

6. Conclusion
We describe an image watermarking algo rithmwhichmakesuseoftheDCTtransform andtheMD5cryptographichashfunctionto gether with an error correcting code. Some practicalresultsofanimplementationofthe algorithmaregiven.

Acknowledgment
The second author would like to thank the Protestant Development Service (EED) of the GermanChurchwhosupportshisstayatthe DutaWacana ChristianUniversityinYogya karta.

References
[1] A.G. Borg and I. Pitas, "Image Water marking using block site selection and DCT domainconstraints",OPTICSEXPRESS,Vol. 3,No.12,1998,availableathttp://wwwuser s.cs.york.ac.uk/~adrian/Papers/Journals/OE98 .pdf. [2] CCSDS, "Telemetry Channel Coding", , available at http://www.ccs ds.org/documents/pdf/CCSDS101.0B5.pdf. [3]ImageMagickStudioLLC,"ImageMagick", 2004,availableathttp://imagemagick.source forge.net/. [4] Phil Karn, "Code for General Purpose ReedSolomonEncodingandDecoding",2004, availableat??. [5] Phil Karn, "Code for General Purpose ReedSolomonEncodingandDecoding",2004, available at http://www.ka9q.net/code/fec/reedsolomon 4.0.tar.gz. [6] N. Mavroyanopoulos and S. Schumann, "Mhash:ALibraryofHashAlgorithms",2004,

VolkerMllerreceived aMas terand a Doctorate Degree in Computer Science from the University of Saarland, Ger many, in 1991 and 1995, re spectively. He worked as a PostdoctoralFellowattheUni versity of Waterloo, Canada, andtheUniversityofTechnology,Darmstadt, Germany.Since 1998heisalecturer inthe FacultyofComputerScienceatDutaWacana Christian University and intheMasterPro gramoftheFacultyofElectricalEngineering atGadjahMadaUniversityinYogyakarta,In donesia.

Das könnte Ihnen auch gefallen