by uutzinger » Tue May 21, 2013 11:00 pm
This was very helpful. Following code segments will expand bfsave on windows to include bigtiff and compression support:
% INPUT:
% I - a 5D matrix containing the pixels data
%
% outputPath - a string containing the location of the path where to
% save the resulting OME-TIFF
%
% dimensionOrder - optional. A string representing the dimension
% order, Default: XYZCT.
%
% Compression - use zlib, bzip2, none, LZW, JPEG, JPEG-2000,
% Uncompressed
% zlib is not available on Windows and results in no compression
% JPEG is very slow
%
% bigTiff - use 64 bit tiff tags, true or false
% List all values of Compression
CompressionValues = ome.xml.model.enums.Compression.values();
Compressions = cell(numel(CompressionValues)+4, 1);
for i = 1 :numel(CompressionValues),
Compressions{i} = char(CompressionValues(i).toString());
end
Compressions{numel(CompressionValues)+1}='LZW'; % Error in OME xml, lists only unix compressors
Compressions{numel(CompressionValues)+2}='JPEG'; % Error in OME xml, lists only unix compressors
Compressions{numel(CompressionValues)+3}='Uncompressed'; % Error in OME xml, lists only unix compressors
Compressions{numel(CompressionValues)+4}='JPEG-2000'; % Error in OME xml, lists only unix compressors
.. some code here ...
ip.addOptional('dimensionOrder', 'XYZCT', @(x) ismember(x, dimensionsOrders));
ip.addOptional('Compression', 'zlib', @(x) ismember(x, Compressions));
ip.addOptional('bigTiff', false , @islogical);
.. some code here ...
% Create ImageWriter
writer = loci.formats.ImageWriter();
writer.setWriteSequentially(true);
writer.setMetadataRetrieve(metadata);
if ~strcmp(ip.Results.Compression, 'none')
writer.setCompression(ip.Results.Compression)
end
writer.getWriter(outputPath).setBigTiff(ip.Results.bigTiff)
writer.setId(outputPath);