Combining bits from two images

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
Tachoknight
Posts: 8
Joined: 2007-03-03T13:30:14-07:00

Combining bits from two images

Post 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!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Combining bits from two images

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Tachoknight
Posts: 8
Joined: 2007-03-03T13:30:14-07:00

Re: Combining bits from two images

Post 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...
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Combining bits from two images

Post 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'
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply