Skip to content

Commit 2b8f941

Browse files
TinoDornbuschdlebauer
authored andcommitted
added matlab/octave scripts for processing PS2, NDVI, FLIR re issue #64
1 parent 8a85ffb commit 2b8f941

File tree

4 files changed

+182
-0
lines changed

4 files changed

+182
-0
lines changed

scripts/FLIR/GetFLIR.m

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[FileName,PathName,FilterIndex] = uigetfile('*.bin');
2+
3+
fileID = fopen([PathName FileName]);
4+
A = fread(fileID,[640,480],'uint16');
5+
6+
7+
%rescale to visible range
8+
Gmin=2800;
9+
Gmax=3300;
10+
11+
At=((A-Gmin)/(Gmax-Gmin));
12+
13+
colormap('hot')
14+
figure(1),imagesc(At),colorbar, axis off

scripts/NDVI/GetNDVI.m

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
## Copyright (C) 2016 LemnaTec
2+
##
3+
## This program is free software; you can redistribute it and/or modify it
4+
## under the terms of the GNU General Public License as published by
5+
## the Free Software Foundation; either version 3 of the License, or
6+
## (at your option) any later version.
7+
##
8+
## This program is distributed in the hope that it will be useful,
9+
## but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
## GNU General Public License for more details.
12+
##
13+
## You should have received a copy of the GNU General Public License
14+
## along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
16+
## -*- texinfo -*-
17+
## @deftypefn {Function File} {@var{retval} =} GetNDVI (@var{input1}, @var{input2})
18+
##
19+
## @seealso{}
20+
## @end deftypefn
21+
22+
## Author: LemnaTec <LemnaTec@S1_CONTAINER>
23+
## Created: 2016-06-03
24+
25+
function [NDVI,x,y,z,time] = GetNDVI (PathName)
26+
27+
if nargin==0
28+
29+
[PathName] = uigetdir();
30+
31+
end
32+
33+
34+
D=dir(PathName);
35+
36+
% read NDVI from file
37+
Text=importdata([PathName '\' D(4).name]);
38+
fi=findstr(Text{2},'"');
39+
NDVI=str2num(Text{2}(fi(3)+1:fi(4)-1));
40+
41+
% read x,y,z from file
42+
Text=importdata([PathName '\' D(3).name]);
43+
% x = row 22 y = row 23 z = row 24
44+
fi=findstr(Text{22},'"');
45+
x=str2num(Text{22}(fi(3)+1:fi(4)-1));
46+
47+
fi=findstr(Text{23},'"');
48+
y=str2num(Text{23}(fi(3)+1:fi(4)-1));
49+
50+
fi=findstr(Text{24},'"');
51+
z=str2num(Text{24}(fi(3)+1:fi(4)-1));
52+
53+
% read time
54+
Text=importdata([PathName '\' D(3).name]);
55+
fi=findstr(Text{21},'"');
56+
timestr=Text{21}(fi(3)+1:fi(4)-1);
57+
Year=timestr(7:10);
58+
Month=timestr(1:2);
59+
Day=timestr(4:5);
60+
Hour=timestr(12:13);
61+
Minute=timestr(15:16);
62+
63+
time = datenum(str2num(Year), str2num(Month), str2num(Day), str2num(Hour), str2num(Minute));
64+
65+
endfunction

scripts/NDVI/PlotNDVI.m

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
## Copyright (C) 2016 LemnaTec
2+
##
3+
## This program is free software; you can redistribute it and/or modify it
4+
## under the terms of the GNU General Public License as published by
5+
## the Free Software Foundation; either version 3 of the License, or
6+
## (at your option) any later version.
7+
##
8+
## This program is distributed in the hope that it will be useful,
9+
## but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
## GNU General Public License for more details.
12+
##
13+
## You should have received a copy of the GNU General Public License
14+
## along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
16+
## -*- texinfo -*-
17+
## @deftypefn {Function File} {@var{retval} =} PlotNDVI (@var{input1}, @var{input2})
18+
##
19+
## @seealso{}
20+
## @end deftypefn
21+
22+
## Author: LemnaTec <LemnaTec@S1_CONTAINER>
23+
## Created: 2016-06-04
24+
25+
function [retval] = PlotNDVI (input1, input2)
26+
27+
[PathName] = uigetdir();
28+
29+
D=dir(PathName);
30+
31+
for i=3:size(D,1)
32+
33+
[NDVI(i-2),x(i-2),y(i-2),z(i-2),t(i-2)]=GetNDVI([PathName '\' D(i).name]);
34+
35+
end
36+
37+
colorMap=jet(length(unique(NDVI)));
38+
set(gcf, 'ColorMap', colorMap);
39+
h=plot(x,y);
40+
41+
endfunction

scripts/PS2/GetPS2.m

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
2+
[FileName,PathName,FilterIndex] = uigetfile('*.bin');
3+
pkg image load
4+
clear M
5+
close all
6+
7+
D=dir(PathName);
8+
9+
10+
11+
for i=4:size(D,1)-1
12+
13+
14+
fileID = fopen([PathName D(i).name]);
15+
A = fread(fileID,[1936,1216],'uint8');
16+
A=double(A)./255;
17+
18+
M(i-3)=mean(mean(A));
19+
20+
21+
22+
end
23+
24+
figure(1),subplot(3,1,1),plot(M), xlabel("frame"),ylabel("mean intensity")
25+
26+
% get Frame 1 as Fdark
27+
fileID = fopen([PathName D(4).name]);
28+
Fdark = fread(fileID,[1936,1216],'uint8');
29+
Fdark=double(Fdark)./255;
30+
% get Frame 2 as Fv
31+
fileID = fopen([PathName D(5).name]);
32+
F0 = fread(fileID,[1936,1216],'uint8');
33+
% subtract Fdark
34+
F0=double(F0)./255-Fdark;
35+
36+
fileID = fopen([PathName D(40).name]);
37+
Fm = fread(fileID,[1936,1216],'uint8');
38+
% subtract Fdark
39+
Fm=double(Fm)./255-Fdark;
40+
FmHist=reshape(Fm,1,1936*1216);
41+
42+
% image mask
43+
threshold=max(max(Fm))/10;
44+
45+
mask=Fm>threshold & (Fm-F0)>=0;
46+
47+
% clean up a bit
48+
se = strel ("square", 5);
49+
% remove background
50+
mask=imerode (mask, se);
51+
% fill holes
52+
mask=imdilate(mask, se);
53+
54+
FvFm=(Fm-F0)./Fm.*mask;
55+
56+
colormap('hot')
57+
figure(1),subplot(3,1,2),imagesc(FvFm),colorbar, axis off
58+
59+
FvFm(FvFm==0)=NaN;
60+
FvFmHist=reshape(FvFm,1,1936*1216);
61+
figure(1),subplot(3,1,3),hist(FvFmHist,50),, xlim([0,1]),xlabel("Fv/Fm"),ylabel("no of pixel")
62+

0 commit comments

Comments
 (0)