1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
rep = 'C:\GM\';
ext = '*.png';
chemin = fullfile(rep,ext);
list = dir(chemin);
if ~exist(strcat(rep, 'Cropped'),'dir')
mkdir(strcat(rep, 'Cropped'));
end
for n = 1:numel(list)
[img, map] = imread(fullfile(rep, list(n).name), ext(3:end));
colormap(map);
image(img);
nb = size(img);
x0 = floor(229/1279*nb(2));
y0 = floor(6/773*nb(1));
width = ceil(502/1279*nb(2));
height = ceil(674/773*nb(1));
img_cropped = imcrop(img,[x0 y0 width height]);
a = strcat(rep,'Cropped\', list(n).name);
imwrite(img_cropped, a,'png');
end
[img2, map2] = imread(fullfile(rep, list(1).name));
colormap(map2)
x0_scale = floor(22/1279*nb(2));
y0_scale = floor(12/773*nb(1));
width_scale = ceil(183/1279*nb(2));
height_scale = ceil(416/773*nb(1));
scale = imcrop(img,[x0_scale y0_scale width_scale height_scale]);
% imwrite(scale,strcat(rep, 'scale.jpg'),'jpg','Quality',100);
imwrite(scale,strcat(rep, 'Cropped\', 'scale.png'),'png'); |
Partager