
// This scilab code is used to detect the human face in the image

//The scilab environment for this is : Scilab 5.5.2

//Toolbox used: SIVP 0.5.3.2
              

//OS used : Windows 7 32 bit
// 
//Reference book name : Digital Image Processing
//book author: Rafael C. Gonzalez and Richard E. Woods

//clc //to clear command window.
//clear all //to kill previously defined variables.
//xdel(winsid())//to close all currently open figure(s).

//This code uses different images having human faces for processing
// Images used:
//   kalpana.jpg
//   random.jpg
//   group.png

img = imread('kalpana.jpg');                         // Reads input image

faces = detectfaces(img);                           // Uses function in the toolbox to detect faces
[m,n] = size(faces);                                // Calculates number of faces in image

for i=1:m,                                          // This block draws rectangles for each face images detected
    img = rectangle(img, faces(i,:), [0,255,0]);
end;

imshow(img);                                        // Shows resultant images with the rectangle around face images

pause;                                              // Pause till user enters resume command at command window
img = imread('random.jpg');                         // Reads input image

faces = detectfaces(img);                           // Uses function in the toolbox to detect faces
[m,n] = size(faces);                                // Calculates number of faces in image

for i=1:m,                                          // This block draws rectangles for each face images detected
    img = rectangle(img, faces(i,:), [0,255,0]);
end;

imshow(img);                                        // Shows resultant images with the rectangle around face images
pause;                                              // Pause till user enters resume command at command window
img = imread('group.png');                          // Reads input image

faces = detectfaces(img);                           // Uses function in the toolbox to detect faces
[m,n] = size(faces);                                // Calculates number of faces in image

for i=1:m,                                          // This block draws rectangles for each face images detected
    img = rectangle(img, faces(i,:), [0,255,0]);
end;

imshow(img);                                        // Shows resultant images with the rectangle around face images
