Pixel colorvalue in an Image

Discussion in 'Java' started by Peter the Swede, Nov 11, 2003.

  1. Best groupmember,

    I'm working with my thesis in Physics and are doing some programming in
    Java. I have a map (gif-image) that for a specific pixel I need to find out
    what RGB-value it has. I will further use it for classification, but that is
    of no importance here.

    I have the picture as an Image object:

    Image myImage = Toolkit.getDefaultToolkit().getImage(URL);

    Can I from my Image-object get the information that I need. Anyone that at
    least can give me an hint where to go to solve the problem.

    I would appreciate any answer.
     
    Peter the Swede, Nov 11, 2003
    #1
    1. Advertising

  2. Peter the Swede

    ak Guest

    a) use PixelGrabber or
    b) create BufferedImage instead of Image

    "Peter the Swede" <> schrieb im Newsbeitrag
    news:3fb0bff9$...
    > Best groupmember,
    >
    > I'm working with my thesis in Physics and are doing some programming in
    > Java. I have a map (gif-image) that for a specific pixel I need to find

    out
    > what RGB-value it has. I will further use it for classification, but that

    is
    > of no importance here.
    >
    > I have the picture as an Image object:
    >
    > Image myImage = Toolkit.getDefaultToolkit().getImage(URL);
    >
    > Can I from my Image-object get the information that I need. Anyone that at
    > least can give me an hint where to go to solve the problem.
    >
    > I would appreciate any answer.
    >
    >
     
    ak, Nov 11, 2003
    #2
    1. Advertising

  3. Peter the Swede:

    >I'm working with my thesis in Physics and are doing some programming in
    >Java. I have a map (gif-image) that for a specific pixel I need to find out
    >what RGB-value it has. I will further use it for classification, but that is
    >of no importance here.


    Instead of getImage use ImageIO.read. This will give you a
    BufferedImage object (that class extends Image) which has a getRGB
    method. This will give you an int value, from which the three values
    for red, green and blue can be decoded like this:
    <http://www.geocities.com/marcoschmidt.geo/java-image-faq.html#rgba>.

    Alternatively you can use the PixelGrabber class.

    And yes, this is all way too complicated for a simple task like "get
    color of pixel". :/

    [...]

    Regards,
    Marco
    --
    Please reply in the newsgroup, not by email!
    Java programming tips: http://jiu.sourceforge.net/javatips.html
    Other Java pages: http://www.geocities.com/marcoschmidt.geo/java.html
     
    Marco Schmidt, Nov 11, 2003
    #3
  4. Thank you Marco, it solved my problem. Cheers!


    "Marco Schmidt" <> wrote in message
    news:...
    > Peter the Swede:
    >
    > >I'm working with my thesis in Physics and are doing some programming in
    > >Java. I have a map (gif-image) that for a specific pixel I need to find

    out
    > >what RGB-value it has. I will further use it for classification, but that

    is
    > >of no importance here.

    >
    > Instead of getImage use ImageIO.read. This will give you a
    > BufferedImage object (that class extends Image) which has a getRGB
    > method. This will give you an int value, from which the three values
    > for red, green and blue can be decoded like this:
    > <http://www.geocities.com/marcoschmidt.geo/java-image-faq.html#rgba>.
    >
    > Alternatively you can use the PixelGrabber class.
    >
    > And yes, this is all way too complicated for a simple task like "get
    > color of pixel". :/
    >
    > [...]
    >
    > Regards,
    > Marco
    > --
    > Please reply in the newsgroup, not by email!
    > Java programming tips: http://jiu.sourceforge.net/javatips.html
    > Other Java pages: http://www.geocities.com/marcoschmidt.geo/java.html
     
    Peter the Swede, Nov 11, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter the Swede

    Pixels colorvalue in an image.

    Peter the Swede, Nov 11, 2003, in forum: Java
    Replies:
    0
    Views:
    320
    Peter the Swede
    Nov 11, 2003
  2. rfractal30
    Replies:
    5
    Views:
    6,930
    rfractal30
    Mar 6, 2005
  3. Sinora
    Replies:
    1
    Views:
    842
    David White
    Nov 11, 2003
  4. Dev S Shrestha
    Replies:
    1
    Views:
    706
    Thomas Matthews
    Nov 11, 2003
  5. André Wagner

    Fastest pixel by pixel operation

    André Wagner, Mar 17, 2008, in forum: Java
    Replies:
    12
    Views:
    1,051
    Larry A Barowski
    Mar 19, 2008
Loading...

Share This Page