fix: preparation orla + cercle a patch

This commit is contained in:
Damien Guillotin 2022-04-06 19:47:56 +02:00
parent 8cb615031e
commit 280eec61a7
2 changed files with 52 additions and 14 deletions

View file

@ -58,11 +58,10 @@ seuil_E = 10;
q_max = 5; q_max = 5;
ind_img = 1; ind_img = 1;
figure; figure(1);
% subplot(2, 2, 1);
imshow(im(:, :, :, ind_img)); title("Image " + num2str(ind_img)); imshow(im(:, :, :, ind_img)); title("Image " + num2str(ind_img));
figure; figure(2);
imshow(im(:, :, :, ind_img)); title("Image " + num2str(ind_img)); imshow(im(:, :, :, ind_img)); title("Image " + num2str(ind_img));
hold on; hold on;
[germes, image_labelise, E] = super_pixel(im(:, :, :, ind_img), K, m, n, seuil_E, q_max); [germes, image_labelise, E] = super_pixel(im(:, :, :, ind_img), K, m, n, seuil_E, q_max);
@ -84,7 +83,7 @@ hold on;
% Binarisation de l'image à partir des superpixels % % Binarisation de l'image à partir des superpixels %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure(4); figure(3);
R = germes(:, 3); R = germes(:, 3);
B = germes(:, 5); B = germes(:, 5);
scatter(R, B); scatter(R, B);
@ -100,13 +99,40 @@ germes = [germes W];
%% %%
figure(4);
tiledlayout(2,2, 'Padding', 'none', 'TileSpacing', 'compact');
bw_img = reshape(germes(image_labelise, 6), size(im, 1), []); bw_img = reshape(germes(image_labelise, 6), size(im, 1), []);
nexttile;
imshow(bw_img);
CC = bwconncomp(bw_img,4);
bw_img = zeros(size(bw_img));
bw_img(CC.PixelIdxList{1}) = 1;
nexttile;
imshow(bw_img);
bw_img = ~bw_img;
CC = bwconncomp(bw_img,4);
bw_img = zeros(size(bw_img));
bw_img(CC.PixelIdxList{1}) = 1;
bw_img = ~bw_img;
nexttile;
imshow(bw_img);
figure(3);
bw_img = im_mask(:,:,ind_img); bw_img = im_mask(:,:,ind_img);
subplot(2,2,1); nexttile;
imshow(bw_img);
figure(5);
tiledlayout(2,2, 'Padding', 'none', 'TileSpacing', 'compact');
nexttile;
imshow(bw_img); imshow(bw_img);
hold on hold on
@ -130,7 +156,7 @@ plot(contour(:,2), contour(:,1), 'g', 'LineWidth', 3);
% scatter(barycentres(:,2), barycentres(:,1)); % scatter(barycentres(:,2), barycentres(:,1));
% % triplot(r, contour(:,2), contour(:,1)); % % triplot(r, contour(:,2), contour(:,1));
T = 10; T = 1;
[vx, vy] = voronoi(contour(1:T:end,1), contour(1:T:end,2)); [vx, vy] = voronoi(contour(1:T:end,1), contour(1:T:end,2));
plot(vy, vx, 'b'); plot(vy, vx, 'b');
@ -144,7 +170,8 @@ ok = vx(1,:) > 1 & vx(1,:) < size(bw_img, 1) & ...
vx = floor(vx(:,ok)); vx = floor(vx(:,ok));
vy = floor(vy(:,ok)); vy = floor(vy(:,ok));
subplot(2,2,2); % subplot(2,2,2);
nexttile;
imshow(bw_img); imshow(bw_img);
hold on hold on
plot(vy, vx, 'b'); plot(vy, vx, 'b');
@ -161,7 +188,8 @@ ok = ok1 & ok2;
vx = vx(:,ok); vx = vx(:,ok);
vy = vy(:,ok); vy = vy(:,ok);
subplot(2,2,3); % subplot(2,2,3);
nexttile;
imshow(bw_img); imshow(bw_img);
hold on hold on
plot(vy, vx, 'b'); plot(vy, vx, 'b');
@ -184,6 +212,8 @@ R = abs(R);
R = min(R, [], 2); R = min(R, [], 2);
R = R'; R = R';
viscircles([V_(1:10:end,2) V_(1:10:end,1)], R(1:10:end));
% Filtrage naif % Filtrage naif
% truc = find(R < 20); % truc = find(R < 20);
% truc = mod(truc - 1, length(vx)) + 1; % truc = mod(truc - 1, length(vx)) + 1;
@ -192,7 +222,8 @@ R = R';
% vy(:,truc) = []; % vy(:,truc) = [];
% Filtrage scalaire % Filtrage scalaire
R_scaled = 1.1 * R; R_scaled = 1.05 * R;
dist = abs(complex(V_(:,1), V_(:,2)) - transpose(complex(V_(:,1), V_(:,2)))); dist = abs(complex(V_(:,1), V_(:,2)) - transpose(complex(V_(:,1), V_(:,2))));
R_vertical = ones(length(R_scaled),1) * R_scaled; R_vertical = ones(length(R_scaled),1) * R_scaled;
@ -203,10 +234,17 @@ R_horizontal = R_scaled' * ones(1,length(R_scaled));
vx(:, mod(c - 1, length(vx)) + 1) = []; vx(:, mod(c - 1, length(vx)) + 1) = [];
vy(:, mod(c - 1, length(vy)) + 1) = []; vy(:, mod(c - 1, length(vy)) + 1) = [];
subplot(2,2,4); R = [R(1:length(R)/2); R(length(R)/2+1:end)];
R(:, mod(c - 1, length(R)) + 1) = [];
R = R(:);
% subplot(2,2,4);
nexttile;
imshow(bw_img); imshow(bw_img);
hold on hold on
plot(vy, vx, 'b'); plot(vy, vx, 'b');
vx_vy = [vy(1,:) vy(2,:); vx(1,:) vx(2,:)]';
viscircles(vx_vy(1:10:end,:), R(1:10:end));
%% %%
@ -254,10 +292,9 @@ for i = 1:size(pts, 1)
end; end;
fprintf('Calcul des points 3D termine : %d points trouves. \n', size(X, 2)); fprintf('Calcul des points 3D termine : %d points trouves. \n', size(X, 2));
view(80, -10);
%affichage du nuage de points 3D %affichage du nuage de points 3D
figure; figure(6);
hold on; hold on;
for i = 1:size(X, 2) for i = 1:size(X, 2)
@ -265,6 +302,7 @@ for i = 1:size(X, 2)
end; end;
axis equal; axis equal;
view(80, -10);
% A COMPLETER % A COMPLETER
% Tetraedrisation de Delaunay % Tetraedrisation de Delaunay
@ -338,7 +376,7 @@ nb_barycentres = length(to_save);
% A DECOMMENTER POUR AFFICHER LE MAILLAGE RESULTAT % A DECOMMENTER POUR AFFICHER LE MAILLAGE RESULTAT
% Affichage des tetraedres restants % Affichage des tetraedres restants
fprintf('Retrait des tetraedres exterieurs a la forme 3D termine : %d tetraedres restants. \n',size(T,1)); fprintf('Retrait des tetraedres exterieurs a la forme 3D termine : %d tetraedres restants. \n',size(T,1));
figure; figure(7);
tetramesh(triBis, T.Points); tetramesh(triBis, T.Points);
view(80, -10); view(80, -10);

Binary file not shown.