Bio-Formats is a Java library for reading and writing data in life sciences image file formats. It is developed by the Open Microscopy Environment (particularly UW-Madison LOCI and Glencoe Software). Bio-Formats is released under the GNU General Public License (GPL); commercial licenses are available from Glencoe Software.
boolean floatingPoint = (pixelType == FormatTools.FLOAT || pixelType == FormatTools.DOUBLE);
int bytesPerPixel = FormatTools.getBytesPerPixel(pixelType);
SVSReader r = new SVSReader();
r.setId("/path/to/myfile.svs");
int pixelType = r.getPixelType();
boolean floatingPoint = (pixelType == FormatTools.FLOAT || pixelType == FormatTools.DOUBLE);
int bytesPerPixel = FormatTools.getBytesPerPixel(pixelType);
boolean litteEndian = r.isLittleEndian();
for (int s=0; s<r.getSeriesCount(); s++) {
r.setSeries(s);
int width = r.getSizeX();
int height = r.getSizeY();
int z = r.getSizeZ();
int timePoints = r.getSizeT();
int channels = r.getSizeC();
for (int i=0; i<r.getImageCount(); i++) {
byte[] plane = r.openBytes(i);
Object pixelData = DataTools.makeDataArray2D(plane, bytesPerPixel, floatingPoint, litteEndian, height);
byte[][] pixels = (byte[][]) pixelData;
for (int c =0; c < channels; c++) {
for (int x =0; x < width; x++) {
for (int y =0; y < height; y++) {
System.out.println("Pixel Value at channel:" + c +" coordinates x: " + x + " y: " + y + " is: " + pixels[(c*x)+x][y]);
}
}
}
}
}
r.close();