forked from ivaaanrm/PIV-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalgo2v2.m
48 lines (38 loc) · 1.11 KB
/
algo2v2.m
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
tic
clear all
load svm_clf.mat
% Lectura de las máscaras
img_path = 'Dataset/Training-Dataset/Images/5_P_hgr1_id01_1.jpg';
img = imread(img_path);
imgName = strsplit(img_path, '/');
imgName = strsplit(string(imgName(4)), '.');
% ************ MODELOS *********** %
[BW_pred1,maskedRGBImage] = binary_svm_clf(img, svm_clf);
[BW_pred,maskedRGBImage] = lab_clf(maskedRGBImage);
% ******** Mejora del sistema usando contornos ***********%
% Usamos el detector de contornos canny para detectar los contornos de
% la mano. Closing para cerrar el objeto. LLenamos los agujeros.
[BW_edge] = postprocessmasks(img);
mask = immultiply(BW_edge, BW_pred);
mask = bwareafilt(mask,1);
% Otro detector de contornos para diferenciar objetos y elegimos el que
% corresponde a la mano.
[x,y] = size(mask);
area =x*y;
if bwarea(mask) > area*0.3
[mask] = postprocessmasks2(img, mask);
end
% Guradmos la máscara
out_mask = imgName(1) + ".bmp";
imwrite(mask, out_mask , "bmp");
toc
% plot pipeline
figure,
subplot(141);
imshow(img);
subplot(142);
imshow(BW_edge);
subplot(143);
imshow(BW_pred);
subplot(144);
imshow(mask);