aspose file tools*
The moose likes Beginning Java and the fly likes Getting RGB values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Getting RGB values " Watch "Getting RGB values " New topic
Author

Getting RGB values

Hafsa Hosani
Greenhorn

Joined: Mar 09, 2009
Posts: 3
Hi there,

Can somebody help me in writing this program. I want a simple program that takes an image of jpg format as an input
and return its pixels RGB values representation.

import java.awt.*;
import java.awt.image.*;
import java.util.*;
class JPEGshow extends Frame {
...
static public void main(String[] args) {
if (args.length == 1) new JPEGshow(args[0]);
else System.err.println("usage: java JPEGshow <image file>");
}
}

Where can I put getRGB method in the above code if it helps solving the problem?
kannan vinayagam Duraiswamy
Ranch Hand

Joined: Jan 12, 2009
Posts: 52




Kannan.DV
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42926
    
  68
You can use the javax.imageio.ImageIO.read method to open JPEG files. That will create a BufferedImage object which has two "getRGB" methods for either getting an individual pixel's value, or all values of a rectangular area inside of it.
Hafsa Hosani
Greenhorn

Joined: Mar 09, 2009
Posts: 3
kannan vinayagam Duraiswamy thanks for your reply.
Ulf Dittmer, my images are in circular shape (iris images), will it work with circular images or not?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42926
    
  68
Well, JPEGs are rectangular by definition. It's up to your code to decide which parts of the image are interesting and which are not. But since you can retrieve RGB values for each individual pixel that's not an impediment.
Hafsa Hosani
Greenhorn

Joined: Mar 09, 2009
Posts: 3
OK. Thanks alot...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting RGB values