-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathisFirePixelLookUp.m
76 lines (70 loc) · 2.06 KB
/
isFirePixelLookUp.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
70
71
72
73
74
75
76
function [fireColorPixel, redPixelsOut] = isFirePixelLookUp( fireImage)
%isFirePixel Determine whether a given pixel can be classified as fire
%pixel or not
imageSize = size(fireImage(:,:,1));
redPixels = zeros(imageSize);
greenPixels = zeros(imageSize);
bluePixels = zeros(imageSize);
fireColorPixel = zeros(imageSize, 'uint8');
% use stored color lookup table for color lookup
red_ctd = [[226, 22];
[246, 30];
[228, 25];
[252, 31];
[250, 34];
[136, 15];
[189, 23];
[240, 24];
[183, 20];
[209, 28]];
green_ctd = [[124, 55];
[217, 64];
[180, 56];
[243, 55];
[184, 64];
[43, 35];
[139, 47];
[152, 59];
[78, 40];
[101, 47]];
blue_ctd = [[57, 51];
[145, 56];
[133, 52];
[173, 51];
[70, 58];
[15, 12];
[109, 37];
[62, 53];
[33, 14];
[45, 40]];
x = imageSize(1);
y = imageSize(2);
NClusters = 10;
alpha = 0.75; % tolerance factor
%fireImage = double(fireImage); % typecast to double to avoid roundoffs
for i = 1 : x
i
for j = 1 : y
for n = 1:NClusters
% dR is the distance between a red pixel of image and red centroid
% of any cluster. Similarly for green and blue pixels
dR = abs(double(fireImage(i,j,1)) - red_ctd(n, 1));
if dR < alpha * red_ctd(n, 2)
redPixels(i,j) = 1;
end
dG = abs(double(fireImage(i,j,2)) - green_ctd(n, 1));
if dG < alpha * green_ctd(n, 2)
greenPixels(i,j) = 1;
end
dB = abs(double(fireImage(i,j,3)) - blue_ctd(n, 1));
if dB < alpha * blue_ctd(n, 2)
bluePixels(i,j) = 1;
end
end
if (redPixels(i,j) == 1 && greenPixels(i,j) == 1)
fireColorPixel(i,j) = 1;
end
end
end
redPixelsOut = redPixels;
end