public void run(BufferedImage image) {
        if (image.getType() != BufferedImage.TYPE_BYTE_GRAY)
            throw new IllegalArgumentException("input image must be greyscaled");

        int width  = image.getWidth();
        int height = image.getHeight();
        
        Raster source = image.getRaster();
        int tmp = Math.max(width, height);
        int hh = (int) (Math.sqrt(2)*tmp);
        int hw = 180;
        int rgb;
        
        houghAccumulator = new long[hw][2*hh];
        thetaStep = Math.PI / hw;

        int centreX = width  / 2;
        int centreY = height / 2;                        

        for (int i = 0; i < hw; i++) {
            for (int j = 0; j < 2*hh; j++) {
                houghAccumulator[i][j] = 0;
            }
        }
               
        // find the edge points and update the Hough array
        for (int i = 0; i < width; i++) {
            for (int j = 0; j < height; j++) {
                rgb = source.getSample(i, j, 0);
                if (rgb != 0) {
                    // edge pixel found
                    for (int k = 0; k < hw; k++) {
                        //work out the r values for each theta step
                        tmp = (int) ((( i - centreX )*Math.cos(k*thetaStep)) +
                                     (( j - centreY )*Math.sin(k*thetaStep)));
                       
                        // move all values into positive range for display purposes
                        tmp = tmp + hh;
                        if (tmp < 0 || tmp >= 2*hh) continue;
                        
                        // increment the hough array
                        houghAccumulator[k][tmp]++;
                    }
                }
            }
        }
        
    }