[magick-users] Changing Image Colors-Magick++
Patrick Husson
patrick.husson at comcast.net
Tue Mar 4 12:33:41 PST 2008
Anthony Thyssen wrote:
> Patrick Husson on wrote...
> | Hi,
> |
> | I am writing a simple c++ program that hides data in a PNG image by
> | replacing insignificant bits with bits from a message on a linux box
> | using the most recent release of ImageMagick.
> |
> See IM examples, Stengo
> http://imagemagick.org/Usage/transform/#stegano
>
> | However, using the
> | functions outlined in the Magick++ tutorial doesn't seem to modify the
> | image.
> |
> | Let's say I want to hide the number of bits I am going d to use to hide
> | data in the first red pixel byte in the image.
> |
> | Bits per byte used: 1
> | Red1 = 0 //read from the image
> | Red2 = 1 //modifed value that should replace the original red value
> |
> | To do this, I read the color of the first pixel and then get the red value
> | //x=0,y=0
> | Color firstPix = original.pixelColor(x,y); //original is the image
> | unsigned char redVal = firstPix.redQuantum(); //MaxRGB = 255
> |
> | After doing operations, redVal becomes the value I want (1) and then it
> | is written
> | firstPix.redQuantum(modRedVal);
> |
> | Then the rest of the image is read row by row (y staying the same)
> | x++;
> |
> | However, a program that reads the value from the modifed image shows
> | that the
> | values haven't changed:
> |
> | Color firstPix = image.pixelColor(x,y); //(0,0);
> | unsigned char redVal = firstPix.redQuantum();
> |
> | output with cout << (int) redVal
> | Red 1 = 0
> |
> | which gives the wrong number of bits to use:
> | BitsUsed = 0
> | .
>
> At some point you should have a syncImage, to place the modified pixels
> back into the image.
>
> Best idea is to first look at the IM Web sites, Archeture page which has
> the basic methods that IM uses.
> http://imagemagick.org/script/architecture.php
>
> All methods involve extracting pixels, modifying then placing the paixel
> basic into the image structure.
>
>
>
> Anthony Thyssen ( System Programmer ) <A.Thyssen at griffith.edu.au>
> -----------------------------------------------------------------------------
> Nietzchean Principle :- That which does not kill us, makes us stronger!
> Larry Niven (BoarderLand of Sol): What we don't know, can kill us.
> -----------------------------------------------------------------------------
> Anthony's Home is his Castle http://www.cit.gu.edu.au/~anthony/
> _______________________________________________
> Magick-users mailing list
> Magick-users at imagemagick.org
> http://studio.imagemagick.org/mailman/listinfo/magick-users
>
>
Thanks for your help. I fixed the program last week and now it works
correctly.
More information about the Magick-users
mailing list