This repository has been archived by the owner. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
littlke fix with possible filename issues
- Loading branch information
1 parent
94ec74c
commit cd52d25
Showing
2 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
function out = readTif(fName) | ||
% Function for speed-optimized reading of tif files, ignoring all meta-data | ||
% and dimension sorting | ||
|
||
ww = imfinfo(fName); % Tif file information | ||
nCol = ww(1).SamplesPerPixel; % Number of color channels (NOT TESTED!) | ||
nImg = numel(ww); % Number of frames | ||
if ww(1).BitsPerSample(1) <= 16 | ||
out = zeros(ww(1).Height, ww(1).Width,nCol, nImg,'uint16'); | ||
else | ||
out = zeros(ww(1).Height, ww(1).Width, nCol, nImg); | ||
end | ||
readLength = [ww(1).Width ww(1).Height]; % order has to be reversed for correct reading of data (don't know why) | ||
gl_fid = fopen (fName, 'r', 'l'); | ||
for j=1:nImg | ||
for col=1:nCol | ||
fseek(gl_fid, ww(j).StripOffsets(col) , 'bof'); | ||
if ww(j).BitsPerSample(col) <=8 | ||
out(:,:,col,j) = uint16(fread(gl_fid,readLength, '*uint8'))'; | ||
elseif ww(j).BitsPerSample(col) <=16 | ||
out(:,:,col,j) = fread(gl_fid, readLength, '*uint16')'; | ||
else ww(j).BitsPerSample(col) | ||
out(:,:,col,j) = fread(gl_fid,readLength, 'uint32')'; | ||
end | ||
end | ||
end | ||
fclose(gl_fid); | ||
out = squeeze(out); |