I am using this phone app as eyes for an application I’m writing on PC. The webcam app allows me to download instant shots in jpeg format. I need to do image processing of those shots and in order to do that I would like to get my hands on the raw data arrays – namely the matrix of pixels describing the image. How can this be done?
Share
The easiest way is to do
ImageIO.read(new File("Image.jpeg"))to get the
BufferedImage. Using theBufferedImageyou can usegetRGB(int x, int y)orgetRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize)for better performance. Additionally,getRaster()is an option, which I’ve found to be the fastest (a little more effort though).For setting pixels, similar
setRGBmethods exist.Edit:
ImageIOisjavax.imageio.ImageIO.