Results 1 to 5 of 5
  1. #1
    forwardbias is offline Member
    Join Date
    Mar 2012
    Posts
    23
    Rep Power
    0

    Default Alter blue values of a pixel

    Hi Guys
    I am doing a project on Steganography.I am at a juncture where I need to alter the blue values of a pixel.I have almost devised an algorithm but it is incomplete.The steps are
    1)Obtain the rgb values of the pixel using getRGB and the do the right shifting and bitwise AND-ing with 0xff.
    2)We will obtain integer RGB values.Change the blue to the desired value
    3)Now obtain the binary equivalent of the value by left shifting and bitwise AND-ing with 0xff.

    My question is how do I combine the RGB values so that I can use the setRGB method in BufferedImage.I am unable to bridge the gap.I hope I have been able to express myself clearly.I would welcome any other algorithm.Please help.I will be really grateful

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,309
    Blog Entries
    7
    Rep Power
    20

    Default Re: Alter blue values of a pixel

    Quote Originally Posted by forwardbias View Post
    Hi Guys
    I am doing a project on Steganography.I am at a juncture where I need to alter the blue values of a pixel.I have almost devised an algorithm but it is incomplete.The steps are
    1)Obtain the rgb values of the pixel using getRGB and the do the right shifting and bitwise AND-ing with 0xff.
    2)We will obtain integer RGB values.Change the blue to the desired value
    3)Now obtain the binary equivalent of the value by left shifting and bitwise AND-ing with 0xff.

    My question is how do I combine the RGB values so that I can use the setRGB method in BufferedImage.I am unable to bridge the gap.I hope I have been able to express myself clearly.I would welcome any other algorithm.Please help.I will be really grateful
    If you ony want to change the lowest bit of the blue value there is no need to unravel the rgb number; the following will do fine:

    Java Code:
    int setLowestBit(int argb, boolean bit) {
       return (argb&-2)|(bit?1:0);
    }
    kind regards,

    Jos (bit fiddler ;-)
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    forwardbias is offline Member
    Join Date
    Mar 2012
    Posts
    23
    Rep Power
    0

    Default Re: Alter blue values of a pixel

    Thank You for replying
    I might have to change the complete value in some cases based on an input.

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,309
    Blog Entries
    7
    Rep Power
    20

    Default Re: Alter blue values of a pixel

    Quote Originally Posted by forwardbias View Post
    Thank You for replying
    I might have to change the complete value in some cases based on an input.
    For the blue component (the least significant byte) of an argb value it's easy:

    Java Code:
    int getValue(int argb) { return argb&0xff; }
    int setValue(int argb, int val) { argb= (argb&0xffffff00)|val; return argb; }
    Two oneliners, that's all that's needed ;-)

    kind regards,

    Jos
    Last edited by JosAH; 04-13-2012 at 06:35 PM.
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    forwardbias is offline Member
    Join Date
    Mar 2012
    Posts
    23
    Rep Power
    0

Similar Threads

  1. reading pixel values
    By jdeep in forum New To Java
    Replies: 3
    Last Post: 02-26-2012, 05:28 PM
  2. reading pixel values from images
    By utkarsh 1 in forum Java 2D
    Replies: 18
    Last Post: 12-22-2011, 10:02 PM
  3. Replies: 8
    Last Post: 05-18-2011, 03:01 PM
  4. How to read the pixel values of a jpg binary image
    By carindia in forum New To Java
    Replies: 2
    Last Post: 09-17-2010, 06:19 PM
  5. problem with pixel values of an image
    By SreerajSarma in forum New To Java
    Replies: 6
    Last Post: 03-06-2010, 03:47 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •