Changes between Version 1 and Version 2 of Matlab


Ignore:
Timestamp:
06/09/10 13:10:19 (9 years ago)
Author:
melissa
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Matlab

    v1 v2  
    5252 
    5353= Saving files = 
     54 
     55First, make sure that you have loci_tools.jar installed in your MATLAB work folder.  
     56 
     57Now, here is the basic code for saving planes to a file: 
     58 
     59{{{ 
     60  javaaddpath(fullfile(fileparts(mfilename('fullpath')), 'loci_tools.jar')); 
     61  writer = loci.formats.ImageWriter(); 
     62  metadata = loci.formats.MetadataTools.createOMEXMLMetadata(); 
     63  metadata.createRoot(); 
     64  metadata.setImageID('Image:0', 0); 
     65  metadata.setPixelsID('Pixels:0', 0); 
     66  metadata.setPixelsBinDataBigEndian(java.lang.Boolean.TRUE, 0, 0); 
     67  metadata.setPixelsDimensionOrder(ome.xml.model.enums.DimensionOrder.XYZCT, 0); 
     68  metadata.setPixelsType(ome.xml.model.enums.PixelType.UINT8, 0); 
     69  metadata.setPixelsSizeX(ome.xml.model.primitives.PositiveInteger(java.lang.Integer(64)), 0); 
     70  metadata.setPixelsSizeY(ome.xml.model.primitives.PositiveInteger(java.lang.Integer(64)), 0); 
     71  metadata.setPixelsSizeZ(ome.xml.model.primitives.PositiveInteger(java.lang.Integer(1)), 0); 
     72  metadata.setPixelsSizeC(ome.xml.model.primitives.PositiveInteger(java.lang.Integer(1)), 0); 
     73  metadata.setPixelsSizeT(ome.xml.model.primitives.PositiveInteger(java.lang.Integer(1)), 0); 
     74  metadata.setChannelID('Channel:0:0', 0, 0); 
     75  metadata.setChannelSamplesPerPixel(1, 0, 0); 
     76   
     77  writer.setMetadataRetrieve(metadata); 
     78  writer.setId("my-file.ome.tiff"); 
     79  writer.saveBytes(0, plane); 
     80  writer.close(); 
     81}}} 
     82 
     83This example will write a single plane to an OME-TIFF file.  It assumes that there are 8 unsigned bits per pixel, and that the image is 64 pixels x 64 pixels.  In your own code, you will need to adjust the dimensions and pixel type accordingly.  Also, 'plane' is an array constructed like so: 
     84 
     85{{{ 
     86  plane = zeros(1, 64 * 64, 'uint8'); 
     87}}} 
     88 
     89In the near future, we will have a script for saving files similar to bfopen.m; see #396.