I use an interface of RenderedImage for reading a tif image.
How can I get all rgb values of this picture in a 2d-Array like this:
red[0][128] = 120; // means x=0, y=128, red value = 120
// the value 120 is the value I have to determine (and oall other rgb values)!
Does anyone know this?
Thanks a lot for your help!
getData()returns aRaster, which has agetData()method.Can you call
YourRenderedImage.getData().getPixel(int x, int y, int iArray[])to get your RGB values?JavaDoc: Returns the samples in an array of int for the specified pixel. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds.
Raster.getPixel() – JavaDoc
I believe the elements returned by the
intarray represent: Red, Green, Blue, Alpha, and Hex key, but I don’t know for sure.