Sunteți pe pagina 1din 51

Detection of Forest Fire

MATLAB Example
Forest Fire Scene
• Sky like regions
• Vegetation like regions
• Fire regions
Approach
• Eliminate sky like regions
• Eliminate vegetation like regions
• The region which remains will indicate the
presence of a fire
Approach
RGB and HSV
RGB and HSV
RGB and HSV
RGB and YCbCr
RGB and YCbCr
Color Spaces
Activity
• Read forest fire image file into MATLAB
Activity
• Read forest fire image file into MATLAB
• a = imread ('forestfire.jpg');
Activity
• Read forest fire image file into MATLAB
• a = imread ('forestfire.jpg');
• Display forest fire image
Activity
• Read forest fire image file into MATLAB
• a = imread ('forestfire.jpg');
• Display forest fire image
• imshow (a);
Activity
• Read forest fire image file into MATLAB
• a = imread ('forestfire.jpg');
• Display forest fire image
• imshow (a);
• What is the size of our input image (rows and
columns)?
Activity
• Read forest fire image file into MATLAB
• a = imread ('forestfire.jpg');
• Display forest fire image
• imshow (a);
• What is the size of our input image (rows and
columns)?
• What is the color format of our input image?
Activity
• Separate our input RGB image into three
channels -- R, G, and B
Activity
• Separate our input RGB image into three
channels -- R, G, and B
• r = a (:, :, 1);
Activity
• Separate our input RGB image into three
channels -- R, G, and B
• r = a (:, :, 1);
• g = a (:, :, 2);
• b = a (:, :, 3);
Activity
• Separate our input RGB image into three
channels -- R, G, and B
• r = a (:, :, 1);
• g = a (:, :, 2);
• b = a (:, :, 3);
• View the red channel image
Activity
• Separate our input RGB image into three
channels -- R, G, and B
• r = a (:, :, 1);
• g = a (:, :, 2);
• b = a (:, :, 3);
• View the red channel image
• imshow (r);
Activity
• Resize our image to 300 rows and 400
columns (why?)
Activity
• Resize our image to 300 rows and 400
columns (why?)
• b = imresize (a, [300 400]);
Approach
Activity
• Resize our image to 300 rows and 400
columns (why?)
• b = imresize (a, [300 400]);
Activity
• Resize our image to 300 rows and 400
columns (why?)
• b = imresize (a, [300 400]);
• Convert our input image from RGB to HSV
Activity
• Resize our image to 300 rows and 400
columns (why?)
• b = imresize (a, [300 400]);
• Convert our input image from RGB to HSV
• c = rgb2hsv (b);
Activity
• Separate into three channels - hue, saturation,
and value
Activity
• Separate into three channels - hue, saturation,
and value
• h = b (:, :, 1);
• s = b (:, :, 2);
• v = b (:, :, 3);
Approach
• Eliminate sky like regions
• Eliminate vegetation like regions
• The region which remains will indicate the
presence of a fire
Approach
• Eliminate sky like regions (best done in HSV)
• Eliminate vegetation like regions (best done in
YCbCr)
• The region which remains will indicate the
presence of a fire
Activity
• Separate into three channels - hue, saturation,
and value
• h = b (:, :, 1);
• s = b (:, :, 2);
• v = b (:, :, 3);
Activity
• Separate into three channels - hue, saturation,
and value
• h = b (:, :, 1);
• s = b (:, :, 2);
• v = b (:, :, 3);
• To identify sky regions, we need:
• h > 0.25 or s >= 0.7
Activity
Identify sky regions
[r, c, v]=find(h>0.25 | s>=0.7);
Activity
Identify sky regions
[r, c, v]=find(h>0.25 | s>=0.7);

Eliminate sky regions (set those pixels to zero)


numid=size(r,1);

for i=1:numid
a(r(i),c(i),:)=0;
end
Activity
• Display our intermediate (sky like regions
removed) image
Activity
• Display our intermediate (sky like regions
removed) image
• imshow (a)
Activity
• Display our intermediate (sky like regions
removed) image
• imshow (a)
• Convert this image to the YCbCr format
Activity
• Display our intermediate (sky like regions
removed) image
• imshow (a)
• Convert this image to the YCbCr format
• ycbcr = rgb2ycbcr (a);
Activity
• Separate into Y, Cb, and Cr channels
Activity
• Separate into Y, Cb, and Cr channels
• y = ycbcr (:, :, 1);
• cb = ycbcr (:, :, 2);
• cr = ycbcr (:, :, 3);
Activity
• Separate into Y, Cb, and Cr channels
• y = ycbcr (:, :, 1);
• cb = ycbcr (:, :, 2);
• cr = ycbcr (:, :, 3);
• To identify vegetation like regions
• cb <= 180, cr <= 150
Activity
• Identify vegetation like regions
• [r, c, v] = find(cb <=180 & cr<=150 );
• Eliminate vegetation like reigons (set these
pixels to zero)
• numid = size(r,1);
• for i=1:numid
• ycbcr(r(i),c(i),:) = 0;
• end
Activity
• Display our final image
• imshow (ycbcr);
Future Scope
Future Scope
RGB and YCbCr
HSV
HSV
HSV vs HSL
RGB and CMYK

S-ar putea să vă placă și