% Augment a image into 5 througn choosing 5 regions of the image which are top left corner, top right
% corner, lower left quarter, lower right quarter and middle.
clc;
clear all;
originPath_test = 'D:\CaffeInfo\B_DataCreate\test_image\';
aimPath_test = 'D:\CaffeInfo\B_DataCreate\crop_picture_test\';
files = dir([originPath_test, '*.tif'])
num = length(files)
for i = 1 : num
filename0 = files(i).name
filename0 = filename0(1:end-4) % the first part of the new name
filename1 = files(i).name;
path_name = [originPath_test, filename1]
ImageData = imread(path_name); % read the original image
picture1 = ImageData(1:224,1:224,:); % top left corner
imwrite(picture1, [aimPath_test , filename0, '_1.tif'],'tif');
picture2 = ImageData(32:256,1:224,:); % top right corner
imwrite(picture2, [aimPath_test , filename0, '_2.tif'],'tif');
picture3 = ImageData(1:224,32:256,:); % bottom left corner
imwrite(picture3, [aimPath_test , filename0, '_3.tif'],'tif');
picture4 = ImageData(32:256,32:256,:); % bottom right corner
imwrite(picture4, [aimPath_test , filename0, '_4.tif'],'tif');
picture5 = ImageData(16:240,16:240,:); % center
imwrite(picture5, [aimPath_test , filename0, '_5.tif'],'tif');
end