Pixel access and modify in JPG

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
suciodesprolijo

Pixel access and modify in JPG

Post by suciodesprolijo »

Hello

first of all, sorry for my english. :lol:

I'm building a steganography system. I have to apply a "simil" LSB (least significant bit) concept to write on te lowest bits of a pixel to store a certain information (plain text's).

What i do for this is something like this:

Code: Select all

//...
//Read 1 pixel
pixel = my_pixel_cache.get(col, row, 1, 1);
red_int=pixel->red;
green_int=pixel->green;
blue_int=pixel->blue;
//Write in the BITS_ESTEGANOGRAFICOS lowest bits
int BITS_ESTEGANOGRAFICOS=3;
red_int >>= BITS_ESTEGANOGRAFICOS;
red_int <<= BITS_ESTEGANOGRAFICOS;
red_int |= red_toWrite;
//idem green and blue
//Save the pixel
memset(&pixel->red,red_int,sizeof(pixel->red));
//...
//Save the image
image.syncPixels();
image.write(path)
This work's ok with format without destructive compression.
My problem is handling the jpg's format.
I see that Write rutine, aplies the compression algorithm of the format, wich destroy information, so i can't get it back.

Is there a way to modify the pixel's of a jpg without re-compressing the image?
i.e. is there a way to pixel-write jpg's and don't lose info?

sorry for the extension, and thank you for your answer

Sebastian.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Pixel access and modify in JPG

Post by magick »

JPEG is a lossy format so you must modify the DCT coefficients directly to hide information inside JPEG. ImageMagick does not permit direct access to the DCT so you may need to write your own utility.
suciodesprolijo

Re: Pixel access and modify in JPG

Post by suciodesprolijo »

Well, that escapes of my knowledge
Thank's for your quick answer and congratulations for your work. :D
Post Reply