in this tutorial you will learn about how to change the extension of all the images in a folder.
detect faces in all images and make that all faces blur and save in the same directory
This program of matlab will detect the faces in a image and it will make all the faces gray in all the (.jpg) images in current directory
%read all the jpg images from the current directoryimagefiles = dir('*.jpg');%nfiles will store the total no of jpg images in the foldernfiles = length(imagefiles); % Number of files found%this loop will read the name and the images in the current directoryfor ii=1:nfiles%to read all the images name currentfilename = imagefiles(ii).name;%read all the jpg images trough itss namecurrentimage = imread(currentfilename);%face detection trough this methodfaceDetector = vision.CascadeObjectDetector;%making a rectangle where detect facebbox=step(faceDetector,currentimage);for j=1:size(bbox)xbox=bbox(j,:);%crop the area where face is save in sub image subImage = imcrop(currentimage, xbox);%convert the cropped image in gray scale it was in rgbt_image=rgb2gray(subImage);%rgb have 3 channels and gray scale have one so to make all the chanels gray use the codesubImage(:,:,1)=t_image;subImage(:,:,2)=t_image;subImage(:,:,3)=t_image;%replace the cropped area image with this gray image currentimage(xbox(2):xbox(2)+xbox(4),xbox(1):xbox(1)+xbox(3),1:end) = subImage;%save the name of the images with pic1 pic2 pic3 etcnewname=strcat('pic',num2str(ii));%save the images with bmp format and also with new nameimwrite(currentimage,strcat(newname,'.bmp'));%end of inner loop end%end of outer loopendoriginal image
output image with having gray faces
This is a image compression method in which you can encode and compress the image in the wtc format and you can decode the image;
imagefiles = dir('*.jpg');
nfiles = length(imagefiles); % Number of files foundfor ii=1:nfiles currentfilename = imagefiles(ii).name; currentimage = imread(currentfilename); images{ii} = currentimage;[CR,BPP]=wcompress('c',currentimage,strcat(currentfilename,'.wtc'),'gbl_mmc_h','BPP',0.5);end"one of my best teacher said that
'tow type of best programmers
one who write his own code
the second is who make some one else code his own
'
bahi matlab ye hai k ksi or ka code beshak copy karo lakin usko aisa bnao k jsa apka khud ka code ho means itna he samjho
thank you!
"