Results 1 to 8 of 8
Like Tree1Likes
  • 1 Post By forwardbias

Thread: Questions on images

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

    Default Questions on images

    I have two questions regarding images
    1)Is the process of extracting the pixel values ( using getRGB then right shift and 0xff ) the same for all image formats(jpeg,png)?
    2)I am writing this program to change the values of certain pixels of an image.Which would be a preferred image format?I need to alter the certain pixel values of an image and then redraw the image.
    Thank You

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: Questions on images

    Are you talking about getRGB(int,int) of BufferedImage? In that case the image doesn't have a format. it's just an image: a bunch of pixels whose colours can be accessed.

    Where formats enter into the picture (sorry) is when the image is externalised in some way - say read from or saved to a file on your hard drive, or obtained from a stream across the network. In that case there needs to be a format (some way of translating between the values in the stream and the coloured pixels.) The ImageIO class takes care of decoding some formatted stream to produce the (formatless) image, or encoding the image into a stream of bytes with some given format.

    I would imagine that formats are important if you want to ensure that when you save an image then read it again you get the same coloured pixels that you started with. For that you would use a format like PNG which is lossless.

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

    Default Re: Questions on images

    Thank You for replying
    Just to confirm
    This means if I perform the operations
    int rgb=image.getRGB(20,20);
    int r=(rgb>>16)&0xff;
    int g=(rgb>>8)&0xff;
    int b=rgb&0xff;
    I will get the rgb value of a pixel of a PNG image.
    Also for steganographic purposes I should use PNG image.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,236
    Rep Power
    19

    Default Re: Questions on images

    Also for steganographic purposes I should use PNG image.
    What happened when you tried it?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

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

    Default Re: Questions on images

    I was actually getting a lot of errors because of the fact that jpeg is a lossy compression.

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,236
    Rep Power
    19

    Default Re: Questions on images

    I meant, what happened when you tried writing the image in PNG format?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

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

    Default Re: Questions on images

    I will try writing it and post back...

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

    Default Re: Questions on images

    Yes it did work well.Sorry I took a long time to post back.Thank you for the help
    DarrylBurke likes this.

Similar Threads

  1. 3 questions
    By silverglade in forum New To Java
    Replies: 11
    Last Post: 05-09-2011, 03:17 PM
  2. Various questions
    By benn22 in forum New To Java
    Replies: 2
    Last Post: 02-11-2011, 02:56 AM
  3. Replies: 0
    Last Post: 12-16-2010, 05:14 PM
  4. Replies: 4
    Last Post: 12-16-2010, 04:32 PM
  5. questions for 1yr exp
    By rahaman.athiq in forum Java Servlet
    Replies: 2
    Last Post: 11-26-2008, 01:13 AM

Posting Permissions

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