Pixel colorvalue in an Image

P

Peter the Swede

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.
 
M

Marco Schmidt

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
 
P

Peter the Swede

Thank you Marco, it solved my problem. Cheers!


Marco Schmidt said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top