Tuesday, 26 July 2011

Digital Watermarks: Part Two Heart of Darkness

In Digital Watermarks Part One, we looked at the need for digital watermarks and the simple steps to impose a visible watermark onto a digital image. As we found last time, a visible watermark placed in the center of the image is really difficult to erase and will remain even if someone crops the image, but it spoils a good composition. Time to go invisible.

A true digital watermark is a digital signature, a pattern of bits impressed into an image file that can be read by a viewing utility. A person viewing the file normally won’t see the it, but the hidden watermark stays intact even if the file is cut, cropped or otherwise manipulated. This is a very secure and unobtrusive method of watermarking an image…

With the right algorithms and tools you can embed an entire library of information inside a high resolution photo and not alter the visible image. At the high-end, digital watermarking involves cryptography and complex algorithms that are way above my pay grade.

The trouble with this method is the variety of image processing which can unintentionally or intentionally attack a watermarked document and render the watermark undetectable. High quality images are often converted to JPEG format to reduce their size, by which the data compression can destroy the watermark. Horizontal or vertical flipping, rotation and cropping can also render an invisible watermark undetectable.

However, if you feel the need to add a simple, hidden watermark to your images using the GIMP, Gnu Image Manipulation Program, let’s give it a go. There are various techniques documented on the Web, none of them foolproof; this one mostly works but not in all cases.
We’re going to create a watermarked copy of an image and use the original as the key to reveal the hidden mark. I’ll assume some basic familiarity with the GIMP and that you read Part One.
  • Open the GIMP with a new transparent image. Create a text layer for your copyright assertion using a clean, legible font. Text layers have peculiar properties, so Merge Down the text layer onto the transparent background.Next, convert your image to a pattern.  Go to Select Menu, All (or use the shortcut Ctrl – A) and copy to clipboard.
  • Using Windows, Dockable Dialogs, Patterns, open the Pattern palette. This is pre-populated with the sample patterns that come with the GIMP.
  • Click the Auto button and GIMP will automatically pickup the selection as a pattern for immediate use. The first pattern in the grid will be the selection you’ll use as the watermark. As it has a transparent background you’ll probably see a blank white square, make sure it has the heavy black border indicating it’s active and it says ‘Clipboard ( 512 x 492)’ where the numbers are the dimensions of your watermark selection.
  • Open the image you want to watermark and create a duplicate of it, Go to Image, Duplicate (or press Ctrl – D. Save it under a new name – don’t mess up your original image, you need it for use as the key!
  • Create a new layer, make sure it’s highlighted as active.
  • Go to the Pattern palette and perform a click-and-drag on your watermark pattern, dragging it over the image to be marked. The Pattern function should automatically tile this across the whole image.
The next step is more experimental.
  • Reduce the opacity of the pattern layer so that it is no longer visible but but DON’T set it to zero. 
  • Zoom in play with the opacity settings, keep it as high as you can without the pattern becoming visible with your Mark I human eyeball. Between 2 and 10 is good. 4.0 worked on my Sedona landscape.
  • Save this version as the one you’ll post to the public. This should work for .png and .jpeg files (but only if you keep the compression to a minimum).
The Case for the Prosecution
The day comes when some despicable cad rips one of your images and you need the evidence to go before the Bench.
  • In the GIMP, paste your original and the swiped, watermarked copy as separate layers into one image file.
  • This is what they call on the TV makeover shows ‘the reveal.’ In the Layers palette, highlight the upper layer as shown in the attached and set its Blend Mode to Grain Extract.
What this does is subtract all the common elements in both images, leaving only the differences visible; in this case your copyright assertion!

Drum roll, please, I thank you!

A few things to note:
  • You may find that Blend Mode, Divide also reveals the watermark, depending on the image.
  • Saving your images as .jpegs with high compression will introduce what are called compression artifacts; the data lost in the process can be enough to destroy your hidden watermark. The enterprising thief will often convert images between formats and scale to low resolutions, destroying the watermark in the process.
  • You can try different fonts, font sizes and colors in your patterns which may work better or worse with the different images you are marking. Go for contrasting watermarks against the dominant shades in your images, light-to-dark, dark-to-light.