-
Notifications
You must be signed in to change notification settings - Fork 0
/
ND2Read.m
27 lines (19 loc) · 1.07 KB
/
ND2Read.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function [ImageStack] = ND2Read(FilePointer, ImagePointer, ImageReadOut, Num)
if ImageReadOut.uiComponents == 1
ImageStack = zeros([ImageReadOut.uiHeight, ImageReadOut.uiWidth, size(Num, 2)],'uint16');
for i = 1:size(Num, 2)
[~, ~, ImageReadOut] = calllib('libNd2ReadSdk', 'Lim_FileGetImageData', FilePointer, uint32(Num(i) - 1), ImagePointer);
Image = reshape(ImageReadOut.pImageData, [ImageReadOut.uiWidth, ImageReadOut.uiHeight]);
ImageStack(:, :, i) = Image';
end
else
ImageStack = cell([1, ImageReadOut.uiComponents]);
for i = 1:size(Num, 2)
[~, ~, ImageReadOut] = calllib('libNd2ReadSdk', 'Lim_FileGetImageData', FilePointer, uint32(Num(i) - 1), ImagePointer);
Image = reshape(ImageReadOut.pImageData, [ImageReadOut.uiComponents, ImageReadOut.uiWidth * ImageReadOut.uiHeight]);
for j = 1:ImageReadOut.uiComponents
ImageStack{j}(:, :, i) = reshape(Image(j, :), [ImageReadOut.uiWidth, ImageReadOut.uiHeight])';
end
end
end
end