Skip to content

Commit 38f5b11

Browse files
committed
update maplab example
update maplab example
1 parent 0803875 commit 38f5b11

11 files changed

Lines changed: 49 additions & 14 deletions

File tree

crf_max_flow_matlab/10.png

-16.2 KB
Binary file not shown.

crf_max_flow_matlab/10prob.png

-1.88 KB
Binary file not shown.

crf_max_flow_matlab/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Matlab wrap of maxflow for 2D image segmentation
2+
This package is a Matlab wrap of maxflow algorithm written in cpp.
3+
4+
To build, run the `make.m` file.
5+
6+
See `test1.m` and 'test2.m' for examples of using this package.
7+
8+
![crf_2d_matlab](../data/crf_2d_matlab.png)
9+

crf_max_flow_matlab/crop.png

-9.31 KB
Binary file not shown.

crf_max_flow_matlab/crop_prob.png

-6.94 KB
Binary file not shown.

crf_max_flow_matlab/img.png

-14.7 KB
Binary file not shown.

crf_max_flow_matlab/prob.png

-5.8 KB
Binary file not shown.

crf_max_flow_matlab/test.m

Lines changed: 0 additions & 14 deletions
This file was deleted.

crf_max_flow_matlab/test1.m

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
I = imread('../data/img2d.png');
2+
if (length(size(I)) == 3)
3+
I = I(:,:,1);
4+
end
5+
P = imread('../data/prob2d.png');
6+
7+
fP = double(P)/255.0;
8+
bP = 1.0-fP;
9+
10+
lambda = 10.0;
11+
sigma = 5.0;
12+
[flow, lab] = automaxflowmex(I, fP, bP, lambda, sigma);
13+
lab = (1-lab)*255;
14+
subplot(1,3,1); imshow(I); title("input image");
15+
subplot(1,3,2); imshow(P); title('probability map');
16+
subplot(1,3,3); imshow(lab); title('CRF result');

crf_max_flow_matlab/test2.m

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
I = imread('../data/img2d.png');
2+
if (length(size(I)) == 3)
3+
I = I(:,:,1);
4+
end
5+
P = imread('../data/prob2d.png');
6+
7+
fP = double(P)/255.0;
8+
bP = 1.0-fP;
9+
10+
seed = uint8(zeros(size(fP)));
11+
seed1_x = 28
12+
seed1_y = 33
13+
seed2_x = 41
14+
seed2_y = 53
15+
16+
seed(seed1_y - 2 : seed1_y + 2, seed1_x - 2 : seed1_x + 2) = 255;
17+
seed(seed2_y - 2 : seed2_y + 2, seed2_x - 2 : seed2_x + 2) = 127;
18+
lambda = 10.0;
19+
sigma = 5.0;
20+
[flow, lab] = interactivemaxflowmex(I, fP, bP, seed, lambda, sigma);
21+
lab = (1-lab)*255;
22+
subplot(1,3,1); imshow(I); title("input image");
23+
subplot(1,3,2); imshow(P); title('probability map');
24+
subplot(1,3,3); imshow(lab); title('CRF result');

0 commit comments

Comments
 (0)