2022-12-09 09:03:22 +01:00
|
|
|
close all;
|
|
|
|
|
|
|
|
%Ouverture d'une image au format couleur
|
|
|
|
ima=single(imread('../Image/ferrari.jpg'));
|
|
|
|
ima=ima./255;
|
|
|
|
|
|
|
|
%Affichage d'une image couleur avec image
|
|
|
|
figure('name','RGB in','numbertitle','off');image(ima);
|
|
|
|
|
|
|
|
|
|
|
|
%Taille d'une image
|
|
|
|
taille=size(ima);
|
|
|
|
display(taille);
|
|
|
|
|
|
|
|
ima_r=ima(:,:,1);
|
|
|
|
ima_g=ima(:,:,2);
|
|
|
|
ima_b=ima(:,:,3);
|
|
|
|
|
|
|
|
%Affichage d'un niveau de couleur de l'image
|
2022-12-11 12:19:03 +01:00
|
|
|
% figure('name','R','numbertitle','off');imagesc(ima_r);colormap gray %Niveau de rouge
|
|
|
|
% figure('name','G','numbertitle','off');imagesc(ima_g);colormap gray %Niveau de vert
|
|
|
|
% figure('name','B','numbertitle','off');imagesc(ima_b);colormap gray %Niveau de bleu
|
2022-12-09 09:03:22 +01:00
|
|
|
|
|
|
|
%Taille d'une image
|
|
|
|
taille=size(ima);
|
|
|
|
display(taille);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%tic toc pour mesurer le temps de calcul
|
|
|
|
disp("Seuil :");
|
|
|
|
|
2022-12-11 12:19:03 +01:00
|
|
|
tic;
|
2022-12-09 09:03:22 +01:00
|
|
|
ima_out=ima;
|
|
|
|
nr = ima_r./sqrt(ima_r.^2 + ima_b.^2 + ima_g.^2);
|
|
|
|
ima_seuil = ima.*(nr>0.7);
|
2022-12-11 12:19:03 +01:00
|
|
|
% toc;
|
|
|
|
% figure('name','RGB out','numbertitle','off');image(ima_seuil);
|
2022-12-09 09:03:22 +01:00
|
|
|
|
2022-12-11 12:19:03 +01:00
|
|
|
% disp("Jaune :")
|
|
|
|
% tic;
|
2022-12-09 09:03:22 +01:00
|
|
|
ima_jaune = ima_seuil;
|
|
|
|
ima_jaune(:,:,2) = ima_seuil(:,:,1);
|
2022-12-11 12:19:03 +01:00
|
|
|
% toc;
|
|
|
|
% figure('name','RGB out','numbertitle','off');image(ima_jaune);
|
2022-12-09 09:03:22 +01:00
|
|
|
|
2022-12-11 12:19:03 +01:00
|
|
|
% disp("Reinsertion dans l'image :")
|
|
|
|
% tic;
|
2022-12-09 09:03:22 +01:00
|
|
|
ima_out = ima - ima_seuil + ima_jaune;
|
|
|
|
toc;
|
2022-12-11 12:19:03 +01:00
|
|
|
figure('name','RGB out','numbertitle','off');image(ima_out);
|
|
|
|
|
2022-12-09 09:03:22 +01:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%Sauvegarde d'une image au format jpg
|
|
|
|
imwrite(ima_out,'../Image/ferrari_out.jpg','jpg');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%Sauvegarde d'une image au format raw
|
|
|
|
fid = fopen('../Image/ferrari_out.raw', 'w');
|
|
|
|
fwrite(fid, ima_out, 'single');
|
|
|
|
fclose(fid);
|
|
|
|
|