public void updateImage(BufferedImage selectedImage) {
    	for (int i = 0; i < X.length; i++) {
    		int x = selectionArea.get(i).x - xMin;
    		int y = selectionArea.get(i).y - yMin;
    		int R = (int)Math.round(X[i][0]);
    		int G = (int)Math.round(X[i][1]);
    		int B = (int)Math.round(X[i][2]);
    		if (R > 255) R = 255;
    		if (R < 0) R = 0;
    		if (G > 255) G = 255;
    		if (G < 0) G = 0;
    		if (B > 255) B = 255;
    		if (B < 0) B = 0;
    		int RGB = 0xFF000000 | (R<<16)&0xFF0000 | (G<<8)&0xFF00 | B&0xFF;
    		selectedImage.setRGB(x, y, RGB);
    	}
    }