-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpatchNormalizeHMM.m
44 lines (38 loc) · 1.51 KB
/
patchNormalizeHMM.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
%
% Copyright 2013, Niko Sünderhauf
%
% This file is part of OpenSeqSLAM.
%
% OpenSeqSLAM is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% OpenSeqSLAM is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with OpenSeqSLAM. If not, see <http://www.gnu.org/licenses/>.
function img2 = patchNormalizeHMM(img,s,normalizationMode,pixelNormaliseOption)
if pixelNormaliseOption == 0
img2 = img;
n = 1:s:size(img,1)+1;
m = 1:s:size(img,2)+1;
for i=1:length(n)-1
for j=1:length(m)-1
p = img(n(i):n(i+1)-1, m(j):m(j+1)-1);
pp=p(:);
if normalizationMode ~=0
pp=double(pp);
img2(n(i):n(i+1)-1, m(j):m(j+1)-1) = 127+reshape(round((pp-mean(pp))/std(pp)), s, s);
else
f = 255.0/double(max(pp) - min(pp));
img2(n(i):n(i+1)-1, m(j):m(j+1)-1) = round(f * (p-min(pp)));
end
end
end
end
end