How to make an small image invisible inside a large image

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
fanaticjasper

How to make an small image invisible inside a large image

Post by fanaticjasper »

and the small image still can be detected by Imagemagick.

thansks fanaticjasper!
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: How to make an small image invisible inside a large image

Post by Bonzo »

You want -stegano, there is some info on this page http://www.imagemagick.org/script/comma ... p?#stegano

BUT I think it is hard to view the image - need an X11 server ? Also if you are using it as an invisible watermark to prove the image is yours and the person who uses your image cuts anything off the top left corner you will probably not be able to find the image again anyway.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to make an small image invisible inside a large image

Post by anthony »

The -stegano operatation is really more of a 'fun' operator. For example it could be use by a spy to hide info in the 'chaos' of a random image.

As a means of image copyright protection, it is useless. The smallest change to an image and the hidden data is lost.

This is why I haven't really added any example of its used in IM examples, as it is pretty useless.

The following is an example...

First the message (and get its size)

Code: Select all

  convert -gravity center label:"Watch\nthe\nBirdy" message.gif
  identify message.gif
Size is 36x43 whcih we will need...

Next the put it into some image...

Code: Select all

  convert rose:   rose_original.png
  composite message.gif rose: -stegano +15+5  rose_message.png
you can check the difference with compare

Code: Select all

  compare -metric PAE rose_original.png rose_message.png rose_difference.png
which shows the image was changed all over, but only a peak difference of 1 color unit (Whcih means JPEG will destroy the data.

now lets recover the hidden image...

Code: Select all

  convert -size 36x43+15+5 stegano:rose_message.png message_recovered.gif
Not that we needed the original images size and its offset for this to work!

if you get the size, or the offset wrong, or the image was modified, or even saved a JPEG, the message will be lost!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
fanaticjasper

Re: How to make an small image invisible inside a large image

Post by fanaticjasper »

Hi, may I have the source code for stegano?(any language:VB, C++, C#,C)

what does "1 color unit difference" mean? thanks you!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to make an small image invisible inside a large image

Post by anthony »

A image is stores with with Red Green and Blue values saved as an 8 bot or 16 bit integer. A 1 color uint change means that value only changed by 1 (basically invisible)

Source code is in IM source . look for SteganoImage() in "magick/fx.h"
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
fanaticjasper

Re: How to make an small image invisible inside a large image

Post by fanaticjasper »

Code: Select all

for (i=QuantumDepth-1; (i >= 0) && (j < QuantumDepth); i--)
  {
    for (y=0; (y < (long) watermark->rows) && (j < QuantumDepth); y++)
    {
      for (x=0; (x < (long) watermark->columns) && (j < QuantumDepth); x++)
      {
        pixel=AcquireOnePixel(watermark,x,y,exception);
        q=GetImagePixels(stegano_image,k % (long) stegano_image->columns,
          k/(long) stegano_image->columns,1,1);
        if (q == (PixelPacket *) NULL)
          break;
        switch (c)
        {
          case 0:
          {
            SetBit(q->red,j,GetBit(PixelIntensityToQuantum(&pixel),i));
            break;
          }
          case 1:
          {
            SetBit(q->green,j,GetBit(PixelIntensityToQuantum(&pixel),i));
            break;
          }
          case 2:
          {
           SetBit(q->blue,j,GetBit(PixelIntensityToQuantum(&pixel),i));
            break;
          }
        }
        if (SyncImagePixels(stegano_image) == MagickFalse)
          break;
        c++;
        if (c == 3)
          c=0;
        k++;
        if (k == (long) (stegano_image->columns*stegano_image->columns))
          k=0;
        if (k == image->offset)
          j++;
      }
    }
if a color's RGB value is 150,150,150, I change it to 150,150,151 and the change is so little that human eye can not see the difference. My question is how I can set an watermark color value to the image from the code above.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to make an small image invisible inside a large image

Post by anthony »

Stegno is NOT a watermarking function.. If you make the changes visible as I did in IM Examples you will see garbage.
http://www.imagemagick.org/Usage/transform/#stegno

It hides images in images, it does not watermarks images.

For Watermarking See...
http://www.imagemagick.org/Usage/annotating/#watermark
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
fanaticjasper

Re: How to make an small image invisible inside a large image

Post by fanaticjasper »

I want to hide an image in image.

The PNG image format supports 16 bit grayscale natively, although browsers and many imaging programs tend to ignore the low order 8 bits of each pixel.

if I have an image R(8bits) G(8bits) B(8bits) , does"Hide watermark in low-order bits of image " means expand to R(16bits) G(16bits) B(16bits) ....
Post Reply