1 | function [CineFileHeader, BitmapInfoHeader, CameraSetup, imageLocations, annotationSize] = readCineHeader(filePath)
|
---|
2 |
|
---|
3 | fid = fopen(filePath);
|
---|
4 |
|
---|
5 | CineFileHeader.Type = fread(fid, 1, 'uint16');
|
---|
6 | CineFileHeader.Headersize = fread(fid, 1, 'uint16');
|
---|
7 | CineFileHeader.Compression = fread(fid, 1, 'uint16');
|
---|
8 | CineFileHeader.Version = fread(fid, 1, 'uint16');
|
---|
9 | CineFileHeader.FirstMovieImage = fread(fid, 1, 'int32');
|
---|
10 | CineFileHeader.TotalImageCount = fread(fid, 1, 'uint32');
|
---|
11 | CineFileHeader.FirstImageNo = fread(fid, 1, 'int32');
|
---|
12 | CineFileHeader.ImageCount = fread(fid, 1, 'uint32');
|
---|
13 | CineFileHeader.OffImageHeader = fread(fid, 1, 'uint32');
|
---|
14 | CineFileHeader.OffSetup = fread(fid, 1, 'uint32');
|
---|
15 | CineFileHeader.OffImageOffsets = fread(fid, 1, 'uint32');
|
---|
16 | CineFileHeader.TriggerTime = fread(fid, 1, 'uint64')/2^32; % Epoch time (secs since jan 1, 1970)
|
---|
17 | %CineFileHeader.TriggerTime2 = fread(fid, 1, 'uint32');
|
---|
18 |
|
---|
19 | BitmapInfoHeader.biSize = fread(fid, 1, 'int32');
|
---|
20 | BitmapInfoHeader.biWidth = fread(fid, 1, 'int32');
|
---|
21 | BitmapInfoHeader.biHeight = fread(fid, 1, 'int32');
|
---|
22 | BitmapInfoHeader.biPlanes = fread(fid, 1, 'uint16');
|
---|
23 | BitmapInfoHeader.biBitCount = fread(fid, 1, 'uint16');
|
---|
24 | BitmapInfoHeader.biCompression = fread(fid, 1, 'uint32');
|
---|
25 | BitmapInfoHeader.biSizeImage = fread(fid, 1, 'uint32');
|
---|
26 | BitmapInfoHeader.biXPelsPerMeter= fread(fid, 1, 'uint32');
|
---|
27 | BitmapInfoHeader.biYPelsPerMeter= fread(fid, 1, 'int32');
|
---|
28 | BitmapInfoHeader.biClrUsed = fread(fid, 1, 'uint32');
|
---|
29 | BitmapInfoHeader.biClrImportant = fread(fid, 1, 'uint32');
|
---|
30 |
|
---|
31 | fseek(fid, hex2dec('0354'), 'bof');
|
---|
32 | CameraSetup.FrameRate = fread(fid, 1, 'uint32');
|
---|
33 |
|
---|
34 | fseek(fid, hex2dec('0360'), 'bof');
|
---|
35 | CameraSetup.PostTrigger = fread(fid, 1, 'uint32');
|
---|
36 |
|
---|
37 | fseek(fid, hex2dec('03D4'), 'bof');
|
---|
38 | CameraSetup.RealBPP = fread(fid, 1, 'uint32');
|
---|
39 |
|
---|
40 | fseek(fid, hex2dec('16B8'), 'bof');
|
---|
41 | CameraSetup.BlackLevel = fread(fid, 1, 'uint32');
|
---|
42 |
|
---|
43 | fseek(fid, hex2dec('16BC'), 'bof');
|
---|
44 | CameraSetup.WhiteLevel = fread(fid, 1, 'uint32');
|
---|
45 |
|
---|
46 | fseek(fid, hex2dec('1B48'), 'bof');
|
---|
47 | CameraSetup.fGain16_8 = fread(fid, 1, 'float32');
|
---|
48 |
|
---|
49 | fseek(fid, hex2dec('17CC'), 'bof');
|
---|
50 | CameraSetup.fOffset = fread(fid, 1, 'float32');
|
---|
51 |
|
---|
52 | fseek(fid, hex2dec('17D0'), 'bof');
|
---|
53 | CameraSetup.fGain = fread(fid, 1, 'float32');
|
---|
54 |
|
---|
55 | fseek(fid, hex2dec('17DC'), 'bof');
|
---|
56 | CameraSetup.fGamma = fread(fid, 1, 'float32');
|
---|
57 |
|
---|
58 | fseek(fid, hex2dec('27D4'), 'bof');
|
---|
59 | CameraSetup.RecBPP = fread(fid, 1, 'uint32');
|
---|
60 |
|
---|
61 |
|
---|
62 | fseek(fid, CineFileHeader.OffImageOffsets, 'bof');
|
---|
63 | imageBlockLocations = fread(fid, CineFileHeader.ImageCount, 'int64');
|
---|
64 |
|
---|
65 |
|
---|
66 | fseek(fid, imageBlockLocations(1), 'bof');
|
---|
67 | annotationSize = fread(fid, 1, 'uint32');
|
---|
68 |
|
---|
69 |
|
---|
70 | imageLocations = imageBlockLocations + annotationSize;
|
---|
71 |
|
---|
72 | fclose(fid); |
---|