[ome-devel] in-memory reading
Manuel Stritt
manuel.stritt at idorsia.com
Fri Sep 1 10:00:45 BST 2017
Dear all,
I'm trying to use the in-memory reading method as documented here:
https://docs.openmicroscopy.org/bio-formats/5.6.0/developers/in-memory.html
in combination with a NDPI reader + BufferedImageReader:
String fn = "test3-DAPI 2 (387) .ndpi";
// read in entire file
System.out.println("Reading file into memory from disk...");
File inputFile = new File(fn);
int fileSize = (int) inputFile.length();
DataInputStream in = new DataInputStream(new
FileInputStream(inputFile));
byte[] inBytes = new byte[fileSize];
in.readFully(inBytes);
System.out.println(fileSize + " bytes read.");
in.close();
String fileName = inputFile.getName();
int dot = fileName.lastIndexOf(".");
String suffix = dot < 0 ? "" : fileName.substring(dot);
// map input id string to input byte array
final String inId = "inBytes" + suffix;
Location.mapFile(inId, new ByteArrayHandle(inBytes));
NDPIReader reader = new NDPIReader();
reader.setFlattenedResolutions(false);
reader.setId(inId);
System.out.println("size reader: "+reader.getSizeX()+" x"
+reader.getSizeY()); // works
try {
BufferedImageReader bir = new BufferedImageReader(reader);
BufferedImage bi = bir.openImage(0, 0, 0, 100, 100); //
IndexOutOfBoundsException !!!
System.out.println("size image: " + bi.getWidth() + " x " +
bi.getHeight());
} finally {
reader.close();
}
NDPI testfile from here:
http://downloads.openmicroscopy.org/images/Hamamatsu-NDPI/manuel/test3-DAPI%202%20(387)%20.ndpi
the line bir.openImage throws an IndexOutOfBoundsException - without the
memory mapping it works.
Any hints what I'm doing wrong?
Thanks a lot for your help!
Regards,
Manuel
--
The information of this email and in any file transmitted with it is
strictly confidential and may be legally privileged.
It is intended solely for the addressee. If you are not the intended
recipient, any copying, distribution or any other use of this email is
prohibited and may be unlawful. In such case, you should please notify the
sender immediately and destroy this email.
The content of this email is not legally binding unless confirmed by letter.
Any views expressed in this message are those of the individual sender,
except where the message states otherwise and the sender is authorized to
state them to be the views of the sender's company.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openmicroscopy.org.uk/pipermail/ome-devel/attachments/20170901/498ea67e/attachment.html>
More information about the ome-devel
mailing list