clear; close all; taille_ecran = get(0,'ScreenSize'); L = taille_ecran(3); H = taille_ecran(4); % Paramètres : N = 50; % Nombre de disques d'une configuration R = 10; % Rayon des disques nb_points_affichage_disque = 30; increment_angulaire = 2*pi/nb_points_affichage_disque; theta = 0:increment_angulaire:2*pi; rose = [253 108 158]/255; q_max = 50000; nb_affichages = 1000; pas_entre_affichages = floor(q_max/nb_affichages); temps_pause = 0.0005; liste_u = []; % Lecture et affichage de l'image : I = imread('colonie.png'); I = rgb2gray(I); I = double(I); I = I(1:400,100:450); [nb_lignes,nb_colonnes] = size(I); figure('Name',['Detection de ' num2str(N) ' flamants roses'],'Position',[0.25*L,0,0.75*L,0.5*H]); % Tirage aléatoire d'une configuration initiale et calcul des niveaux de gris moyens : c = zeros(N,2); I_moyen = zeros(N,1); cond = 1; while cond == 1 for i = 1:N c_i = [nb_colonnes*rand nb_lignes*rand]; c(i,:) = c_i; I_moyen(i) = calcul_I_moyen(I,c_i,R); end liste_q = 0; I_moyen_config = mean(I_moyen); liste_I_moyen_config = I_moyen_config; for i = 1:N for j = i+1:N if ~ (norm((c(i,:) - c(j,:))) <= sqrt(2) * R) cond = 0; end end end end % Affichage de la configuration initiale : subplot(1,2,1); imagesc(I); axis image; axis off; colormap gray; hold on; for i = 1:N x_affich = c(i,1)+R*cos(theta); y_affich = c(i,2)+R*sin(theta); indices = find(x_affich>0 & x_affich0 & y_affichI_moyen_cour c(i,:) = c_alea; I_moyen(i) = I_moyen_nouv; hold off; subplot(1,2,1); imagesc(I); axis image; axis off; colormap gray; hold on; for j = 1:N x_affich = c(j,1)+R*cos(theta); y_affich = c(j,2)+R*sin(theta); indices = find(x_affich>0 & x_affich0 & y_affich