I am using setRGB() for changing the values of the pixel of an image.
int rgb=new Color(0,0,0).getRGB(); image1.setRGB(i,j,rgb); //where i,j is the boundarie
Color col = new Color(newValue, newValue, newValue); image1.setRGB(i, j, col.getRGB());