Page 1 of 1

Pixel access and modify in JPG

Posted: 2008-11-07T07:07:36-07:00
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.

Re: Pixel access and modify in JPG

Posted: 2008-11-07T07:19:20-07:00
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.

Re: Pixel access and modify in JPG

Posted: 2008-11-07T07:49:45-07:00
by suciodesprolijo
Well, that escapes of my knowledge
Thank's for your quick answer and congratulations for your work. :D