Page 1 of 1

Combining bits from two images

Posted: 2011-02-22T23:41:29-07:00
by Tachoknight
Hi all-

I'm trying to use ImageMagick to perform a bit of steganography similar to the tree/cat picture http://en.wikipedia.org/wiki/Steganogra ... ganography. The built-in -stegano command does not seem to do what I want insofar as I'd like to preserve the "private" picture in some semblance of color.

I have two images, both 8-bit color of the same dimensions, and am invoking convert like:

Code: Select all

convert public.png private.png -fx "(u[0] & 0xFC) | (u[1] >> 6)" steno.png
where I'm trying to zero out the two last bits of public.png and or them with the converted two bits of private.png. I'm doing something wrong though, as my steno.png always comes out black.

I'm using ImageMagick 6.6.7-8 on the Mac (from MacPorts) and 6.5.7-8 on Linux.

Might anyone have an idea what I'm doing wrong, and/or how I might achieve a similar effect as the aforementioned tree/cat picture?

Thanks for any info!

Re: Combining bits from two images

Posted: 2011-02-23T01:34:58-07:00
by anthony
The values u[0] and u[1] are floating point numbers from 0 to 1. You will have to scale those numbers first.
FX is not well suited to handling bit-level manipulation of the image.

Re: Combining bits from two images

Posted: 2011-02-23T06:15:43-07:00
by Tachoknight
Ah, okay. I guess I got confused about how to use u and v in the fx block. If fx isn't the right thing to use, what would be more appropriate? There are so many things IM can do; it's quite overwhelming...

Re: Combining bits from two images

Posted: 2011-02-23T18:00:12-07:00
by anthony
It can be used. by scaling the bits first, then normalizing it again afterward.
For example set the lower 2 bits to 1 on all colors

Code: Select all

    -fx '((u * 0xFF) | 0x03) / 0xFF'