troubleshooting Question


Avatar of ellandrd
ellandrdFlag for Ireland asked on
32 Comments3 Solutions297 ViewsLast Modified:
getting error for getRGB() and i dont know why?

package colourclustering;

import java.awt.Image;
import java.awt.Toolkit;
import java.util.HashMap;

 * @author u0207372

public class ColourClusterTester {
    private HashMap hashMap;
    private Image img;
     * Creates a new instance of ColourClusterTester
    public ColourClusterTester( String filename ) {
        hashMap = new HashMap();
        img = Toolkit.getDefaultToolkit().getImage( filename );
        for ( int i = 0; i < img.getWidth(null); i++ )
            for ( int j = 0; j < img.getHeight(null); j++ )
                int pixelFreq;
                int pixelValue = img.getRGB();
                hashMap.put( pixelValue, 1 );
     * @param args the command line arguments
    public static void main(String[] args) {
        new ColourClusterTester( "H:\\MIOCReader\\ColourClustering\\ColourClustering\\src\\colourclustering\\test.gif" ) ;

bascially what im trying to do is read image, get pixel value of each pixel and store value in hash map. along with the number of time that value appears but having some problems actually getting the RGB() for each pixel?
Join our community to see this answer!
Unlock 3 Answers and 32 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 32 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros