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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
% Chargement des images:
Ii6 = imread('62a.bmp');
Ii7 = imread('85a.bmp');
Ii8 = imread('43a.bmp');
Ii9 = imread('15a.bmp');
Ii10 = imread('23a.bmp');
%Conversion RGB to HSV
I6 = rgb2hsv(Ii6);
I7 = rgb2hsv(Ii7);
I8 = rgb2hsv(Ii8);
I9 = rgb2hsv(Ii9);
I10 = rgb2hsv(Ii10);
%Décomposition sur l'espace HSV
HSV6 = reshape(I6, [], 3);
uHSV6 = unique(HSV6, 'rows');
HSV7 = reshape(I7, [], 3);
uHSV7 = unique(HSV7, 'rows');
HSV8 = reshape(I8, [], 3);
uHSV8 = unique(HSV8, 'rows');
HSV9 = reshape(I9, [], 3);
uHSV9 = unique(HSV9, 'rows');
HSV10 = reshape(I10, [], 3);
uHSV10 = unique(HSV10, 'rows');
%Tracé sur le plan HS
figure(25)
plot(uHSV10(:,1),uHSV10(:,2),'b',uHSV9(:,1),uHSV9(:,2),'b',uHSV8(:,1),uHSV8(:,2),'.b',uHSV7(:,1),uHSV7(:,2),'.b',uHSV6(:,1),uHSV6(:,2),'.b')
axis square
title('HS')
xlim([0 1])
ylim([0 1])
xlabel('H')
ylabel('S')
%Utilisation de la fonction polyfit
x = [uHSV10(:,1);uHSV9(:,1); uHSV8(:,1); uHSV7(:,1); uHSV6(:,1)]; %Composantes H
y = [uHSV10(:,2); uHSV9(:,2); uHSV8(:,2); uHSV7(:,2); uHSV6(:,2)];%Composantes S
plot(x,y,'.')
xlim([0 1])
ylim([0 1])
xlabel('H')
ylabel('S')
p = polyfit(x,y,1);
poly_line = polyval(p,x);
figure
plot(x,poly_line,'.r')
xlim([0 1])
ylim([0 1])
xlabel('H')
ylabel('H')
box |
Partager