1 pièce(s) jointe(s)
traitement image correction
Bonjour,:calim2:
j'ai fait ce code qui est censé transférer les couleurs d'une image coloré à une image Gris (colorer l'image gris) j'ai commencé par faire une distance euclidienne pixel par pixel .
donc j'arrive à obtenir une image coloré mais le problème c'est que mon image résultat elle est mal coloré (pas nette ).
avez vous des idées (méthode) pour corriger mon image resulat !!!
Code:
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 36 37 38 39 40
| clear variable ;
close all;
clc;
% conversion image couleur en gris
img=imread('imgColor.png');
% premier essai on cnovertie vers gris
img1=double(rgb2gray(img)) / 255;
figure;imagesc(img);axis image
figure;imagesc(img1);axis image; colormap gray;
imgG = double(rgb2gray( imread('imgGrey.png') ) ) / 255;%%image gris
figure;imagesc(imgG);axis image; colormap gray;
h=img1(:);%%premiere colonne de l'image coloré
% initialise d'une variable pour la recoloriser
imgresult=zeros([size(imgG),3]);
% i et j pour parcourir l image grise
idx = zeros( size(imgG) );
for n=1:size(imgG,1)
for k=1:size(imgG,2)
Dist = abs( imgG(n,k)-h); %%distance euclidienne qui mesure la l'intensité lumineuse
% calcul de minimum de distance pour avoir le pixel le plus proche
% index de l image couleur
[x, idx(n,k)] = min(Dist(:));
end
end
%%stoquage couleur
for c = 1:1:3
imgC = img(:,:,c);
tmp = imgC(idx);
imgresult(:,:,c) = tmp;
end
% % coversion double vers entiers par unit8
figure;imagesc(uint8(imgresult));axis image; |
voici l'image obtenu
Pièce jointe 466918