-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSmoothenLuminosity.m
69 lines (53 loc) · 1.66 KB
/
SmoothenLuminosity.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function smoothLuminance = SmoothenLuminosity(inLuminance, fHandle)
%if nargin == 1
% interactive = false;
%elseif nargin == 2
% interactive = true;
%else
% error('Wrong number of arguments');
%end
%smootheningMethods = {'lowpass', 'loess'};
%methodIdx = true;
method = 'lowpass';
factor = 0.5;
figure(fHandle);
smoothCurve = SmoothLowPass(factor, inLuminance);
sCurveHandle = plot(smoothCurve, 'r');
title(sprintf('%s, %d', method, factor));
inputChar='q';
% Warning: Clumsy code ahead
while(~strcmpi(inputChar,'d'))
inputChar = sprintf('%c',getkey);
if strcmpi(inputChar,'m');
if strcmpi(method, 'lowpass')
method = 'loess';
factor = 0.5;
elseif strcmpi(method, 'loess')
method = 'lowpass';
factor = 0.5;
end
elseif strcmpi(inputChar, 'a')
if strcmpi(method, 'lowpass')
factor = max(factor/2, 0);
elseif strcmpi(method, 'loess')
factor = min(factor*2, 1);
end
elseif strcmpi(inputChar, 's')
if strcmpi(method, 'lowpass')
factor = min(factor*2, 1);
elseif strcmpi(method, 'loess')
factor = max(factor/2, 0);
end
end
if strcmpi(method, 'lowpass')
delete(sCurveHandle);
smoothCurve = SmoothLowPass(factor, inLuminance);
elseif strcmpi(method, 'loess')
delete(sCurveHandle);
smoothCurve = SmoothLowess(inLuminance, factor);
end
sCurveHandle = plot(smoothCurve, 'r');
title(sprintf('%s, %f', method, factor));
end
smoothLuminance = smoothCurve;
end