We're Hiring!

Fastest way to open and save images

Historical discussions about the Bio-Formats library. Please look for and ask new questions at https://forum.image.sc/tags/bio-formats
Please note:
Historical discussions about the Bio-Formats library. Please look for and ask new questions at https://forum.image.sc/tags/bio-formats

If you are having trouble with image files, there is information about reporting bugs in the Bio-Formats documentation. Please send us the data and let us know what version of Bio-Formats you are using. For issues with your code, please provide a link to a public repository, ideally GitHub.

Fastest way to open and save images

Postby Oli » Fri Jul 01, 2011 8:28 am

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
Oli
 
Posts: 71
Joined: Mon Nov 29, 2010 4:57 pm

Re: Fastest way to open and save images

Postby mlinkert » Wed Jul 06, 2011 5:44 pm

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
User avatar
mlinkert
Team Member
 
Posts: 353
Joined: Fri May 29, 2009 2:12 pm
Location: Southwest Wisconsin


Return to User Discussion [Legacy]

Who is online

Users browsing this forum: No registered users and 0 guests