rharkes / fast_tiff_write Goto Github PK
View Code? Open in Web Editor NEWA fast multi-image tiff writer for Matlab
License: GNU General Public License v3.0
A fast multi-image tiff writer for Matlab
License: GNU General Public License v3.0
My data is int16 tif
Using Fast_Tiff_Write to save large TIFF files takes approximately half the time compared to saving with the Tiff library. The time difference between the two is not more than ten times greater than stated in Readme.
only change the tags in code.
tf.setTag('Photometric',Tiff.Photometric.MinIsBlack);
tf.setTag('Compression',Tiff.Compression.None);
tf.setTag('BitsPerSample',16);
tf.setTag('SamplesPerPixel',1);
tf.setTag('SampleFormat',Tiff.SampleFormat.UInt);
tf.setTag('ImageLength',size(IM,1));
tf.setTag('ImageWidth',size(IM,2));
tf.setTag('ResolutionUnit',3);
tf.setTag('PlanarConfiguration',Tiff.PlanarConfiguration.Chunky);
My Computer is Thinkbook 16+ 2023,CPU is AMD R7480H, GPU is GTX 4050
like XResolution, YResolution, and ResolutionUnit
I used MATLAB R2019a Update 6 (on macOS Sierra 10.12.6) to run the included test_fTiff.m. The resulting test.tif cannot be read by ImageJ (only the first frame is recognized). MATLAB 'imread' gives the following error:
Unable to read TIFF file "test.tif". File is corrupt or image does not contain any readable strips.
Consider that the aspect ratio of the image is not 1:1
It's fast and mostly reliable, it helps a lot for writing large image stacks. Thanks.
However, the written images appear to be rotated and flipped (x and y axes are swapped)
Here is a bit of code to show this:
% fast Tiff test
testImg = [1,2;3,4;5,6];
testImg = im2uint16(rescale(testImg));
imwrite(testImg,'tiff-imwrite.tif');
fTIFF = Fast_Tiff_Write('tiff-fTIFF.tif',1,0);
fTIFF.WriteIMG(testImg); %% this does not work for some reason
% fTIFF.WriteIMG(permute(testImg,[2,1])); %% this does work
fTIFF.close;
subplot(1,3,1);
imagesc(testImg);
axis equal tight
title('original image')
subplot(1,3,2)
imagesc(imread('tiff-imwrite.tif'));
axis equal tight
title('read after imwrite')
subplot(1,3,3)
imagesc(imread('tiff-fTIFF.tif'));
axis equal tight
title('read after fTIFF.WriteIMG')
This produces this result:
In case OS and Matlab version are relevant: '9.6.0.1214997 (R2019a) Update 6' on 'PCWIN64' (Windows 10).
A simple workaround is to permute the image before writing (as in the commented-out line 10), but perhaps there is a way to not have to do this.
(Or perhaps I'm missing something obvious, that's also quite possible).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.