I need to save an image like the original image, for example:
original image = 001A.jpg
saved image = 001A(1).jpg
clear allclc%Detect objects using Viola-Jones Algorithm
imgdir = 'C:\Users\Lewis\Documents\MATLAB\testingimage';DestDir = 'C:\Users\Lewis\Documents\MATLAB\violajones\croppedimage';%To detect Face
FDetect = vision.CascadeObjectDetector;%Read the input image
images = dir(fullfile(imgdir, '*.jpg'));numfiles = length(images);myimage = cell(1,numfiles);for k = 1:numfiles myimage{k} = imread(fullfile( imgdir, images(k).name)); %Returns Bounding Box values based on number of objects
BB = step(FDetect,myimage{k}); for i = 1:size(BB,1) rectangle('Position',BB(i,:),'LineWidth',5,'LineStyle','-','EdgeColor','r'); croppedimage = imcrop(myimage{k},BB(i,:)); end filename = ['croppedTE' ,num2str(k),'.jpg']; imwrite(croppedimage, fullfile(DestDir, filename));end
Best Answer