Wednesday 9 October 2013

Fire Detecion with image processing using matlab


Abstract:

Conventional fire detection systems use physical sensors to detect fire. Chemical properties of particles in the air are acquired by sensors and are used by conventional fire detection systems to raise an alarm. However, this can also cause false alarms; for example, a person smoking in a room may trigger a typical fire alarm system. In order to manage false alarms of conventional fire detection systems, therefore a computer vision-based fire detection algorithm is needed.  The algorithm can be used in parallel with conventional fire detection systems to reduce false alarms. It can also be deployed as a stand-alone system to detect fire by using video frames acquired through a video acquisition device. A novel fire color model is developed in CIE L*a*b* color space to identify fire pixels.

Flowchart:

The motivation for using CIE L*a*b* color space is because it is perceptually uniform color space, thus making it possible to represent color information of fire better than other color spaces.

RGB to CIE L*a*b* Color Space Conversion:

Following equation shows conversions.


Where, Xn, Yn, and Zn are the tri-stimulus values of the reference color white. The data range of RGB color channels is between 0 and 255 for 8-bit data representation. Meanwhile, the data ranges of L*, a*, and b* components are [0, 100], [–110, 110], and [–110, 110], respectively.

Color Modeling for Fire Detection:

The range of fire color can be defined as an interval of color values between red and yellow. Since the color of fire is generally close to red and has high illumination, we can use this property to define measures to detect the existence of fire in an image. For a given image in CIE L*a*b* color space, the following statistical measures for each color channel are defined as,
                                      
Where Lm*, am* and bm* are a collection of average values of the L*, a*, and b* color channels, respectively; N is the total number of pixels in the image; and (x, y) is spatial pixel location in an imaging grid. The numeric color responses L*, a*, and b* are normalized to [0, 1]. It is assumed that the fire in an image has the brightest image region and is near to the color red. Thus, the following rules can be used to define a fire pixel:

Where, R1, R2, R3, and R4 are binary images which represent the existence of fire in a spatial pixel location (x, y) by 1 and the non-existence of fire by 0. R1(x, y), R2(x, y), and R3(x, y) are calculated from global properties of the input image. R4(x, y) represents the color information of fire.
a final fire pixel detection equation can be defined as,

Where, F(x, y) is the final decision on whether a pixel located at spatial location (x, y) results from fire or not.
You can detect the fire using following matlab code.

Code:


% Put image fire in the same folder where this code is put.

i=imread('fire.jpg');
C = makecform('srgb2Lab');
i_Lab = applycform(i,C);
x=i_Lab(:,:,1);
y=i_Lab(:,:,2);
z=i_Lab(:,:,3);
L=sum(x);
L=sum(L');
a=sum(y);
a=sum(a');
b=sum(z);
b=sum(b');
d=zeros(150,200);
L=L/(150*200);
a=a/(150*200);
b=b/(150*200);
for p=1:1:150
    for q=1:1:200
        if (x(p,q)>L)
            d(p,q)=1;
        else d(p,q)=0;
        end;
    end;
end;
e=zeros(150,200);
for p=1:1:150
    for q=1:1:200
        if (y(p,q)>a)
            e(p,q)=1;
        else e(p,q)=0;
        end;
    end;
end;
f=zeros(150,200);
for p=1:1:150
    for q=1:1:200
        if (z(p,q)>b)
            f(p,q)=1;
        else f(p,q)=0;
        end;
    end;
end;
g=zeros(150,200);
for p=1:1:150
    for q=1:1:200
        if (y(p,q)>z(p,q))
            g(p,q)=1;
        else g(p,q)=0;
        end;
    end;
end;
h=zeros(150,200);
for p=1:1:150
    for q=1:1:200
        if (d(p,q)&&e(p,q)&&f(p,q)&&g(p,q)==1)
            h(p,q)=1;
        else h(p,q)=0;
        end;
    end;
end;
h=sum(h);
h=sum(h');
if (h >10 )
    fprintf('FIRE DETECTED\n');
else
    fprintf('FIRE NOT DETECTED\n');
end;


8 comments:

  1. Hi, can you just help me how to solve this equation, and how to convert interns of matlab coding, if you help me , i will complete my project.

    ReplyDelete
  2. Replies
    1. This comment has been removed by the author.

      Delete
  3. every time you need to change dimensions depending on the image...in every for loop the values are set to some random dimensions u need to change it everytime

    ReplyDelete
  4. but this code is not strong..the algorithm is poor

    ReplyDelete
  5. can someone explain why the condition is h>10? where did the 10 come from?

    ReplyDelete