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 41 42 43 44 45 46
| %% transformation HSV
I=imread('image.jpg');
I1=rgb2hsv(I);
% subplot(2,2,1);imshow(I)
% subplot(2,2,2);imshow(I1)
h=I1(:,:,1);
[m n l]=size(h);
%% subdivision en blocs
w=16;
for i=m/w
for j=n/w
B(1:w,1:w)=h((i-1)*w+1:i*w,(j-1)*w+1:j*w);
%% calcul de l'histogramme pour chaque bloc de la teinte:
bh=floor(B*100);
hi(1:100)=0;
for u=1:w
for v=1:w
hi(uint8(bh(u,v)+1))=hi((bh(u,v))+1)+1;
end
end
vect1=[hi];
%% ouvrir un fichier
a=100;
fp=fopen('fich111.dat','w');
fwrite(fp,a,'int');
fwrite(fp,hi,'int');
fclose(fp);
%% lecture du fichier
fp1=fopen('fich111.dat','r');
a1=fread(fp1,1,'int');
%% construction du vecteur de la teinte max de chaque bloc
k=1;
M=[]
ma=hi(1)
for u=1:100
if (hi(u)>ma)
ma=hi(u);
l=u;
end
end
vectma(k)=l/100;
k=k+1;
end
end
M=vectma |
Partager