forked from yaksoy/AffinityBasedMattingToolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.m
29 lines (23 loc) · 948 Bytes
/
demo.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
image = imread('Training4.png');
trimap = imread('Training4Trimap.png');
% Closed-form matting
a_cf = closedFormMatting(image, trimap);
% Some alternatives:
% a_ifm = informationFlowMatting(image, trimap);
% a_knn = KNNMatting(image, trimap);
% Get the parameter struct and edit for customization if desired
params = getMattingParams('IFM');
params.useKnownToUnknown = 0;
% params.iu_xyw = 0.1;
% params.loc_mult = 3;
a_ifm = informationFlowMatting(image, trimap, params);
% Trim the trimap
trimmed = patchBasedTrimming(image, trimap);
% An alternative:
% trimmed = trimmingFromUnknownToKnownEdges(image, trimap);
% Run K-to-U information flow to get a rough alpha and confidences
[alphaHat, conf] = knownToUnknownColorMixture(image, trimmed);
% Refine alphaHat shared matting
a_sm_ref = sharedMattingMatteRefinement(image, trimmed, alphaHat, conf);
% Alternative:
% a_ifm_ref = informationFlowMatteRefinement(image, trimmed, alphaHat, conf);