
function trim_face(file_in, name_out,tx,ty)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% function trim_face(file_in, name_out,tx,ty)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%file_in ---> input image name (Image001.bmp)
%name out --> output image name without the extension, e.g.: face1_1
%tx  --> trimmed image width, e.g.:92
%ty --> trimmed image high, e.g.:112

IM=imread(file_in); %reading the input image
figure(1)
imshow(IM);  %visualization of the image
[cx,cy]=ginput(1)  %center image capture (NOSE)
clear new
new=IM((cy-ty):(cy+ty),(cx-tx):(cx+tx),:); %new image

file_out1 = sprintf('%s.jpg', name_out)
file_out2 = sprintf('%s.pgm', name_out)

imwrite(new,file_out1)%save new image in color in JPG format
imwrite(new,file_out2)%save new image in grayscale in PGM format


figure(2)  %visualization of the new image 
imshow(file_out1)
figure(3)
imshow(file_out2)
