[993] | 1 | function [CineFileHeader, BitmapInfoHeader, CameraSetup, TimeOnlyBlock, ExposureOnlyBlock, TimeCodeBlock, imageLocations, annotationSize] = readCineHeader(filePath)
|
---|
[979] | 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 |
|
---|
[993] | 31 | fseek(fid, hex2dec('00E2'), 'bof');
|
---|
| 32 | CameraSetup.Length = fread(fid, 1, 'uint16');
|
---|
| 33 |
|
---|
| 34 | fseek(fid, hex2dec('0370'), 'bof');
|
---|
| 35 | CameraSetup.FirmwareVersion = fread(fid, 1, 'uint32');
|
---|
| 36 |
|
---|
| 37 | fseek(fid, hex2dec('0374'), 'bof');
|
---|
| 38 | CameraSetup.SoftwareVersion = fread(fid, 1, 'uint32');
|
---|
| 39 |
|
---|
[979] | 40 | fseek(fid, hex2dec('0354'), 'bof');
|
---|
| 41 | CameraSetup.FrameRate = fread(fid, 1, 'uint32');
|
---|
| 42 |
|
---|
| 43 | fseek(fid, hex2dec('0360'), 'bof');
|
---|
| 44 | CameraSetup.PostTrigger = fread(fid, 1, 'uint32');
|
---|
| 45 |
|
---|
| 46 | fseek(fid, hex2dec('03D4'), 'bof');
|
---|
| 47 | CameraSetup.RealBPP = fread(fid, 1, 'uint32');
|
---|
| 48 |
|
---|
| 49 | fseek(fid, hex2dec('16B8'), 'bof');
|
---|
| 50 | CameraSetup.BlackLevel = fread(fid, 1, 'uint32');
|
---|
| 51 |
|
---|
| 52 | fseek(fid, hex2dec('16BC'), 'bof');
|
---|
| 53 | CameraSetup.WhiteLevel = fread(fid, 1, 'uint32');
|
---|
| 54 |
|
---|
| 55 | fseek(fid, hex2dec('1B48'), 'bof');
|
---|
| 56 | CameraSetup.fGain16_8 = fread(fid, 1, 'float32');
|
---|
| 57 |
|
---|
| 58 | fseek(fid, hex2dec('17CC'), 'bof');
|
---|
| 59 | CameraSetup.fOffset = fread(fid, 1, 'float32');
|
---|
| 60 |
|
---|
| 61 | fseek(fid, hex2dec('17D0'), 'bof');
|
---|
| 62 | CameraSetup.fGain = fread(fid, 1, 'float32');
|
---|
| 63 |
|
---|
| 64 | fseek(fid, hex2dec('17DC'), 'bof');
|
---|
| 65 | CameraSetup.fGamma = fread(fid, 1, 'float32');
|
---|
| 66 |
|
---|
| 67 | fseek(fid, hex2dec('27D4'), 'bof');
|
---|
| 68 | CameraSetup.RecBPP = fread(fid, 1, 'uint32');
|
---|
| 69 |
|
---|
| 70 |
|
---|
[993] | 71 | %% Tagged Information Blocks
|
---|
| 72 | % AnalogDigitalSignals (ADS) -> not contained in MIRO cine-files
|
---|
| 73 | % ImageTimeTaggedBlock (ITTB) -> not contained in MIRO cine-files
|
---|
| 74 |
|
---|
| 75 | % TimeOnlyBlock (TOB) -> Type should be 1002
|
---|
| 76 | PositionTOB = CineFileHeader.OffSetup + CameraSetup.Length;
|
---|
| 77 | fseek(fid, PositionTOB , 'bof');
|
---|
| 78 | TimeOnlyBlock.Length = fread(fid, 1, 'uint32');
|
---|
| 79 | TimeOnlyBlock.Type = fread(fid, 1, 'uint16');
|
---|
| 80 | TimeOnlyBlock.Reserved = fread(fid, 1, 'uint16');
|
---|
| 81 | TimeOnlyBlock.Data = transpose([1:CineFileHeader.ImageCount ; fread(fid,[2,CineFileHeader.ImageCount], 'uint32')]); % Framenumber combined with Data contained in TOB
|
---|
| 82 | TimeOnlyBlock.TimestampsDatetime = datetime(TimeOnlyBlock.Data(:,3), 'ConvertFrom', 'posixtime'); % Timestamp as Datetime
|
---|
| 83 | % TimeOnlyBlock.TimestampsDatestr = datestr(TimeOnlyBlock.TimestampsDatetime); % Timestamp as String
|
---|
| 84 | TimeOnlyBlock.TimestampsMillisec = TimeOnlyBlock.Data(:,2)./(2^32); % Milliseconds of the Timestamp
|
---|
| 85 | TimeOnlyBlock.ExposureTimeDelays = [0 ; TimeOnlyBlock.TimestampsMillisec(2:end)-TimeOnlyBlock.TimestampsMillisec(1:end-1)]; % Timedifference between two frames. First frame is set to have no timedifference
|
---|
| 86 |
|
---|
| 87 | % ExposureOnlyBlock (EOB) -> Type should be 1003
|
---|
| 88 | PositionEOB = PositionTOB + TimeOnlyBlock.Length;
|
---|
| 89 | fseek(fid, PositionEOB , 'bof');
|
---|
| 90 | ExposureOnlyBlock.Length = fread(fid, 1, 'uint32');
|
---|
| 91 | ExposureOnlyBlock.Type = fread(fid, 1, 'uint16');
|
---|
| 92 | ExposureOnlyBlock.Reserved = fread(fid, 1, 'uint16');
|
---|
| 93 | ExposureOnlyBlock.Data = fread(fid,CineFileHeader.ImageCount, 'uint32');
|
---|
| 94 | ExposureOnlyBlock.ExposureTimesMillisec = ExposureOnlyBlock.Data ./(2^32) .*1000;
|
---|
| 95 | ExposureOnlyBlock.test1 = fread(fid, 1, 'uint32');
|
---|
| 96 | ExposureOnlyBlock.test2 = fread(fid, 1, 'uint16');
|
---|
| 97 | ExposureOnlyBlock.test3 = fread(fid, 1, 'uint16');
|
---|
| 98 |
|
---|
| 99 | % RangeDataBlock (RDB) -> not contained in MIRO cine-files
|
---|
| 100 | % BinSigBlock (BSB) -> not contained in MIRO cine-files
|
---|
| 101 | % AnaSigBlock (ASB) -> not contained in MIRO cine-files
|
---|
| 102 |
|
---|
| 103 | % TimeCodeBlock (TCB) -> Type should be 1007
|
---|
| 104 | PositionTCB = PositionEOB + ExposureOnlyBlock.Length;
|
---|
| 105 | fseek(fid, PositionTCB , 'bof');
|
---|
| 106 | TimeCodeBlock.Length = fread(fid, 1, 'uint32');
|
---|
| 107 | TimeCodeBlock.Type = fread(fid, 1, 'uint16');
|
---|
| 108 | TimeCodeBlock.Reserved = fread(fid, 1, 'uint16');
|
---|
| 109 | TimeCodeBlock.Data = fread(fid, 1, 'uint8');
|
---|
| 110 |
|
---|
| 111 |
|
---|
| 112 | %% Image Locations and their Annotations
|
---|
[979] | 113 | fseek(fid, CineFileHeader.OffImageOffsets, 'bof');
|
---|
| 114 | imageBlockLocations = fread(fid, CineFileHeader.ImageCount, 'int64');
|
---|
| 115 |
|
---|
| 116 | fseek(fid, imageBlockLocations(1), 'bof');
|
---|
| 117 | annotationSize = fread(fid, 1, 'uint32');
|
---|
| 118 |
|
---|
| 119 | imageLocations = imageBlockLocations + annotationSize;
|
---|
| 120 |
|
---|
[993] | 121 |
|
---|
| 122 | %%
|
---|
[979] | 123 | fclose(fid); |
---|