feat: skelettte ok pour notre segmenattion

This commit is contained in:
Damien Guillotin 2022-03-25 12:07:02 +01:00
parent 3d4fe8d58c
commit bba783bcdc
2 changed files with 30 additions and 10 deletions

View file

@ -1,6 +1,6 @@
clear; clear;
close all; close all;
load(i) load("mask.mat");
nb_images = 36; % Nombre d'images nb_images = 36; % Nombre d'images
% chargement des images % chargement des images
@ -88,13 +88,22 @@ plot([0 1], [b a + b]);
W = a * R + b - B > 0; W = a * R + b - B > 0;
germes = [germes W]; germes = [germes W];
bw_img = reshape(germes(image_labelise, 6), size(im, 1), []);
%% %%
bw_img = reshape(germes(image_labelise, 6), size(im, 1), []);
figure; figure;
bw_img = imread("mask.mat") bw_img = im_mask(:,:,1) == 0;
bw_img(8:end-1,1:end) = 0;
bw_img(1:end-5,1:end) = 0;
bw_img(1:end,5:end) = 0;
bw_img(1:end,1:end-30) = 0;
imshow(bw_img); imshow(bw_img);
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% A FAIRE SI VOUS UTILISEZ LES MASQUES BINAIRES FOURNIS % % A FAIRE SI VOUS UTILISEZ LES MASQUES BINAIRES FOURNIS %
@ -102,6 +111,7 @@ imshow(bw_img);
% de taille nb_lignes x nb_colonnes x nb_images % % de taille nb_lignes x nb_colonnes x nb_images %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
pixel_b = find(bw_img == 1); pixel_b = find(bw_img == 1);
[r, c] = ind2sub(size(bw_img), pixel_b(1)); [r, c] = ind2sub(size(bw_img), pixel_b(1));
contour = bwtraceboundary(bw_img, [r c], 'W', 8); contour = bwtraceboundary(bw_img, [r c], 'W', 8);

View file

@ -47,15 +47,16 @@ m = 0.1;
n = 3; n = 3;
seuil_E = 10; seuil_E = 10;
q_max = 20; q_max = 20;
ind_img = 25;
figure; figure;
% subplot(2, 2, 1); % subplot(2, 2, 1);
imshow(im(:, :, :, 1)); title('Image 1'); imshow(im(:, :, :, ind_img)); title('Image 1');
figure; figure;
imshow(im(:, :, :, 1)); title('Image 1'); imshow(im(:, :, :, ind_img)); title('Image 1');
hold on; hold on;
[germes, image_labelise, E] = super_pixel(im(:, :, :, 1), K, m, n, seuil_E, q_max); [germes, image_labelise, E] = super_pixel(im(:, :, :, ind_img), K, m, n, seuil_E, q_max);
% subplot(2, 2, 2); imshow(im(:, :, :, 9)); title('Image 9'); % subplot(2, 2, 2); imshow(im(:, :, :, 9)); title('Image 9');
% hold on; % hold on;
@ -95,15 +96,24 @@ bw_img = reshape(germes(image_labelise, 6), size(im, 1), []);
figure; figure;
% bw_img = im_mask(:,:,1) == 0; % bw_img = im_mask(:,:,ind_img) == 0;
%
% bw_img(1:8,:) = 0;
% bw_img(end-5:end,:) = 0;
% bw_img(:,1:5) = 0;
% bw_img(:,end-30:end) = 0;
imshow(bw_img); imshow(bw_img);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% A FAIRE SI VOUS UTILISEZ LES MASQUES BINAIRES FOURNIS % % A FAIRE SI VOUS UTILISEZ LES MASQUES BINAIRES FOURNIS %
% Chargement des masques binaires % % Chargement des masques binaires %
% de taille nb_lignes x nb_colonnes x nb_images % % de taille nb_lignes x nb_colonnes x nb_images %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
pixel_b = find(bw_img == 1); pixel_b = find(bw_img == 1);
[r, c] = ind2sub(size(bw_img), pixel_b(1)); [r, c] = ind2sub(size(bw_img), pixel_b(1));
contour = bwtraceboundary(bw_img, [r c], 'W', 8); contour = bwtraceboundary(bw_img, [r c], 'W', 8);
@ -118,7 +128,7 @@ hold on
[vx, vy] = voronoi(contour(:,1), contour(:,2)); [vx, vy] = voronoi(contour(:,1), contour(:,2));
% plot(vx, vy); % plot(vy, vx, 'g');
ok = vx(1,:) > 0 & vx(1,:) < size(bw_img, 1) & ... ok = vx(1,:) > 0 & vx(1,:) < size(bw_img, 1) & ...
vx(2,:) > 0 & vx(2,:) < size(bw_img, 1) & ... vx(2,:) > 0 & vx(2,:) < size(bw_img, 1) & ...
@ -127,7 +137,7 @@ ok = vx(1,:) > 0 & vx(1,:) < size(bw_img, 1) & ...
vx = floor(vx(:,ok)); vx = floor(vx(:,ok));
vy = floor(vy(:,ok)); vy = floor(vy(:,ok));
% plot(vx, vy, 'b'); % plot(vy, vx, 'b');
ind1 = sub2ind(size(bw_img), vx(1,:), vy(1,:)); ind1 = sub2ind(size(bw_img), vx(1,:), vy(1,:));
ok1 = bw_img(ind1) > 0; ok1 = bw_img(ind1) > 0;