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
| clc;
clear all;
close all;
nomImage = 'image';
img = [nomImage,'.png'];
% Lecture de l'image
matImg = imread(img);
figure(1), imagesc(matImg), axis square;
% Symétrie verticale de l'image (up & down)
[nc,nl,dim] = size(matImg);
matImgMiroir = zeros(nc,nl,dim);
for i=1:3
matImgMiroir(:,:,i) = flipud(matImg(:,:,i));
end
% Vérification
figure(2); colormap(gray)
subplot(2,3,1), imagesc(matImg(:,:,1)), axis square, title('Canal 1 - original');
subplot(2,3,2), imagesc(matImg(:,:,2)), axis square, title('Canal 2 - original');
subplot(2,3,3), imagesc(matImg(:,:,3)), axis square, title('Canal 3 - original');
subplot(2,3,4), imagesc(matImgMiroir(:,:,1)), axis square, title('Canal 1 - sym vert');
subplot(2,3,5), imagesc(matImgMiroir(:,:,2)), axis square, title('Canal 2 - sym vert');
subplot(2,3,6), imagesc(matImgMiroir(:,:,3)), axis square, title('Canal 3 - sym vert');
% rgb2gray :
matGr = 0.2989.*matImgMiroir(:,:,1) + 0.5870.*matImgMiroir(:,:,2) + 0.1140.*matImgMiroir(:,:,3);
figure(3); imagesc(matGr); axis square, colormap(gray);
% Enregistrement
imwrite(matGr,[nomImage,'_miroir.png'],'png'); |
Partager