Automatic Fire Detection with Matlab

Hello all,

I am want to share my term project that lessons name is Digital Signal Processing Design & Applications. I spend a lot of my time to this project unfortunately I couldn’t find what I did want to do. So I thought a little and came up with basic algorithm to do solve this project. Sorry I forget to explain my project to you.

So The important things is recognize to fire on early stage ! I want to detect fire automatically when it’s on early stages. Also to make fire extinction easier for controlling the fire and smoke.

Imagine that if you see fire and you run to where is the fire break glass. This is one of the solutions. Another solution is a smoke and heat sensor system. Yes, this is a good solution but this is not recognized as the early stage of fire!

So, what I am thinking about this problem ? . I want to say I didn’t search any Project for this course. I wanted to this Project. And also I have already develop this Project.

My solution is image processing because images see that wide area. And computer determinate to fire detected or no fire in here. This also solves the basic solution. In the future it makes saves lives.

Algorithm

  • Determine of digital image
  • Convert to R G B Colour range Matrix
  • Selection of yellow colour range on photo
  • Convert image to binary range
  • Count that how much binary inside the image
foto = imread('fire.jpg');
foto2 = imread('fire2.jpg');
foto3 = imread('fire3.jpg');
foto4 = imread('fire4.jpg');
foto5 = imread('fire5.jpg');
foto6 = imread('fire6.jpg');
foto7 = imread('fire7.jpg');
foto8 = imread('fire8.jpg');
foto9 = imread('fire9.jpg');
foto10 = imread('fire10.jpg');
foto11 = imread('fire11.jpg');
foto12 = imread('fire12.jpg');
foto13 = imread('fire13.jpg');
 
figure(1)
 
%--------------------------------
subplot(4,6,1)
imshow(foto)
 
title(num2str(1))
 
R = foto(:, :, 1);
G = foto(:, :, 2);
B = foto(:, :, 3);
 
yellowness = (single(R) + single(G))/2 - single(B);
binaryYellow = yellowness > 120; 
 
subplot(4,6,2)
imshow(binaryYellow)
 
 
 tesbit1=sum(binaryYellow(:));
 
 if tesbit1>1500 
h = waitbar(0, 'Fire Detected');
set(h,'Name', 'Picture 1')
title('Fire Detected')
else
h = waitbar(0, 'No fire');
set(h,'Name', 'Picture 1')
title('No Fire')
end
 
 %----------------------------------------------------------------------------
 
subplot(4,6,3)
imshow(foto2)
 
title(num2str(2))
 
R = foto2(:, :, 1);
G = foto2(:, :, 2);
B = foto2(:, :, 3);
 
yellowness = (single(R) + single(G))/2 - single(B);
binaryYellow = yellowness > 120; 
 
subplot(4,6,4)
imshow(binaryYellow)
 
 tesbit2=sum(binaryYellow(:));
 
 if tesbit2>1500 
h = waitbar(0, 'Fire Detected');
set(h,'Name', 'Picture 2')
title('Fire Detected')
else
h = waitbar(0, 'No fire');
set(h,'Name', 'Picture 2') 
title('No Fire')
end
 
%--------------------------------
 subplot(4,6,5)
imshow(foto3)
 
title(num2str(3))
 
R = foto3(:, :, 1);
G = foto3(:, :, 2);
B = foto3(:, :, 3);
 
yellowness = (single(R) + single(G))/2 - single(B);
binaryYellow = yellowness > 120; 
 
subplot(4,6,6)
imshow(binaryYellow)
 
 tesbit3=sum(binaryYellow(:));
 
 if tesbit3>1500 
h = waitbar(0, 'Fire Detected');
set(h,'Name', 'Picture 3')
title('Fire Detected')
else
h = waitbar(0, 'No fire');
set(h,'Name', 'Picture 3')
title('No Fire')
end
%--------------------------------
subplot(4,6,7)
imshow(foto4)
 
title(num2str(4))
 
R = foto4(:, :, 1);
G = foto4(:, :, 2);
B = foto4(:, :, 3);
 
yellowness = (single(R) + single(G))/2 - single(B);
binaryYellow = yellowness > 120; 
 
subplot(4,6,8)
imshow(binaryYellow)
 
 tesbit4=sum(binaryYellow(:));
 
if tesbit4>1500 
h = waitbar(0, 'Fire Detected');
set(h,'Name', 'Picture 4')
title('Fire Detected')
else
h = waitbar(0, 'No fire');
set(h,'Name', 'Picture 4')
title('No Fire')
end
%--------------------------------
subplot(4,6,9)
imshow(foto5)
 
title(num2str(5))
 
R = foto5(:, :, 1);
G = foto5(:, :, 2);
B = foto5(:, :, 3);
 
yellowness = (single(R) + single(G))/2 - single(B);
binaryYellow = yellowness > 120; 
 
subplot(4,6,10)
imshow(binaryYellow)
 
 tesbit5=sum(binaryYellow(:));
 
 if tesbit5>1500 
h = waitbar(0, 'Fire Detected');
set(h,'Name', 'Picture 5')
title('Fire Detected')
else
h = waitbar(0, 'No fire');
set(h,'Name', 'Picture 5')
title('No Fire')
end
 
%--------------------------------
subplot(4,6,11)
imshow(foto6)
 
title(num2str(6))
 
R = foto6(:, :, 1);
G = foto6(:, :, 2);
B = foto6(:, :, 3);
 
yellowness = (single(R) + single(G))/2 - single(B);
binaryYellow = yellowness > 120; 
 
subplot(4,6,12)
imshow(binaryYellow)
 
 tesbit6=sum(binaryYellow(:));
 
 if tesbit6>1500 
h = waitbar(0, 'Fire Detected');
set(h,'Name', 'Picture 6')
title('Fire Detected')
else
h = waitbar(0, 'No fire');
set(h,'Name', 'Picture 6')
title('No Fire')
end
%--------------------------------
subplot(4,6,13)
imshow(foto7)
 
title(num2str(7))
 
R = foto7(:, :, 1);
G = foto7(:, :, 2);
B = foto7(:, :, 3);
 
yellowness = (single(R) + single(G))/2 - single(B);
binaryYellow = yellowness > 120; 
 
subplot(4,6,14)
imshow(binaryYellow)
 
 tesbit7=sum(binaryYellow(:));
 
 if tesbit7>1500 
h = waitbar(0, 'Fire Detected');
set(h,'Name', 'Picture 7')
title('Fire Detected')
else
h = waitbar(0, 'No fire');
set(h,'Name', 'Picture 7')
title('No Fire')
end
%--------------------------------
subplot(4,6,15)
imshow(foto8)
 
title(num2str(8))
 
R = foto8(:, :, 1);
G = foto8(:, :, 2);
B = foto8(:, :, 3);
 
yellowness = (single(R) + single(G))/2 - single(B);
binaryYellow = yellowness > 120; 
 
subplot(4,6,16)
imshow(binaryYellow)
 
 tesbit8=sum(binaryYellow(:));
 
 if tesbit8>1500 
h = waitbar(0, 'Fire Detected');
set(h,'Name', 'Picture 8')
title('Fire Detected')
else
h = waitbar(0, 'No fire');
set(h,'Name', 'Picture 8')
title('No Fire')
end
%--------------------------------
subplot(4,6,17)
imshow(foto9)
 
title(num2str(9))
 
R = foto9(:, :, 1);
G = foto9(:, :, 2);
B = foto9(:, :, 3);
 
yellowness = (single(R) + single(G))/2 - single(B);
binaryYellow = yellowness > 120; 
 
subplot(4,6,18)
imshow(binaryYellow)
 
 tesbit9=sum(binaryYellow(:));
 
 if tesbit9>1500 
h = waitbar(0, 'Fire Detected');
set(h,'Name', 'Picture 9')
title('Fire Detected')
else
h = waitbar(0, 'No fire');
set(h,'Name', 'Picture 9')
title('No Fire')
end
%--------------------------------
subplot(4,6,19)
imshow(foto10)
 
title(num2str(10))
 
R = foto10(:, :, 1);
G = foto10(:, :, 2);
B = foto10(:, :, 3);
 
yellowness = (single(R) + single(G))/2 - single(B);
binaryYellow = yellowness > 120; 
 
subplot(4,6,20)
imshow(binaryYellow)
 
 tesbit10=sum(binaryYellow(:));
 
 if tesbit10>1500 
h = waitbar(0, 'Fire Detected');
set(h,'Name', 'Picture 10')
title('Fire Detected')
else
h = waitbar(0, 'No fire');
set(h,'Name', 'Picture 10')
title('No Fire')
end
%--------------------------------
subplot(4,6,21)
imshow(foto11)
 
title(num2str(11))
 
R = foto11(:, :, 1);
G = foto11(:, :, 2);
B = foto11(:, :, 3);
 
yellowness = (single(R) + single(G))/2 - single(B);
binaryYellow = yellowness > 120; 
 
subplot(4,6,22)
imshow(binaryYellow)
 
 tesbit11=sum(binaryYellow(:));
 
 if tesbit11>1500 
h = waitbar(0, 'Fire Detected');
set(h,'Name', 'Picture 11')
title('Fire Detected')
else
h = waitbar(0, 'No fire');
set(h,'Name', 'Picture 11')
title('No Fire')
end
%--------------------------------
subplot(4,6,23)
imshow(foto12)
 
title(num2str(12))
 
R = foto12(:, :, 1);
G = foto12(:, :, 2);
B = foto12(:, :, 3);
 
yellowness = (single(R) + single(G))/2 - single(B);
binaryYellow = yellowness > 120; 
 
subplot(4,6,24)
imshow(binaryYellow)
 
 tesbit12=sum(binaryYellow(:));
 
 if tesbit12>1500 
h = waitbar(0, 'Fire Detected');
set(h,'Name', 'Picture 12')
title('Fire Detected')
else
h = waitbar(0, 'No fire');
set(h,'Name', 'Picture 12')
title('No Fire')
end
%--------------------------------
 
%--------------------------------
 


Leave a Reply

Your email address will not be published. Required fields are marked *