Image file to spreadsheet

I want to take an image file (eg tiff) and convert it to a spreadsheet (csv, or whatever) such that each pixel becomes a cell with a numeric value for that pixel.

I have googled it, and everyone is trying to sell me OCR software, that is certainly not what I want.

I will be editing the image beforehand, so can convert it to any format required, and can crop it down to a managable size.

It's mainly greyscale I'm interested in, and could do the little bit of colour that I will need as 3 separate files (one per colour channel) .

I will be doing statistical analysis on the spreadsheet later. I could likelly knock somthing together in java to do it, especially given that this is a proof of concept for a (much) later programming project, but that really feels like far too much hastle for what should be a simple task.


It's not too complicated. Here's an approach in Java. You'd just need to write this to CSV.. just simple writing to a file.

for (int x = 0; x < image.getWidth(); ++x)
  for (int y = 0; y < image.getHeight(); ++y) {
    int pixel = image.getRGB(x, y);
    int r = (pixel >> 16) & 0xff;
    int g = (pixel >> 8) & 0xff;
    int b = (pixel) & 0xff;
  }
}

where image is a BufferedImage. You can load a BufferedImage with ImageIO.read(File input);. You'll find this in javax.imageio.ImageIO.