Page 1 of 1

Fastest way to open and save images

PostPosted: Fri Jul 01, 2011 8:28 am
by Oli
Hello,

Thanks again for your excellent support and help. I've been playing a bit with the different classes in LOCI BioFormats in its Java form and was wondering what would be the fastest way to open and save files?

The situation is this: I have an LSM file and I need to extract some files and save them on a hard drive to perform some operations.

The current scheme works like this:
Code: Select all
for (int i = 1; i <= getnImages(); i++) {
   r1.setSeries(i-1);
   ImageProcessor ip = r1.openProcessors(r1.getIndex(z-1, c-1, t-1))[0];
   ImagePlus imp = new ImagePlus("Image " + i + ", Plane " + z
                  + ", channel " + c + ", timepoint " + t, ip);

   FileSaver stitchSave = new FileSaver(imp);
   String filePath = getTempDir()+getFileName("Temp",i,0,0,t)+".tif";

   stitchSave.saveAsTiff(filePath);

   imp.close();


I'm guessing using a reader that handles the BufferedImage type might be faster but I haven't found a way to do that yet. If anyone has any clues, it would be a great help!

Best

Oli

Re: Fastest way to open and save images

PostPosted: Wed Jul 06, 2011 5:44 pm
by mlinkert
Hi Oli,

Thanks again for your excellent support and help. I've been playing a bit with the different classes in LOCI BioFormats in its Java form and was wondering what would be the fastest way to open and save files?

The situation is this: I have an LSM file and I need to extract some files and save them on a hard drive to perform some operations.

The current scheme works like this:

*snipped code*
I'm guessing using a reader that handles the BufferedImage type might be faster but I haven't found a way to do that yet. If anyone has any clues, it would be a great help!


Probably the fastest approach is to use Bio-Formats' TIFF writer and work with the images as byte arrays instead of constructing ImageProcessor and ImagePlus objects (which requires some overhead). This does require a bit more code, though. This page on the OME wiki explains how to use Bio-Formats to convert files:

http://trac.openmicroscopy.org.uk/ome/w ... ats-Export

If all you need to do is convert files to TIFF, you then you might also have a look at the 'bfconvert' command line tool: http://loci.wisc.edu/bio-formats/command-line-tools
That allows you to convert files without writing any code, and provides a number of options for specifying which planes within a file are to be converted.

Regards,
-Melissa